@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/server.js CHANGED
@@ -4953,6 +4953,534 @@ function registerPartiesTools(server, getToken, baseUrl) {
4953
4953
  );
4954
4954
  }
4955
4955
  }
4956
+ var readOnly5 = {
4957
+ readOnlyHint: true,
4958
+ destructiveHint: false,
4959
+ idempotentHint: true,
4960
+ openWorldHint: false
4961
+ };
4962
+ var write5 = (idempotent, destructive = false) => ({
4963
+ readOnlyHint: false,
4964
+ destructiveHint: destructive,
4965
+ idempotentHint: idempotent,
4966
+ openWorldHint: false
4967
+ });
4968
+ var domainSchema = z.enum(["vendors", "customers", "materials"]).describe("Master data domain: vendors, customers or materials.");
4969
+ var domainPath = (domain, rest = "") => `/v1/master-records/${encodeURIComponent(domain)}${rest}`;
4970
+ var CONFIG_DESCRIPTION2 = [
4971
+ "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.",
4972
+ "USE WHEN: before changing the configuration, or to explain which systems feed a domain.",
4973
+ "NOT FOR: the golden records (talonic_master_records_overview).",
4974
+ "",
4975
+ "ARGS: none.",
4976
+ "RETURNS: { domains { vendors|customers|materials { sources[], auto_threshold?, review_threshold?, changes[]?, open_items[]?, evidence? } } }."
4977
+ ].join("\n");
4978
+ function handleConfig2(getToken, baseUrl) {
4979
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/master-records/config"));
4980
+ }
4981
+ var SAVE_CONFIG_DESCRIPTION2 = [
4982
+ "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.",
4983
+ "USE WHEN: setting up Master Records for a workspace, or adding a source system or change log.",
4984
+ "NOT FOR: partial edits; read talonic_master_records_config, change it, and send the whole object.",
4985
+ "",
4986
+ "ARGS: `config` (the whole configuration object), `dry_run` (validate only).",
4987
+ "RETURNS: { config, saved }. A broken config returns the list of problems."
4988
+ ].join("\n");
4989
+ var saveConfigInputSchema2 = {
4990
+ config: z.record(z.string(), z.unknown()).describe("The whole Master Records configuration object (see talonic_master_records_config)."),
4991
+ dry_run: z.boolean().optional().describe("Validate only; nothing is saved.")
4992
+ };
4993
+ function handleSaveConfig2(getToken, baseUrl, args) {
4994
+ return runTool(
4995
+ () => apiJson(getToken, baseUrl, "PUT", "/v1/master-records/config", {
4996
+ body: { config: args.config, dry_run: args.dry_run ?? false }
4997
+ })
4998
+ );
4999
+ }
5000
+ var RUN_DESCRIPTION = [
5001
+ "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.",
5002
+ "USE WHEN: the sources changed, or the domain has never been resolved.",
5003
+ "NOT FOR: reading the result (talonic_master_records_overview).",
5004
+ "",
5005
+ "ARGS: `domain` vendors|customers|materials.",
5006
+ "RETURNS: { run_id, stats { source_rows, records, multi_source, auto_merged, to_review, conflicts, bad_conflicts, per_source, pairs_compared, resolve_ms } }."
5007
+ ].join("\n");
5008
+ var runInputSchema = { domain: domainSchema };
5009
+ function handleRun(getToken, baseUrl, args) {
5010
+ return runTool(() => apiJson(getToken, baseUrl, "POST", domainPath(args.domain, "/run")));
5011
+ }
5012
+ var OVERVIEW_DESCRIPTION2 = [
5013
+ "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.",
5014
+ 'USE WHEN: the headline ("how many duplicates across the ERPs, how many need review") or finding a record by name or source id.',
5015
+ "NOT FOR: one record's fields and reasons (talonic_master_records_get_record); single-source rows (talonic_master_records_crosswalk).",
5016
+ "",
5017
+ "ARGS: `domain`, `status` review|auto|accepted|split|conflict|all (default all), `query` (name or source id contains), `limit` (default 100), `offset`.",
5018
+ "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[] } }."
5019
+ ].join("\n");
5020
+ var overviewInputSchema = {
5021
+ domain: domainSchema,
5022
+ status: z.enum(["review", "auto", "accepted", "split", "conflict", "all"]).optional().describe("Only records with this status; conflict = any field disagreement."),
5023
+ query: z.string().max(200).optional().describe("Name or source id contains."),
5024
+ limit: z.number().int().min(1).max(5e3).optional().describe("Maximum records returned."),
5025
+ offset: z.number().int().min(0).optional().describe("Records to skip, for paging.")
5026
+ };
5027
+ function handleOverview2(getToken, baseUrl, args) {
5028
+ return runTool(
5029
+ () => apiJson(getToken, baseUrl, "GET", domainPath(args.domain, "/overview"), {
5030
+ params: { status: args.status, q: args.query, limit: args.limit, offset: args.offset }
5031
+ })
5032
+ );
5033
+ }
5034
+ var RECORD_DESCRIPTION = [
5035
+ "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.",
5036
+ "USE WHEN: explaining why rows were merged, which system a value came from, or before accepting or splitting a record.",
5037
+ "NOT FOR: listing records (talonic_master_records_overview).",
5038
+ "",
5039
+ "ARGS: `domain`, `key` (from talonic_master_records_overview or talonic_master_records_crosswalk).",
5040
+ "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 }."
5041
+ ].join("\n");
5042
+ var recordInputSchema = {
5043
+ domain: domainSchema,
5044
+ key: z.string().min(1).describe("Golden record key.")
5045
+ };
5046
+ function handleGetRecord(getToken, baseUrl, args) {
5047
+ return runTool(
5048
+ () => apiJson(
5049
+ getToken,
5050
+ baseUrl,
5051
+ "GET",
5052
+ domainPath(args.domain, `/records/${encodeURIComponent(args.key)}`)
5053
+ )
5054
+ );
5055
+ }
5056
+ var DECIDE_DESCRIPTION2 = [
5057
+ "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.",
5058
+ "USE WHEN: the user has reviewed a record and asks to accept or split it.",
5059
+ "NOT FOR: looking at the record (talonic_master_records_get_record).",
5060
+ "",
5061
+ "ARGS: `domain`, `key`, `decision` accept|split|reopen.",
5062
+ "RETURNS: { key, decision, stats } (stats of the re-run)."
5063
+ ].join("\n");
5064
+ var decideInputSchema2 = {
5065
+ domain: domainSchema,
5066
+ key: z.string().min(1).describe("Golden record key."),
5067
+ decision: z.enum(["accept", "split", "reopen"]).describe("accept, split or reopen.")
5068
+ };
5069
+ function handleDecide2(getToken, baseUrl, args) {
5070
+ return runTool(
5071
+ () => apiJson(
5072
+ getToken,
5073
+ baseUrl,
5074
+ "POST",
5075
+ domainPath(args.domain, `/records/${encodeURIComponent(args.key)}/decision`),
5076
+ { body: { decision: args.decision } }
5077
+ )
5078
+ );
5079
+ }
5080
+ var CHANGES_DESCRIPTION = [
5081
+ "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.",
5082
+ 'USE WHEN: "which bank detail changes have no document behind them", vendor bank fraud checks, terms changes.',
5083
+ "NOT FOR: the golden records (talonic_master_records_overview).",
5084
+ "",
5085
+ "ARGS: `domain`, `flagged` (only the changes that need attention).",
5086
+ "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 } }."
5087
+ ].join("\n");
5088
+ var changesInputSchema = {
5089
+ domain: domainSchema,
5090
+ flagged: z.boolean().optional().describe("Only flagged changes.")
5091
+ };
5092
+ function handleChanges(getToken, baseUrl, args) {
5093
+ return runTool(
5094
+ () => apiJson(getToken, baseUrl, "GET", domainPath(args.domain, "/changes"), {
5095
+ params: { flagged: args.flagged ? "true" : void 0 }
5096
+ })
5097
+ );
5098
+ }
5099
+ var CROSSWALK_DESCRIPTION = [
5100
+ "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.",
5101
+ "USE WHEN: looking up which golden record a system's id belongs to, or handing the mapping to another system.",
5102
+ "NOT FOR: the merge reasons (talonic_master_records_get_record).",
5103
+ "",
5104
+ "ARGS: `domain`.",
5105
+ "RETURNS: { domain, rows[] { golden_key, golden_name, source, source_id, status } }."
5106
+ ].join("\n");
5107
+ var crosswalkInputSchema = { domain: domainSchema };
5108
+ function handleCrosswalk(getToken, baseUrl, args) {
5109
+ return runTool(() => apiJson(getToken, baseUrl, "GET", domainPath(args.domain, "/crosswalk")));
5110
+ }
5111
+ async function probeMasterRecordsAccess(token, baseUrl) {
5112
+ try {
5113
+ const res = await fetch(buildUrl(baseUrl, "/v1/master-records/config"), {
5114
+ headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
5115
+ signal: AbortSignal.timeout(5e3)
5116
+ });
5117
+ return res.ok;
5118
+ } catch {
5119
+ return false;
5120
+ }
5121
+ }
5122
+ function registerMasterRecordsTools(server, getToken, baseUrl) {
5123
+ const tools = [
5124
+ [
5125
+ "talonic_master_records_config",
5126
+ "Read the Master Records configuration",
5127
+ CONFIG_DESCRIPTION2,
5128
+ {},
5129
+ readOnly5,
5130
+ () => handleConfig2(getToken, baseUrl)
5131
+ ],
5132
+ [
5133
+ "talonic_master_records_save_config",
5134
+ "Save the Master Records configuration",
5135
+ SAVE_CONFIG_DESCRIPTION2,
5136
+ saveConfigInputSchema2,
5137
+ write5(true, true),
5138
+ (a) => handleSaveConfig2(getToken, baseUrl, a)
5139
+ ],
5140
+ [
5141
+ "talonic_master_records_run",
5142
+ "Resolve master records",
5143
+ RUN_DESCRIPTION,
5144
+ runInputSchema,
5145
+ write5(true),
5146
+ (a) => handleRun(getToken, baseUrl, a)
5147
+ ],
5148
+ [
5149
+ "talonic_master_records_overview",
5150
+ "Master records overview",
5151
+ OVERVIEW_DESCRIPTION2,
5152
+ overviewInputSchema,
5153
+ readOnly5,
5154
+ (a) => handleOverview2(getToken, baseUrl, a)
5155
+ ],
5156
+ [
5157
+ "talonic_master_records_get_record",
5158
+ "One golden record",
5159
+ RECORD_DESCRIPTION,
5160
+ recordInputSchema,
5161
+ readOnly5,
5162
+ (a) => handleGetRecord(getToken, baseUrl, a)
5163
+ ],
5164
+ [
5165
+ "talonic_master_records_decide",
5166
+ "Accept or split a golden record",
5167
+ DECIDE_DESCRIPTION2,
5168
+ decideInputSchema2,
5169
+ write5(true),
5170
+ (a) => handleDecide2(getToken, baseUrl, a)
5171
+ ],
5172
+ [
5173
+ "talonic_master_records_changes",
5174
+ "Master data changes checked against documents",
5175
+ CHANGES_DESCRIPTION,
5176
+ changesInputSchema,
5177
+ readOnly5,
5178
+ (a) => handleChanges(getToken, baseUrl, a)
5179
+ ],
5180
+ [
5181
+ "talonic_master_records_crosswalk",
5182
+ "Source id to golden record crosswalk",
5183
+ CROSSWALK_DESCRIPTION,
5184
+ crosswalkInputSchema,
5185
+ readOnly5,
5186
+ (a) => handleCrosswalk(getToken, baseUrl, a)
5187
+ ]
5188
+ ];
5189
+ for (const [name, title, description, inputSchema11, annotations, handler] of tools) {
5190
+ server.registerTool(
5191
+ name,
5192
+ { title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
5193
+ async (args) => handler(args)
5194
+ );
5195
+ }
5196
+ }
5197
+ var readOnly6 = {
5198
+ readOnlyHint: true,
5199
+ destructiveHint: false,
5200
+ idempotentHint: true,
5201
+ openWorldHint: false
5202
+ };
5203
+ var write6 = (idempotent, destructive = false) => ({
5204
+ readOnlyHint: false,
5205
+ destructiveHint: destructive,
5206
+ idempotentHint: idempotent,
5207
+ openWorldHint: false
5208
+ });
5209
+ var specId = z.string().uuid().describe("Target structure id (talonic_submissions_specs). Omit to use none.");
5210
+ var SPECS_DESCRIPTION = [
5211
+ "List the workspace's target structures: the client formats submissions are mapped into, with field count and how many label mappings still await review.",
5212
+ "USE WHEN: before any other submissions tool, to pick the spec_id.",
5213
+ "NOT FOR: the submissions themselves (talonic_submissions_list).",
5214
+ "",
5215
+ "ARGS: none.",
5216
+ "RETURNS: [{ id, name, updated_at, field_count, labels_to_review }]."
5217
+ ].join("\n");
5218
+ function handleSpecs(getToken, baseUrl) {
5219
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/submissions/specs"));
5220
+ }
5221
+ var LIST_DESCRIPTION = [
5222
+ "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.",
5223
+ 'USE WHEN: the headline ("which submissions are in, which are mapped, which have problems") or finding a submission by file name.',
5224
+ "NOT FOR: what to fix (talonic_submissions_issues); the facts (talonic_submissions_export).",
5225
+ "",
5226
+ "ARGS: `spec_id` (optional), `q` (file name contains), `limit` (default 100, max 500), `offset`.",
5227
+ "RETURNS: { total, submissions[] { document_id, filename, cedent, status, tables, values, facts, metrics, checks_failed, checks_warned, embedded_files, captured_at } }."
5228
+ ].join("\n");
5229
+ var listInputSchema = {
5230
+ spec_id: specId.optional(),
5231
+ q: z.string().optional().describe("File name contains."),
5232
+ limit: z.number().int().min(1).max(500).optional(),
5233
+ offset: z.number().int().min(0).optional()
5234
+ };
5235
+ function handleList(getToken, baseUrl, args) {
5236
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/submissions", { params: args }));
5237
+ }
5238
+ var ISSUES_DESCRIPTION5 = [
5239
+ "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).",
5240
+ "USE WHEN: deciding what to do next; after talonic_submissions_process to see what is left.",
5241
+ "NOT FOR: the full list (talonic_submissions_list).",
5242
+ "",
5243
+ "ARGS: `spec_id` (optional; mapping-related kinds need it).",
5244
+ "RETURNS: [{ kind, document_id, filename, detail }]."
5245
+ ].join("\n");
5246
+ var issuesInputSchema3 = { spec_id: specId.optional() };
5247
+ function handleIssues5(getToken, baseUrl, args) {
5248
+ return runTool(
5249
+ () => apiJson(getToken, baseUrl, "GET", "/v1/submissions/issues", { params: args })
5250
+ );
5251
+ }
5252
+ var PROCESS_DESCRIPTION = [
5253
+ "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.",
5254
+ "USE WHEN: new submissions arrived (only: not_captured), or a target structure changed and submissions need re-mapping (only: not_mapped or all).",
5255
+ "NOT FOR: reading results (talonic_submissions_list, talonic_submissions_issues).",
5256
+ "",
5257
+ "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`.",
5258
+ "RETURNS: dry_run \u2192 { plan[] { document_id, filename, capture, map } }; otherwise { results[] { document_id, ok, facts?, checks_failed?, error? } }."
5259
+ ].join("\n");
5260
+ var processInputSchema = {
5261
+ spec_id: specId.optional(),
5262
+ document_ids: z.array(z.string().uuid()).max(200).optional(),
5263
+ only: z.enum(["not_captured", "not_mapped", "all"]).optional(),
5264
+ recapture: z.boolean().optional().describe("Capture again even when already captured; earlier facts are replaced."),
5265
+ limit: z.number().int().min(1).max(200).optional(),
5266
+ dry_run: z.boolean().optional().describe("List what would run; nothing runs.")
5267
+ };
5268
+ function handleProcess(getToken, baseUrl, args) {
5269
+ return runTool(
5270
+ () => apiJson(getToken, baseUrl, "POST", "/v1/submissions/process", { body: args })
5271
+ );
5272
+ }
5273
+ var COMPLETENESS_DESCRIPTION = [
5274
+ "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.",
5275
+ "USE WHEN: judging whether a submission carries what a quote needs, or explaining what is missing.",
5276
+ "NOT FOR: the facts themselves (talonic_submissions_export).",
5277
+ "",
5278
+ "ARGS: `document_id`, `spec_id`.",
5279
+ "RETURNS: { metrics[] { metric, in_format, facts, fields[] } }."
5280
+ ].join("\n");
5281
+ var completenessInputSchema = {
5282
+ document_id: z.string().uuid().describe("Submission (workbook document) id."),
5283
+ spec_id: specId
5284
+ };
5285
+ function handleCompleteness(getToken, baseUrl, args) {
5286
+ return runTool(
5287
+ () => apiJson(
5288
+ getToken,
5289
+ baseUrl,
5290
+ "GET",
5291
+ `/v1/submissions/${encodeURIComponent(args.document_id)}/completeness`,
5292
+ {
5293
+ params: { spec_id: args.spec_id }
5294
+ }
5295
+ )
5296
+ );
5297
+ }
5298
+ var EXPORT_DESCRIPTION = [
5299
+ "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.",
5300
+ "USE WHEN: handing facts to the client or another system, or answering a question about figures.",
5301
+ "NOT FOR: the inbox (talonic_submissions_list).",
5302
+ "",
5303
+ "ARGS: `spec_id`, `document_id` (optional; all submissions when omitted).",
5304
+ "RETURNS: { header[], rows[][] }."
5305
+ ].join("\n");
5306
+ var exportInputSchema = {
5307
+ spec_id: specId,
5308
+ document_id: z.string().uuid().optional().describe("Only this submission.")
5309
+ };
5310
+ function handleExport(getToken, baseUrl, args) {
5311
+ return runTool(
5312
+ () => apiJson(getToken, baseUrl, "GET", "/v1/submissions/export", { params: args })
5313
+ );
5314
+ }
5315
+ var MATRIX_DESCRIPTION = [
5316
+ "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.",
5317
+ "USE WHEN: seeing what a submission covers before answering a question about it; finding which metric and year to read with talonic_submissions_facts.",
5318
+ "NOT FOR: the figures themselves (talonic_submissions_facts).",
5319
+ "",
5320
+ "ARGS: `document_id`, `spec_id`.",
5321
+ "RETURNS: { years[], rows[] { metric, family, in_format, facts, years { year: count } } }."
5322
+ ].join("\n");
5323
+ var matrixInputSchema = {
5324
+ document_id: z.string().uuid().describe("Submission (workbook document) id."),
5325
+ spec_id: specId
5326
+ };
5327
+ function handleMatrix(getToken, baseUrl, args) {
5328
+ return runTool(
5329
+ () => apiJson(
5330
+ getToken,
5331
+ baseUrl,
5332
+ "GET",
5333
+ `/v1/submissions/${encodeURIComponent(args.document_id)}/matrix`,
5334
+ {
5335
+ params: { spec_id: args.spec_id }
5336
+ }
5337
+ )
5338
+ );
5339
+ }
5340
+ var FACTS_DESCRIPTION = [
5341
+ `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.`,
5342
+ '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.',
5343
+ "NOT FOR: every fact of a submission (talonic_submissions_export).",
5344
+ "",
5345
+ "ARGS: `document_id`, `spec_id`, `metric`, `year`, `fields`, `limit` (1\u20131000, default 200), `offset`.",
5346
+ "RETURNS: { total, facts[] { metric, figure, year, fields, source { sheet, a1, embedded }, derived, total } }."
5347
+ ].join("\n");
5348
+ var factsInputSchema = {
5349
+ document_id: z.string().uuid().describe("Submission (workbook document) id."),
5350
+ spec_id: specId,
5351
+ metric: z.string().max(200).optional().describe("Metric name exactly as talonic_submissions_matrix lists it."),
5352
+ year: z.string().regex(/^((19|20)\d{2})?$/).optional().describe("Four-digit year, or '' for facts with no period."),
5353
+ fields: z.record(z.string(), z.string()).optional().describe("Field values every fact must carry."),
5354
+ limit: z.number().int().min(1).max(1e3).optional(),
5355
+ offset: z.number().int().min(0).optional()
5356
+ };
5357
+ function handleFacts(getToken, baseUrl, args) {
5358
+ const { document_id, fields, ...rest } = args;
5359
+ return runTool(
5360
+ () => apiJson(getToken, baseUrl, "GET", `/v1/submissions/${encodeURIComponent(document_id)}/facts`, {
5361
+ params: { ...rest, ...fields ? { fields: JSON.stringify(fields) } : {} }
5362
+ })
5363
+ );
5364
+ }
5365
+ var CHECKS_DESCRIPTION = [
5366
+ "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.",
5367
+ "USE WHEN: reviewing a submission's quality, or before quoting a figure that a finding concerns.",
5368
+ "NOT FOR: counts across submissions (talonic_submissions_list).",
5369
+ "",
5370
+ "ARGS: `document_id`, `spec_id` (optional; identities need it).",
5371
+ "RETURNS: [{ kind, severity, sheet, a1, embedded, expected, actual, parts[], check }]."
5372
+ ].join("\n");
5373
+ var checksInputSchema = {
5374
+ document_id: z.string().uuid().describe("Submission (workbook document) id."),
5375
+ spec_id: specId.optional()
5376
+ };
5377
+ function handleChecks(getToken, baseUrl, args) {
5378
+ return runTool(
5379
+ () => apiJson(
5380
+ getToken,
5381
+ baseUrl,
5382
+ "GET",
5383
+ `/v1/submissions/${encodeURIComponent(args.document_id)}/checks`,
5384
+ {
5385
+ params: args.spec_id ? { spec_id: args.spec_id } : {}
5386
+ }
5387
+ )
5388
+ );
5389
+ }
5390
+ async function probeSubmissionsAccess(token, baseUrl) {
5391
+ try {
5392
+ const res = await fetch(buildUrl(baseUrl, "/v1/submissions/specs"), {
5393
+ headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
5394
+ signal: AbortSignal.timeout(5e3)
5395
+ });
5396
+ return res.ok;
5397
+ } catch {
5398
+ return false;
5399
+ }
5400
+ }
5401
+ function registerSubmissionsTools(server, getToken, baseUrl) {
5402
+ const tools = [
5403
+ [
5404
+ "talonic_submissions_specs",
5405
+ "Submission target structures",
5406
+ SPECS_DESCRIPTION,
5407
+ {},
5408
+ readOnly6,
5409
+ () => handleSpecs(getToken, baseUrl)
5410
+ ],
5411
+ [
5412
+ "talonic_submissions_list",
5413
+ "Submissions inbox",
5414
+ LIST_DESCRIPTION,
5415
+ listInputSchema,
5416
+ readOnly6,
5417
+ (a) => handleList(getToken, baseUrl, a)
5418
+ ],
5419
+ [
5420
+ "talonic_submissions_issues",
5421
+ "Submissions worklist",
5422
+ ISSUES_DESCRIPTION5,
5423
+ issuesInputSchema3,
5424
+ readOnly6,
5425
+ (a) => handleIssues5(getToken, baseUrl, a)
5426
+ ],
5427
+ [
5428
+ "talonic_submissions_process",
5429
+ "Capture and map submissions",
5430
+ PROCESS_DESCRIPTION,
5431
+ processInputSchema,
5432
+ write6(true),
5433
+ (a) => handleProcess(getToken, baseUrl, a)
5434
+ ],
5435
+ [
5436
+ "talonic_submissions_completeness",
5437
+ "Submission completeness",
5438
+ COMPLETENESS_DESCRIPTION,
5439
+ completenessInputSchema,
5440
+ readOnly6,
5441
+ (a) => handleCompleteness(getToken, baseUrl, a)
5442
+ ],
5443
+ [
5444
+ "talonic_submissions_matrix",
5445
+ "Submission facts by metric and year",
5446
+ MATRIX_DESCRIPTION,
5447
+ matrixInputSchema,
5448
+ readOnly6,
5449
+ (a) => handleMatrix(getToken, baseUrl, a)
5450
+ ],
5451
+ [
5452
+ "talonic_submissions_facts",
5453
+ "Submission figures",
5454
+ FACTS_DESCRIPTION,
5455
+ factsInputSchema,
5456
+ readOnly6,
5457
+ (a) => handleFacts(getToken, baseUrl, a)
5458
+ ],
5459
+ [
5460
+ "talonic_submissions_checks",
5461
+ "Submission checks",
5462
+ CHECKS_DESCRIPTION,
5463
+ checksInputSchema,
5464
+ readOnly6,
5465
+ (a) => handleChecks(getToken, baseUrl, a)
5466
+ ],
5467
+ [
5468
+ "talonic_submissions_export",
5469
+ "Export submission facts",
5470
+ EXPORT_DESCRIPTION,
5471
+ exportInputSchema,
5472
+ readOnly6,
5473
+ (a) => handleExport(getToken, baseUrl, a)
5474
+ ]
5475
+ ];
5476
+ for (const [name, title, description, inputSchema11, annotations, handler] of tools) {
5477
+ server.registerTool(
5478
+ name,
5479
+ { title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
5480
+ async (args) => handler(args)
5481
+ );
5482
+ }
5483
+ }
4956
5484
  var DEFAULT_BASE3 = "https://api.talonic.com";
4957
5485
  var TASK_STATUSES = ["available", "claimed", "submitted", "timed_out", "cancelled"];
4958
5486
  var taskId = z.string().uuid().describe("Agent task UUID.");
@@ -5689,7 +6217,7 @@ async function resolveFieldId(getToken, baseUrl, args) {
5689
6217
  resolution: { matched_by: resolved.matched_by, redirected_from: resolved.redirected_from }
5690
6218
  };
5691
6219
  }
5692
- var LIST_DESCRIPTION = [
6220
+ var LIST_DESCRIPTION2 = [
5693
6221
  "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.",
5694
6222
  "",
5695
6223
  "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.",
@@ -5803,7 +6331,7 @@ function registerFieldTools(server, getToken, baseUrl) {
5803
6331
  "talonic_list_fields",
5804
6332
  {
5805
6333
  title: "List Registry Fields",
5806
- description: LIST_DESCRIPTION,
6334
+ description: LIST_DESCRIPTION2,
5807
6335
  inputSchema: listFieldsInputSchema,
5808
6336
  annotations: {
5809
6337
  title: "List Registry Fields",
@@ -6025,7 +6553,7 @@ function registerAgentRegistryTools(server, getToken, baseUrl, opts = {}) {
6025
6553
  async (args) => handleInvokeAgentTool(getToken, baseUrl, args)
6026
6554
  );
6027
6555
  }
6028
- var LIST_DESCRIPTION2 = [
6556
+ var LIST_DESCRIPTION3 = [
6029
6557
  "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.",
6030
6558
  "",
6031
6559
  "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.",
@@ -6085,7 +6613,7 @@ function registerSpecTools(server, getToken, baseUrl) {
6085
6613
  "talonic_list_specs",
6086
6614
  {
6087
6615
  title: "List Specs",
6088
- description: LIST_DESCRIPTION2,
6616
+ description: LIST_DESCRIPTION3,
6089
6617
  inputSchema: listSpecsInputSchema,
6090
6618
  annotations: { title: "List Specs", ...READ_ONLY4 },
6091
6619
  _meta: widgetToolMeta("listSpecs")
@@ -6110,7 +6638,7 @@ function mapRunStatus(raw) {
6110
6638
  return "failed";
6111
6639
  return "processing";
6112
6640
  }
6113
- var RUN_DESCRIPTION = [
6641
+ var RUN_DESCRIPTION2 = [
6114
6642
  "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.",
6115
6643
  "",
6116
6644
  "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.",
@@ -6325,7 +6853,7 @@ function registerRunTools(server, getToken, baseUrl) {
6325
6853
  "talonic_run_spec",
6326
6854
  {
6327
6855
  title: "Run a Spec pipeline",
6328
- description: RUN_DESCRIPTION,
6856
+ description: RUN_DESCRIPTION2,
6329
6857
  inputSchema: runSpecInputSchema,
6330
6858
  annotations: {
6331
6859
  title: "Run a Spec pipeline",
@@ -6499,7 +7027,7 @@ function registerAskTools(server, getToken, baseUrl) {
6499
7027
 
6500
7028
  // package.json
6501
7029
  var package_default = {
6502
- version: "0.1.89"};
7030
+ version: "0.1.91"};
6503
7031
 
6504
7032
  // src/version.ts
6505
7033
  var VERSION = package_default.version;
@@ -6552,7 +7080,7 @@ function buildServerInstructions(opts) {
6552
7080
  "apps:decide consent and a senior_member role or above; if a decision tool is marked",
6553
7081
  "not invocable in this session, or a call returns 403, tell the user which consent or",
6554
7082
  "role is missing instead of retrying.",
6555
- "Tools that change workspace data (saving schemas, contract and AP updates, decisions)",
7083
+ "Tools that change workspace data (saving schemas, contract, AP and master record updates, decisions)",
6556
7084
  "should only be called when the user asked for that change."
6557
7085
  ].join(" ");
6558
7086
  }
@@ -6662,6 +7190,12 @@ function createServer(options) {
6662
7190
  if (options.includePartiesTools) {
6663
7191
  registerPartiesTools(server, rawToken, baseUrl);
6664
7192
  }
7193
+ if (options.includeMasterRecordsTools) {
7194
+ registerMasterRecordsTools(server, rawToken, baseUrl);
7195
+ }
7196
+ if (options.includeSubmissionsTools) {
7197
+ registerSubmissionsTools(server, rawToken, baseUrl);
7198
+ }
6665
7199
  registerSchemasResource(server, getTalonic);
6666
7200
  registerWebhooksResource(server, rawToken, baseUrl);
6667
7201
  registerWidgets(server);
@@ -6720,14 +7254,18 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
6720
7254
  includeContractsTools,
6721
7255
  includeApTools,
6722
7256
  includeDocGenTools,
6723
- includePartiesTools
7257
+ includePartiesTools,
7258
+ includeMasterRecordsTools,
7259
+ includeSubmissionsTools
6724
7260
  ] = await Promise.all([
6725
7261
  probeGrowthAccess(apiKey, baseUrl),
6726
7262
  probeAgentTaskAdminAccess(apiKey, baseUrl),
6727
7263
  probeContractsAccess(apiKey, baseUrl),
6728
7264
  probeApAccess(apiKey, baseUrl),
6729
7265
  probeDocGenAccess(apiKey, baseUrl),
6730
- probePartiesAccess(apiKey, baseUrl)
7266
+ probePartiesAccess(apiKey, baseUrl),
7267
+ probeMasterRecordsAccess(apiKey, baseUrl),
7268
+ probeSubmissionsAccess(apiKey, baseUrl)
6731
7269
  ]);
6732
7270
  const server = createServer({
6733
7271
  apiKey,
@@ -6737,7 +7275,9 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
6737
7275
  includeContractsTools,
6738
7276
  includeApTools,
6739
7277
  includeDocGenTools,
6740
- includePartiesTools
7278
+ includePartiesTools,
7279
+ includeMasterRecordsTools,
7280
+ includeSubmissionsTools
6741
7281
  });
6742
7282
  const transport = new StdioServerTransport();
6743
7283
  await server.connect(transport);