@talonic/mcp 0.1.91 → 0.1.92
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/CHANGELOG.md +9 -0
- package/dist/http-server.js +970 -10
- package/dist/http-server.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +944 -7
- package/dist/index.js.map +1 -1
- package/dist/server.js +961 -10
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/http-server.js
CHANGED
|
@@ -3135,6 +3135,56 @@ function handleUpcoming(getToken, baseUrl, args) {
|
|
|
3135
3135
|
() => apiJson(getToken, baseUrl, "GET", "/v1/contracts/upcoming", { params: { days: args.days } })
|
|
3136
3136
|
);
|
|
3137
3137
|
}
|
|
3138
|
+
var PROCESSES_DESCRIPTION = [
|
|
3139
|
+
"Open processes the contract data starts for people across contracts, from the captured Spec fields, the ERP contract register (Dynamics ku_* columns), document types and Money Found: sales (price fixing 3 months before commissioning, the notice window as the ERP keeps it, missing sales opportunity, tacit renewals to reprice, lost to competition), billing (billing held until commissioning, ERP record after signing, run-out phase, CPI adjustment, rent due), legal (land-register entry, termination received, breach, change of control, consumer law), operations (overdue supply start, missing commissioning protocol, SLAs, fuels, warranties), property (the easement DBK chain, security rights target vs actual), contract_management (signing workflow backlog: drafts, originals, documents, owner missing), procurement (subcontracts, purchase-side notice, upstream supplier), controlling (severance, asset transfer, tax and levy clauses, intercompany). Each item names its department, phase, kind (deadline / event / ingest / backlog), due date (null when the data names none yet), days_left (negative = overdue) and the fields it rests on. Items marked handled are left out.",
|
|
3140
|
+
"USE WHEN: what a department has to start now; preparing a sales, billing, legal or operations worklist from contract data; a digest or ticket export.",
|
|
3141
|
+
"NOT FOR: dates only (talonic_contracts_upcoming); one contract's processes (talonic_contracts_contract, `processes[]`).",
|
|
3142
|
+
"",
|
|
3143
|
+
"ARGS: `department` (sales | billing | legal | operations | property | contract_management | procurement | controlling), `days` (horizon for dated items, default the workspace's process horizon, 180), `contract_id`.",
|
|
3144
|
+
"RETURNS: data[] { id, contract_id, contract_key, title, counterparty, rule_id, department, phase, kind, due_date, days_left, evidence[] { field, value, document_id } }."
|
|
3145
|
+
].join("\n");
|
|
3146
|
+
var DEPARTMENTS = [
|
|
3147
|
+
"sales",
|
|
3148
|
+
"billing",
|
|
3149
|
+
"legal",
|
|
3150
|
+
"operations",
|
|
3151
|
+
"property",
|
|
3152
|
+
"contract_management",
|
|
3153
|
+
"procurement",
|
|
3154
|
+
"controlling"
|
|
3155
|
+
];
|
|
3156
|
+
var processesInputSchema = {
|
|
3157
|
+
department: z.enum(DEPARTMENTS).optional().describe("Only this department's items."),
|
|
3158
|
+
days: z.number().int().min(1).max(3650).optional().describe("Days ahead for dated items."),
|
|
3159
|
+
contract_id: z.string().uuid().optional().describe("Only this contract's items.")
|
|
3160
|
+
};
|
|
3161
|
+
function handleProcesses(getToken, baseUrl, args) {
|
|
3162
|
+
return runTool(
|
|
3163
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/contracts/processes", {
|
|
3164
|
+
params: { department: args.department, days: args.days, contract_id: args.contract_id }
|
|
3165
|
+
})
|
|
3166
|
+
);
|
|
3167
|
+
}
|
|
3168
|
+
var PROCESS_DESCRIPTION = [
|
|
3169
|
+
"Mark a process item handled (it ran: the price was agreed, the invoice went out, the entry was filed) or open again. A decision, recorded with who made it; it survives every rebuild. A moved deadline opens the process again.",
|
|
3170
|
+
"USE WHEN: a process from talonic_contracts_processes was done, or was marked by mistake.",
|
|
3171
|
+
"NOT FOR: key dates (talonic_contracts_key_date).",
|
|
3172
|
+
"",
|
|
3173
|
+
"ARGS: `process_id`, `handled` (true / false), `note` (what was done).",
|
|
3174
|
+
"RETURNS: { id, handled }."
|
|
3175
|
+
].join("\n");
|
|
3176
|
+
var processInputSchema = {
|
|
3177
|
+
process_id: z.string().uuid(),
|
|
3178
|
+
handled: z.boolean(),
|
|
3179
|
+
note: z.string().max(2e3).optional()
|
|
3180
|
+
};
|
|
3181
|
+
function handleProcess(getToken, baseUrl, args) {
|
|
3182
|
+
return runTool(
|
|
3183
|
+
() => apiJson(getToken, baseUrl, "POST", `/v1/contracts/processes/${args.process_id}`, {
|
|
3184
|
+
body: { handled: args.handled, note: args.note }
|
|
3185
|
+
})
|
|
3186
|
+
);
|
|
3187
|
+
}
|
|
3138
3188
|
var CANDIDATES_DESCRIPTION = [
|
|
3139
3189
|
"Contract documents whose terms have not been read yet, grouped by the contract key in their filename; keys Contract Pricing already models first.",
|
|
3140
3190
|
"USE WHEN: choosing what to read, or checking how the documents will group before importing.",
|
|
@@ -3444,6 +3494,22 @@ function registerContractsTools(server, getToken, baseUrl) {
|
|
|
3444
3494
|
write(true),
|
|
3445
3495
|
(a) => handleKeyDate(getToken, baseUrl, a)
|
|
3446
3496
|
],
|
|
3497
|
+
[
|
|
3498
|
+
"talonic_contracts_processes",
|
|
3499
|
+
"Processes the contract data starts",
|
|
3500
|
+
PROCESSES_DESCRIPTION,
|
|
3501
|
+
processesInputSchema,
|
|
3502
|
+
readOnly,
|
|
3503
|
+
(a) => handleProcesses(getToken, baseUrl, a)
|
|
3504
|
+
],
|
|
3505
|
+
[
|
|
3506
|
+
"talonic_contracts_process",
|
|
3507
|
+
"Mark a process handled",
|
|
3508
|
+
PROCESS_DESCRIPTION,
|
|
3509
|
+
processInputSchema,
|
|
3510
|
+
write(true),
|
|
3511
|
+
(a) => handleProcess(getToken, baseUrl, a)
|
|
3512
|
+
],
|
|
3447
3513
|
[
|
|
3448
3514
|
"talonic_contracts_set_term",
|
|
3449
3515
|
"Set a contract term with its quote",
|
|
@@ -5264,7 +5330,7 @@ function handleIssues5(getToken, baseUrl, args) {
|
|
|
5264
5330
|
() => apiJson(getToken, baseUrl, "GET", "/v1/submissions/issues", { params: args })
|
|
5265
5331
|
);
|
|
5266
5332
|
}
|
|
5267
|
-
var
|
|
5333
|
+
var PROCESS_DESCRIPTION2 = [
|
|
5268
5334
|
"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.",
|
|
5269
5335
|
"USE WHEN: new submissions arrived (only: not_captured), or a target structure changed and submissions need re-mapping (only: not_mapped or all).",
|
|
5270
5336
|
"NOT FOR: reading results (talonic_submissions_list, talonic_submissions_issues).",
|
|
@@ -5272,7 +5338,7 @@ var PROCESS_DESCRIPTION = [
|
|
|
5272
5338
|
"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`.",
|
|
5273
5339
|
"RETURNS: dry_run \u2192 { plan[] { document_id, filename, capture, map } }; otherwise { results[] { document_id, ok, facts?, checks_failed?, error? } }."
|
|
5274
5340
|
].join("\n");
|
|
5275
|
-
var
|
|
5341
|
+
var processInputSchema2 = {
|
|
5276
5342
|
spec_id: specId.optional(),
|
|
5277
5343
|
document_ids: z.array(z.string().uuid()).max(200).optional(),
|
|
5278
5344
|
only: z.enum(["not_captured", "not_mapped", "all"]).optional(),
|
|
@@ -5280,7 +5346,7 @@ var processInputSchema = {
|
|
|
5280
5346
|
limit: z.number().int().min(1).max(200).optional(),
|
|
5281
5347
|
dry_run: z.boolean().optional().describe("List what would run; nothing runs.")
|
|
5282
5348
|
};
|
|
5283
|
-
function
|
|
5349
|
+
function handleProcess2(getToken, baseUrl, args) {
|
|
5284
5350
|
return runTool(
|
|
5285
5351
|
() => apiJson(getToken, baseUrl, "POST", "/v1/submissions/process", { body: args })
|
|
5286
5352
|
);
|
|
@@ -5402,6 +5468,56 @@ function handleChecks(getToken, baseUrl, args) {
|
|
|
5402
5468
|
)
|
|
5403
5469
|
);
|
|
5404
5470
|
}
|
|
5471
|
+
var REVIEW_DESCRIPTION = [
|
|
5472
|
+
"Agentic review of a target structure's label mappings (how each spreadsheet label maps onto the client's metrics and fields). Without `start`: the review's progress and the decisions stored (confirmed, corrected, best guesses, answered by experts, still proposed, open questions). With `start: true`: rule-made mappings are confirmed, the review agent decides the rest, the few only the client can answer become questions, and every mapped submission is re-mapped; runs in the background, poll without `start`.",
|
|
5473
|
+
"USE WHEN: labels are waiting for review (talonic_submissions_specs shows labels_to_review) and nobody will check them one by one.",
|
|
5474
|
+
"NOT FOR: the questions themselves (talonic_submissions_questions).",
|
|
5475
|
+
"",
|
|
5476
|
+
"ARGS: `spec_id`, `start` (true to start a review).",
|
|
5477
|
+
"RETURNS: { run: { phase, done, total, stats } | null, decisions: { total, proposed, questions, confirmed, fixed, best_guess, answered } }."
|
|
5478
|
+
].join("\n");
|
|
5479
|
+
var reviewInputSchema = {
|
|
5480
|
+
spec_id: z.string().uuid().describe("Target structure id (talonic_submissions_specs)."),
|
|
5481
|
+
start: z.boolean().optional().describe("Start a review instead of reading its status.")
|
|
5482
|
+
};
|
|
5483
|
+
function handleReview(getToken, baseUrl, args) {
|
|
5484
|
+
return runTool(
|
|
5485
|
+
() => args.start ? apiJson(getToken, baseUrl, "POST", "/v1/submissions/review", {
|
|
5486
|
+
body: { spec_id: args.spec_id }
|
|
5487
|
+
}) : apiJson(getToken, baseUrl, "GET", "/v1/submissions/review", {
|
|
5488
|
+
params: { spec_id: args.spec_id }
|
|
5489
|
+
})
|
|
5490
|
+
);
|
|
5491
|
+
}
|
|
5492
|
+
var QUESTIONS_DESCRIPTION = [
|
|
5493
|
+
"The open questions the label review left for the client's experts, one per group, heaviest first. Without `group`: the questions with their options and the labels each settles. With `group` and `option`: record the expert's answer; every label of the group takes the mapping that answer means, and the submissions are re-mapped.",
|
|
5494
|
+
"USE WHEN: walking the client's experts through the few questions only they can answer, or recording their answers.",
|
|
5495
|
+
"NOT FOR: starting a review (talonic_submissions_review).",
|
|
5496
|
+
"",
|
|
5497
|
+
"ARGS: `spec_id`; to answer: `group` (from the list) and `option` (0-based index into its options).",
|
|
5498
|
+
"RETURNS: list: data[] { group, question, options[], labels[] { label_key, text, where, samples[] } }; answer: { settled }."
|
|
5499
|
+
].join("\n");
|
|
5500
|
+
var questionsInputSchema = {
|
|
5501
|
+
spec_id: z.string().uuid().describe("Target structure id (talonic_submissions_specs)."),
|
|
5502
|
+
group: z.string().max(400).optional().describe("The question group to answer (from the list)."),
|
|
5503
|
+
option: z.number().int().min(0).max(5).optional().describe("0-based index of the chosen option.")
|
|
5504
|
+
};
|
|
5505
|
+
function handleQuestions(getToken, baseUrl, args) {
|
|
5506
|
+
if (args.group === void 0 !== (args.option === void 0)) {
|
|
5507
|
+
return Promise.resolve(
|
|
5508
|
+
validationError(
|
|
5509
|
+
"Give both `group` and `option` to answer, or neither to list the questions."
|
|
5510
|
+
)
|
|
5511
|
+
);
|
|
5512
|
+
}
|
|
5513
|
+
return runTool(
|
|
5514
|
+
() => args.group !== void 0 ? apiJson(getToken, baseUrl, "POST", "/v1/submissions/questions/answer", {
|
|
5515
|
+
body: { spec_id: args.spec_id, group: args.group, option: args.option }
|
|
5516
|
+
}) : apiJson(getToken, baseUrl, "GET", "/v1/submissions/questions", {
|
|
5517
|
+
params: { spec_id: args.spec_id }
|
|
5518
|
+
})
|
|
5519
|
+
);
|
|
5520
|
+
}
|
|
5405
5521
|
async function probeSubmissionsAccess(token, baseUrl) {
|
|
5406
5522
|
try {
|
|
5407
5523
|
const res = await fetch(buildUrl(baseUrl, "/v1/submissions/specs"), {
|
|
@@ -5442,10 +5558,10 @@ function registerSubmissionsTools(server, getToken, baseUrl) {
|
|
|
5442
5558
|
[
|
|
5443
5559
|
"talonic_submissions_process",
|
|
5444
5560
|
"Capture and map submissions",
|
|
5445
|
-
|
|
5446
|
-
|
|
5561
|
+
PROCESS_DESCRIPTION2,
|
|
5562
|
+
processInputSchema2,
|
|
5447
5563
|
write6(true),
|
|
5448
|
-
(a) =>
|
|
5564
|
+
(a) => handleProcess2(getToken, baseUrl, a)
|
|
5449
5565
|
],
|
|
5450
5566
|
[
|
|
5451
5567
|
"talonic_submissions_completeness",
|
|
@@ -5479,6 +5595,22 @@ function registerSubmissionsTools(server, getToken, baseUrl) {
|
|
|
5479
5595
|
readOnly6,
|
|
5480
5596
|
(a) => handleChecks(getToken, baseUrl, a)
|
|
5481
5597
|
],
|
|
5598
|
+
[
|
|
5599
|
+
"talonic_submissions_review",
|
|
5600
|
+
"Review label mappings",
|
|
5601
|
+
REVIEW_DESCRIPTION,
|
|
5602
|
+
reviewInputSchema,
|
|
5603
|
+
write6(true),
|
|
5604
|
+
(a) => handleReview(getToken, baseUrl, a)
|
|
5605
|
+
],
|
|
5606
|
+
[
|
|
5607
|
+
"talonic_submissions_questions",
|
|
5608
|
+
"Questions for the client's experts",
|
|
5609
|
+
QUESTIONS_DESCRIPTION,
|
|
5610
|
+
questionsInputSchema,
|
|
5611
|
+
write6(true),
|
|
5612
|
+
(a) => handleQuestions(getToken, baseUrl, a)
|
|
5613
|
+
],
|
|
5482
5614
|
[
|
|
5483
5615
|
"talonic_submissions_export",
|
|
5484
5616
|
"Export submission facts",
|
|
@@ -5496,6 +5628,819 @@ function registerSubmissionsTools(server, getToken, baseUrl) {
|
|
|
5496
5628
|
);
|
|
5497
5629
|
}
|
|
5498
5630
|
}
|
|
5631
|
+
var MONTH_RE = /^\d{4}-\d{2}$/;
|
|
5632
|
+
var INDEX_PERIOD_RE = /^\d{4}(-\d{2}|-Q[1-4]|-H[12])?$/;
|
|
5633
|
+
var modelIdArg = z.string().uuid().describe("Price model id (from talonic_price_baseline_models).");
|
|
5634
|
+
var fromArg = z.string().regex(MONTH_RE).describe("First month of the evaluation window, `YYYY-MM`.");
|
|
5635
|
+
var toArg = z.string().regex(MONTH_RE).describe("Last month of the evaluation window, `YYYY-MM`.");
|
|
5636
|
+
var readOnly7 = {
|
|
5637
|
+
readOnlyHint: true,
|
|
5638
|
+
destructiveHint: false,
|
|
5639
|
+
idempotentHint: true,
|
|
5640
|
+
openWorldHint: false
|
|
5641
|
+
};
|
|
5642
|
+
var DOCUMENTS_DESCRIPTION = [
|
|
5643
|
+
"Find contracts and invoices in the workspace to build a price baseline from.",
|
|
5644
|
+
"USE WHEN: picking the contract for talonic_price_baseline_extract or the invoice for talonic_price_baseline_compare.",
|
|
5645
|
+
"NOT FOR: general document search across all content (talonic_search).",
|
|
5646
|
+
"",
|
|
5647
|
+
"ARGS: `query` (filename contains, optional).",
|
|
5648
|
+
"RETURNS: data[] { id, filename, created_at }. Which contracts already have a model: talonic_price_baseline_models."
|
|
5649
|
+
].join("\n");
|
|
5650
|
+
var documentsInputSchema = {
|
|
5651
|
+
query: z.string().optional().describe("Filename contains match (e.g. 'W\xE4rmeliefervertrag').")
|
|
5652
|
+
};
|
|
5653
|
+
function handleDocuments(getToken, baseUrl, args) {
|
|
5654
|
+
return runTool(
|
|
5655
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/price-baseline/documents", {
|
|
5656
|
+
params: { q: args.query }
|
|
5657
|
+
})
|
|
5658
|
+
);
|
|
5659
|
+
}
|
|
5660
|
+
var EXTRACT_DESCRIPTION = [
|
|
5661
|
+
"Read a contract's price clause into a standard price model: components (Arbeitspreis, Grundpreis, CO2, ...), their formulas, the named indices with base year and reference months, and every stated number with its verified contract quote. With `model_id` instead, read only the contract's identity (contract number, customer, site) and agreed quantities into that existing model, keeping its formulas and values.",
|
|
5662
|
+
"USE WHEN: a contract has no price model yet (`document_id`), or a model lacks its contract number or agreed quantities, e.g. the contract workbook asks for a quantity (`model_id`). Many contracts at once: talonic_price_baseline_import.",
|
|
5663
|
+
"NOT FOR: generic field extraction (talonic_extract); editing an existing model (talonic_price_baseline_update_model).",
|
|
5664
|
+
"",
|
|
5665
|
+
"ARGS: `document_id` (contract UUID) or `model_id` (enrich), `use_opus` (slower, for long or unusual clauses; document_id only).",
|
|
5666
|
+
"RETURNS: the stored model { id, document_id, contract_key, contract_label, status, model }. Costs one LLM call. A value whose quote does not verify carries `evidence.verified: false` and counts as missing. Enrich keys the model by its contract number when it has no key yet."
|
|
5667
|
+
].join("\n");
|
|
5668
|
+
var extractInputSchema = {
|
|
5669
|
+
document_id: z.string().uuid().optional().describe("Contract document UUID (new model)."),
|
|
5670
|
+
model_id: modelIdArg.optional().describe(
|
|
5671
|
+
"Existing model to enrich with contract number, customer, site and agreed quantities."
|
|
5672
|
+
),
|
|
5673
|
+
use_opus: z.boolean().optional().describe("Use the larger model for long or unusual price clauses.")
|
|
5674
|
+
};
|
|
5675
|
+
function handleExtract2(getToken, baseUrl, args) {
|
|
5676
|
+
if (!!args.document_id === !!args.model_id) {
|
|
5677
|
+
return Promise.resolve(
|
|
5678
|
+
validationError("provide either `document_id` (new model) or `model_id` (enrich), not both")
|
|
5679
|
+
);
|
|
5680
|
+
}
|
|
5681
|
+
if (args.model_id) {
|
|
5682
|
+
return runTool(
|
|
5683
|
+
() => apiJson(
|
|
5684
|
+
getToken,
|
|
5685
|
+
baseUrl,
|
|
5686
|
+
"POST",
|
|
5687
|
+
`/v1/price-baseline/models/${encodeURIComponent(args.model_id)}/enrich`
|
|
5688
|
+
)
|
|
5689
|
+
);
|
|
5690
|
+
}
|
|
5691
|
+
return runTool(
|
|
5692
|
+
() => apiJson(getToken, baseUrl, "POST", "/v1/price-baseline/models", {
|
|
5693
|
+
body: { document_id: args.document_id, use_opus: args.use_opus }
|
|
5694
|
+
})
|
|
5695
|
+
);
|
|
5696
|
+
}
|
|
5697
|
+
var MODELS_DESCRIPTION = [
|
|
5698
|
+
"List the workspace's price models, or read one in full when `model_id` is given.",
|
|
5699
|
+
"USE WHEN: finding a model id, or reviewing a model's components, formulas, indices and quotes before confirming it.",
|
|
5700
|
+
"NOT FOR: computed prices (talonic_price_baseline_prices); invoice checks (talonic_price_baseline_compare).",
|
|
5701
|
+
"",
|
|
5702
|
+
"ARGS: `model_id` (optional UUID).",
|
|
5703
|
+
"RETURNS: without id, data[] { id, document_id, contract_label, status, components, unverified_values, index_series, updated_at }; with id, the stored model with its full `model`."
|
|
5704
|
+
].join("\n");
|
|
5705
|
+
var modelsInputSchema = {
|
|
5706
|
+
model_id: modelIdArg.optional()
|
|
5707
|
+
};
|
|
5708
|
+
function handleModels(getToken, baseUrl, args) {
|
|
5709
|
+
const path = args.model_id ? `/v1/price-baseline/models/${encodeURIComponent(args.model_id)}` : "/v1/price-baseline/models";
|
|
5710
|
+
return runTool(() => apiJson(getToken, baseUrl, "GET", path));
|
|
5711
|
+
}
|
|
5712
|
+
var UPDATE_DESCRIPTION = [
|
|
5713
|
+
"Edit a price model after review: replace its model, confirm it, place it in a contract, or exclude it.",
|
|
5714
|
+
"USE WHEN: a formula, index or reference month was read wrong; the reviewer confirms the model; a document belongs to another contract (`contract_key`); a document of the contract sets no price, e.g. a withdrawn letter or cover mail (`status: excluded`).",
|
|
5715
|
+
"NOT FOR: first extraction (talonic_price_baseline_extract); entering one missing contract value (talonic_price_baseline_answer).",
|
|
5716
|
+
"",
|
|
5717
|
+
"ARGS: `model_id`, and at least one of `model` (the full model object from talonic_price_baseline_models, edited), `status` (draft | confirmed | excluded), `contract_key` (the contract number every version of the contract shares; null clears a hand-set key), `superseded_by` (model of a later amendment that replaces this one from its valid_from; null unlinks).",
|
|
5718
|
+
"RETURNS: the stored model. The platform re-verifies every quote: an edited number only counts when its quote occurs in the contract and prints that number. Models with the same `contract_key` are versions of one contract, ordered by valid_from."
|
|
5719
|
+
].join("\n");
|
|
5720
|
+
var updateInputSchema = {
|
|
5721
|
+
model_id: modelIdArg,
|
|
5722
|
+
model: z.record(z.string(), z.unknown()).optional().describe("The full edited model object (the `model` field of the stored model)."),
|
|
5723
|
+
status: z.enum(["draft", "confirmed", "excluded"]).optional().describe(
|
|
5724
|
+
"`confirmed` once a reviewer accepts the model; `excluded` for a document of the contract that sets no price."
|
|
5725
|
+
),
|
|
5726
|
+
contract_key: z.string().max(64).nullable().optional().describe(
|
|
5727
|
+
"Contract this document belongs to (its contract number); null clears a hand-set key."
|
|
5728
|
+
),
|
|
5729
|
+
superseded_by: z.string().uuid().nullable().optional().describe("Model of the amendment or price sheet that replaces this one; null unlinks.")
|
|
5730
|
+
};
|
|
5731
|
+
function handleUpdate(getToken, baseUrl, args) {
|
|
5732
|
+
const { model_id, ...patch } = args;
|
|
5733
|
+
if (Object.values(patch).every((v) => v === void 0)) {
|
|
5734
|
+
return Promise.resolve(
|
|
5735
|
+
validationError("provide at least one of `model`, `status`, `contract_key`, `superseded_by`")
|
|
5736
|
+
);
|
|
5737
|
+
}
|
|
5738
|
+
return runTool(
|
|
5739
|
+
() => apiJson(getToken, baseUrl, "PUT", `/v1/price-baseline/models/${encodeURIComponent(model_id)}`, {
|
|
5740
|
+
body: patch
|
|
5741
|
+
})
|
|
5742
|
+
);
|
|
5743
|
+
}
|
|
5744
|
+
var PRICES_DESCRIPTION = [
|
|
5745
|
+
"Recompute every price of a model for each price period in a window, from the index values on file.",
|
|
5746
|
+
"USE WHEN: you need the contract's own price per period, independent of the biller's price sheet.",
|
|
5747
|
+
"NOT FOR: checking a specific invoice (talonic_price_baseline_compare); the Excel file (talonic_price_baseline_workbook).",
|
|
5748
|
+
"",
|
|
5749
|
+
"ARGS: `model_id`, `from`, `to` (YYYY-MM).",
|
|
5750
|
+
"RETURNS: prices[] { component, period { label, from, to }, price, unit, status, detail, indices[] { variable, series, months, value, sources, independent } } and the index values used. `status` other than ok (missing_index, missing_value, rebase_mismatch, custom_reference, formula_error) means `price` is null; nothing is estimated. Fetch missing public indices with talonic_price_baseline_refresh_indices."
|
|
5751
|
+
].join("\n");
|
|
5752
|
+
var pricesInputSchema = { model_id: modelIdArg, from: fromArg, to: toArg };
|
|
5753
|
+
function handlePrices(getToken, baseUrl, args) {
|
|
5754
|
+
return runTool(
|
|
5755
|
+
() => apiJson(
|
|
5756
|
+
getToken,
|
|
5757
|
+
baseUrl,
|
|
5758
|
+
"GET",
|
|
5759
|
+
`/v1/price-baseline/models/${encodeURIComponent(args.model_id)}/prices`,
|
|
5760
|
+
{
|
|
5761
|
+
params: { from: args.from, to: args.to }
|
|
5762
|
+
}
|
|
5763
|
+
)
|
|
5764
|
+
);
|
|
5765
|
+
}
|
|
5766
|
+
var WORKBOOK_DESCRIPTION = [
|
|
5767
|
+
"Download the standard Excel workbook for a model: Variablen, Preise (live formulas), Indizes, Rechnungspr\xFCfung, Hinweise, Quellen. Every contract comes out in the same layout.",
|
|
5768
|
+
"USE WHEN: the user wants the baseline as a spreadsheet, or to hand over an invoice check.",
|
|
5769
|
+
"NOT FOR: reading prices as data (talonic_price_baseline_prices).",
|
|
5770
|
+
"",
|
|
5771
|
+
"ARGS: `model_id`, `from`, `to` (YYYY-MM), `comparison_id` (optional, fills the Rechnungspr\xFCfung sheet).",
|
|
5772
|
+
"RETURNS: the .xlsx as an embedded resource (base64) plus its filename and size."
|
|
5773
|
+
].join("\n");
|
|
5774
|
+
var workbookInputSchema = {
|
|
5775
|
+
model_id: modelIdArg,
|
|
5776
|
+
from: fromArg,
|
|
5777
|
+
to: toArg,
|
|
5778
|
+
comparison_id: z.string().uuid().optional().describe("Invoice comparison to include (from talonic_price_baseline_compare).")
|
|
5779
|
+
};
|
|
5780
|
+
var XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
5781
|
+
async function handleWorkbook(getToken, baseUrl, args) {
|
|
5782
|
+
try {
|
|
5783
|
+
const url = buildUrl(
|
|
5784
|
+
baseUrl,
|
|
5785
|
+
`/v1/price-baseline/models/${encodeURIComponent(args.model_id)}/workbook.xlsx`,
|
|
5786
|
+
{
|
|
5787
|
+
from: args.from,
|
|
5788
|
+
to: args.to,
|
|
5789
|
+
comparison_id: args.comparison_id
|
|
5790
|
+
}
|
|
5791
|
+
);
|
|
5792
|
+
const res = await resolveFetch(getToken)(url, {
|
|
5793
|
+
headers: { Authorization: `Bearer ${getToken()}`, Accept: XLSX_MIME }
|
|
5794
|
+
});
|
|
5795
|
+
if (!res.ok) {
|
|
5796
|
+
const text = await res.text().catch(() => "");
|
|
5797
|
+
throw new Error(`Talonic API error: HTTP ${res.status}${text ? ` \u2014 ${text}` : ""}`);
|
|
5798
|
+
}
|
|
5799
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
5800
|
+
const filename = /filename="([^"]+)"/.exec(res.headers.get("content-disposition") ?? "")?.[1] ?? `price-baseline-${args.model_id}.xlsx`;
|
|
5801
|
+
return {
|
|
5802
|
+
content: [
|
|
5803
|
+
{ type: "text", text: JSON.stringify({ filename, bytes: buf.length }, null, 2) },
|
|
5804
|
+
{
|
|
5805
|
+
type: "resource",
|
|
5806
|
+
resource: {
|
|
5807
|
+
uri: `talonic://price-baseline/${args.model_id}/${filename}`,
|
|
5808
|
+
mimeType: XLSX_MIME,
|
|
5809
|
+
blob: buf.toString("base64")
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
]
|
|
5813
|
+
};
|
|
5814
|
+
} catch (err) {
|
|
5815
|
+
return toolError(err);
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5818
|
+
var COMPARE_DESCRIPTION = [
|
|
5819
|
+
"Check an invoice against a model: read the invoice's billed prices and quantities, recompute each price from the contract, and report the difference per line.",
|
|
5820
|
+
"USE WHEN: establishing Money Found for an invoice, or listing past checks (`list: true`).",
|
|
5821
|
+
"NOT FOR: prices without an invoice (talonic_price_baseline_prices).",
|
|
5822
|
+
"",
|
|
5823
|
+
"ARGS: `model_id`, `invoice_document_id` (invoice UUID, to run a new check) or `list: true` (past checks).",
|
|
5824
|
+
"RETURNS: { id, invoice, prices, comparison { lines[] { line, baseline_price, billed_price, unit, effect_eur, verdict, reason, independent }, totals { underbilled_eur, overbilled_eur, compared_lines, not_comparable_lines }, amendment_suspects[] } }. Suspected amendments are held out of totals. A baseline built on an index printed only on the invoice is `independent: false`. Costs one LLM call."
|
|
5825
|
+
].join("\n");
|
|
5826
|
+
var compareInputSchema = {
|
|
5827
|
+
model_id: modelIdArg,
|
|
5828
|
+
invoice_document_id: z.string().uuid().optional().describe("Invoice document UUID to check."),
|
|
5829
|
+
list: z.boolean().optional().describe("List this model's past comparisons instead of running one.")
|
|
5830
|
+
};
|
|
5831
|
+
function handleCompare(getToken, baseUrl, args) {
|
|
5832
|
+
const base = `/v1/price-baseline/models/${encodeURIComponent(args.model_id)}`;
|
|
5833
|
+
if (args.list) return runTool(() => apiJson(getToken, baseUrl, "GET", `${base}/comparisons`));
|
|
5834
|
+
if (!args.invoice_document_id) {
|
|
5835
|
+
return Promise.resolve(
|
|
5836
|
+
validationError("provide `invoice_document_id`, or `list: true` for past comparisons")
|
|
5837
|
+
);
|
|
5838
|
+
}
|
|
5839
|
+
return runTool(
|
|
5840
|
+
() => apiJson(getToken, baseUrl, "POST", `${base}/compare`, {
|
|
5841
|
+
body: { invoice_document_id: args.invoice_document_id }
|
|
5842
|
+
})
|
|
5843
|
+
);
|
|
5844
|
+
}
|
|
5845
|
+
var PROOF_INVOICE_DESCRIPTION = [
|
|
5846
|
+
"Restate a checked invoice as the audit-proof invoice the contract supports: every line restated at the contract price, every input (base value, weight, index value, quantity) listed with its source (contract quote, publisher URL and line, the biller's invoice, or a marked assumption), and eight checks that say whether the restatement holds up without anyone's word for it.",
|
|
5847
|
+
"USE WHEN: an invoice was already checked (a comparison exists) and the user needs the corrected invoice to send, file or audit, or wants to know what still keeps it from being audit-proof.",
|
|
5848
|
+
"NOT FOR: running a new check or listing past checks (talonic_price_baseline_compare); prices without an invoice (talonic_price_baseline_prices).",
|
|
5849
|
+
"",
|
|
5850
|
+
"ARGS: `comparison_id` (from talonic_price_baseline_compare), `format` (json, default | html).",
|
|
5851
|
+
"RETURNS (json): { lines[] { label, quantity, unit_price, amount, billed_amount, delta, inputs[] { symbol, value, period, source }, verdict, independent }, totals { net, billed_net, delta, tax_rate, tax, gross }, checks[8] { key, label, passed, detail }, audit_proof, hash, sources[], restates, currency, pdf_url }. delta > 0 = billed too little. html: { html (self-contained page), pdf_url }. pdf_url needs the same bearer; this tool does not download it."
|
|
5852
|
+
].join("\n");
|
|
5853
|
+
var proofInvoiceInputSchema = {
|
|
5854
|
+
comparison_id: z.string().uuid().describe("Comparison UUID (talonic_price_baseline_compare)."),
|
|
5855
|
+
format: z.enum(["json", "html"]).optional().describe("json (default): the restated invoice; html: the self-contained page.")
|
|
5856
|
+
};
|
|
5857
|
+
function handleProofInvoice(getToken, baseUrl, args) {
|
|
5858
|
+
const path = `/v1/price-baseline/comparisons/${encodeURIComponent(args.comparison_id)}/proof-invoice`;
|
|
5859
|
+
return runTool(async () => {
|
|
5860
|
+
const { invoice, html } = await apiJson(
|
|
5861
|
+
getToken,
|
|
5862
|
+
baseUrl,
|
|
5863
|
+
"GET",
|
|
5864
|
+
path
|
|
5865
|
+
);
|
|
5866
|
+
const pdf_url = buildUrl(baseUrl, `${path}.pdf`);
|
|
5867
|
+
return args.format === "html" ? { html, pdf_url } : { ...invoice, pdf_url };
|
|
5868
|
+
});
|
|
5869
|
+
}
|
|
5870
|
+
var INDICES_DESCRIPTION = [
|
|
5871
|
+
"Show the index catalog (series the platform can fetch or accept manually), the sync state of the workspace's external series, or the stored values of given series.",
|
|
5872
|
+
"USE WHEN: a price period reports a missing index, to see which source a value came from, or to see which series are stale or failing (`view: sync`).",
|
|
5873
|
+
"NOT FOR: fetching new values (talonic_price_baseline_sync_series, talonic_price_baseline_refresh_indices) or entering them (talonic_price_baseline_add_index_values).",
|
|
5874
|
+
"",
|
|
5875
|
+
"ARGS: `series` (optional list of series keys, e.g. ['destatis.vpi', 'behg.co2']) for values; else `view` (catalog, default | sync).",
|
|
5876
|
+
"RETURNS: values data[] { series, period, value, unit, base_year, source, source_url, quote, document_id }; catalog data[] { key, label, provider, unit, base_year, note, stored { count, first, last } }; sync data[] { key, label, provider, connector (catalog | manual), shared, sync_hours, active, last_synced_at, last_status, last_error, due, stored, contracts (how many contracts read it) }."
|
|
5877
|
+
].join("\n");
|
|
5878
|
+
var indicesInputSchema = {
|
|
5879
|
+
series: z.array(z.string().min(1)).max(50).optional().describe("Series keys to read values for."),
|
|
5880
|
+
view: z.enum(["catalog", "sync"]).optional().describe("Without `series`: the catalog (default) or each series' sync state.")
|
|
5881
|
+
};
|
|
5882
|
+
function handleIndices(getToken, baseUrl, args) {
|
|
5883
|
+
if (args.series?.length) {
|
|
5884
|
+
return runTool(
|
|
5885
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/price-baseline/indices/values", {
|
|
5886
|
+
params: { series: args.series?.join(",") }
|
|
5887
|
+
})
|
|
5888
|
+
);
|
|
5889
|
+
}
|
|
5890
|
+
if (args.view === "sync") {
|
|
5891
|
+
return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/price-baseline/data/series"));
|
|
5892
|
+
}
|
|
5893
|
+
return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/price-baseline/indices"));
|
|
5894
|
+
}
|
|
5895
|
+
var REFRESH_DESCRIPTION = [
|
|
5896
|
+
"Fetch index values from their publishers: BEHG CO2 price (\xA710 law text), Bundesbank VPI and Erzeugerpreise, Destatis GENESIS tables (needs the platform's GENESIS token).",
|
|
5897
|
+
"USE WHEN: talonic_price_baseline_prices reports a missing public index for a specific year range (backfill).",
|
|
5898
|
+
"NOT FOR: routine sync of every due series (talonic_price_baseline_sync_series); THE levies or grid tariffs, which have no free feed (talonic_price_baseline_add_index_values).",
|
|
5899
|
+
"",
|
|
5900
|
+
"ARGS: `series` (catalog keys), `from_year`, `to_year`.",
|
|
5901
|
+
"RETURNS: data[] { series, stored, error }. A failed series reports its error; it never succeeds empty."
|
|
5902
|
+
].join("\n");
|
|
5903
|
+
var refreshInputSchema = {
|
|
5904
|
+
series: z.array(z.string().min(1)).min(1).max(20).describe("Catalog series keys to fetch."),
|
|
5905
|
+
from_year: z.number().int().min(2e3).max(2100).describe("First year to fetch."),
|
|
5906
|
+
to_year: z.number().int().min(2e3).max(2100).describe("Last year to fetch.")
|
|
5907
|
+
};
|
|
5908
|
+
function handleRefresh(getToken, baseUrl, args) {
|
|
5909
|
+
if (args.to_year < args.from_year)
|
|
5910
|
+
return Promise.resolve(validationError("`to_year` is before `from_year`"));
|
|
5911
|
+
return runTool(
|
|
5912
|
+
() => apiJson(getToken, baseUrl, "POST", "/v1/price-baseline/indices/refresh", { body: args })
|
|
5913
|
+
);
|
|
5914
|
+
}
|
|
5915
|
+
var MANUAL_DESCRIPTION = [
|
|
5916
|
+
"Enter index values that have no free feed (EEX, THE levies, grid tariffs) for this workspace, each with its source.",
|
|
5917
|
+
"USE WHEN: a price needs an index talonic_price_baseline_refresh_indices cannot fetch.",
|
|
5918
|
+
"NOT FOR: public series with a feed (talonic_price_baseline_refresh_indices).",
|
|
5919
|
+
"",
|
|
5920
|
+
"ARGS: `values[]` { series, period (YYYY, YYYY-MM, YYYY-Qn, YYYY-Hn), value, unit?, base_year?, quote, source_url | document_id }. `quote` is the publisher's own line printing the value; a document-backed quote must verify in that document.",
|
|
5921
|
+
"RETURNS: { stored }. A value without a quote and a URL or document is rejected. Never enter a value you did not read from its publication."
|
|
5922
|
+
].join("\n");
|
|
5923
|
+
var manualInputSchema = {
|
|
5924
|
+
values: z.array(
|
|
5925
|
+
z.object({
|
|
5926
|
+
series: z.string().min(1),
|
|
5927
|
+
period: z.string().regex(INDEX_PERIOD_RE),
|
|
5928
|
+
value: z.number(),
|
|
5929
|
+
unit: z.string().optional(),
|
|
5930
|
+
base_year: z.number().int().optional(),
|
|
5931
|
+
quote: z.string().min(1).describe("The publisher's line that prints this value."),
|
|
5932
|
+
source_url: z.string().url().optional(),
|
|
5933
|
+
document_id: z.string().uuid().optional()
|
|
5934
|
+
})
|
|
5935
|
+
).min(1).max(500).describe("Index values, each with its source.")
|
|
5936
|
+
};
|
|
5937
|
+
function handleManual(getToken, baseUrl, args) {
|
|
5938
|
+
const unsourced = args.values.findIndex((v) => !v.source_url && !v.document_id);
|
|
5939
|
+
if (unsourced >= 0) {
|
|
5940
|
+
return Promise.resolve(
|
|
5941
|
+
validationError(`values[${unsourced}] needs a \`source_url\` or \`document_id\``)
|
|
5942
|
+
);
|
|
5943
|
+
}
|
|
5944
|
+
return runTool(
|
|
5945
|
+
() => apiJson(getToken, baseUrl, "POST", "/v1/price-baseline/indices/manual", { body: args })
|
|
5946
|
+
);
|
|
5947
|
+
}
|
|
5948
|
+
var RULES = "RULES: every number needs a source: a verbatim contract quote that prints it, or a publisher URL plus the publisher's line. Nothing is estimated. An assumption is marked on every number built on it, is never independent, and is replaced by a real value automatically.";
|
|
5949
|
+
var REGISTER_DESCRIPTION2 = [
|
|
5950
|
+
"The contract register: one row per contract (all its documents as versions), with the expected invoice for a year and what is still open.",
|
|
5951
|
+
"USE WHEN: seeing what every contract should bill for a year, which contracts still have open inputs, or finding a contract's `id` and `contract_key`.",
|
|
5952
|
+
"NOT FOR: one contract's open inputs in detail (talonic_price_baseline_contract); single model documents (talonic_price_baseline_models).",
|
|
5953
|
+
"",
|
|
5954
|
+
"ARGS: `year` (optional; default the last full calendar year).",
|
|
5955
|
+
"RETURNS: data[] { id (latest version's model id), contract_key, contract_number, customer, customer_number, site, contract_label, valid_from, versions, amended, priced, expected { basis (invoice | plan), net, vat, gross, currency, complete, assumed_net }, invoice { comparison_id, invoice_number, period_from, period_to } | null, open { price (unanswered), waiting (source chosen), assumed, invoice (still missing), period } }. `complete: false` means the totals cover only what could be computed; `assumed_net` is the part resting on assumptions."
|
|
5956
|
+
].join("\n");
|
|
5957
|
+
var registerInputSchema2 = {
|
|
5958
|
+
year: z.number().int().min(2e3).max(2100).optional().describe("Calendar year the expected invoice is computed for.")
|
|
5959
|
+
};
|
|
5960
|
+
function handleRegister2(getToken, baseUrl, args) {
|
|
5961
|
+
return runTool(async () => ({
|
|
5962
|
+
data: await apiJson(getToken, baseUrl, "GET", "/v1/price-baseline/register", {
|
|
5963
|
+
params: { year: args.year }
|
|
5964
|
+
})
|
|
5965
|
+
}));
|
|
5966
|
+
}
|
|
5967
|
+
var CONTRACT_DESCRIPTION3 = [
|
|
5968
|
+
"One contract's workbook: what it should bill for a period, every open input as a question with the ways to answer it, and the assumptions its numbers rest on.",
|
|
5969
|
+
"USE WHEN: finding what is missing for a contract before answering it, or checking the expected invoice after an answer.",
|
|
5970
|
+
"NOT FOR: the Excel file (talonic_price_baseline_workbook); all contracts at once (talonic_price_baseline_register).",
|
|
5971
|
+
"",
|
|
5972
|
+
"ARGS: `model_id` (any version), one period: `year`, `comparison_id` (an invoice check) or `from`+`to` (YYYY-MM); default the newest invoice check, else the last full year. `include_grid` adds all cells.",
|
|
5973
|
+
"RETURNS: { contract_key, period, expected { basis, net, vat, gross, complete, assumed_net }, open[] { key, kind, model_id, variable, series, periods, question, options, decision, assumption, assume_target }, assumptions[], gaps[], sources[], sheets[] }.",
|
|
5974
|
+
"ANSWER by the input's options: enter_contract_value, from_invoice, request \u2192 talonic_price_baseline_answer (with the input's `model_id`); enter_published \u2192 talonic_price_baseline_add_index_values; assume \u2192 talonic_price_baseline_assume (`assume_target`); upload_invoice \u2192 talonic_price_baseline_compare.",
|
|
5975
|
+
RULES
|
|
5976
|
+
].join("\n");
|
|
5977
|
+
var contractInputSchema3 = {
|
|
5978
|
+
model_id: modelIdArg,
|
|
5979
|
+
year: z.number().int().min(2e3).max(2100).optional().describe("Calendar year to prepare."),
|
|
5980
|
+
comparison_id: z.string().uuid().optional().describe("Invoice check whose period and quantities to use."),
|
|
5981
|
+
from: fromArg.optional(),
|
|
5982
|
+
to: toArg.optional(),
|
|
5983
|
+
include_grid: z.boolean().optional().describe("Include every sheet's cell rows (large). Default: sheet names and row counts only.")
|
|
5984
|
+
};
|
|
5985
|
+
function handleContract3(getToken, baseUrl, args) {
|
|
5986
|
+
if (!!args.from !== !!args.to) {
|
|
5987
|
+
return Promise.resolve(validationError("give `from` and `to` together"));
|
|
5988
|
+
}
|
|
5989
|
+
const periods = [args.year !== void 0, !!args.comparison_id, !!args.from].filter(Boolean);
|
|
5990
|
+
if (periods.length > 1) {
|
|
5991
|
+
return Promise.resolve(
|
|
5992
|
+
validationError("choose one period: `year`, `comparison_id`, or `from`+`to`")
|
|
5993
|
+
);
|
|
5994
|
+
}
|
|
5995
|
+
if (args.from && args.to && args.from > args.to) {
|
|
5996
|
+
return Promise.resolve(validationError("`to` is before `from`"));
|
|
5997
|
+
}
|
|
5998
|
+
return runTool(async () => {
|
|
5999
|
+
const book = await apiJson(
|
|
6000
|
+
getToken,
|
|
6001
|
+
baseUrl,
|
|
6002
|
+
"GET",
|
|
6003
|
+
`/v1/price-baseline/models/${encodeURIComponent(args.model_id)}/sheets`,
|
|
6004
|
+
{
|
|
6005
|
+
params: {
|
|
6006
|
+
year: args.year,
|
|
6007
|
+
comparison_id: args.comparison_id,
|
|
6008
|
+
from: args.from,
|
|
6009
|
+
to: args.to
|
|
6010
|
+
}
|
|
6011
|
+
}
|
|
6012
|
+
);
|
|
6013
|
+
if (args.include_grid || !Array.isArray(book?.sheets)) return book;
|
|
6014
|
+
return {
|
|
6015
|
+
...book,
|
|
6016
|
+
sheets: book.sheets.map((s) => ({ name: s.name, rows: s.rows?.length ?? 0 }))
|
|
6017
|
+
};
|
|
6018
|
+
});
|
|
6019
|
+
}
|
|
6020
|
+
var ANSWER_DESCRIPTION = [
|
|
6021
|
+
"Answer an open input of a contract workbook: enter a contract value with its verbatim quote, or record where the value will come from.",
|
|
6022
|
+
"USE WHEN: talonic_price_baseline_contract lists an open input whose options include enter_contract_value, from_invoice or request.",
|
|
6023
|
+
"NOT FOR: published index values (talonic_price_baseline_add_index_values); stand-in values (talonic_price_baseline_assume); editing formulas (talonic_price_baseline_update_model).",
|
|
6024
|
+
"",
|
|
6025
|
+
"ARGS: `model_id` (the open input's own `model_id`: the version that states the value), `action`:",
|
|
6026
|
+
"- enter_contract_value: `variable` (the input's `variable`), `value`, `quote` (the contract's passage, copied verbatim, that prints the value).",
|
|
6027
|
+
"- choose_source: `key` (the input's `key`), `choice` (from_invoice | request; null clears), `note`.",
|
|
6028
|
+
"RETURNS: enter_contract_value, the stored model; choose_source, { key, decision }. A quote that does not occur in the contract or does not print the value is rejected and nothing is saved. A choice records a plan; it never fills a number.",
|
|
6029
|
+
RULES
|
|
6030
|
+
].join("\n");
|
|
6031
|
+
var answerInputSchema = {
|
|
6032
|
+
model_id: modelIdArg,
|
|
6033
|
+
action: z.enum(["enter_contract_value", "choose_source"]),
|
|
6034
|
+
variable: z.string().min(1).max(64).optional().describe("Model variable name (enter_contract_value)."),
|
|
6035
|
+
value: z.number().optional().describe("The number the contract states (enter_contract_value)."),
|
|
6036
|
+
quote: z.string().min(1).max(2e3).optional().describe("Verbatim contract passage that prints the value (enter_contract_value)."),
|
|
6037
|
+
key: z.string().min(1).max(300).optional().describe("Open input key (choose_source)."),
|
|
6038
|
+
choice: z.enum(["from_invoice", "request"]).nullable().optional().describe("Where the value will come from; null clears the choice (choose_source)."),
|
|
6039
|
+
note: z.string().max(2e3).optional().describe("Why, or whom to ask (choose_source).")
|
|
6040
|
+
};
|
|
6041
|
+
function handleAnswer(getToken, baseUrl, args) {
|
|
6042
|
+
const base = `/v1/price-baseline/models/${encodeURIComponent(args.model_id)}`;
|
|
6043
|
+
if (args.action === "enter_contract_value") {
|
|
6044
|
+
if (!args.variable || args.value === void 0 || !args.quote?.trim()) {
|
|
6045
|
+
return Promise.resolve(
|
|
6046
|
+
validationError(
|
|
6047
|
+
"enter_contract_value needs `variable`, `value` and `quote` (the verbatim contract passage printing the value)"
|
|
6048
|
+
)
|
|
6049
|
+
);
|
|
6050
|
+
}
|
|
6051
|
+
return runTool(
|
|
6052
|
+
() => apiJson(getToken, baseUrl, "POST", `${base}/values`, {
|
|
6053
|
+
body: { variable: args.variable, value: args.value, quote: args.quote }
|
|
6054
|
+
})
|
|
6055
|
+
);
|
|
6056
|
+
}
|
|
6057
|
+
if (!args.key || args.choice === void 0) {
|
|
6058
|
+
return Promise.resolve(
|
|
6059
|
+
validationError("choose_source needs `key` and `choice` (from_invoice | request | null)")
|
|
6060
|
+
);
|
|
6061
|
+
}
|
|
6062
|
+
return runTool(
|
|
6063
|
+
() => apiJson(getToken, baseUrl, "POST", `${base}/decide`, {
|
|
6064
|
+
body: { key: args.key, choice: args.choice, note: args.note ?? null }
|
|
6065
|
+
})
|
|
6066
|
+
);
|
|
6067
|
+
}
|
|
6068
|
+
var ASSUMPTIONS_DESCRIPTION = [
|
|
6069
|
+
"List the active assumptions: stand-in values used where no real value exists yet.",
|
|
6070
|
+
"USE WHEN: reviewing what the numbers rest on, or finding an assumption's id to replace or withdraw it.",
|
|
6071
|
+
"NOT FOR: making or changing one (talonic_price_baseline_assume).",
|
|
6072
|
+
"",
|
|
6073
|
+
"ARGS: `contract_key` (optional; the assumptions that apply to that contract, its own and the workspace's). Without it, every active assumption of the workspace.",
|
|
6074
|
+
"RETURNS: data[] { id, contract_key (null = workspace), target_kind, target, period_from, period_to, rule, value, unit, params { series, factor }, note, created_by }."
|
|
6075
|
+
].join("\n");
|
|
6076
|
+
var assumptionsInputSchema = {
|
|
6077
|
+
contract_key: z.string().min(1).max(64).optional().describe("Contract key (from the register) to list the assumptions applying to it.")
|
|
6078
|
+
};
|
|
6079
|
+
function handleAssumptions(getToken, baseUrl, args) {
|
|
6080
|
+
return runTool(
|
|
6081
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/price-baseline/assumptions", {
|
|
6082
|
+
params: { contract_key: args.contract_key }
|
|
6083
|
+
})
|
|
6084
|
+
);
|
|
6085
|
+
}
|
|
6086
|
+
var ASSUME_DESCRIPTION = [
|
|
6087
|
+
"Make, replace or withdraw an assumption: a marked stand-in for a value nobody has yet, for one contract or the whole workspace.",
|
|
6088
|
+
"USE WHEN: an open input offers `assume` and the real value cannot be had now (e.g. a levy not yet published, a quantity the customer has not sent). Use the input's `assume_target` as `target_kind` + `target`.",
|
|
6089
|
+
"NOT FOR: a value you can source: enter it (talonic_price_baseline_answer, talonic_price_baseline_add_index_values). Never assume a number you could read.",
|
|
6090
|
+
"",
|
|
6091
|
+
"ARGS: `action` (create | replace | withdraw), `assumption_id` (replace, withdraw). create/replace (full assumption): `scope` (contract + `contract_key` | workspace), `target_kind` (series | variable | quantity | profile), `target` (series key or variable; `*` = every series, carry_forward only), `rule`, `value`, `unit`, `params { series, factor }`, `period_from`/`period_to` (YYYY[-MM|-Qn|-Hn]; omit = open-ended), `note` (required: why).",
|
|
6092
|
+
"Rule value = this number; carry_forward = the series' last real value; proxy = `params.series` \xD7 `params.factor`. A contract assumption wins over a workspace one. Withdraw reopens the gap.",
|
|
6093
|
+
"RETURNS: the stored assumption, or { id, active: false }.",
|
|
6094
|
+
RULES
|
|
6095
|
+
].join("\n");
|
|
6096
|
+
var assumeInputSchema = {
|
|
6097
|
+
action: z.enum(["create", "replace", "withdraw"]),
|
|
6098
|
+
assumption_id: z.string().uuid().optional().describe("Assumption to replace or withdraw."),
|
|
6099
|
+
scope: z.enum(["contract", "workspace"]).optional().describe("One contract (needs `contract_key`) or every contract of the workspace."),
|
|
6100
|
+
contract_key: z.string().min(1).max(64).optional().describe("Contract key (scope: contract)."),
|
|
6101
|
+
target_kind: z.enum(["series", "variable", "quantity", "profile"]).optional(),
|
|
6102
|
+
target: z.string().min(1).max(120).optional().describe("Series key or variable name; `*` = every series."),
|
|
6103
|
+
rule: z.enum(["value", "carry_forward", "proxy"]).optional(),
|
|
6104
|
+
value: z.number().optional().describe("The assumed number (rule: value)."),
|
|
6105
|
+
unit: z.string().max(40).optional(),
|
|
6106
|
+
params: z.object({
|
|
6107
|
+
series: z.string().min(1).max(120).optional().describe("Source series (proxy, profile)."),
|
|
6108
|
+
factor: z.number().optional().describe("Multiplier on the source series (proxy).")
|
|
6109
|
+
}).optional(),
|
|
6110
|
+
period_from: z.string().regex(INDEX_PERIOD_RE).optional(),
|
|
6111
|
+
period_to: z.string().regex(INDEX_PERIOD_RE).optional(),
|
|
6112
|
+
note: z.string().min(1).max(2e3).optional().describe("Why this assumption is made (required).")
|
|
6113
|
+
};
|
|
6114
|
+
function assumptionProblem(a) {
|
|
6115
|
+
if (!a.scope) return "`scope` is required: contract (with `contract_key`) or workspace";
|
|
6116
|
+
if (a.scope === "contract" && !a.contract_key?.trim())
|
|
6117
|
+
return "scope contract needs `contract_key`";
|
|
6118
|
+
if (a.scope === "workspace" && a.contract_key) return "scope workspace takes no `contract_key`";
|
|
6119
|
+
if (!a.target_kind || !a.target?.trim() || !a.rule)
|
|
6120
|
+
return "`target_kind`, `target` and `rule` are required";
|
|
6121
|
+
if (!a.note?.trim()) return "`note` is required: say why the value is assumed";
|
|
6122
|
+
if (a.rule === "value" && a.target_kind !== "profile" && a.value === void 0)
|
|
6123
|
+
return "rule value needs `value`";
|
|
6124
|
+
if (a.rule === "carry_forward" && a.target_kind !== "series")
|
|
6125
|
+
return "only a series value can be carried forward";
|
|
6126
|
+
if ((a.rule === "proxy" || a.target_kind === "profile") && !a.params?.series)
|
|
6127
|
+
return "name the series it is derived from in `params.series`";
|
|
6128
|
+
if (a.target === "*" && (a.target_kind !== "series" || a.rule !== "carry_forward"))
|
|
6129
|
+
return "a default for every series (*) can only carry the last value forward";
|
|
6130
|
+
return null;
|
|
6131
|
+
}
|
|
6132
|
+
function handleAssume(getToken, baseUrl, args) {
|
|
6133
|
+
const path = (id) => `/v1/price-baseline/assumptions/${encodeURIComponent(id)}`;
|
|
6134
|
+
if (args.action !== "create" && !args.assumption_id) {
|
|
6135
|
+
return Promise.resolve(validationError(`${args.action} needs \`assumption_id\``));
|
|
6136
|
+
}
|
|
6137
|
+
if (args.action === "withdraw") {
|
|
6138
|
+
return runTool(() => apiJson(getToken, baseUrl, "DELETE", path(args.assumption_id)));
|
|
6139
|
+
}
|
|
6140
|
+
const problem = assumptionProblem(args);
|
|
6141
|
+
if (problem) return Promise.resolve(validationError(problem));
|
|
6142
|
+
const body = {
|
|
6143
|
+
contract_key: args.scope === "contract" ? args.contract_key?.trim() : null,
|
|
6144
|
+
target_kind: args.target_kind,
|
|
6145
|
+
target: args.target?.trim(),
|
|
6146
|
+
rule: args.rule,
|
|
6147
|
+
value: args.rule === "value" ? args.value ?? null : null,
|
|
6148
|
+
unit: args.unit ?? null,
|
|
6149
|
+
params: args.params,
|
|
6150
|
+
period_from: args.period_from ?? null,
|
|
6151
|
+
period_to: args.period_to ?? null,
|
|
6152
|
+
note: args.note?.trim()
|
|
6153
|
+
};
|
|
6154
|
+
return args.action === "create" ? runTool(() => apiJson(getToken, baseUrl, "POST", "/v1/price-baseline/assumptions", { body })) : runTool(() => apiJson(getToken, baseUrl, "PUT", path(args.assumption_id), { body }));
|
|
6155
|
+
}
|
|
6156
|
+
var SYNC_DESCRIPTION = [
|
|
6157
|
+
"Sync external price data now (BEHG, Bundesbank, Destatis, EEX via Energy-Charts, DWD degree days), or change how often a series syncs.",
|
|
6158
|
+
"USE WHEN: talonic_price_baseline_indices `view: sync` shows a series as due, failed or stale, or a contract waits on a published value that should be out by now.",
|
|
6159
|
+
"NOT FOR: series with no feed, e.g. THE levies and grid tariffs (talonic_price_baseline_add_index_values); a backfill for a specific year range (talonic_price_baseline_refresh_indices).",
|
|
6160
|
+
"",
|
|
6161
|
+
"ARGS: sync: `keys` (series keys; omit to sync every shared series whose interval has passed). Schedule: `key` with `sync_hours` (1\u20132160) and/or `active` (false pauses; a shared series changes for everyone).",
|
|
6162
|
+
"RETURNS: sync data[] { series, stored, error } (a failed series reports its error, never an empty success); schedule, the series definition. Values arriving replace any assumption standing in for them."
|
|
6163
|
+
].join("\n");
|
|
6164
|
+
var syncInputSchema = {
|
|
6165
|
+
keys: z.array(z.string().min(1)).max(50).optional().describe("Series keys to fetch now."),
|
|
6166
|
+
key: z.string().min(1).max(120).optional().describe("Series whose schedule to change."),
|
|
6167
|
+
sync_hours: z.number().int().min(1).max(2160).optional().describe("Sync interval in hours."),
|
|
6168
|
+
active: z.boolean().optional().describe("false pauses syncing.")
|
|
6169
|
+
};
|
|
6170
|
+
function handleSync(getToken, baseUrl, args) {
|
|
6171
|
+
const schedule = args.key !== void 0 || args.sync_hours !== void 0 || args.active !== void 0;
|
|
6172
|
+
if (schedule) {
|
|
6173
|
+
if (args.keys?.length) {
|
|
6174
|
+
return Promise.resolve(
|
|
6175
|
+
validationError("either sync (`keys`) or change a schedule (`key`), not both")
|
|
6176
|
+
);
|
|
6177
|
+
}
|
|
6178
|
+
if (!args.key || args.sync_hours === void 0 && args.active === void 0) {
|
|
6179
|
+
return Promise.resolve(
|
|
6180
|
+
validationError("a schedule change needs `key` and `sync_hours` or `active`")
|
|
6181
|
+
);
|
|
6182
|
+
}
|
|
6183
|
+
return runTool(
|
|
6184
|
+
() => apiJson(getToken, baseUrl, "PUT", "/v1/price-baseline/data/series", {
|
|
6185
|
+
body: { key: args.key, sync_hours: args.sync_hours, active: args.active }
|
|
6186
|
+
})
|
|
6187
|
+
);
|
|
6188
|
+
}
|
|
6189
|
+
return runTool(async () => ({
|
|
6190
|
+
data: await apiJson(getToken, baseUrl, "POST", "/v1/price-baseline/data/series/sync", {
|
|
6191
|
+
body: args.keys?.length ? { keys: args.keys } : {}
|
|
6192
|
+
})
|
|
6193
|
+
}));
|
|
6194
|
+
}
|
|
6195
|
+
var IMPORTS_DESCRIPTION = [
|
|
6196
|
+
"Contract documents in data capture that have no price model yet, grouped by contract number, or the state of the import queue.",
|
|
6197
|
+
"USE WHEN: bringing a workspace's contracts into Price Baseline: pick candidates, queue them with talonic_price_baseline_import, then poll `view: status`.",
|
|
6198
|
+
"NOT FOR: documents that already have a model (talonic_price_baseline_register); invoices (talonic_price_baseline_documents).",
|
|
6199
|
+
"",
|
|
6200
|
+
"ARGS: `view` (candidates, default | status), `query` (filename contains; candidates only).",
|
|
6201
|
+
"RETURNS: candidates data[] { contract_key, documents[] { document_id, filename, kind (contract | amendment | price_sheet), created_at, import { status, error } | null } }; status { counts { pending, processing, done, failed }, failed[] { document_id, filename, error, attempts } }."
|
|
6202
|
+
].join("\n");
|
|
6203
|
+
var importsInputSchema = {
|
|
6204
|
+
view: z.enum(["candidates", "status"]).optional(),
|
|
6205
|
+
query: z.string().optional().describe("Filename contains match (candidates).")
|
|
6206
|
+
};
|
|
6207
|
+
function handleImports(getToken, baseUrl, args) {
|
|
6208
|
+
if (args.view === "status") {
|
|
6209
|
+
return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/price-baseline/import/status"));
|
|
6210
|
+
}
|
|
6211
|
+
return runTool(
|
|
6212
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/price-baseline/import/candidates", {
|
|
6213
|
+
params: { q: args.query }
|
|
6214
|
+
})
|
|
6215
|
+
);
|
|
6216
|
+
}
|
|
6217
|
+
var IMPORT_DESCRIPTION2 = [
|
|
6218
|
+
"Queue contract documents for import: each one's price model is read in the background, and documents sharing a contract number become versions of one contract.",
|
|
6219
|
+
"USE WHEN: importing several contracts at once from talonic_price_baseline_imports candidates, or retrying failed imports (a failed document is queued again).",
|
|
6220
|
+
"NOT FOR: one contract you want to read now and inspect (talonic_price_baseline_extract).",
|
|
6221
|
+
"",
|
|
6222
|
+
"ARGS: `document_ids` (1\u2013500 document UUIDs).",
|
|
6223
|
+
"RETURNS: { queued, skipped } (a document already queued or done is skipped). Each document costs one LLM call. Poll talonic_price_baseline_imports `view: status`; finished contracts appear in talonic_price_baseline_register."
|
|
6224
|
+
].join("\n");
|
|
6225
|
+
var importInputSchema2 = {
|
|
6226
|
+
document_ids: z.array(z.string().uuid()).min(1).max(500).describe("Contract document UUIDs (from talonic_price_baseline_imports).")
|
|
6227
|
+
};
|
|
6228
|
+
function handleImport2(getToken, baseUrl, args) {
|
|
6229
|
+
return runTool(
|
|
6230
|
+
() => apiJson(getToken, baseUrl, "POST", "/v1/price-baseline/import", {
|
|
6231
|
+
body: { document_ids: [...new Set(args.document_ids)] }
|
|
6232
|
+
})
|
|
6233
|
+
);
|
|
6234
|
+
}
|
|
6235
|
+
async function probePriceBaselineAccess(token, baseUrl) {
|
|
6236
|
+
try {
|
|
6237
|
+
const res = await fetch(buildUrl(baseUrl, "/v1/price-baseline/indices"), {
|
|
6238
|
+
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
|
|
6239
|
+
signal: AbortSignal.timeout(5e3)
|
|
6240
|
+
});
|
|
6241
|
+
return res.ok;
|
|
6242
|
+
} catch {
|
|
6243
|
+
return false;
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
6246
|
+
function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
6247
|
+
const write7 = (idempotent) => ({
|
|
6248
|
+
readOnlyHint: false,
|
|
6249
|
+
destructiveHint: false,
|
|
6250
|
+
idempotentHint: idempotent,
|
|
6251
|
+
openWorldHint: false
|
|
6252
|
+
});
|
|
6253
|
+
server.registerTool(
|
|
6254
|
+
"talonic_price_baseline_documents",
|
|
6255
|
+
{
|
|
6256
|
+
title: "Find contracts and invoices",
|
|
6257
|
+
description: DOCUMENTS_DESCRIPTION,
|
|
6258
|
+
inputSchema: documentsInputSchema,
|
|
6259
|
+
annotations: readOnly7
|
|
6260
|
+
},
|
|
6261
|
+
async (args) => handleDocuments(getToken, baseUrl, args)
|
|
6262
|
+
);
|
|
6263
|
+
server.registerTool(
|
|
6264
|
+
"talonic_price_baseline_extract",
|
|
6265
|
+
{
|
|
6266
|
+
title: "Build or enrich a price model from a contract",
|
|
6267
|
+
description: EXTRACT_DESCRIPTION,
|
|
6268
|
+
inputSchema: extractInputSchema,
|
|
6269
|
+
annotations: write7(false)
|
|
6270
|
+
},
|
|
6271
|
+
async (args) => handleExtract2(getToken, baseUrl, args)
|
|
6272
|
+
);
|
|
6273
|
+
server.registerTool(
|
|
6274
|
+
"talonic_price_baseline_models",
|
|
6275
|
+
{
|
|
6276
|
+
title: "List or read price models",
|
|
6277
|
+
description: MODELS_DESCRIPTION,
|
|
6278
|
+
inputSchema: modelsInputSchema,
|
|
6279
|
+
annotations: readOnly7
|
|
6280
|
+
},
|
|
6281
|
+
async (args) => handleModels(getToken, baseUrl, args)
|
|
6282
|
+
);
|
|
6283
|
+
server.registerTool(
|
|
6284
|
+
"talonic_price_baseline_update_model",
|
|
6285
|
+
{
|
|
6286
|
+
title: "Edit or confirm a price model",
|
|
6287
|
+
description: UPDATE_DESCRIPTION,
|
|
6288
|
+
inputSchema: updateInputSchema,
|
|
6289
|
+
annotations: write7(true)
|
|
6290
|
+
},
|
|
6291
|
+
async (args) => handleUpdate(getToken, baseUrl, args)
|
|
6292
|
+
);
|
|
6293
|
+
server.registerTool(
|
|
6294
|
+
"talonic_price_baseline_prices",
|
|
6295
|
+
{
|
|
6296
|
+
title: "Recompute contract prices",
|
|
6297
|
+
description: PRICES_DESCRIPTION,
|
|
6298
|
+
inputSchema: pricesInputSchema,
|
|
6299
|
+
annotations: readOnly7
|
|
6300
|
+
},
|
|
6301
|
+
async (args) => handlePrices(getToken, baseUrl, args)
|
|
6302
|
+
);
|
|
6303
|
+
server.registerTool(
|
|
6304
|
+
"talonic_price_baseline_workbook",
|
|
6305
|
+
{
|
|
6306
|
+
title: "Download the price baseline workbook",
|
|
6307
|
+
description: WORKBOOK_DESCRIPTION,
|
|
6308
|
+
inputSchema: workbookInputSchema,
|
|
6309
|
+
annotations: readOnly7
|
|
6310
|
+
},
|
|
6311
|
+
async (args) => handleWorkbook(getToken, baseUrl, args)
|
|
6312
|
+
);
|
|
6313
|
+
server.registerTool(
|
|
6314
|
+
"talonic_price_baseline_compare",
|
|
6315
|
+
{
|
|
6316
|
+
title: "Check an invoice against the contract",
|
|
6317
|
+
description: COMPARE_DESCRIPTION,
|
|
6318
|
+
inputSchema: compareInputSchema,
|
|
6319
|
+
annotations: write7(false)
|
|
6320
|
+
},
|
|
6321
|
+
async (args) => handleCompare(getToken, baseUrl, args)
|
|
6322
|
+
);
|
|
6323
|
+
server.registerTool(
|
|
6324
|
+
"talonic_price_baseline_proof_invoice",
|
|
6325
|
+
{
|
|
6326
|
+
title: "Audit-proof invoice",
|
|
6327
|
+
description: PROOF_INVOICE_DESCRIPTION,
|
|
6328
|
+
inputSchema: proofInvoiceInputSchema,
|
|
6329
|
+
annotations: readOnly7
|
|
6330
|
+
},
|
|
6331
|
+
async (args) => handleProofInvoice(getToken, baseUrl, args)
|
|
6332
|
+
);
|
|
6333
|
+
server.registerTool(
|
|
6334
|
+
"talonic_price_baseline_indices",
|
|
6335
|
+
{
|
|
6336
|
+
title: "Index catalog and values",
|
|
6337
|
+
description: INDICES_DESCRIPTION,
|
|
6338
|
+
inputSchema: indicesInputSchema,
|
|
6339
|
+
annotations: readOnly7
|
|
6340
|
+
},
|
|
6341
|
+
async (args) => handleIndices(getToken, baseUrl, args)
|
|
6342
|
+
);
|
|
6343
|
+
server.registerTool(
|
|
6344
|
+
"talonic_price_baseline_refresh_indices",
|
|
6345
|
+
{
|
|
6346
|
+
title: "Fetch public index values",
|
|
6347
|
+
description: REFRESH_DESCRIPTION,
|
|
6348
|
+
inputSchema: refreshInputSchema,
|
|
6349
|
+
annotations: { ...write7(true), openWorldHint: true }
|
|
6350
|
+
},
|
|
6351
|
+
async (args) => handleRefresh(getToken, baseUrl, args)
|
|
6352
|
+
);
|
|
6353
|
+
server.registerTool(
|
|
6354
|
+
"talonic_price_baseline_add_index_values",
|
|
6355
|
+
{
|
|
6356
|
+
title: "Enter sourced index values",
|
|
6357
|
+
description: MANUAL_DESCRIPTION,
|
|
6358
|
+
inputSchema: manualInputSchema,
|
|
6359
|
+
annotations: write7(true)
|
|
6360
|
+
},
|
|
6361
|
+
async (args) => handleManual(getToken, baseUrl, args)
|
|
6362
|
+
);
|
|
6363
|
+
server.registerTool(
|
|
6364
|
+
"talonic_price_baseline_register",
|
|
6365
|
+
{
|
|
6366
|
+
title: "Contract register and expected invoices",
|
|
6367
|
+
description: REGISTER_DESCRIPTION2,
|
|
6368
|
+
inputSchema: registerInputSchema2,
|
|
6369
|
+
annotations: readOnly7
|
|
6370
|
+
},
|
|
6371
|
+
async (args) => handleRegister2(getToken, baseUrl, args)
|
|
6372
|
+
);
|
|
6373
|
+
server.registerTool(
|
|
6374
|
+
"talonic_price_baseline_contract",
|
|
6375
|
+
{
|
|
6376
|
+
title: "Contract workbook and open inputs",
|
|
6377
|
+
description: CONTRACT_DESCRIPTION3,
|
|
6378
|
+
inputSchema: contractInputSchema3,
|
|
6379
|
+
annotations: readOnly7
|
|
6380
|
+
},
|
|
6381
|
+
async (args) => handleContract3(getToken, baseUrl, args)
|
|
6382
|
+
);
|
|
6383
|
+
server.registerTool(
|
|
6384
|
+
"talonic_price_baseline_answer",
|
|
6385
|
+
{
|
|
6386
|
+
title: "Answer an open contract input",
|
|
6387
|
+
description: ANSWER_DESCRIPTION,
|
|
6388
|
+
inputSchema: answerInputSchema,
|
|
6389
|
+
annotations: write7(true)
|
|
6390
|
+
},
|
|
6391
|
+
async (args) => handleAnswer(getToken, baseUrl, args)
|
|
6392
|
+
);
|
|
6393
|
+
server.registerTool(
|
|
6394
|
+
"talonic_price_baseline_assumptions",
|
|
6395
|
+
{
|
|
6396
|
+
title: "List assumptions",
|
|
6397
|
+
description: ASSUMPTIONS_DESCRIPTION,
|
|
6398
|
+
inputSchema: assumptionsInputSchema,
|
|
6399
|
+
annotations: readOnly7
|
|
6400
|
+
},
|
|
6401
|
+
async (args) => handleAssumptions(getToken, baseUrl, args)
|
|
6402
|
+
);
|
|
6403
|
+
server.registerTool(
|
|
6404
|
+
"talonic_price_baseline_assume",
|
|
6405
|
+
{
|
|
6406
|
+
title: "Make, replace or withdraw an assumption",
|
|
6407
|
+
description: ASSUME_DESCRIPTION,
|
|
6408
|
+
inputSchema: assumeInputSchema,
|
|
6409
|
+
annotations: { ...write7(false), destructiveHint: true }
|
|
6410
|
+
},
|
|
6411
|
+
async (args) => handleAssume(getToken, baseUrl, args)
|
|
6412
|
+
);
|
|
6413
|
+
server.registerTool(
|
|
6414
|
+
"talonic_price_baseline_sync_series",
|
|
6415
|
+
{
|
|
6416
|
+
title: "Sync external price data",
|
|
6417
|
+
description: SYNC_DESCRIPTION,
|
|
6418
|
+
inputSchema: syncInputSchema,
|
|
6419
|
+
annotations: { ...write7(true), openWorldHint: true }
|
|
6420
|
+
},
|
|
6421
|
+
async (args) => handleSync(getToken, baseUrl, args)
|
|
6422
|
+
);
|
|
6423
|
+
server.registerTool(
|
|
6424
|
+
"talonic_price_baseline_imports",
|
|
6425
|
+
{
|
|
6426
|
+
title: "Import candidates and status",
|
|
6427
|
+
description: IMPORTS_DESCRIPTION,
|
|
6428
|
+
inputSchema: importsInputSchema,
|
|
6429
|
+
annotations: readOnly7
|
|
6430
|
+
},
|
|
6431
|
+
async (args) => handleImports(getToken, baseUrl, args)
|
|
6432
|
+
);
|
|
6433
|
+
server.registerTool(
|
|
6434
|
+
"talonic_price_baseline_import",
|
|
6435
|
+
{
|
|
6436
|
+
title: "Import contracts from data capture",
|
|
6437
|
+
description: IMPORT_DESCRIPTION2,
|
|
6438
|
+
inputSchema: importInputSchema2,
|
|
6439
|
+
annotations: write7(true)
|
|
6440
|
+
},
|
|
6441
|
+
async (args) => handleImport2(getToken, baseUrl, args)
|
|
6442
|
+
);
|
|
6443
|
+
}
|
|
5499
6444
|
var DEFAULT_BASE3 = "https://api.talonic.com";
|
|
5500
6445
|
var TASK_STATUSES = ["available", "claimed", "submitted", "timed_out", "cancelled"];
|
|
5501
6446
|
var taskId = z.string().uuid().describe("Agent task UUID.");
|
|
@@ -7054,7 +7999,7 @@ function registerAskTools(server, getToken, baseUrl) {
|
|
|
7054
7999
|
|
|
7055
8000
|
// package.json
|
|
7056
8001
|
var package_default = {
|
|
7057
|
-
version: "0.1.
|
|
8002
|
+
version: "0.1.92"};
|
|
7058
8003
|
|
|
7059
8004
|
// src/version.ts
|
|
7060
8005
|
var VERSION = package_default.version;
|
|
@@ -7223,6 +8168,9 @@ function createServer(options) {
|
|
|
7223
8168
|
if (options.includeSubmissionsTools) {
|
|
7224
8169
|
registerSubmissionsTools(server, rawToken, baseUrl);
|
|
7225
8170
|
}
|
|
8171
|
+
if (options.includePriceBaselineTools) {
|
|
8172
|
+
registerPriceBaselineTools(server, rawToken, baseUrl);
|
|
8173
|
+
}
|
|
7226
8174
|
registerSchemasResource(server, getTalonic);
|
|
7227
8175
|
registerWebhooksResource(server, rawToken, baseUrl);
|
|
7228
8176
|
registerWidgets(server);
|
|
@@ -7292,6 +8240,15 @@ async function submissionsAccessCached(token, probe = (t) => probeSubmissionsAcc
|
|
|
7292
8240
|
submissionsProbeCache.set(token, { ok, expiresAt: now() + GROWTH_PROBE_TTL_MS });
|
|
7293
8241
|
return ok;
|
|
7294
8242
|
}
|
|
8243
|
+
var priceBaselineProbeCache = /* @__PURE__ */ new Map();
|
|
8244
|
+
async function priceBaselineAccessCached(token, probe = (t) => probePriceBaselineAccess(t, process.env["TALONIC_BASE_URL"]), now = Date.now) {
|
|
8245
|
+
const hit = priceBaselineProbeCache.get(token);
|
|
8246
|
+
if (hit && hit.expiresAt > now()) return hit.ok;
|
|
8247
|
+
const ok = await probe(token);
|
|
8248
|
+
if (priceBaselineProbeCache.size >= 1e3) priceBaselineProbeCache.clear();
|
|
8249
|
+
priceBaselineProbeCache.set(token, { ok, expiresAt: now() + GROWTH_PROBE_TTL_MS });
|
|
8250
|
+
return ok;
|
|
8251
|
+
}
|
|
7295
8252
|
var docGenProbeCache = /* @__PURE__ */ new Map();
|
|
7296
8253
|
async function docGenAccessCached(token, probe = (t) => probeDocGenAccess(t, process.env["TALONIC_BASE_URL"]), now = Date.now) {
|
|
7297
8254
|
const hit = docGenProbeCache.get(token);
|
|
@@ -7575,7 +8532,8 @@ function createRequestHandler(options = {}) {
|
|
|
7575
8532
|
includeDocGenTools,
|
|
7576
8533
|
includePartiesTools,
|
|
7577
8534
|
includeMasterRecordsTools,
|
|
7578
|
-
includeSubmissionsTools
|
|
8535
|
+
includeSubmissionsTools,
|
|
8536
|
+
includePriceBaselineTools
|
|
7579
8537
|
] = await Promise.all([
|
|
7580
8538
|
(options.growthAccess ?? ((currentToken) => growthAccessCached(
|
|
7581
8539
|
currentToken,
|
|
@@ -7594,7 +8552,8 @@ function createRequestHandler(options = {}) {
|
|
|
7594
8552
|
token
|
|
7595
8553
|
),
|
|
7596
8554
|
(options.masterRecordsAccess ?? ((currentToken) => masterRecordsAccessCached(currentToken)))(token),
|
|
7597
|
-
(options.submissionsAccess ?? ((currentToken) => submissionsAccessCached(currentToken)))(token)
|
|
8555
|
+
(options.submissionsAccess ?? ((currentToken) => submissionsAccessCached(currentToken)))(token),
|
|
8556
|
+
(options.priceBaselineAccess ?? ((currentToken) => priceBaselineAccessCached(currentToken)))(token)
|
|
7598
8557
|
]);
|
|
7599
8558
|
const mcpServer = createServer({
|
|
7600
8559
|
tokenProvider: () => token,
|
|
@@ -7606,6 +8565,7 @@ function createRequestHandler(options = {}) {
|
|
|
7606
8565
|
includePartiesTools,
|
|
7607
8566
|
includeMasterRecordsTools,
|
|
7608
8567
|
includeSubmissionsTools,
|
|
8568
|
+
includePriceBaselineTools,
|
|
7609
8569
|
...process.env["TALONIC_BASE_URL"] ? { baseUrl: process.env["TALONIC_BASE_URL"] } : {},
|
|
7610
8570
|
// Listing UX only: an OAuth token that visibly lacks apps:decide gets
|
|
7611
8571
|
// the decision-task tools marked non-invocable. The platform decides.
|
|
@@ -7644,6 +8604,6 @@ if (isDirectInvocation()) {
|
|
|
7644
8604
|
});
|
|
7645
8605
|
}
|
|
7646
8606
|
|
|
7647
|
-
export { adminAgentTaskAccessCached, apAccessCached, contractsAccessCached, createRequestHandler, docGenAccessCached, growthAccessCached, isOpenAiClient, masterRecordsAccessCached, partiesAccessCached, submissionsAccessCached };
|
|
8607
|
+
export { adminAgentTaskAccessCached, apAccessCached, contractsAccessCached, createRequestHandler, docGenAccessCached, growthAccessCached, isOpenAiClient, masterRecordsAccessCached, partiesAccessCached, priceBaselineAccessCached, submissionsAccessCached };
|
|
7648
8608
|
//# sourceMappingURL=http-server.js.map
|
|
7649
8609
|
//# sourceMappingURL=http-server.js.map
|