@talonic/mcp 0.1.88 → 0.1.89
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 +13 -1
- package/dist/http-server.js +602 -15
- package/dist/http-server.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +574 -12
- package/dist/index.js.map +1 -1
- package/dist/server.js +591 -15
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/http-server.js
CHANGED
|
@@ -3723,7 +3723,7 @@ var templateIdArg = z.string().uuid().describe("Template id (from talonic_doc_ge
|
|
|
3723
3723
|
var productIdArg = z.string().uuid().describe("Data product id (from talonic_doc_gen_products).");
|
|
3724
3724
|
var jobIdArg = z.string().uuid().describe("Batch id (from talonic_doc_gen_jobs or _generate).");
|
|
3725
3725
|
var valuesArg = z.record(z.string(), z.string()).describe(
|
|
3726
|
-
|
|
3726
|
+
'Values by field key (or case key). A field whose source type is `case` (entered per document) takes the value as entered; a passage decided per document (condition `ask`) takes "yes" or "no" (include or leave out; it stays missing until decided); a value for any other field is an edit over the fill, recorded in the document history.'
|
|
3727
3727
|
);
|
|
3728
3728
|
var ENTERED_RULE = "Fields whose source type is `case` are entered per document: the data does not hold them (e.g. the new owner), so pass them in `values` by field key (or case key). A value for any other field overrides the fill and is recorded as an edit in the document history.";
|
|
3729
3729
|
function waitSeconds(requested, max) {
|
|
@@ -3798,10 +3798,11 @@ var UPDATE_TEMPLATE_DESCRIPTION = [
|
|
|
3798
3798
|
"Change a template's metadata (name, group, kind, companion template, version) and its fields by key: a field's label, source, confirmed flag or reason. Fields not named stay as they are; an unknown key is refused. Run with dry_run first to see the sheet as it would be.",
|
|
3799
3799
|
"USE WHEN: fixing a field the proposal got wrong (e.g. pointing it at another column or making it entered per document with source { type: 'case', caseKey }), or pairing a letter with its agreement.",
|
|
3800
3800
|
"Setting `confirmed: true` is a person's decision: only do it when the user asked (see talonic_doc_gen_confirm_fields).",
|
|
3801
|
+
"Red passages (fields with `spot.original`, red text in the Word file): set a `variant` for grammar that depends on the party, a `condition` for text printed only sometimes, any value source, or `fixed` to keep the words (in black). `rescan: true` first adds the red passages of a template whose sheet predates them.",
|
|
3801
3802
|
"NOT FOR: confirming many fields at once (talonic_doc_gen_confirm_fields).",
|
|
3802
3803
|
"",
|
|
3803
|
-
"ARGS: `template_id`; optional `name`, `group`, `kind` letter|agreement, `pair_template_id`, `version` (null clears group/kind/pair/version); `fields[] { key, label?, source?, confirmed?, reason? }`; `dry_run`.",
|
|
3804
|
-
"RETURNS: { dry_run, template } with the field sheet."
|
|
3804
|
+
"ARGS: `template_id`; optional `name`, `group`, `kind` letter|agreement, `pair_template_id`, `version` (null clears group/kind/pair/version); `fields[] { key, label?, source?, confirmed?, reason? }`; `rescan` (add the fields the file has and the sheet lacks; alone or before the changes); `dry_run`.",
|
|
3805
|
+
"RETURNS: { dry_run, template } with the field sheet; with `rescan` alone { template, added[] } (keys added)."
|
|
3805
3806
|
].join("\n");
|
|
3806
3807
|
var updateTemplateInputSchema = {
|
|
3807
3808
|
template_id: templateIdArg,
|
|
@@ -3815,29 +3816,39 @@ var updateTemplateInputSchema = {
|
|
|
3815
3816
|
key: z.string().min(1).max(200).describe("Field key from the field sheet."),
|
|
3816
3817
|
label: z.string().max(120).optional(),
|
|
3817
3818
|
source: z.record(z.string(), z.unknown()).optional().describe(
|
|
3818
|
-
"Field source as the sheet stores it, e.g. { type: 'product', field }, { type: 'reference', column }, { type: 'case', caseKey }, { type: 'user', profile }, { type: 'rule', rule }, { type: 'today' }."
|
|
3819
|
+
"Field source as the sheet stores it, e.g. { type: 'product', field }, { type: 'reference', column }, { type: 'case', caseKey }, { type: 'user', profile }, { type: 'rule', rule }, { type: 'today' }, { type: 'party', role: addressee|owner_addressee|effective_partner|partner|manager|tenant|previous_owner|new_owner, attribute: name|salutation|greeting|street|postcode_town|address|address_block|email|kind|channel }, { type: 'variant', by: <party role>, map: { herr, frau, eheleute, person, company, association }, fallback } (grammar such as 'der/von'), { type: 'condition', when: { kind: 'party', role, present } | { kind: 'document', pattern, present } | { kind: 'field', field, present?, equals? } | { kind: 'ask' }, text? } (printed only when the condition holds; `ask`: the person generating decides per document, e.g. case variants), { type: 'fixed', text }."
|
|
3819
3820
|
),
|
|
3820
3821
|
confirmed: z.boolean().optional().describe("Only when the user asked to confirm."),
|
|
3821
3822
|
reason: z.string().max(400).nullable().optional()
|
|
3822
3823
|
})
|
|
3823
3824
|
).max(500).optional().describe("Field changes by key."),
|
|
3825
|
+
rescan: z.boolean().optional().describe(
|
|
3826
|
+
"Read the Word file again and add the fields the sheet lacks (red passages); existing fields stay."
|
|
3827
|
+
),
|
|
3824
3828
|
dry_run: z.boolean().optional().describe("Return the sheet as it would be; nothing is saved.")
|
|
3825
3829
|
};
|
|
3826
3830
|
function handleUpdateTemplate(getToken, baseUrl, args) {
|
|
3827
|
-
const { template_id, dry_run, ...changes } = args;
|
|
3831
|
+
const { template_id, dry_run, rescan, ...changes } = args;
|
|
3828
3832
|
const body = Object.fromEntries(Object.entries(changes).filter(([, v]) => v !== void 0));
|
|
3829
|
-
if (Object.keys(body).length === 0) {
|
|
3833
|
+
if (Object.keys(body).length === 0 && !rescan) {
|
|
3830
3834
|
return Promise.resolve(
|
|
3831
3835
|
validationError(
|
|
3832
|
-
"name nothing to change: pass name, group, kind, pair_template_id, version or
|
|
3836
|
+
"name nothing to change: pass name, group, kind, pair_template_id, version, fields or rescan."
|
|
3833
3837
|
)
|
|
3834
3838
|
);
|
|
3835
3839
|
}
|
|
3836
|
-
|
|
3837
|
-
|
|
3840
|
+
if (rescan && dry_run) {
|
|
3841
|
+
return Promise.resolve(
|
|
3842
|
+
validationError("rescan saves the added fields; it cannot run as a dry run.")
|
|
3843
|
+
);
|
|
3844
|
+
}
|
|
3845
|
+
return runTool(async () => {
|
|
3846
|
+
const scanned = rescan ? await apiJson(getToken, baseUrl, "POST", `/v1/doc-gen/templates/${template_id}/rescan`) : null;
|
|
3847
|
+
if (Object.keys(body).length === 0) return scanned;
|
|
3848
|
+
return apiJson(getToken, baseUrl, "PATCH", `/v1/doc-gen/templates/${template_id}`, {
|
|
3838
3849
|
body: { ...body, dry_run: dry_run ?? false }
|
|
3839
|
-
})
|
|
3840
|
-
);
|
|
3850
|
+
});
|
|
3851
|
+
});
|
|
3841
3852
|
}
|
|
3842
3853
|
var CONFIRM_DESCRIPTION = [
|
|
3843
3854
|
"Confirm fields of a template's field sheet: the named keys, or every unconfirmed field (with include_entered false, leaving the fields entered per document unconfirmed). Confirming says a person checked the field's source; it is the user's decision, so only call this when the user asked to confirm. Run with dry_run first to list what would be confirmed.",
|
|
@@ -4398,6 +4409,565 @@ function registerDocGenTools(server, getToken, baseUrl, opts = {}) {
|
|
|
4398
4409
|
);
|
|
4399
4410
|
}
|
|
4400
4411
|
}
|
|
4412
|
+
var readOnly4 = {
|
|
4413
|
+
readOnlyHint: true,
|
|
4414
|
+
destructiveHint: false,
|
|
4415
|
+
idempotentHint: true,
|
|
4416
|
+
openWorldHint: false
|
|
4417
|
+
};
|
|
4418
|
+
var write4 = (idempotent, destructive = false) => ({
|
|
4419
|
+
readOnlyHint: false,
|
|
4420
|
+
destructiveHint: destructive,
|
|
4421
|
+
idempotentHint: idempotent,
|
|
4422
|
+
openWorldHint: false
|
|
4423
|
+
});
|
|
4424
|
+
var PARTIES_POLL_INTERVAL_MS = 5e3;
|
|
4425
|
+
var READ_MAX_WAIT_S = 600;
|
|
4426
|
+
var ROLES2 = [
|
|
4427
|
+
"partner",
|
|
4428
|
+
"manager",
|
|
4429
|
+
"tenant",
|
|
4430
|
+
"previous_owner",
|
|
4431
|
+
"new_owner",
|
|
4432
|
+
"contact",
|
|
4433
|
+
"invoice_recipient"
|
|
4434
|
+
];
|
|
4435
|
+
var KINDS = ["person", "company", "owners_association", "unknown"];
|
|
4436
|
+
var SALUTATIONS = ["herr", "frau", "eheleute", "firma", "weg"];
|
|
4437
|
+
var ROLE_STATES = ["suggested", "confirmed", "rejected"];
|
|
4438
|
+
var ISSUE_CODES = [
|
|
4439
|
+
"no_partner",
|
|
4440
|
+
"several_partners",
|
|
4441
|
+
"reference_disagrees",
|
|
4442
|
+
"kind_unknown",
|
|
4443
|
+
"address_missing",
|
|
4444
|
+
"manager_without_party",
|
|
4445
|
+
"tenant_without_period",
|
|
4446
|
+
"owner_change_open",
|
|
4447
|
+
"cost_unit_disagrees",
|
|
4448
|
+
"cost_unit_missing",
|
|
4449
|
+
"not_read",
|
|
4450
|
+
"read_failed",
|
|
4451
|
+
"possible_duplicate"
|
|
4452
|
+
];
|
|
4453
|
+
var ROLES_EXPLAINED = "Roles: partner (the contract partner), manager (Verwalter: acts for a company or an owners' association and is written to on its behalf; represents_id names the role it acts for), tenant (with enters_contract: true the tenant is the temporary partner for the lease period valid_from..valid_to), previous_owner / new_owner (an owner change: the new owner holds from the transfer date valid_from), contact, invoice_recipient.";
|
|
4454
|
+
var COMPUTED_RULE = "The effective partner (the tenant entering the contract during its lease, else the partner) and the addressee (the effective partner's Verwalter when it has one, else the effective partner) are computed by the platform from the roles in force on the day; never set them yourself, fix the roles.";
|
|
4455
|
+
var DECISION_RULE = "A read only makes suggestions and never overwrites a person's decision (a confirmed role stays, a rejected one never comes back). Confirming, rejecting and merging are a person's decisions: only do them when the user asked.";
|
|
4456
|
+
var dateArg = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "a date YYYY-MM-DD").describe("ISO date YYYY-MM-DD.");
|
|
4457
|
+
var contractIdArg2 = z.string().uuid().describe("Contract id (from talonic_parties_contracts or talonic_parties_issues).");
|
|
4458
|
+
var partyIdArg = z.string().uuid().describe("Party id (from talonic_parties_search, _contract or _issues).");
|
|
4459
|
+
function waitSeconds2(requested, max) {
|
|
4460
|
+
const n = Number.isFinite(requested) ? requested : 0;
|
|
4461
|
+
return Math.max(0, Math.min(max, Math.floor(n)));
|
|
4462
|
+
}
|
|
4463
|
+
function defined(obj) {
|
|
4464
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
|
|
4465
|
+
}
|
|
4466
|
+
var STATUS_DESCRIPTION3 = [
|
|
4467
|
+
"Contract Party Management at a glance: how many contracts, how many have confirmed parties, only suggestions, or no partner; active parties; open suggestions; and the parties-read queue.",
|
|
4468
|
+
"USE WHEN: starting any parties work, or to report where things stand. The loop: talonic_parties_status \u2192 talonic_parties_read (dry_run first, then with wait_seconds) \u2192 talonic_parties_issues \u2192 talonic_parties_contract per flagged contract \u2192 talonic_parties_set_role / talonic_parties_confirm \u2192 talonic_parties_merge duplicates \u2192 talonic_parties_issues again.",
|
|
4469
|
+
"NOT FOR: what to fix (talonic_parties_issues); one contract (talonic_parties_contract).",
|
|
4470
|
+
"",
|
|
4471
|
+
"ARGS: none.",
|
|
4472
|
+
"RETURNS: { contracts, contracts_confirmed, contracts_suggested, contracts_without_partner, parties, suggestions, reads { counts { pending, running, done, failed }, unread, failed } }."
|
|
4473
|
+
].join("\n");
|
|
4474
|
+
function handleStatus2(getToken, baseUrl) {
|
|
4475
|
+
return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/parties/status"));
|
|
4476
|
+
}
|
|
4477
|
+
var ISSUES_DESCRIPTION4 = [
|
|
4478
|
+
"The parties worklist: per contract what looks wrong today (no partner, several partners, the reference table names another partner, person-or-company unknown, no postal address, a Verwalter for a party no longer on the contract, a tenant entering the contract without a lease period, an owner change without a transfer date, cost unit disagreeing or missing, not read, read failed), plus parties that look like duplicates (same name, and postcode when both have one).",
|
|
4479
|
+
"USE WHEN: after talonic_parties_read, deciding what to fix; open each flagged contract with talonic_parties_contract. Duplicates are merge candidates: never merged on their own (talonic_parties_merge, only when the user asked).",
|
|
4480
|
+
"NOT FOR: the headline counts (talonic_parties_status); all contracts (talonic_parties_contracts).",
|
|
4481
|
+
"",
|
|
4482
|
+
`ARGS: \`code\` (only this issue; one of ${ISSUE_CODES.join(", ")}).`,
|
|
4483
|
+
"RETURNS: { contracts[] { contract_id, contract_key, title, issues[] { code, detail, role_ids[], party_ids[] } }, duplicates[] { name_key, party_ids[], names[] } }."
|
|
4484
|
+
].join("\n");
|
|
4485
|
+
var issuesInputSchema2 = {
|
|
4486
|
+
code: z.enum(ISSUE_CODES).optional().describe("Only this issue code.")
|
|
4487
|
+
};
|
|
4488
|
+
function handleIssues4(getToken, baseUrl, args) {
|
|
4489
|
+
return runTool(
|
|
4490
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/parties/issues", { params: { code: args.code } })
|
|
4491
|
+
);
|
|
4492
|
+
}
|
|
4493
|
+
var CONTRACTS_DESCRIPTION = [
|
|
4494
|
+
"List the workspace's contracts with their parties today: effective partner, addressee and Verwalter by name, the parties' state (confirmed: every role counted is confirmed; suggested: any is a suggestion; none: no partner), open suggestions and the read state.",
|
|
4495
|
+
"USE WHEN: getting an overview, finding a contract by key, title or party name, or listing contracts still on suggestions (state: suggested) or without a partner (state: none).",
|
|
4496
|
+
"NOT FOR: one contract's roles and evidence (talonic_parties_contract); what needs fixing (talonic_parties_issues).",
|
|
4497
|
+
"",
|
|
4498
|
+
"ARGS: `query` (contract key, title, counterparty, partner or Verwalter contains), `state` confirmed|suggested|none, `limit` (1-5000, default 500).",
|
|
4499
|
+
"RETURNS: { total, data[] { id, contract_key, title, counterparty, status, partner, addressee, manager, state, suggestions, read } }."
|
|
4500
|
+
].join("\n");
|
|
4501
|
+
var contractsInputSchema = {
|
|
4502
|
+
query: z.string().optional().describe("Key, title, counterparty, partner or Verwalter contains."),
|
|
4503
|
+
state: z.enum(["confirmed", "suggested", "none"]).optional().describe("Only contracts whose parties are in this state."),
|
|
4504
|
+
limit: z.number().int().min(1).max(5e3).optional().describe("At most this many (default 500).")
|
|
4505
|
+
};
|
|
4506
|
+
function handleContracts(getToken, baseUrl, args) {
|
|
4507
|
+
return runTool(
|
|
4508
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/parties/contracts", {
|
|
4509
|
+
params: { q: args.query, state: args.state, limit: args.limit }
|
|
4510
|
+
})
|
|
4511
|
+
);
|
|
4512
|
+
}
|
|
4513
|
+
var CONTRACT_DESCRIPTION2 = [
|
|
4514
|
+
"One contract's parties on a day: the computed view (partner, manager, tenant, previous and new owner, effective partner, addressee with its postal address lines, contacts, state), every role row with its party, state (suggested|confirmed|rejected), confidence and evidence (document quotes, reference table rows, a person's word), the issues, the cost unit (documents vs. contract register) and the read state.",
|
|
4515
|
+
"USE WHEN: checking or fixing a flagged contract; you need role ids (roles[].id) for talonic_parties_set_role, or to answer who the partner is and where a letter goes.",
|
|
4516
|
+
ROLES_EXPLAINED,
|
|
4517
|
+
COMPUTED_RULE,
|
|
4518
|
+
"NOT FOR: the list of contracts (talonic_parties_contracts); one party across contracts (talonic_parties_party).",
|
|
4519
|
+
"",
|
|
4520
|
+
"ARGS: `contract_id`, `on` (YYYY-MM-DD; default today: the roles in force on that day).",
|
|
4521
|
+
"RETURNS: { contract { id, contract_key, title, counterparty, status }, on, view { partner, manager, tenant, previous_owner, new_owner, effective_partner, addressee { ...party, role_id, role, state, valid_from, valid_to, address_lines[] }, contacts[], state }, roles[] { id, party_id, role, represents_id, valid_from, valid_to, enters_contract, state, confidence, evidence[], origin, decided_by, decided_at, note, party }, issues[], cost_unit { documents, quote, register[] }, reference_names[], read { status, read_at, error, notes, read_with } | null }."
|
|
4522
|
+
].join("\n");
|
|
4523
|
+
var contractInputSchema2 = {
|
|
4524
|
+
contract_id: contractIdArg2,
|
|
4525
|
+
on: dateArg.optional().describe("The day to read the parties for (YYYY-MM-DD; default today).")
|
|
4526
|
+
};
|
|
4527
|
+
function handleContract2(getToken, baseUrl, args) {
|
|
4528
|
+
return runTool(
|
|
4529
|
+
() => apiJson(getToken, baseUrl, "GET", `/v1/parties/contracts/${args.contract_id}`, {
|
|
4530
|
+
params: { on: args.on }
|
|
4531
|
+
})
|
|
4532
|
+
);
|
|
4533
|
+
}
|
|
4534
|
+
var SEARCH_DESCRIPTION = [
|
|
4535
|
+
"Search the party register (people, companies, owners' associations): name, street, postcode, town, email or an external reference contains the query; each with how many contracts it holds a role on.",
|
|
4536
|
+
"USE WHEN: finding a party to add to a contract (its id for talonic_parties_set_role), checking whether a party already exists before creating one, or finding duplicates by name.",
|
|
4537
|
+
"NOT FOR: one party with its roles (talonic_parties_party); a contract's parties (talonic_parties_contract).",
|
|
4538
|
+
"",
|
|
4539
|
+
"ARGS: `query`, `kind` person|company|owners_association|unknown, `limit` (1-1000, default 200).",
|
|
4540
|
+
"RETURNS: { total, data[] { id, kind, display_name, salutation, title, first_name, last_name, company_name, legal_form, street, postcode, town, country, email, phone, preferred_channel, external_refs, status, contracts } }."
|
|
4541
|
+
].join("\n");
|
|
4542
|
+
var searchInputSchema = {
|
|
4543
|
+
query: z.string().optional().describe("Name, address, email or external reference contains."),
|
|
4544
|
+
kind: z.enum(KINDS).optional().describe("Only parties of this kind."),
|
|
4545
|
+
limit: z.number().int().min(1).max(1e3).optional().describe("At most this many (default 200).")
|
|
4546
|
+
};
|
|
4547
|
+
function handleSearch2(getToken, baseUrl, args) {
|
|
4548
|
+
return runTool(
|
|
4549
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/parties", {
|
|
4550
|
+
params: { q: args.query, kind: args.kind, limit: args.limit }
|
|
4551
|
+
})
|
|
4552
|
+
);
|
|
4553
|
+
}
|
|
4554
|
+
var PARTY_FIELD_KEYS = [
|
|
4555
|
+
"kind",
|
|
4556
|
+
"display_name",
|
|
4557
|
+
"salutation",
|
|
4558
|
+
"title",
|
|
4559
|
+
"first_name",
|
|
4560
|
+
"last_name",
|
|
4561
|
+
"company_name",
|
|
4562
|
+
"legal_form",
|
|
4563
|
+
"street",
|
|
4564
|
+
"postcode",
|
|
4565
|
+
"town",
|
|
4566
|
+
"country",
|
|
4567
|
+
"email",
|
|
4568
|
+
"phone",
|
|
4569
|
+
"preferred_channel",
|
|
4570
|
+
"external_refs"
|
|
4571
|
+
];
|
|
4572
|
+
var PARTY_DESCRIPTION = [
|
|
4573
|
+
"Read, change or create one party. With `party_id` alone: the party with its roles on every contract, its contacts (members), the companies it is a contact of and the documents it appears in (with quotes). With `party_id` and fields: changes those fields (the rest stay). Without `party_id`: creates a party; `display_name` is required (kind and salutation are inferred from it when not given).",
|
|
4574
|
+
"USE WHEN: checking a party; fixing its name, kind (person or company decides a letter's wording), salutation or postal address (issues kind_unknown, address_missing); creating a party the documents miss before adding it to a contract with talonic_parties_set_role. Search first (talonic_parties_search) so you do not create a duplicate.",
|
|
4575
|
+
"NOT FOR: its role on a contract (talonic_parties_set_role); combining duplicates (talonic_parties_merge).",
|
|
4576
|
+
"",
|
|
4577
|
+
"ARGS: `party_id` (omit to create); fields `kind` person|company|owners_association|unknown, `display_name`, `salutation` herr|frau|eheleute|firma|weg, `title`, `first_name`, `last_name`, `company_name`, `legal_form`, `street`, `postcode`, `town`, `country`, `email`, `phone`, `preferred_channel` post|email, `external_refs` { name: value } (null clears a text field).",
|
|
4578
|
+
"RETURNS: read { party, merged_into, roles[] { ...role, contract }, members[] { id, function, party }, member_of[], documents[] { document_id, filename, quotes[] } }; change or create: the party."
|
|
4579
|
+
].join("\n");
|
|
4580
|
+
var nullableText = (max) => z.string().max(max).nullable().optional();
|
|
4581
|
+
var partyInputSchema = {
|
|
4582
|
+
party_id: partyIdArg.optional().describe("The party to read or change; omit to create one."),
|
|
4583
|
+
kind: z.enum(KINDS).optional().describe("Person, company, owners' association or unknown."),
|
|
4584
|
+
display_name: z.string().min(1).max(300).optional().describe("Name as printed; required to create."),
|
|
4585
|
+
salutation: z.enum(SALUTATIONS).nullable().optional().describe("Salutation; null clears it."),
|
|
4586
|
+
title: nullableText(60).describe("Academic title, e.g. 'Dr.'."),
|
|
4587
|
+
first_name: nullableText(120),
|
|
4588
|
+
last_name: nullableText(120),
|
|
4589
|
+
company_name: nullableText(300),
|
|
4590
|
+
legal_form: nullableText(60).describe("e.g. GmbH, AG, KG."),
|
|
4591
|
+
street: nullableText(200).describe("Street and house number."),
|
|
4592
|
+
postcode: nullableText(12),
|
|
4593
|
+
town: nullableText(120),
|
|
4594
|
+
country: nullableText(60),
|
|
4595
|
+
email: z.string().email().nullable().optional(),
|
|
4596
|
+
phone: nullableText(60),
|
|
4597
|
+
preferred_channel: z.enum(["post", "email"]).nullable().optional(),
|
|
4598
|
+
external_refs: z.record(z.string(), z.string()).optional().describe("References in other systems by name, e.g. { debitor: '10042' }.")
|
|
4599
|
+
};
|
|
4600
|
+
function handleParty(getToken, baseUrl, args) {
|
|
4601
|
+
const fields = defined(Object.fromEntries(PARTY_FIELD_KEYS.map((k) => [k, args[k]])));
|
|
4602
|
+
const changing = Object.keys(fields).length > 0;
|
|
4603
|
+
if (args.party_id) {
|
|
4604
|
+
const path = `/v1/parties/${args.party_id}`;
|
|
4605
|
+
return runTool(
|
|
4606
|
+
() => changing ? apiJson(getToken, baseUrl, "PATCH", path, { body: fields }) : apiJson(getToken, baseUrl, "GET", path)
|
|
4607
|
+
);
|
|
4608
|
+
}
|
|
4609
|
+
if (typeof args.display_name !== "string" || !args.display_name.trim()) {
|
|
4610
|
+
return Promise.resolve(
|
|
4611
|
+
validationError("pass party_id to read or change a party, or display_name to create one.")
|
|
4612
|
+
);
|
|
4613
|
+
}
|
|
4614
|
+
return runTool(() => apiJson(getToken, baseUrl, "POST", "/v1/parties", { body: fields }));
|
|
4615
|
+
}
|
|
4616
|
+
var SET_ROLE_DESCRIPTION = [
|
|
4617
|
+
"Add a role to a contract, or change one role row. With `contract_id`, `party_id` and `role`: adds the party in that role (confirmed unless `state` says suggested; a party already holding that role on the contract has that row updated). With `role_id`: changes that row: confirm or reject it (`state`), move it to another role or party, set the period, the Verwalter link or enters_contract. Any change by a person is a decision: an edited suggestion becomes confirmed unless `state` says otherwise.",
|
|
4618
|
+
"USE WHEN: fixing a contract's parties after reading talonic_parties_contract: a partner missing (no_partner), two partners at once (reject the wrong one, or give the old one valid_to), a Verwalter for the right party (represents_id), a tenant entering the contract (enters_contract with valid_from / valid_to), an owner change (previous_owner, new_owner with valid_from = transfer date).",
|
|
4619
|
+
ROLES_EXPLAINED,
|
|
4620
|
+
COMPUTED_RULE,
|
|
4621
|
+
DECISION_RULE,
|
|
4622
|
+
"NOT FOR: confirming many suggestions at once (talonic_parties_confirm); the party's own details (talonic_parties_party).",
|
|
4623
|
+
"",
|
|
4624
|
+
"ARGS: add: `contract_id`, `party_id`, `role`; change: `role_id` (roles[].id from talonic_parties_contract) and optional `party_id`, `role`. Both: `state` suggested|confirmed|rejected, `represents_id` (another role id on the same contract; null clears), `valid_from`, `valid_to` (YYYY-MM-DD; null clears), `enters_contract` (tenant only), `note` (say where the decision comes from).",
|
|
4625
|
+
"RETURNS: the role row { id, contract_id, party_id, role, represents_id, valid_from, valid_to, enters_contract, state, confidence, evidence[], origin, decided_by, decided_at, note }."
|
|
4626
|
+
].join("\n");
|
|
4627
|
+
var setRoleInputSchema = {
|
|
4628
|
+
contract_id: contractIdArg2.optional().describe("Add: the contract to add the role to."),
|
|
4629
|
+
role_id: z.string().uuid().optional().describe("Change: the role row (roles[].id from talonic_parties_contract)."),
|
|
4630
|
+
party_id: partyIdArg.optional().describe("Add: the party; change: move the row to this party."),
|
|
4631
|
+
role: z.enum(ROLES2).optional().describe("The role."),
|
|
4632
|
+
state: z.enum(ROLE_STATES).optional().describe("confirmed or rejected (a person's decision); suggested keeps it open."),
|
|
4633
|
+
represents_id: z.string().uuid().nullable().optional().describe("Manager / contact: the role id it acts for on the same contract; null clears."),
|
|
4634
|
+
valid_from: dateArg.nullable().optional().describe("From this day (YYYY-MM-DD); null clears."),
|
|
4635
|
+
valid_to: dateArg.nullable().optional().describe("Until this day (YYYY-MM-DD); null clears."),
|
|
4636
|
+
enters_contract: z.boolean().optional().describe("Tenant: enters the contract (temporary partner for the lease period)."),
|
|
4637
|
+
note: z.string().max(1e3).nullable().optional().describe("Why; where the decision comes from.")
|
|
4638
|
+
};
|
|
4639
|
+
function handleSetRole(getToken, baseUrl, args) {
|
|
4640
|
+
const { contract_id, role_id, ...rest } = args;
|
|
4641
|
+
const body = defined(rest);
|
|
4642
|
+
if (!!contract_id === !!role_id) {
|
|
4643
|
+
return Promise.resolve(
|
|
4644
|
+
validationError("pass contract_id (with party_id and role) to add, or role_id to change.")
|
|
4645
|
+
);
|
|
4646
|
+
}
|
|
4647
|
+
if (contract_id) {
|
|
4648
|
+
if (!args.party_id || !args.role) {
|
|
4649
|
+
return Promise.resolve(validationError("adding a role needs party_id and role."));
|
|
4650
|
+
}
|
|
4651
|
+
return runTool(
|
|
4652
|
+
() => apiJson(getToken, baseUrl, "POST", `/v1/parties/contracts/${contract_id}/roles`, { body })
|
|
4653
|
+
);
|
|
4654
|
+
}
|
|
4655
|
+
if (Object.keys(body).length === 0) {
|
|
4656
|
+
return Promise.resolve(
|
|
4657
|
+
validationError(
|
|
4658
|
+
"name something to change: state, role, party_id, represents_id, valid_from, valid_to, enters_contract or note."
|
|
4659
|
+
)
|
|
4660
|
+
);
|
|
4661
|
+
}
|
|
4662
|
+
return runTool(
|
|
4663
|
+
() => apiJson(getToken, baseUrl, "PATCH", `/v1/parties/roles/${role_id}`, { body })
|
|
4664
|
+
);
|
|
4665
|
+
}
|
|
4666
|
+
var CONFIRM_DESCRIPTION2 = [
|
|
4667
|
+
"Confirm suggested roles in bulk: by default only high-confidence suggestions (a verified quote the contract register agrees with), optionally only of named contracts or roles. Confirming says a person checked them; it is the user's decision, so only call this when the user asked. Run with dry_run first and say how many it would confirm.",
|
|
4668
|
+
"USE WHEN: the user asks to accept the suggestions (all, or of some contracts / roles).",
|
|
4669
|
+
DECISION_RULE,
|
|
4670
|
+
"NOT FOR: rejecting or fixing one role (talonic_parties_set_role).",
|
|
4671
|
+
"",
|
|
4672
|
+
"ARGS: `contract_ids[]` (omit for all), `roles[]` (e.g. ['partner']), `min_confidence` high|medium|low (default high), `limit` (1-5000, default 500), `dry_run`.",
|
|
4673
|
+
"RETURNS: { dry_run, confirmed, rows[] { id, contract_id, party_id, role, confidence } } (rows: the first 100)."
|
|
4674
|
+
].join("\n");
|
|
4675
|
+
var confirmInputSchema2 = {
|
|
4676
|
+
contract_ids: z.array(z.string().uuid()).max(1e3).optional().describe("Only these contracts."),
|
|
4677
|
+
roles: z.array(z.enum(ROLES2)).max(ROLES2.length).optional().describe("Only these roles."),
|
|
4678
|
+
min_confidence: z.enum(["high", "medium", "low"]).optional().describe("Lowest confidence confirmed (default high)."),
|
|
4679
|
+
limit: z.number().int().min(1).max(5e3).optional().describe("At most this many (default 500)."),
|
|
4680
|
+
dry_run: z.boolean().optional().describe("Count only; nothing is confirmed.")
|
|
4681
|
+
};
|
|
4682
|
+
function handleConfirm2(getToken, baseUrl, args) {
|
|
4683
|
+
return runTool(
|
|
4684
|
+
() => apiJson(getToken, baseUrl, "POST", "/v1/parties/roles/confirm", {
|
|
4685
|
+
body: {
|
|
4686
|
+
...args.contract_ids ? { contract_ids: args.contract_ids } : {},
|
|
4687
|
+
...args.roles ? { roles: args.roles } : {},
|
|
4688
|
+
min_confidence: args.min_confidence ?? "high",
|
|
4689
|
+
...args.limit ? { limit: args.limit } : {},
|
|
4690
|
+
dry_run: args.dry_run ?? false
|
|
4691
|
+
}
|
|
4692
|
+
})
|
|
4693
|
+
);
|
|
4694
|
+
}
|
|
4695
|
+
var MERGE_DESCRIPTION2 = [
|
|
4696
|
+
"Merge one party into another: every role and contact link moves to the survivor (`into`); a role the survivor already holds on the same contract keeps the survivor's row and takes the merged one's evidence. The merged party stays only as a pointer to the survivor. Cannot be undone; a person's decision, so only when the user asked. Run with dry_run first.",
|
|
4697
|
+
"USE WHEN: talonic_parties_issues lists duplicates (same name and postcode) and the user confirms they are the same party.",
|
|
4698
|
+
"NOT FOR: two different parties with similar names; moving one role to another party (talonic_parties_set_role with role_id and party_id).",
|
|
4699
|
+
"",
|
|
4700
|
+
"ARGS: `party_id` (the one that goes), `into` (the survivor), `dry_run`.",
|
|
4701
|
+
"RETURNS: { dry_run, moves, combined, party } (party: the survivor, after a real merge)."
|
|
4702
|
+
].join("\n");
|
|
4703
|
+
var mergeInputSchema2 = {
|
|
4704
|
+
party_id: partyIdArg.describe("The party merged away."),
|
|
4705
|
+
into: z.string().uuid().describe("The party that survives."),
|
|
4706
|
+
dry_run: z.boolean().optional().describe("Count the moves; nothing changes.")
|
|
4707
|
+
};
|
|
4708
|
+
function handleMerge2(getToken, baseUrl, args) {
|
|
4709
|
+
if (args.party_id === args.into) {
|
|
4710
|
+
return Promise.resolve(validationError("a party cannot be merged into itself."));
|
|
4711
|
+
}
|
|
4712
|
+
return runTool(
|
|
4713
|
+
() => apiJson(getToken, baseUrl, "POST", `/v1/parties/${args.party_id}/merge`, {
|
|
4714
|
+
body: { into: args.into, dry_run: args.dry_run ?? false }
|
|
4715
|
+
})
|
|
4716
|
+
);
|
|
4717
|
+
}
|
|
4718
|
+
var READ_DESCRIPTION = [
|
|
4719
|
+
"Read the parties from contract documents: queues contracts for the platform to read in the background (one model call per contract) and store every party and role it finds as a suggestion, with quotes. By default every contract not read yet (only_unread); `contract_ids` reads exactly those again. With `status: true` only reports the queue. Pass `wait_seconds` to wait until the queue is empty (polls the queue every 5 s).",
|
|
4720
|
+
"USE WHEN: filling the app or after new contract documents arrived: run with dry_run first and say how many contracts it will read, then without dry_run and with wait_seconds; then talonic_parties_issues.",
|
|
4721
|
+
DECISION_RULE,
|
|
4722
|
+
"NOT FOR: one contract's parties (talonic_parties_contract).",
|
|
4723
|
+
"",
|
|
4724
|
+
"ARGS: `status` (only the queue); or `contract_ids[]` (omit for all), `only_unread` (default true), `force` (read again although read), `limit` (1-5000, default 500), `dry_run`; `wait_seconds` (0-600, default 0; not with dry_run).",
|
|
4725
|
+
"RETURNS: dry_run { dry_run, would_queue, skipped, contracts[] (first 50) }; queued { dry_run, queued, skipped }; status { contracts, counts { pending, running, done, failed }, unread, failed[] { contract_id, contract_key, error, attempts } }. After a wait also { status, waited_ms, still_running }."
|
|
4726
|
+
].join("\n");
|
|
4727
|
+
var readInputSchema = {
|
|
4728
|
+
status: z.boolean().optional().describe("Only report the read queue; nothing is queued."),
|
|
4729
|
+
contract_ids: z.array(z.string().uuid()).max(5e3).optional().describe("Only these contracts (read again when already read)."),
|
|
4730
|
+
only_unread: z.boolean().optional().describe("All contracts: only those not read yet (default true)."),
|
|
4731
|
+
force: z.boolean().optional().describe("Read again although already read."),
|
|
4732
|
+
limit: z.number().int().min(1).max(5e3).optional().describe("Queue at most this many."),
|
|
4733
|
+
dry_run: z.boolean().optional().describe("Count and list what would be read; nothing is queued."),
|
|
4734
|
+
wait_seconds: z.number().min(0).max(READ_MAX_WAIT_S).optional().describe(`Seconds to wait for the queue to empty (0-${READ_MAX_WAIT_S}).`)
|
|
4735
|
+
};
|
|
4736
|
+
var busy = (s) => (s.counts?.["pending"] ?? 0) + (s.counts?.["running"] ?? 0) > 0;
|
|
4737
|
+
function handleRead(getToken, baseUrl, args, deps = {}) {
|
|
4738
|
+
const waitS = waitSeconds2(args.wait_seconds, READ_MAX_WAIT_S);
|
|
4739
|
+
const readStatus = () => apiJson(getToken, baseUrl, "GET", "/v1/parties/read/status");
|
|
4740
|
+
return runTool(async () => {
|
|
4741
|
+
let started = null;
|
|
4742
|
+
if (!args.status) {
|
|
4743
|
+
started = await apiJson(
|
|
4744
|
+
getToken,
|
|
4745
|
+
baseUrl,
|
|
4746
|
+
"POST",
|
|
4747
|
+
"/v1/parties/read",
|
|
4748
|
+
{
|
|
4749
|
+
body: {
|
|
4750
|
+
...args.contract_ids ? { contract_ids: args.contract_ids } : {},
|
|
4751
|
+
...args.only_unread !== void 0 ? { only_unread: args.only_unread } : {},
|
|
4752
|
+
...args.force !== void 0 ? { force: args.force } : {},
|
|
4753
|
+
...args.limit ? { limit: args.limit } : {},
|
|
4754
|
+
dry_run: args.dry_run ?? false
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
);
|
|
4758
|
+
if (waitS === 0 || args.dry_run) return started;
|
|
4759
|
+
}
|
|
4760
|
+
const first = await readStatus();
|
|
4761
|
+
if (waitS === 0) return first;
|
|
4762
|
+
const sleep2 = deps.sleep ?? sleep;
|
|
4763
|
+
const now = deps.now ?? Date.now;
|
|
4764
|
+
const start = now();
|
|
4765
|
+
const deadline = start + waitS * 1e3;
|
|
4766
|
+
let status3 = first;
|
|
4767
|
+
let pollError;
|
|
4768
|
+
while (busy(status3) && now() < deadline) {
|
|
4769
|
+
await sleep2(Math.min(PARTIES_POLL_INTERVAL_MS, deadline - now()));
|
|
4770
|
+
try {
|
|
4771
|
+
status3 = await readStatus();
|
|
4772
|
+
} catch (err) {
|
|
4773
|
+
pollError = err instanceof Error ? err.message : String(err);
|
|
4774
|
+
break;
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
const stillRunning = pollError !== void 0 || busy(status3);
|
|
4778
|
+
return {
|
|
4779
|
+
...started ?? {},
|
|
4780
|
+
status: status3,
|
|
4781
|
+
waited_ms: now() - start,
|
|
4782
|
+
still_running: stillRunning,
|
|
4783
|
+
...pollError ? { poll_error: pollError } : {},
|
|
4784
|
+
next: stillRunning ? "Still reading: call talonic_parties_read with status: true (and wait_seconds) later." : "Read done: open the worklist with talonic_parties_issues."
|
|
4785
|
+
};
|
|
4786
|
+
});
|
|
4787
|
+
}
|
|
4788
|
+
var MEMBERS_DESCRIPTION = [
|
|
4789
|
+
"Add a contact person to a company or an owners' association (with their function), or remove a contact link. A contact is always a person; the company is a company or an owners' association. Adding the same person again updates the function.",
|
|
4790
|
+
"USE WHEN: the user names the person to write to at a company (e.g. the WEG's Verwalter contact), or a contact left.",
|
|
4791
|
+
"NOT FOR: a contact role on one contract (talonic_parties_set_role with role contact).",
|
|
4792
|
+
"",
|
|
4793
|
+
"ARGS: add: `party_id` (the company), `person_id`, `function` (e.g. 'Gesch\xE4ftsf\xFChrer'); remove: `member_id` (members[].id from talonic_parties_party) alone.",
|
|
4794
|
+
"RETURNS: add: the link { id, company_party_id, person_party_id, function }; remove: { ok: true }."
|
|
4795
|
+
].join("\n");
|
|
4796
|
+
var membersInputSchema = {
|
|
4797
|
+
party_id: partyIdArg.optional().describe("Add: the company or owners' association."),
|
|
4798
|
+
person_id: z.string().uuid().optional().describe("Add: the person (a party of kind person)."),
|
|
4799
|
+
function: z.string().max(200).nullable().optional().describe("Add: their function."),
|
|
4800
|
+
member_id: z.string().uuid().optional().describe("Remove: the link (members[].id from talonic_parties_party).")
|
|
4801
|
+
};
|
|
4802
|
+
function handleMembers(getToken, baseUrl, args) {
|
|
4803
|
+
if (args.member_id) {
|
|
4804
|
+
if (args.party_id || args.person_id || args.function !== void 0) {
|
|
4805
|
+
return Promise.resolve(validationError("member_id (remove) goes alone."));
|
|
4806
|
+
}
|
|
4807
|
+
return runTool(
|
|
4808
|
+
() => apiJson(getToken, baseUrl, "DELETE", `/v1/parties/members/${args.member_id}`)
|
|
4809
|
+
);
|
|
4810
|
+
}
|
|
4811
|
+
if (!args.party_id || !args.person_id) {
|
|
4812
|
+
return Promise.resolve(
|
|
4813
|
+
validationError("pass party_id and person_id to add a contact, or member_id to remove one.")
|
|
4814
|
+
);
|
|
4815
|
+
}
|
|
4816
|
+
return runTool(
|
|
4817
|
+
() => apiJson(getToken, baseUrl, "POST", `/v1/parties/${args.party_id}/members`, {
|
|
4818
|
+
body: {
|
|
4819
|
+
person_id: args.person_id,
|
|
4820
|
+
...args.function !== void 0 ? { function: args.function } : {}
|
|
4821
|
+
}
|
|
4822
|
+
})
|
|
4823
|
+
);
|
|
4824
|
+
}
|
|
4825
|
+
var GROUP_COMPANIES_DESCRIPTION = [
|
|
4826
|
+
"Read the workspace's own companies (the group: lead company, subsidiaries, sisters), or replace them all with `companies`. The read uses them to tell our side from the contract partner. Replacing deletes every company not in the new list: read first, change, send the whole list, and only when the user asked.",
|
|
4827
|
+
"USE WHEN: a read takes one of our own companies for the partner, or setting up the workspace.",
|
|
4828
|
+
"NOT FOR: contract partners (talonic_parties_party).",
|
|
4829
|
+
"",
|
|
4830
|
+
"ARGS: none to read; `companies[] { name, parent? (another name in the list), relation? subsidiary|sister|parent }` to replace.",
|
|
4831
|
+
"RETURNS: { data[] { id, name, parent_id, relation } } (after a replace: the stored list)."
|
|
4832
|
+
].join("\n");
|
|
4833
|
+
var groupCompaniesInputSchema = {
|
|
4834
|
+
companies: z.array(
|
|
4835
|
+
z.object({
|
|
4836
|
+
name: z.string().min(1).max(300),
|
|
4837
|
+
parent: z.string().max(300).nullable().optional().describe("Another name in the list."),
|
|
4838
|
+
relation: z.enum(["subsidiary", "sister", "parent"]).nullable().optional()
|
|
4839
|
+
})
|
|
4840
|
+
).max(1e3).optional().describe("The complete new list; omit to read.")
|
|
4841
|
+
};
|
|
4842
|
+
function handleGroupCompanies(getToken, baseUrl, args) {
|
|
4843
|
+
return runTool(
|
|
4844
|
+
() => args.companies ? apiJson(getToken, baseUrl, "PUT", "/v1/parties/group-companies", {
|
|
4845
|
+
body: { companies: args.companies }
|
|
4846
|
+
}) : apiJson(getToken, baseUrl, "GET", "/v1/parties/group-companies")
|
|
4847
|
+
);
|
|
4848
|
+
}
|
|
4849
|
+
async function probePartiesAccess(token, baseUrl) {
|
|
4850
|
+
try {
|
|
4851
|
+
const res = await fetch(buildUrl(baseUrl, "/v1/parties/status"), {
|
|
4852
|
+
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
|
|
4853
|
+
signal: AbortSignal.timeout(5e3)
|
|
4854
|
+
});
|
|
4855
|
+
return res.ok;
|
|
4856
|
+
} catch {
|
|
4857
|
+
return false;
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
function registerPartiesTools(server, getToken, baseUrl) {
|
|
4861
|
+
const tools = [
|
|
4862
|
+
[
|
|
4863
|
+
"talonic_parties_status",
|
|
4864
|
+
"Contract parties status",
|
|
4865
|
+
STATUS_DESCRIPTION3,
|
|
4866
|
+
{},
|
|
4867
|
+
readOnly4,
|
|
4868
|
+
() => handleStatus2(getToken, baseUrl)
|
|
4869
|
+
],
|
|
4870
|
+
[
|
|
4871
|
+
"talonic_parties_issues",
|
|
4872
|
+
"Contract parties worklist",
|
|
4873
|
+
ISSUES_DESCRIPTION4,
|
|
4874
|
+
issuesInputSchema2,
|
|
4875
|
+
readOnly4,
|
|
4876
|
+
(a) => handleIssues4(getToken, baseUrl, a)
|
|
4877
|
+
],
|
|
4878
|
+
[
|
|
4879
|
+
"talonic_parties_contracts",
|
|
4880
|
+
"Contracts with their parties",
|
|
4881
|
+
CONTRACTS_DESCRIPTION,
|
|
4882
|
+
contractsInputSchema,
|
|
4883
|
+
readOnly4,
|
|
4884
|
+
(a) => handleContracts(getToken, baseUrl, a)
|
|
4885
|
+
],
|
|
4886
|
+
[
|
|
4887
|
+
"talonic_parties_contract",
|
|
4888
|
+
"One contract's parties",
|
|
4889
|
+
CONTRACT_DESCRIPTION2,
|
|
4890
|
+
contractInputSchema2,
|
|
4891
|
+
readOnly4,
|
|
4892
|
+
(a) => handleContract2(getToken, baseUrl, a)
|
|
4893
|
+
],
|
|
4894
|
+
[
|
|
4895
|
+
"talonic_parties_search",
|
|
4896
|
+
"Search parties",
|
|
4897
|
+
SEARCH_DESCRIPTION,
|
|
4898
|
+
searchInputSchema,
|
|
4899
|
+
readOnly4,
|
|
4900
|
+
(a) => handleSearch2(getToken, baseUrl, a)
|
|
4901
|
+
],
|
|
4902
|
+
[
|
|
4903
|
+
"talonic_parties_party",
|
|
4904
|
+
"Read, change or create a party",
|
|
4905
|
+
PARTY_DESCRIPTION,
|
|
4906
|
+
partyInputSchema,
|
|
4907
|
+
// With fields it overwrites the party's details: destructive per OpenAI's annotation rules.
|
|
4908
|
+
write4(false, true),
|
|
4909
|
+
(a) => handleParty(getToken, baseUrl, a)
|
|
4910
|
+
],
|
|
4911
|
+
[
|
|
4912
|
+
"talonic_parties_set_role",
|
|
4913
|
+
"Add or change a contract role",
|
|
4914
|
+
SET_ROLE_DESCRIPTION,
|
|
4915
|
+
setRoleInputSchema,
|
|
4916
|
+
// Overwrites or rejects a role row: destructive.
|
|
4917
|
+
write4(true, true),
|
|
4918
|
+
(a) => handleSetRole(getToken, baseUrl, a)
|
|
4919
|
+
],
|
|
4920
|
+
[
|
|
4921
|
+
"talonic_parties_confirm",
|
|
4922
|
+
"Confirm suggested roles",
|
|
4923
|
+
CONFIRM_DESCRIPTION2,
|
|
4924
|
+
confirmInputSchema2,
|
|
4925
|
+
write4(true),
|
|
4926
|
+
(a) => handleConfirm2(getToken, baseUrl, a)
|
|
4927
|
+
],
|
|
4928
|
+
[
|
|
4929
|
+
"talonic_parties_merge",
|
|
4930
|
+
"Merge duplicate parties",
|
|
4931
|
+
MERGE_DESCRIPTION2,
|
|
4932
|
+
mergeInputSchema2,
|
|
4933
|
+
write4(true, true),
|
|
4934
|
+
(a) => handleMerge2(getToken, baseUrl, a)
|
|
4935
|
+
],
|
|
4936
|
+
[
|
|
4937
|
+
"talonic_parties_read",
|
|
4938
|
+
"Read parties from contracts",
|
|
4939
|
+
READ_DESCRIPTION,
|
|
4940
|
+
readInputSchema,
|
|
4941
|
+
write4(true),
|
|
4942
|
+
(a) => handleRead(getToken, baseUrl, a)
|
|
4943
|
+
],
|
|
4944
|
+
[
|
|
4945
|
+
"talonic_parties_members",
|
|
4946
|
+
"Company contacts",
|
|
4947
|
+
MEMBERS_DESCRIPTION,
|
|
4948
|
+
membersInputSchema,
|
|
4949
|
+
// Removing a contact link deletes it: destructive.
|
|
4950
|
+
write4(true, true),
|
|
4951
|
+
(a) => handleMembers(getToken, baseUrl, a)
|
|
4952
|
+
],
|
|
4953
|
+
[
|
|
4954
|
+
"talonic_parties_group_companies",
|
|
4955
|
+
"Our group companies",
|
|
4956
|
+
GROUP_COMPANIES_DESCRIPTION,
|
|
4957
|
+
groupCompaniesInputSchema,
|
|
4958
|
+
// With `companies` it replaces the whole list: destructive.
|
|
4959
|
+
write4(true, true),
|
|
4960
|
+
(a) => handleGroupCompanies(getToken, baseUrl, a)
|
|
4961
|
+
]
|
|
4962
|
+
];
|
|
4963
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools) {
|
|
4964
|
+
server.registerTool(
|
|
4965
|
+
name,
|
|
4966
|
+
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
4967
|
+
async (args) => handler(args)
|
|
4968
|
+
);
|
|
4969
|
+
}
|
|
4970
|
+
}
|
|
4401
4971
|
var DEFAULT_BASE3 = "https://api.talonic.com";
|
|
4402
4972
|
var TASK_STATUSES = ["available", "claimed", "submitted", "timed_out", "cancelled"];
|
|
4403
4973
|
var taskId = z.string().uuid().describe("Agent task UUID.");
|
|
@@ -5956,7 +6526,7 @@ function registerAskTools(server, getToken, baseUrl) {
|
|
|
5956
6526
|
|
|
5957
6527
|
// package.json
|
|
5958
6528
|
var package_default = {
|
|
5959
|
-
version: "0.1.
|
|
6529
|
+
version: "0.1.89"};
|
|
5960
6530
|
|
|
5961
6531
|
// src/version.ts
|
|
5962
6532
|
var VERSION = package_default.version;
|
|
@@ -6116,6 +6686,9 @@ function createServer(options) {
|
|
|
6116
6686
|
if (options.includeDocGenTools) {
|
|
6117
6687
|
registerDocGenTools(server, rawToken, baseUrl, { localFiles: !options.tokenProvider });
|
|
6118
6688
|
}
|
|
6689
|
+
if (options.includePartiesTools) {
|
|
6690
|
+
registerPartiesTools(server, rawToken, baseUrl);
|
|
6691
|
+
}
|
|
6119
6692
|
registerSchemasResource(server, getTalonic);
|
|
6120
6693
|
registerWebhooksResource(server, rawToken, baseUrl);
|
|
6121
6694
|
registerWidgets(server);
|
|
@@ -6176,6 +6749,15 @@ async function docGenAccessCached(token, probe = (t) => probeDocGenAccess(t, pro
|
|
|
6176
6749
|
docGenProbeCache.set(token, { ok, expiresAt: now() + GROWTH_PROBE_TTL_MS });
|
|
6177
6750
|
return ok;
|
|
6178
6751
|
}
|
|
6752
|
+
var partiesProbeCache = /* @__PURE__ */ new Map();
|
|
6753
|
+
async function partiesAccessCached(token, probe = (t) => probePartiesAccess(t, process.env["TALONIC_BASE_URL"]), now = Date.now) {
|
|
6754
|
+
const hit = partiesProbeCache.get(token);
|
|
6755
|
+
if (hit && hit.expiresAt > now()) return hit.ok;
|
|
6756
|
+
const ok = await probe(token);
|
|
6757
|
+
if (partiesProbeCache.size >= 1e3) partiesProbeCache.clear();
|
|
6758
|
+
partiesProbeCache.set(token, { ok, expiresAt: now() + GROWTH_PROBE_TTL_MS });
|
|
6759
|
+
return ok;
|
|
6760
|
+
}
|
|
6179
6761
|
var GROWTH_PROBE_TTL_MS = 5 * 60 * 1e3;
|
|
6180
6762
|
var growthProbeCache = /* @__PURE__ */ new Map();
|
|
6181
6763
|
async function growthAccessCached(token, probe = probeGrowthAccess, now = Date.now) {
|
|
@@ -6438,7 +7020,8 @@ function createRequestHandler(options = {}) {
|
|
|
6438
7020
|
includeAdminAgentTaskTools,
|
|
6439
7021
|
includeContractsTools,
|
|
6440
7022
|
includeApTools,
|
|
6441
|
-
includeDocGenTools
|
|
7023
|
+
includeDocGenTools,
|
|
7024
|
+
includePartiesTools
|
|
6442
7025
|
] = await Promise.all([
|
|
6443
7026
|
(options.growthAccess ?? ((currentToken) => growthAccessCached(
|
|
6444
7027
|
currentToken,
|
|
@@ -6452,7 +7035,10 @@ function createRequestHandler(options = {}) {
|
|
|
6452
7035
|
token
|
|
6453
7036
|
),
|
|
6454
7037
|
(options.apAccess ?? ((currentToken) => apAccessCached(currentToken)))(token),
|
|
6455
|
-
(options.docGenAccess ?? ((currentToken) => docGenAccessCached(currentToken)))(token)
|
|
7038
|
+
(options.docGenAccess ?? ((currentToken) => docGenAccessCached(currentToken)))(token),
|
|
7039
|
+
(options.partiesAccess ?? ((currentToken) => partiesAccessCached(currentToken)))(
|
|
7040
|
+
token
|
|
7041
|
+
)
|
|
6456
7042
|
]);
|
|
6457
7043
|
const mcpServer = createServer({
|
|
6458
7044
|
tokenProvider: () => token,
|
|
@@ -6461,6 +7047,7 @@ function createRequestHandler(options = {}) {
|
|
|
6461
7047
|
includeContractsTools,
|
|
6462
7048
|
includeApTools,
|
|
6463
7049
|
includeDocGenTools,
|
|
7050
|
+
includePartiesTools,
|
|
6464
7051
|
...process.env["TALONIC_BASE_URL"] ? { baseUrl: process.env["TALONIC_BASE_URL"] } : {},
|
|
6465
7052
|
// Listing UX only: an OAuth token that visibly lacks apps:decide gets
|
|
6466
7053
|
// the decision-task tools marked non-invocable. The platform decides.
|
|
@@ -6499,6 +7086,6 @@ if (isDirectInvocation()) {
|
|
|
6499
7086
|
});
|
|
6500
7087
|
}
|
|
6501
7088
|
|
|
6502
|
-
export { adminAgentTaskAccessCached, apAccessCached, contractsAccessCached, createRequestHandler, docGenAccessCached, growthAccessCached, isOpenAiClient };
|
|
7089
|
+
export { adminAgentTaskAccessCached, apAccessCached, contractsAccessCached, createRequestHandler, docGenAccessCached, growthAccessCached, isOpenAiClient, partiesAccessCached };
|
|
6503
7090
|
//# sourceMappingURL=http-server.js.map
|
|
6504
7091
|
//# sourceMappingURL=http-server.js.map
|