@talonic/mcp 0.1.80 → 0.1.82

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.
@@ -2974,6 +2974,455 @@ function registerGrowthTools(server, getToken, baseUrl) {
2974
2974
  async (args) => handleGrowthToolsUsage(getToken, baseUrl, args)
2975
2975
  );
2976
2976
  }
2977
+ var contractIdArg = z.string().uuid().describe("Contract id (from talonic_contracts_register or talonic_contracts_issues).");
2978
+ var rowIdArg = z.string().uuid().describe(
2979
+ "Document row id on the contract: `documents[].id` from talonic_contracts_contract (not the workspace document id)."
2980
+ );
2981
+ var readOnly = {
2982
+ readOnlyHint: true,
2983
+ destructiveHint: false,
2984
+ idempotentHint: true,
2985
+ openWorldHint: false
2986
+ };
2987
+ var write = (idempotent, destructive = false) => ({
2988
+ readOnlyHint: false,
2989
+ destructiveHint: destructive,
2990
+ idempotentHint: idempotent,
2991
+ openWorldHint: false
2992
+ });
2993
+ var ROLES = ["master", "amendment", "renewal", "termination", "price_sheet", "other"];
2994
+ var STATUSES = ["draft", "active", "expired", "terminated", "unknown"];
2995
+ var DECISIONS = ["terminated", "notice_sent", "renewal_declined", "active"];
2996
+ var TERMS = [
2997
+ "title",
2998
+ "counterparty",
2999
+ "our_party",
3000
+ "family",
3001
+ "site",
3002
+ "signed_date",
3003
+ "effective_date",
3004
+ "expiry_date",
3005
+ "initial_term_months",
3006
+ "auto_renewal",
3007
+ "renewal_term_months",
3008
+ "notice_days",
3009
+ "notice_months",
3010
+ "terminated_on",
3011
+ "annual_value",
3012
+ "currency",
3013
+ "escalation_pct",
3014
+ "escalation_date",
3015
+ "min_commitment",
3016
+ "cap_amount",
3017
+ "payment_terms_days",
3018
+ "governing_law",
3019
+ "is_draft"
3020
+ ];
3021
+ var REGISTER_DESCRIPTION = [
3022
+ "List the workspace's contracts: key, title, counterparty, status, start, end in force, notice deadline, document count, next open date, and what Contract Pricing and Money Found report per contract.",
3023
+ "USE WHEN: getting an overview, finding a contract by key/name, or counting by status.",
3024
+ "NOT FOR: one contract's terms and documents (talonic_contracts_contract); what needs cleaning (talonic_contracts_issues).",
3025
+ "",
3026
+ "ARGS: `query` (key, title or counterparty contains), `status`, `key` (exact).",
3027
+ "RETURNS: data[] { id, contract_key, title, counterparty, status, effective_date, expiry_date, notice_deadline, documents, next_date, links }."
3028
+ ].join("\n");
3029
+ var registerInputSchema = {
3030
+ query: z.string().optional().describe("Key, title or counterparty contains."),
3031
+ status: z.enum(STATUSES).optional().describe("Only contracts in this status."),
3032
+ key: z.string().optional().describe("Exact contract key, e.g. '1042460' or '3042-WLV'.")
3033
+ };
3034
+ function handleRegister(getToken, baseUrl, args) {
3035
+ return runTool(
3036
+ () => apiJson(getToken, baseUrl, "GET", "/v1/contracts", {
3037
+ params: { q: args.query, status: args.status, key: args.key }
3038
+ })
3039
+ );
3040
+ }
3041
+ var CONTRACT_DESCRIPTION = [
3042
+ "Read one contract in full: terms in force (each with the document and verbatim quote it rests on), documents in fold order with what each states (unverified values carry their `problem`), key dates, decisions and links to the other apps.",
3043
+ "USE WHEN: checking or cleaning a contract; you need document row ids for talonic_contracts_update_document.",
3044
+ "NOT FOR: the list of contracts (talonic_contracts_register).",
3045
+ "",
3046
+ "ARGS: `contract_id`.",
3047
+ "RETURNS: { contract, documents[] { id, document_id, filename, role, excluded, extract }, key_dates[], links, decision, history }."
3048
+ ].join("\n");
3049
+ var contractInputSchema = { contract_id: contractIdArg };
3050
+ function handleContract(getToken, baseUrl, args) {
3051
+ return runTool(() => apiJson(getToken, baseUrl, "GET", `/v1/contracts/${args.contract_id}`));
3052
+ }
3053
+ var ISSUES_DESCRIPTION = [
3054
+ "The cleaning worklist: contracts that look wrong and why. Codes: several_base_contracts (one key holds several contracts), printed_number_differs, several_counterparties, several_sites, ended_by_message (an email read as the termination), unread_documents, no_dates, unverified_terms.",
3055
+ "USE WHEN: after an import, to decide what to fix; again after fixing, to confirm it is clean.",
3056
+ "NOT FOR: contracts that are fine (talonic_contracts_register).",
3057
+ "",
3058
+ "ARGS: `code` (only contracts with this issue, optional).",
3059
+ "RETURNS: data[] { contract_id, contract_key, title, status, issues[] { code, detail, document_ids } }. document_ids are workspace document ids; match them to documents[].document_id in talonic_contracts_contract."
3060
+ ].join("\n");
3061
+ var issuesInputSchema = {
3062
+ code: z.enum([
3063
+ "several_base_contracts",
3064
+ "printed_number_differs",
3065
+ "several_counterparties",
3066
+ "several_sites",
3067
+ "ended_by_message",
3068
+ "unread_documents",
3069
+ "no_dates",
3070
+ "unverified_terms"
3071
+ ]).optional().describe("Only contracts with this issue.")
3072
+ };
3073
+ async function handleIssues(getToken, baseUrl, args) {
3074
+ return runTool(async () => {
3075
+ const res = await apiJson(
3076
+ getToken,
3077
+ baseUrl,
3078
+ "GET",
3079
+ "/v1/contracts/issues"
3080
+ );
3081
+ return args.code ? { data: res.data.filter((c) => c.issues.some((i) => i.code === args.code)) } : res;
3082
+ });
3083
+ }
3084
+ var UPCOMING_DESCRIPTION = [
3085
+ "Open key dates across all contracts, soonest first: notice deadlines, ends of term, renewals, price changes, terminations, dated obligations. Dates marked handled are left out.",
3086
+ "USE WHEN: what needs someone soon; preparing a renewal or notice decision.",
3087
+ "NOT FOR: one contract's dates (talonic_contracts_contract).",
3088
+ "",
3089
+ "ARGS: `days` (horizon, default the workspace's alert horizon, 90).",
3090
+ "RETURNS: data[] { id, contract_id, contract_key, title, kind, due_date, days_left, label, quote }."
3091
+ ].join("\n");
3092
+ var upcomingInputSchema = {
3093
+ days: z.number().int().min(1).max(3650).optional().describe("Days ahead.")
3094
+ };
3095
+ function handleUpcoming(getToken, baseUrl, args) {
3096
+ return runTool(
3097
+ () => apiJson(getToken, baseUrl, "GET", "/v1/contracts/upcoming", { params: { days: args.days } })
3098
+ );
3099
+ }
3100
+ var CANDIDATES_DESCRIPTION = [
3101
+ "Contract documents whose terms have not been read yet, grouped by the contract key in their filename; keys Contract Pricing already models first.",
3102
+ "USE WHEN: choosing what to read, or checking how the documents will group before importing.",
3103
+ "NOT FOR: reading them (talonic_contracts_import).",
3104
+ "",
3105
+ "ARGS: `query` (filename contains).",
3106
+ "RETURNS: data[] { contract_key, in_price_baseline, documents[] { document_id, filename, import } }."
3107
+ ].join("\n");
3108
+ var candidatesInputSchema = { query: z.string().optional().describe("Filename contains.") };
3109
+ function handleCandidates(getToken, baseUrl, args) {
3110
+ return runTool(
3111
+ () => apiJson(getToken, baseUrl, "GET", "/v1/contracts/import/candidates", {
3112
+ params: { q: args.query }
3113
+ })
3114
+ );
3115
+ }
3116
+ var STATUS_DESCRIPTION = [
3117
+ "Where the read queue stands: counts by status (pending, running, done, failed) and the latest failures with their error.",
3118
+ "USE WHEN: after talonic_contracts_import, poll until pending and running are 0.",
3119
+ "NOT FOR: the contracts themselves (talonic_contracts_register).",
3120
+ "",
3121
+ "ARGS: none.",
3122
+ "RETURNS: { counts, failed[] { document_id, filename, error, attempts } }."
3123
+ ].join("\n");
3124
+ function handleImportStatus(getToken, baseUrl) {
3125
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/contracts/import/status"));
3126
+ }
3127
+ var IMPORT_DESCRIPTION = [
3128
+ "Queue contract documents to be read; the platform reads them in the background (one model call each) and files each under its contract.",
3129
+ "USE WHEN: filling the app. `all: true` queues every unread candidate (narrow with query, contract_keys, only_priced; `limit` for a first batch); `document_ids` queues exactly those. Always run `all` with `dry_run: true` first and say how many documents it will read.",
3130
+ "NOT FOR: reading a contract again after cleaning (talonic_contracts_reread).",
3131
+ "",
3132
+ "ARGS: `all` or `document_ids`; with all: `query`, `contract_keys`, `only_priced`, `limit`, `dry_run`; with document_ids: `force` (read again even if read).",
3133
+ "RETURNS: all \u2192 { dry_run, contracts, documents, queued, skipped }; document_ids \u2192 { queued, skipped }. Then poll talonic_contracts_import_status."
3134
+ ].join("\n");
3135
+ var importInputSchema = {
3136
+ all: z.boolean().optional().describe("Queue every unread candidate (with the filters below)."),
3137
+ document_ids: z.array(z.string().uuid()).min(1).max(500).optional().describe("Workspace document ids to read."),
3138
+ query: z.string().optional().describe("all: only filenames containing this."),
3139
+ contract_keys: z.array(z.string()).max(2e3).optional().describe("all: only these contract keys."),
3140
+ only_priced: z.boolean().optional().describe("all: only keys Contract Pricing already models."),
3141
+ limit: z.number().int().min(1).max(2e4).optional().describe("all: queue at most this many documents."),
3142
+ dry_run: z.boolean().optional().describe("all: count only, queue nothing."),
3143
+ force: z.boolean().optional().describe("document_ids: read again even when already read.")
3144
+ };
3145
+ function handleImport(getToken, baseUrl, args) {
3146
+ if (!!args.all === !!args.document_ids?.length)
3147
+ return Promise.resolve(validationError("Pass either `all: true` or `document_ids`, not both."));
3148
+ if (args.all) {
3149
+ const { query, contract_keys, only_priced, limit: limit2, dry_run } = args;
3150
+ return runTool(
3151
+ () => apiJson(getToken, baseUrl, "POST", "/v1/contracts/import/all", {
3152
+ body: { query, contract_keys, only_priced, limit: limit2, dry_run }
3153
+ })
3154
+ );
3155
+ }
3156
+ return runTool(
3157
+ () => apiJson(getToken, baseUrl, "POST", "/v1/contracts/import", {
3158
+ body: { document_ids: args.document_ids, force: args.force }
3159
+ })
3160
+ );
3161
+ }
3162
+ var UPDATE_DOCUMENT_DESCRIPTION = [
3163
+ "Fix one document of a contract: set what it is (`role`), leave it out of the fold (`excluded`), file it under another contract key (`contract_key`; a new key creates that contract, null returns it to its derived key), or take it off the contract (`remove`).",
3164
+ "USE WHEN: cleaning \u2014 a key holds several contracts (move each set to its own key, e.g. '1042460-WLV / An der Walze 12'), an email is read as a termination (exclude it), an amendment is read as a base contract (role).",
3165
+ "NOT FOR: moving all documents of a contract at once (talonic_contracts_merge).",
3166
+ "",
3167
+ "ARGS: `contract_id`, `document_row_id`, and one or more of `role`, `excluded`, `contract_key`; or `remove: true` alone.",
3168
+ "RETURNS: the contract the document ends up in, recomputed. A hand-set key and role survive re-reading."
3169
+ ].join("\n");
3170
+ var updateDocumentInputSchema = {
3171
+ contract_id: contractIdArg,
3172
+ document_row_id: rowIdArg,
3173
+ role: z.enum(ROLES).optional().describe("What the document is."),
3174
+ excluded: z.boolean().optional().describe("true = leave it out of the contract's terms."),
3175
+ contract_key: z.string().max(64).nullable().optional().describe("File under this key; null = back to the derived key."),
3176
+ remove: z.boolean().optional().describe("Take the document off the contract (the document stays in the workspace).")
3177
+ };
3178
+ function handleUpdateDocument(getToken, baseUrl, args) {
3179
+ const path = `/v1/contracts/${args.contract_id}/documents/${args.document_row_id}`;
3180
+ if (args.remove) {
3181
+ if (args.role !== void 0 || args.excluded !== void 0 || args.contract_key !== void 0)
3182
+ return Promise.resolve(validationError("`remove` goes alone."));
3183
+ return runTool(() => apiJson(getToken, baseUrl, "DELETE", path));
3184
+ }
3185
+ if (args.role === void 0 && args.excluded === void 0 && args.contract_key === void 0)
3186
+ return Promise.resolve(
3187
+ validationError("Nothing to change: pass role, excluded, contract_key or remove.")
3188
+ );
3189
+ return runTool(
3190
+ () => apiJson(getToken, baseUrl, "PUT", path, {
3191
+ body: { role: args.role, excluded: args.excluded, contract_key: args.contract_key }
3192
+ })
3193
+ );
3194
+ }
3195
+ var MERGE_DESCRIPTION = [
3196
+ "Move every document of one contract under another key (the same contract read under two keys, e.g. '1042460' and '1042460-WLV'). The emptied contract disappears.",
3197
+ "USE WHEN: two register rows are the same contract.",
3198
+ "NOT FOR: moving single documents (talonic_contracts_update_document).",
3199
+ "",
3200
+ "ARGS: `contract_id` (the one to empty), `into_key`.",
3201
+ "RETURNS: { moved, contract } \u2014 the contract under into_key, recomputed."
3202
+ ].join("\n");
3203
+ var mergeInputSchema = {
3204
+ contract_id: contractIdArg,
3205
+ into_key: z.string().min(1).max(64).describe("The key to move everything under.")
3206
+ };
3207
+ function handleMerge(getToken, baseUrl, args) {
3208
+ return runTool(
3209
+ () => apiJson(getToken, baseUrl, "POST", `/v1/contracts/${args.contract_id}/merge`, {
3210
+ body: { into_key: args.into_key }
3211
+ })
3212
+ );
3213
+ }
3214
+ var REREAD_DESCRIPTION = [
3215
+ "Read a contract's documents again (or one of them), e.g. after cleaning or when values did not verify. One model call per document; hand-set values and roles are kept.",
3216
+ "USE WHEN: a contract's terms look wrong and the documents are right.",
3217
+ "NOT FOR: documents never read (talonic_contracts_import).",
3218
+ "",
3219
+ "ARGS: `contract_id`, `document_row_id` (optional, all when omitted).",
3220
+ "RETURNS: { queued, skipped }. Then poll talonic_contracts_import_status."
3221
+ ].join("\n");
3222
+ var rereadInputSchema = {
3223
+ contract_id: contractIdArg,
3224
+ document_row_id: rowIdArg.optional()
3225
+ };
3226
+ function handleReread(getToken, baseUrl, args) {
3227
+ return runTool(
3228
+ () => apiJson(getToken, baseUrl, "POST", `/v1/contracts/${args.contract_id}/reread`, {
3229
+ body: args.document_row_id ? { document_row_id: args.document_row_id } : {}
3230
+ })
3231
+ );
3232
+ }
3233
+ var DECIDE_DESCRIPTION = [
3234
+ "Record a decision on a contract: terminated, notice_sent, renewal_declined, or active (withdraws the earlier one). Recorded as made through the API key, with your note; the contract's status, end and key dates follow.",
3235
+ "USE WHEN: the user states the decision or it is confirmed by a document they point to. Never infer a termination on your own.",
3236
+ "NOT FOR: a termination letter already in the documents (it is read as a fact; check talonic_contracts_contract).",
3237
+ "",
3238
+ "ARGS: `contract_id`, `state`, `note` (say where the decision comes from).",
3239
+ "RETURNS: the contract, recomputed."
3240
+ ].join("\n");
3241
+ var decideInputSchema = {
3242
+ contract_id: contractIdArg,
3243
+ state: z.enum(DECISIONS),
3244
+ note: z.string().max(2e3).optional().describe("Source of the decision, e.g. 'K\xFCndigungsschreiben vom 12.01.2026'.")
3245
+ };
3246
+ function handleDecide(getToken, baseUrl, args) {
3247
+ return runTool(
3248
+ () => apiJson(getToken, baseUrl, "POST", `/v1/contracts/${args.contract_id}/decision`, {
3249
+ body: { state: args.state, note: args.note }
3250
+ })
3251
+ );
3252
+ }
3253
+ var KEY_DATE_DESCRIPTION = [
3254
+ "Mark a key date handled (or open again), e.g. a notice deadline someone has dealt with. Handled dates leave the upcoming list and raise no alert.",
3255
+ "USE WHEN: the user confirms a date is taken care of.",
3256
+ "NOT FOR: changing the date itself (it follows the documents).",
3257
+ "",
3258
+ "ARGS: `key_date_id` (key_dates[].id from talonic_contracts_contract or id from talonic_contracts_upcoming), `handled`, `note`.",
3259
+ "RETURNS: { id, handled }."
3260
+ ].join("\n");
3261
+ var keyDateInputSchema = {
3262
+ key_date_id: z.string().uuid(),
3263
+ handled: z.boolean(),
3264
+ note: z.string().max(2e3).optional()
3265
+ };
3266
+ function handleKeyDate(getToken, baseUrl, args) {
3267
+ return runTool(
3268
+ () => apiJson(getToken, baseUrl, "POST", `/v1/contracts/key-dates/${args.key_date_id}`, {
3269
+ body: { handled: args.handled, note: args.note }
3270
+ })
3271
+ );
3272
+ }
3273
+ var SET_TERM_DESCRIPTION = [
3274
+ "Set one term on one document by hand, with the passage that states it copied verbatim from that document. The platform saves it only when the quote occurs in the document and prints the value.",
3275
+ "USE WHEN: a term was missed or read wrong and you have the exact passage (talonic_get_document or talonic_search to find it).",
3276
+ "NOT FOR: guessing a value; decisions (talonic_contracts_decide).",
3277
+ "",
3278
+ "ARGS: `contract_id`, `document_row_id`, `field`, `value` (ISO date for dates; fraction for escalation_pct; months for *_months), `quote`.",
3279
+ "RETURNS: the contract, recomputed; an error naming the problem when the quote does not verify."
3280
+ ].join("\n");
3281
+ var setTermInputSchema = {
3282
+ contract_id: contractIdArg,
3283
+ document_row_id: rowIdArg,
3284
+ field: z.enum(TERMS),
3285
+ value: z.union([z.string(), z.number(), z.boolean()]),
3286
+ quote: z.string().min(3).max(2e3).describe("Copied character for character from the document.")
3287
+ };
3288
+ function handleSetTerm(getToken, baseUrl, args) {
3289
+ const { field, value, quote } = args;
3290
+ return runTool(
3291
+ () => apiJson(
3292
+ getToken,
3293
+ baseUrl,
3294
+ "POST",
3295
+ `/v1/contracts/${args.contract_id}/documents/${args.document_row_id}/terms`,
3296
+ { body: { field, value, quote } }
3297
+ )
3298
+ );
3299
+ }
3300
+ async function probeContractsAccess(token, baseUrl) {
3301
+ try {
3302
+ const res = await fetch(buildUrl(baseUrl, "/v1/contracts/import/status"), {
3303
+ headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
3304
+ signal: AbortSignal.timeout(5e3)
3305
+ });
3306
+ return res.ok;
3307
+ } catch {
3308
+ return false;
3309
+ }
3310
+ }
3311
+ function registerContractsTools(server, getToken, baseUrl) {
3312
+ const tools = [
3313
+ [
3314
+ "talonic_contracts_register",
3315
+ "List contracts",
3316
+ REGISTER_DESCRIPTION,
3317
+ registerInputSchema,
3318
+ readOnly,
3319
+ (a) => handleRegister(getToken, baseUrl, a)
3320
+ ],
3321
+ [
3322
+ "talonic_contracts_contract",
3323
+ "Read one contract",
3324
+ CONTRACT_DESCRIPTION,
3325
+ contractInputSchema,
3326
+ readOnly,
3327
+ (a) => handleContract(getToken, baseUrl, a)
3328
+ ],
3329
+ [
3330
+ "talonic_contracts_issues",
3331
+ "Contracts to clean",
3332
+ ISSUES_DESCRIPTION,
3333
+ issuesInputSchema,
3334
+ readOnly,
3335
+ (a) => handleIssues(getToken, baseUrl, a)
3336
+ ],
3337
+ [
3338
+ "talonic_contracts_upcoming",
3339
+ "Upcoming contract dates",
3340
+ UPCOMING_DESCRIPTION,
3341
+ upcomingInputSchema,
3342
+ readOnly,
3343
+ (a) => handleUpcoming(getToken, baseUrl, a)
3344
+ ],
3345
+ [
3346
+ "talonic_contracts_import_candidates",
3347
+ "Unread contract documents",
3348
+ CANDIDATES_DESCRIPTION,
3349
+ candidatesInputSchema,
3350
+ readOnly,
3351
+ (a) => handleCandidates(getToken, baseUrl, a)
3352
+ ],
3353
+ [
3354
+ "talonic_contracts_import_status",
3355
+ "Contract read queue",
3356
+ STATUS_DESCRIPTION,
3357
+ {},
3358
+ readOnly,
3359
+ () => handleImportStatus(getToken, baseUrl)
3360
+ ],
3361
+ [
3362
+ "talonic_contracts_import",
3363
+ "Read contract documents",
3364
+ IMPORT_DESCRIPTION,
3365
+ importInputSchema,
3366
+ write(true),
3367
+ (a) => handleImport(getToken, baseUrl, a)
3368
+ ],
3369
+ [
3370
+ "talonic_contracts_update_document",
3371
+ "Fix a contract document",
3372
+ UPDATE_DOCUMENT_DESCRIPTION,
3373
+ updateDocumentInputSchema,
3374
+ write(false, true),
3375
+ (a) => handleUpdateDocument(getToken, baseUrl, a)
3376
+ ],
3377
+ [
3378
+ "talonic_contracts_merge",
3379
+ "Merge two contracts",
3380
+ MERGE_DESCRIPTION,
3381
+ mergeInputSchema,
3382
+ write(true, true),
3383
+ (a) => handleMerge(getToken, baseUrl, a)
3384
+ ],
3385
+ [
3386
+ "talonic_contracts_reread",
3387
+ "Read a contract again",
3388
+ REREAD_DESCRIPTION,
3389
+ rereadInputSchema,
3390
+ write(true),
3391
+ (a) => handleReread(getToken, baseUrl, a)
3392
+ ],
3393
+ [
3394
+ "talonic_contracts_decide",
3395
+ "Record a contract decision",
3396
+ DECIDE_DESCRIPTION,
3397
+ decideInputSchema,
3398
+ write(true),
3399
+ (a) => handleDecide(getToken, baseUrl, a)
3400
+ ],
3401
+ [
3402
+ "talonic_contracts_key_date",
3403
+ "Mark a key date handled",
3404
+ KEY_DATE_DESCRIPTION,
3405
+ keyDateInputSchema,
3406
+ write(true),
3407
+ (a) => handleKeyDate(getToken, baseUrl, a)
3408
+ ],
3409
+ [
3410
+ "talonic_contracts_set_term",
3411
+ "Set a contract term with its quote",
3412
+ SET_TERM_DESCRIPTION,
3413
+ setTermInputSchema,
3414
+ write(true),
3415
+ (a) => handleSetTerm(getToken, baseUrl, a)
3416
+ ]
3417
+ ];
3418
+ for (const [name, title, description, inputSchema11, annotations, handler] of tools) {
3419
+ server.registerTool(
3420
+ name,
3421
+ { title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
3422
+ async (args) => handler(args)
3423
+ );
3424
+ }
3425
+ }
2977
3426
  var DEFAULT_BASE3 = "https://api.talonic.com";
2978
3427
  var TASK_STATUSES = ["available", "claimed", "submitted", "timed_out", "cancelled"];
2979
3428
  var taskId = z.string().uuid().describe("Agent task UUID.");
@@ -3440,7 +3889,6 @@ var MUTATING2 = {
3440
3889
  openWorldHint: false
3441
3890
  };
3442
3891
  var AUTH_NOTE = "AUTH: a tlnc_ key needs a per-app 'decide' grant; an OAuth connector session needs the apps:decide scope (consented at connect) and a live workspace role of senior_member or above. A 403 (decide_grant_required, insufficient_scope, insufficient_tier) names what is missing \u2014 tell the user, do not retry.";
3443
- var NOT_INVOCABLE_PREFIX = "NOT INVOCABLE IN THIS SESSION: the connector's OAuth token lacks the apps:decide scope. Ask the user to reconnect the Talonic connector and approve 'Claim and decide tasks' before calling this; a call now returns 403 insufficient_scope.\n\n";
3444
3892
  var DESCRIPTIONS2 = {
3445
3893
  list: [
3446
3894
  "List one External-mode app's decision tasks (runs parked for an outside agent to decide), newest first.",
@@ -3500,7 +3948,6 @@ var DESCRIPTIONS2 = {
3500
3948
  };
3501
3949
  function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
3502
3950
  const invocable = options.invocable !== false;
3503
- const describe = (text) => invocable ? text : NOT_INVOCABLE_PREFIX + text;
3504
3951
  const metaFor = (key) => ({
3505
3952
  _meta: {
3506
3953
  ...widgetToolMeta(key),
@@ -3511,7 +3958,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
3511
3958
  "talonic_list_decision_tasks",
3512
3959
  {
3513
3960
  title: "List Decision Tasks",
3514
- description: describe(DESCRIPTIONS2.list),
3961
+ description: DESCRIPTIONS2.list,
3515
3962
  inputSchema: listInput2,
3516
3963
  annotations: { title: "List Decision Tasks", ...READ_ONLY3 },
3517
3964
  ...metaFor("listDecisionTasks")
@@ -3522,7 +3969,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
3522
3969
  "talonic_claim_decision_task",
3523
3970
  {
3524
3971
  title: "Claim Decision Task",
3525
- description: describe(DESCRIPTIONS2.claim),
3972
+ description: DESCRIPTIONS2.claim,
3526
3973
  inputSchema: idInput2,
3527
3974
  annotations: { title: "Claim Decision Task", ...MUTATING2 },
3528
3975
  ...metaFor("claimDecisionTask")
@@ -3533,7 +3980,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
3533
3980
  "talonic_read_decision_package",
3534
3981
  {
3535
3982
  title: "Read Decision Package",
3536
- description: describe(DESCRIPTIONS2.package),
3983
+ description: DESCRIPTIONS2.package,
3537
3984
  inputSchema: packageInput,
3538
3985
  annotations: { title: "Read Decision Package", ...READ_ONLY3 },
3539
3986
  ...metaFor("readDecisionPackage")
@@ -3544,7 +3991,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
3544
3991
  "talonic_heartbeat_decision_task",
3545
3992
  {
3546
3993
  title: "Heartbeat Decision Task",
3547
- description: describe(DESCRIPTIONS2.heartbeat),
3994
+ description: DESCRIPTIONS2.heartbeat,
3548
3995
  inputSchema: epochInput,
3549
3996
  annotations: { title: "Heartbeat Decision Task", ...MUTATING2 },
3550
3997
  ...metaFor("heartbeatDecisionTask")
@@ -3555,7 +4002,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
3555
4002
  "talonic_submit_decision_task",
3556
4003
  {
3557
4004
  title: "Submit Decision Task",
3558
- description: describe(DESCRIPTIONS2.submit),
4005
+ description: DESCRIPTIONS2.submit,
3559
4006
  inputSchema: submitInput2,
3560
4007
  annotations: { title: "Submit Decision Task", ...MUTATING2 },
3561
4008
  ...metaFor("submitDecisionTask")
@@ -3566,7 +4013,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
3566
4013
  "talonic_release_decision_task",
3567
4014
  {
3568
4015
  title: "Release Decision Task",
3569
- description: describe(DESCRIPTIONS2.release),
4016
+ description: DESCRIPTIONS2.release,
3570
4017
  inputSchema: epochInput,
3571
4018
  annotations: { title: "Release Decision Task", ...MUTATING2 },
3572
4019
  ...metaFor("releaseDecisionTask")
@@ -3577,7 +4024,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
3577
4024
  "talonic_fail_decision_task",
3578
4025
  {
3579
4026
  title: "Fail Decision Task",
3580
- description: describe(DESCRIPTIONS2.fail),
4027
+ description: DESCRIPTIONS2.fail,
3581
4028
  inputSchema: failInput,
3582
4029
  annotations: { title: "Fail Decision Task", ...MUTATING2 },
3583
4030
  ...metaFor("failDecisionTask")
@@ -3817,10 +4264,11 @@ function registerFieldTools(server, getToken, baseUrl) {
3817
4264
  server.registerTool(
3818
4265
  "talonic_list_fields",
3819
4266
  {
3820
- title: "List registry fields",
4267
+ title: "List Registry Fields",
3821
4268
  description: LIST_DESCRIPTION,
3822
4269
  inputSchema: listFieldsInputSchema,
3823
4270
  annotations: {
4271
+ title: "List Registry Fields",
3824
4272
  readOnlyHint: true,
3825
4273
  destructiveHint: false,
3826
4274
  idempotentHint: true,
@@ -3833,10 +4281,11 @@ function registerFieldTools(server, getToken, baseUrl) {
3833
4281
  server.registerTool(
3834
4282
  "talonic_get_field",
3835
4283
  {
3836
- title: "Get a field's concept card",
4284
+ title: "Get Field Concept Card",
3837
4285
  description: GET_DESCRIPTION,
3838
4286
  inputSchema: getFieldInputSchema,
3839
4287
  annotations: {
4288
+ title: "Get Field Concept Card",
3840
4289
  readOnlyHint: true,
3841
4290
  destructiveHint: false,
3842
4291
  idempotentHint: true,
@@ -3849,10 +4298,11 @@ function registerFieldTools(server, getToken, baseUrl) {
3849
4298
  server.registerTool(
3850
4299
  "talonic_field_values",
3851
4300
  {
3852
- title: "Read a field's values across documents",
4301
+ title: "Read Field Values",
3853
4302
  description: VALUES_DESCRIPTION,
3854
4303
  inputSchema: fieldValuesInputSchema,
3855
4304
  annotations: {
4305
+ title: "Read Field Values",
3856
4306
  readOnlyHint: true,
3857
4307
  destructiveHint: false,
3858
4308
  idempotentHint: true,
@@ -3987,10 +4437,11 @@ function registerAgentRegistryTools(server, getToken, baseUrl) {
3987
4437
  server.registerTool(
3988
4438
  "talonic_find_data",
3989
4439
  {
3990
- title: "Find the data behind a concept",
4440
+ title: "Find Data by Concept",
3991
4441
  description: FIND_DESCRIPTION,
3992
4442
  inputSchema: findDataInputSchema,
3993
4443
  annotations: {
4444
+ title: "Find Data by Concept",
3994
4445
  readOnlyHint: true,
3995
4446
  destructiveHint: false,
3996
4447
  idempotentHint: true,
@@ -4003,10 +4454,11 @@ function registerAgentRegistryTools(server, getToken, baseUrl) {
4003
4454
  server.registerTool(
4004
4455
  "talonic_list_agent_tools",
4005
4456
  {
4006
- title: "List the platform agent tools",
4457
+ title: "List Platform Agent Tools",
4007
4458
  description: LIST_TOOLS_DESCRIPTION,
4008
4459
  inputSchema: listAgentToolsInputSchema,
4009
4460
  annotations: {
4461
+ title: "List Platform Agent Tools",
4010
4462
  readOnlyHint: true,
4011
4463
  destructiveHint: false,
4012
4464
  idempotentHint: true,
@@ -4019,10 +4471,11 @@ function registerAgentRegistryTools(server, getToken, baseUrl) {
4019
4471
  server.registerTool(
4020
4472
  "talonic_invoke_agent_tool",
4021
4473
  {
4022
- title: "Invoke a platform agent tool",
4474
+ title: "Invoke Platform Agent Tool",
4023
4475
  description: INVOKE_DESCRIPTION,
4024
4476
  inputSchema: invokeAgentToolInputSchema,
4025
4477
  annotations: {
4478
+ title: "Invoke Platform Agent Tool",
4026
4479
  readOnlyHint: true,
4027
4480
  destructiveHint: false,
4028
4481
  idempotentHint: false,
@@ -4507,7 +4960,7 @@ function registerAskTools(server, getToken, baseUrl) {
4507
4960
 
4508
4961
  // package.json
4509
4962
  var package_default = {
4510
- version: "0.1.80"};
4963
+ version: "0.1.82"};
4511
4964
 
4512
4965
  // src/version.ts
4513
4966
  var VERSION = package_default.version;
@@ -4660,6 +5113,9 @@ function createServer(options) {
4660
5113
  if (options.includeAdminAgentTaskTools) {
4661
5114
  registerAdminAgentTaskTools(server, rawToken, baseUrl);
4662
5115
  }
5116
+ if (options.includeContractsTools) {
5117
+ registerContractsTools(server, rawToken, baseUrl);
5118
+ }
4663
5119
  registerSchemasResource(server, getTalonic);
4664
5120
  registerWebhooksResource(server, rawToken, baseUrl);
4665
5121
  registerWidgets(server);
@@ -4693,6 +5149,15 @@ var FAVICON_BYTES = Buffer.from(FAVICON_BASE64, "base64");
4693
5149
 
4694
5150
  // src/http-server.ts
4695
5151
  var PORT = Number(process.env["PORT"] ?? 3e3);
5152
+ var contractsProbeCache = /* @__PURE__ */ new Map();
5153
+ async function contractsAccessCached(token, probe = (t) => probeContractsAccess(t, process.env["TALONIC_BASE_URL"]), now = Date.now) {
5154
+ const hit = contractsProbeCache.get(token);
5155
+ if (hit && hit.expiresAt > now()) return hit.ok;
5156
+ const ok = await probe(token);
5157
+ if (contractsProbeCache.size >= 1e3) contractsProbeCache.clear();
5158
+ contractsProbeCache.set(token, { ok, expiresAt: now() + GROWTH_PROBE_TTL_MS });
5159
+ return ok;
5160
+ }
4696
5161
  var GROWTH_PROBE_TTL_MS = 5 * 60 * 1e3;
4697
5162
  var growthProbeCache = /* @__PURE__ */ new Map();
4698
5163
  async function growthAccessCached(token, probe = probeGrowthAccess, now = Date.now) {
@@ -4936,7 +5401,7 @@ function createRequestHandler(options = {}) {
4936
5401
  return;
4937
5402
  }
4938
5403
  const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
4939
- const [includeGrowthTools, includeAdminAgentTaskTools] = await Promise.all([
5404
+ const [includeGrowthTools, includeAdminAgentTaskTools, includeContractsTools] = await Promise.all([
4940
5405
  (options.growthAccess ?? ((currentToken) => growthAccessCached(
4941
5406
  currentToken,
4942
5407
  (candidate) => probeGrowthAccess(candidate, process.env["TALONIC_BASE_URL"])
@@ -4944,12 +5409,14 @@ function createRequestHandler(options = {}) {
4944
5409
  (options.adminAgentTaskAccess ?? ((currentToken) => adminAgentTaskAccessCached(
4945
5410
  currentToken,
4946
5411
  (candidate) => probeAgentTaskAdminAccess(candidate, process.env["TALONIC_BASE_URL"])
4947
- )))(token)
5412
+ )))(token),
5413
+ (options.contractsAccess ?? ((currentToken) => contractsAccessCached(currentToken)))(token)
4948
5414
  ]);
4949
5415
  const mcpServer = createServer({
4950
5416
  tokenProvider: () => token,
4951
5417
  includeGrowthTools,
4952
5418
  includeAdminAgentTaskTools,
5419
+ includeContractsTools,
4953
5420
  ...process.env["TALONIC_BASE_URL"] ? { baseUrl: process.env["TALONIC_BASE_URL"] } : {},
4954
5421
  // Listing UX only: an OAuth token that visibly lacks apps:decide gets
4955
5422
  // the decision-task tools marked non-invocable. The platform decides.
@@ -4981,6 +5448,6 @@ if (isDirectInvocation()) {
4981
5448
  });
4982
5449
  }
4983
5450
 
4984
- export { adminAgentTaskAccessCached, createRequestHandler, growthAccessCached };
5451
+ export { adminAgentTaskAccessCached, contractsAccessCached, createRequestHandler, growthAccessCached };
4985
5452
  //# sourceMappingURL=http-server.js.map
4986
5453
  //# sourceMappingURL=http-server.js.map