@talonic/mcp 0.1.103 → 0.1.105
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 +45 -1
- package/dist/content.js +5221 -164
- package/dist/content.js.map +1 -1
- package/dist/http-server.js +3527 -357
- package/dist/http-server.js.map +1 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +3478 -339
- package/dist/index.js.map +1 -1
- package/dist/server.js +3520 -338
- package/dist/server.js.map +1 -1
- package/package.json +3 -1
package/dist/server.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { realpathSync } from 'fs';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
-
import {
|
|
5
|
+
import { TalonicError, Talonic } from '@talonic/node';
|
|
6
6
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { readFile } from 'fs/promises';
|
|
@@ -151,12 +151,26 @@ async function apiJson(getToken, baseUrl, method, path, opts = {}) {
|
|
|
151
151
|
}
|
|
152
152
|
return await res.json();
|
|
153
153
|
}
|
|
154
|
+
async function probeAccessState(token, baseUrl, path, accept = () => true, params = {}) {
|
|
155
|
+
try {
|
|
156
|
+
const res = await fetch(buildUrl(baseUrl, path, params), {
|
|
157
|
+
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
|
|
158
|
+
signal: AbortSignal.timeout(5e3)
|
|
159
|
+
});
|
|
160
|
+
if (res.status >= 500 || res.status === 429) return "unknown";
|
|
161
|
+
if (!res.ok) return false;
|
|
162
|
+
const body = await res.json().catch(() => null);
|
|
163
|
+
return accept(body);
|
|
164
|
+
} catch {
|
|
165
|
+
return "unknown";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
154
168
|
async function apiForm(getToken, baseUrl, path, fields) {
|
|
155
169
|
const form = new FormData();
|
|
156
|
-
for (const [
|
|
170
|
+
for (const [key2, value] of Object.entries(fields)) {
|
|
157
171
|
if (value === void 0) continue;
|
|
158
|
-
if (Array.isArray(value)) for (const item of value) form.append(
|
|
159
|
-
else form.append(
|
|
172
|
+
if (Array.isArray(value)) for (const item of value) form.append(key2, item);
|
|
173
|
+
else form.append(key2, value);
|
|
160
174
|
}
|
|
161
175
|
const res = await resolveFetch(getToken)(buildUrl(baseUrl, path), {
|
|
162
176
|
method: "POST",
|
|
@@ -272,7 +286,7 @@ function registerWebhooksResource(server, getToken, baseUrl) {
|
|
|
272
286
|
const results = {};
|
|
273
287
|
const token = getToken();
|
|
274
288
|
await Promise.all(
|
|
275
|
-
WEBHOOK_INFO_ENDPOINTS.map(async ({ path, key }) => {
|
|
289
|
+
WEBHOOK_INFO_ENDPOINTS.map(async ({ path, key: key2 }) => {
|
|
276
290
|
try {
|
|
277
291
|
const res = await resolveFetch(getToken)(`${base}${path}`, {
|
|
278
292
|
headers: {
|
|
@@ -281,15 +295,15 @@ function registerWebhooksResource(server, getToken, baseUrl) {
|
|
|
281
295
|
}
|
|
282
296
|
});
|
|
283
297
|
if (res.ok) {
|
|
284
|
-
results[
|
|
298
|
+
results[key2] = await res.json();
|
|
285
299
|
} else {
|
|
286
|
-
results[
|
|
300
|
+
results[key2] = {
|
|
287
301
|
error: `HTTP ${res.status}`,
|
|
288
302
|
message: await res.text().catch(() => "")
|
|
289
303
|
};
|
|
290
304
|
}
|
|
291
305
|
} catch (err) {
|
|
292
|
-
results[
|
|
306
|
+
results[key2] = {
|
|
293
307
|
error: "fetch_failed",
|
|
294
308
|
message: err instanceof Error ? err.message : String(err)
|
|
295
309
|
};
|
|
@@ -456,14 +470,14 @@ var CARD_TOOL_KEYS = /* @__PURE__ */ new Set([
|
|
|
456
470
|
"saveSchema",
|
|
457
471
|
"createAccount"
|
|
458
472
|
]);
|
|
459
|
-
function widgetToolMeta(
|
|
460
|
-
const uri = WIDGET_URIS[
|
|
461
|
-
const status3 = TOOL_INVOCATION_STATUS[
|
|
473
|
+
function widgetToolMeta(key2) {
|
|
474
|
+
const uri = WIDGET_URIS[key2];
|
|
475
|
+
const status3 = TOOL_INVOCATION_STATUS[key2];
|
|
462
476
|
const meta = {
|
|
463
477
|
"openai/toolInvocation/invoking": status3.invoking,
|
|
464
478
|
"openai/toolInvocation/invoked": status3.invoked
|
|
465
479
|
};
|
|
466
|
-
if (CARD_TOOL_KEYS.has(
|
|
480
|
+
if (CARD_TOOL_KEYS.has(key2)) {
|
|
467
481
|
meta["ui"] = { resourceUri: uri };
|
|
468
482
|
meta["openai/outputTemplate"] = uri;
|
|
469
483
|
}
|
|
@@ -2369,18 +2383,18 @@ var WIDGET_REGISTRY = {
|
|
|
2369
2383
|
html: getDecisionFailedWidgetHtml
|
|
2370
2384
|
}
|
|
2371
2385
|
};
|
|
2372
|
-
function registerOne(server,
|
|
2373
|
-
const entry = WIDGET_REGISTRY[
|
|
2386
|
+
function registerOne(server, key2) {
|
|
2387
|
+
const entry = WIDGET_REGISTRY[key2];
|
|
2374
2388
|
registerWidget(server, {
|
|
2375
2389
|
name: entry.name,
|
|
2376
|
-
uri: WIDGET_URIS[
|
|
2390
|
+
uri: WIDGET_URIS[key2],
|
|
2377
2391
|
title: entry.title,
|
|
2378
|
-
description: WIDGET_DESCRIPTIONS[
|
|
2392
|
+
description: WIDGET_DESCRIPTIONS[key2],
|
|
2379
2393
|
html: entry.html()
|
|
2380
2394
|
});
|
|
2381
2395
|
}
|
|
2382
2396
|
function registerWidgets(server) {
|
|
2383
|
-
for (const
|
|
2397
|
+
for (const key2 of Object.keys(WIDGET_REGISTRY)) registerOne(server, key2);
|
|
2384
2398
|
}
|
|
2385
2399
|
var DESCRIPTION = [
|
|
2386
2400
|
"Extract structured, schema-validated JSON from a document: PDF, scan, image, DOCX, email, or photo. Returns the requested fields with per-field confidence scores and, with include_provenance, the page and source text each value came from.",
|
|
@@ -2973,8 +2987,8 @@ async function handleListSchemas(talonic) {
|
|
|
2973
2987
|
const result = await talonic.schemas.list();
|
|
2974
2988
|
const data = Array.isArray(result?.data) ? result.data.map((schema) => {
|
|
2975
2989
|
const summary = {};
|
|
2976
|
-
for (const [
|
|
2977
|
-
if (!LIST_ITEM_OMIT.has(
|
|
2990
|
+
for (const [key2, value] of Object.entries(schema)) {
|
|
2991
|
+
if (!LIST_ITEM_OMIT.has(key2)) summary[key2] = value;
|
|
2978
2992
|
}
|
|
2979
2993
|
return summary;
|
|
2980
2994
|
}) : result?.data;
|
|
@@ -3893,10 +3907,10 @@ function handleImport(getToken, baseUrl, args) {
|
|
|
3893
3907
|
if (!!args.all === !!args.document_ids?.length)
|
|
3894
3908
|
return Promise.resolve(validationError("Pass either `all: true` or `document_ids`, not both."));
|
|
3895
3909
|
if (args.all) {
|
|
3896
|
-
const { query, contract_keys, only_priced, limit:
|
|
3910
|
+
const { query, contract_keys, only_priced, limit: limit3, dry_run } = args;
|
|
3897
3911
|
return runTool(
|
|
3898
3912
|
() => apiJson(getToken, baseUrl, "POST", "/v1/contracts/import/all", {
|
|
3899
|
-
body: { query, contract_keys, only_priced, limit:
|
|
3913
|
+
body: { query, contract_keys, only_priced, limit: limit3, dry_run }
|
|
3900
3914
|
})
|
|
3901
3915
|
);
|
|
3902
3916
|
}
|
|
@@ -4060,7 +4074,7 @@ async function probeContractsAccess(token, baseUrl) {
|
|
|
4060
4074
|
}
|
|
4061
4075
|
}
|
|
4062
4076
|
function registerContractsTools(server, getToken, baseUrl) {
|
|
4063
|
-
const
|
|
4077
|
+
const tools2 = [
|
|
4064
4078
|
[
|
|
4065
4079
|
"talonic_contracts_register",
|
|
4066
4080
|
"List contracts",
|
|
@@ -4183,7 +4197,7 @@ function registerContractsTools(server, getToken, baseUrl) {
|
|
|
4183
4197
|
(a) => handleSetTerm(getToken, baseUrl, a)
|
|
4184
4198
|
]
|
|
4185
4199
|
];
|
|
4186
|
-
for (const [name, title, description, inputSchema11, annotations, handler] of
|
|
4200
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools2) {
|
|
4187
4201
|
server.registerTool(
|
|
4188
4202
|
name,
|
|
4189
4203
|
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
@@ -4358,7 +4372,7 @@ async function probeApAccess(token, baseUrl) {
|
|
|
4358
4372
|
}
|
|
4359
4373
|
}
|
|
4360
4374
|
function registerApTools(server, getToken, baseUrl) {
|
|
4361
|
-
const
|
|
4375
|
+
const tools2 = [
|
|
4362
4376
|
[
|
|
4363
4377
|
"talonic_ap_overview",
|
|
4364
4378
|
"AP totals",
|
|
@@ -4424,7 +4438,7 @@ function registerApTools(server, getToken, baseUrl) {
|
|
|
4424
4438
|
(a) => handleRuns(getToken, baseUrl, a)
|
|
4425
4439
|
]
|
|
4426
4440
|
];
|
|
4427
|
-
for (const [name, title, description, inputSchema11, annotations, handler] of
|
|
4441
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools2) {
|
|
4428
4442
|
server.registerTool(
|
|
4429
4443
|
name,
|
|
4430
4444
|
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
@@ -4907,15 +4921,15 @@ function handleGenerate(getToken, baseUrl, args, deps = {}) {
|
|
|
4907
4921
|
dry_run: args.dry_run ?? false
|
|
4908
4922
|
}
|
|
4909
4923
|
});
|
|
4910
|
-
const
|
|
4911
|
-
if (waitS === 0 || !
|
|
4924
|
+
const jobId2 = created.job?.id;
|
|
4925
|
+
if (waitS === 0 || !jobId2 || created.job?.status !== "running") return created;
|
|
4912
4926
|
const polled = await pollUntilDone(
|
|
4913
4927
|
created.job,
|
|
4914
4928
|
() => apiJson(
|
|
4915
4929
|
getToken,
|
|
4916
4930
|
baseUrl,
|
|
4917
4931
|
"GET",
|
|
4918
|
-
`/v1/doc-gen/jobs/${
|
|
4932
|
+
`/v1/doc-gen/jobs/${jobId2}`
|
|
4919
4933
|
),
|
|
4920
4934
|
(job) => job?.status === "running",
|
|
4921
4935
|
waitS,
|
|
@@ -5009,7 +5023,7 @@ async function probeDocGenAccess(token, baseUrl) {
|
|
|
5009
5023
|
}
|
|
5010
5024
|
}
|
|
5011
5025
|
function registerDocGenTools(server, getToken, baseUrl, opts = {}) {
|
|
5012
|
-
const
|
|
5026
|
+
const tools2 = [
|
|
5013
5027
|
[
|
|
5014
5028
|
"talonic_doc_gen_status",
|
|
5015
5029
|
"Document Generation status",
|
|
@@ -5142,7 +5156,7 @@ function registerDocGenTools(server, getToken, baseUrl, opts = {}) {
|
|
|
5142
5156
|
(a) => handleFile(getToken, baseUrl, a)
|
|
5143
5157
|
]
|
|
5144
5158
|
];
|
|
5145
|
-
for (const [name, title, description, inputSchema11, annotations, handler] of
|
|
5159
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools2) {
|
|
5146
5160
|
server.registerTool(
|
|
5147
5161
|
name,
|
|
5148
5162
|
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
@@ -5164,8 +5178,10 @@ var write4 = (idempotent, destructive2 = false) => ({
|
|
|
5164
5178
|
});
|
|
5165
5179
|
var PARTIES_POLL_INTERVAL_MS = 5e3;
|
|
5166
5180
|
var READ_MAX_WAIT_S = 600;
|
|
5181
|
+
var CONFIRM_MAX_ROLES = 200;
|
|
5167
5182
|
var ROLES2 = [
|
|
5168
5183
|
"partner",
|
|
5184
|
+
"our_party",
|
|
5169
5185
|
"manager",
|
|
5170
5186
|
"tenant",
|
|
5171
5187
|
"previous_owner",
|
|
@@ -5176,29 +5192,18 @@ var ROLES2 = [
|
|
|
5176
5192
|
var KINDS = ["person", "company", "owners_association", "unknown"];
|
|
5177
5193
|
var SALUTATIONS = ["herr", "frau", "eheleute", "firma", "weg"];
|
|
5178
5194
|
var ROLE_STATES = ["suggested", "confirmed", "rejected"];
|
|
5179
|
-
var
|
|
5180
|
-
"no_partner",
|
|
5181
|
-
"several_partners",
|
|
5182
|
-
"reference_disagrees",
|
|
5183
|
-
"kind_unknown",
|
|
5184
|
-
"address_missing",
|
|
5185
|
-
"manager_without_party",
|
|
5186
|
-
"tenant_without_period",
|
|
5187
|
-
"owner_change_open",
|
|
5188
|
-
"cost_unit_disagrees",
|
|
5189
|
-
"cost_unit_missing",
|
|
5190
|
-
"not_read",
|
|
5191
|
-
"read_failed",
|
|
5192
|
-
"possible_duplicate"
|
|
5193
|
-
];
|
|
5194
|
-
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.";
|
|
5195
|
+
var ROLES_EXPLAINED = "Roles: partner (the contract partner), our_party (our own company on the contract), 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.";
|
|
5195
5196
|
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.";
|
|
5196
|
-
var DECISION_RULE = "
|
|
5197
|
+
var DECISION_RULE = "Suggestions never overwrite 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.";
|
|
5198
|
+
var CONTRACT_IS_A_ROW = "A contract is a row of a data product: `product_id` (contracts[].row.data_product_id from talonic_parties_contracts, or products[].id from talonic_parties_status) and `row_id` (contracts[].row.row_id).";
|
|
5197
5199
|
var dateArg = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "a date YYYY-MM-DD").describe("ISO date YYYY-MM-DD.");
|
|
5198
|
-
var
|
|
5199
|
-
"
|
|
5200
|
+
var productIdArg2 = zUuid().describe(
|
|
5201
|
+
"Data product of the contract (contracts[].row.data_product_id from talonic_parties_contracts)."
|
|
5200
5202
|
);
|
|
5201
|
-
var
|
|
5203
|
+
var rowIdArg2 = z.string().min(1).max(200).describe("The contract's row id in that product (contracts[].row.row_id).");
|
|
5204
|
+
var partyIdArg = zUuid().describe("Party id (from talonic_parties_search, _issues or _contract).");
|
|
5205
|
+
var limitArg = (max, dflt) => z.number().int().min(1).max(max).optional().describe(`At most this many (1-${max}, default ${dflt}).`);
|
|
5206
|
+
var offsetArg = z.number().int().min(0).max(1e6).optional().describe("Skip this many (paging; default 0).");
|
|
5202
5207
|
function waitSeconds2(requested, max) {
|
|
5203
5208
|
const n = Number.isFinite(requested) ? requested : 0;
|
|
5204
5209
|
return Math.max(0, Math.min(max, Math.floor(n)));
|
|
@@ -5206,91 +5211,165 @@ function waitSeconds2(requested, max) {
|
|
|
5206
5211
|
function defined(obj) {
|
|
5207
5212
|
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
|
|
5208
5213
|
}
|
|
5214
|
+
var rowPath = (productId, rowId) => `/v1/parties/rows/${productId}/${encodeURIComponent(rowId)}`;
|
|
5215
|
+
async function waitUntil(probe, done, waitS, deps) {
|
|
5216
|
+
const sleep2 = deps.sleep ?? sleep;
|
|
5217
|
+
const now = deps.now ?? Date.now;
|
|
5218
|
+
const start = now();
|
|
5219
|
+
const deadline = start + waitS * 1e3;
|
|
5220
|
+
let last = await probe();
|
|
5221
|
+
let pollError;
|
|
5222
|
+
while (!done(last) && now() < deadline) {
|
|
5223
|
+
await sleep2(Math.min(PARTIES_POLL_INTERVAL_MS, deadline - now()));
|
|
5224
|
+
try {
|
|
5225
|
+
last = await probe();
|
|
5226
|
+
} catch (err) {
|
|
5227
|
+
pollError = err instanceof Error ? err.message : String(err);
|
|
5228
|
+
break;
|
|
5229
|
+
}
|
|
5230
|
+
}
|
|
5231
|
+
return {
|
|
5232
|
+
last,
|
|
5233
|
+
waited_ms: now() - start,
|
|
5234
|
+
still_running: pollError !== void 0 || !done(last),
|
|
5235
|
+
...pollError ? { poll_error: pollError } : {}
|
|
5236
|
+
};
|
|
5237
|
+
}
|
|
5209
5238
|
var STATUS_DESCRIPTION3 = [
|
|
5210
|
-
"Contract Party Management at a glance:
|
|
5211
|
-
"USE WHEN: starting any parties work, or to report where things stand. The loop: talonic_parties_status \u2192
|
|
5212
|
-
"NOT FOR:
|
|
5239
|
+
"Contract Party Management at a glance: whether it is set up, the data products whose rows are the contracts (with row counts), how many rows are filled, the document-read queue, the party count, how many parties need attention, when the last sync finished and the CRM directory's link counts.",
|
|
5240
|
+
"USE WHEN: starting any parties work, or to report where things stand. The loop: talonic_parties_status \u2192 talonic_parties_issues \u2192 talonic_parties_party per flagged party \u2192 talonic_parties_contract per contract \u2192 talonic_parties_set_role / talonic_parties_confirm \u2192 talonic_parties_merge duplicates \u2192 talonic_parties_issues again.",
|
|
5241
|
+
"NOT FOR: which parties need fixing (talonic_parties_issues); one contract (talonic_parties_contract).",
|
|
5213
5242
|
"",
|
|
5214
5243
|
"ARGS: none.",
|
|
5215
|
-
"RETURNS: {
|
|
5244
|
+
"RETURNS: { configured, first_fill, syncing, finding_fields, setup_errors[] { product_id, name, error }, products[] { id, name, rows }, rows, rows_read, reads { pending, running, done, failed }, parties, needs_attention, synced_at, directory { active, label, linked, pick, none } }."
|
|
5216
5245
|
].join("\n");
|
|
5217
5246
|
function handleStatus2(getToken, baseUrl) {
|
|
5218
5247
|
return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/parties/status"));
|
|
5219
5248
|
}
|
|
5220
5249
|
var ISSUES_DESCRIPTION4 = [
|
|
5221
|
-
"The parties worklist:
|
|
5222
|
-
"USE WHEN:
|
|
5223
|
-
"NOT FOR: the headline counts (talonic_parties_status);
|
|
5250
|
+
"The parties worklist: every party that needs a person, because a problem on one of its contracts names it (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, an owners' association without a Verwalter, cost unit disagreeing or missing, not read, read failed, not in the CRM directory, several CRM matches, CRM address far from the contract's) or because it has a duplicate candidate.",
|
|
5251
|
+
"USE WHEN: deciding what to fix; open each party with talonic_parties_party (its contracts with their issues[] codes and details, and its duplicates[]). Duplicates are merge candidates: never merged on their own (talonic_parties_merge, only when the user asked).",
|
|
5252
|
+
"NOT FOR: the headline counts (talonic_parties_status); the whole register (talonic_parties_search).",
|
|
5224
5253
|
"",
|
|
5225
|
-
|
|
5226
|
-
"RETURNS: {
|
|
5254
|
+
"ARGS: `query` (name, street, postcode, town or email contains), `kind` person|company|owners_association|unknown, `product_id` (only contracts of that data product), `scope` all (default: every party) | partners (contract partners only), `limit` (1-5000, default 200), `offset`.",
|
|
5255
|
+
"RETURNS: { total, needs_attention, offset, limit, data[] { id, kind, display_name, street, postcode, town, email, phone, status, contracts, roles[], issues (problems plus duplicate candidates) } }."
|
|
5227
5256
|
].join("\n");
|
|
5228
5257
|
var issuesInputSchema2 = {
|
|
5229
|
-
|
|
5258
|
+
query: z.string().max(300).optional().describe("Name, address or email contains."),
|
|
5259
|
+
kind: z.enum(KINDS).optional().describe("Only parties of this kind."),
|
|
5260
|
+
product_id: zUuid().optional().describe("Only contracts of this data product."),
|
|
5261
|
+
scope: z.enum(["all", "partners"]).optional().describe("all (default): every party; partners: contract partners only."),
|
|
5262
|
+
limit: limitArg(5e3, 200),
|
|
5263
|
+
offset: offsetArg
|
|
5230
5264
|
};
|
|
5231
5265
|
function handleIssues4(getToken, baseUrl, args) {
|
|
5232
5266
|
return runTool(
|
|
5233
|
-
() => apiJson(getToken, baseUrl, "GET", "/v1/parties
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
].join("\n");
|
|
5244
|
-
var contractsInputSchema = {
|
|
5245
|
-
query: z.string().optional().describe("Key, title, counterparty, partner or Verwalter contains."),
|
|
5246
|
-
state: z.enum(["confirmed", "suggested", "none"]).optional().describe("Only contracts whose parties are in this state."),
|
|
5247
|
-
limit: z.number().int().min(1).max(5e3).optional().describe("At most this many (default 500).")
|
|
5248
|
-
};
|
|
5249
|
-
function handleContracts(getToken, baseUrl, args) {
|
|
5250
|
-
return runTool(
|
|
5251
|
-
() => apiJson(getToken, baseUrl, "GET", "/v1/parties/contracts", {
|
|
5252
|
-
params: { q: args.query, state: args.state, limit: args.limit }
|
|
5267
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/parties", {
|
|
5268
|
+
params: {
|
|
5269
|
+
attention: "true",
|
|
5270
|
+
scope: args.scope === "partners" ? void 0 : "all",
|
|
5271
|
+
q: args.query,
|
|
5272
|
+
kind: args.kind,
|
|
5273
|
+
product_id: args.product_id,
|
|
5274
|
+
limit: args.limit,
|
|
5275
|
+
offset: args.offset
|
|
5276
|
+
}
|
|
5253
5277
|
})
|
|
5254
5278
|
);
|
|
5255
5279
|
}
|
|
5256
5280
|
var CONTRACT_DESCRIPTION2 = [
|
|
5257
|
-
"One contract's parties on a day:
|
|
5258
|
-
"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.",
|
|
5281
|
+
"One contract's parties on a day: every role row with its party, state (suggested|confirmed|rejected), confidence and evidence (data fields, document quotes, reference table rows, a person's word); the computed view (partner, manager, tenant, previous and new owner, effective partner, addressee with its postal address lines, contacts, state); the issues; the document read's state; the cost unit the documents name.",
|
|
5282
|
+
"USE WHEN: checking or fixing a flagged contract; you need role ids (roles[].id) for talonic_parties_set_role or talonic_parties_confirm, or to answer who the partner is and where a letter goes.",
|
|
5283
|
+
CONTRACT_IS_A_ROW,
|
|
5259
5284
|
ROLES_EXPLAINED,
|
|
5260
5285
|
COMPUTED_RULE,
|
|
5261
|
-
"NOT FOR:
|
|
5286
|
+
"NOT FOR: one party's contracts (talonic_parties_contracts); the worklist (talonic_parties_issues).",
|
|
5262
5287
|
"",
|
|
5263
|
-
"ARGS: `
|
|
5264
|
-
"RETURNS: {
|
|
5288
|
+
"ARGS: `product_id`, `row_id`, `on` (YYYY-MM-DD; default today: the roles in force on that day).",
|
|
5289
|
+
"RETURNS: { row { data_product_id, product_name, row_id, label, document_ids[] }, on, roles[] { id, party_id, role, represents_id, valid_from, valid_to, enters_contract, state, confidence, evidence[], origin, decided_by, decided_at, note, party }, view { partner, manager, tenant, previous_owner, new_owner, effective_partner, addressee { ...party, address_lines[] }, contacts[], state }, issues[] { code, detail, role_ids[], party_ids[] }, read { status, read_at, error, notes, read_with }, cost_unit { documents, quote } }."
|
|
5265
5290
|
].join("\n");
|
|
5266
5291
|
var contractInputSchema2 = {
|
|
5267
|
-
|
|
5292
|
+
product_id: productIdArg2,
|
|
5293
|
+
row_id: rowIdArg2,
|
|
5268
5294
|
on: dateArg.optional().describe("The day to read the parties for (YYYY-MM-DD; default today).")
|
|
5269
5295
|
};
|
|
5270
5296
|
function handleContract2(getToken, baseUrl, args) {
|
|
5271
5297
|
return runTool(
|
|
5272
|
-
() => apiJson(getToken, baseUrl, "GET",
|
|
5298
|
+
() => apiJson(getToken, baseUrl, "GET", rowPath(args.product_id, args.row_id), {
|
|
5273
5299
|
params: { on: args.on }
|
|
5274
5300
|
})
|
|
5275
5301
|
);
|
|
5276
5302
|
}
|
|
5303
|
+
var SECTION_PATHS = {
|
|
5304
|
+
contracts: (id) => `/v1/parties/${id}/contracts`,
|
|
5305
|
+
documents: (id) => `/v1/parties/${id}/documents`,
|
|
5306
|
+
history: (id) => `/v1/parties/${id}/history`
|
|
5307
|
+
};
|
|
5308
|
+
var SECTION_ARGS = "ARGS: `party_id`, `product_id` (only contracts of that data product), `limit` (1-500, default 50), `offset`.";
|
|
5309
|
+
var CONTRACTS_DESCRIPTION = [
|
|
5310
|
+
"One party's contracts, a page at a time: per contract the row (product_id, row_id, label, documents, read state), this party's roles on it with their evidence, the other parties' roles, the computed view and the contract's issues.",
|
|
5311
|
+
"USE WHEN: answering which contracts a party is on and in what role, or finding the product_id and row_id to open one contract with talonic_parties_contract or to add a role with talonic_parties_set_role.",
|
|
5312
|
+
"NOT FOR: one contract's full parties (talonic_parties_contract); the party's details (talonic_parties_party).",
|
|
5313
|
+
"",
|
|
5314
|
+
SECTION_ARGS,
|
|
5315
|
+
"RETURNS: { total, offset, limit, data[] { row { data_product_id, product_name, row_id, label, document_ids[], read }, roles[], others[] { ...role, party }, view, issues[] } }."
|
|
5316
|
+
].join("\n");
|
|
5317
|
+
var DOCUMENTS_DESCRIPTION = [
|
|
5318
|
+
"The documents a party appears in, a page at a time: each document of its contracts with its filename, the contract's label and the quotes that name the party.",
|
|
5319
|
+
"USE WHEN: showing where a party comes from, or checking the evidence before confirming its roles.",
|
|
5320
|
+
"NOT FOR: the document itself (talonic_get_document); the party's contracts (talonic_parties_contracts).",
|
|
5321
|
+
"",
|
|
5322
|
+
SECTION_ARGS,
|
|
5323
|
+
"RETURNS: { total, offset, limit, data[] { document_id, filename, row_label, quotes[] } }."
|
|
5324
|
+
].join("\n");
|
|
5325
|
+
var HISTORY_DESCRIPTION = [
|
|
5326
|
+
"A party's history, newest first, a page at a time: its names (aliases, former names), role dates on its contracts, its CRM directory link and the decisions people took.",
|
|
5327
|
+
"USE WHEN: the user asks what changed on a party, who decided something, or since when it holds a role.",
|
|
5328
|
+
"NOT FOR: its current details (talonic_parties_party).",
|
|
5329
|
+
"",
|
|
5330
|
+
SECTION_ARGS,
|
|
5331
|
+
"RETURNS: { total, offset, limit, data[] } (each entry a dated event with what changed and who did it)."
|
|
5332
|
+
].join("\n");
|
|
5333
|
+
var sectionInputSchema = {
|
|
5334
|
+
party_id: partyIdArg,
|
|
5335
|
+
product_id: zUuid().optional().describe("Only contracts of this data product."),
|
|
5336
|
+
limit: limitArg(500, 50),
|
|
5337
|
+
offset: offsetArg
|
|
5338
|
+
};
|
|
5339
|
+
function handlePartySection(getToken, baseUrl, section, args) {
|
|
5340
|
+
return runTool(
|
|
5341
|
+
() => apiJson(getToken, baseUrl, "GET", SECTION_PATHS[section](args.party_id), {
|
|
5342
|
+
params: { product_id: args.product_id, limit: args.limit, offset: args.offset }
|
|
5343
|
+
})
|
|
5344
|
+
);
|
|
5345
|
+
}
|
|
5277
5346
|
var SEARCH_DESCRIPTION = [
|
|
5278
|
-
"Search the party register (people, companies, owners' associations): name, street, postcode, town
|
|
5347
|
+
"Search the party register (people, companies, owners' associations): name (aliases included), street, postcode, town or email contains the query; each with how many contracts it is on, its roles and how many problems it has. By default the contract partners; `scope: all` lists every party (Verwalter, tenants, contacts too).",
|
|
5279
5348
|
"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.",
|
|
5280
|
-
"NOT FOR:
|
|
5349
|
+
"NOT FOR: the parties needing attention (talonic_parties_issues); one party in full (talonic_parties_party).",
|
|
5281
5350
|
"",
|
|
5282
|
-
"ARGS: `query`, `kind` person|company|owners_association|unknown, `limit` (1-
|
|
5283
|
-
"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 } }."
|
|
5351
|
+
"ARGS: `query`, `kind` person|company|owners_association|unknown, `product_id`, `scope` partners (default) | all, `limit` (1-5000, default 200), `offset`.",
|
|
5352
|
+
"RETURNS: { total, needs_attention, offset, limit, 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, roles[], issues } }."
|
|
5284
5353
|
].join("\n");
|
|
5285
5354
|
var searchInputSchema = {
|
|
5286
|
-
query: z.string().optional().describe("Name, address
|
|
5355
|
+
query: z.string().max(300).optional().describe("Name, address or email contains."),
|
|
5287
5356
|
kind: z.enum(KINDS).optional().describe("Only parties of this kind."),
|
|
5288
|
-
|
|
5357
|
+
product_id: zUuid().optional().describe("Only contracts of this data product."),
|
|
5358
|
+
scope: z.enum(["partners", "all"]).optional().describe("partners (default): contract partners; all: every party."),
|
|
5359
|
+
limit: limitArg(5e3, 200),
|
|
5360
|
+
offset: offsetArg
|
|
5289
5361
|
};
|
|
5290
5362
|
function handleSearch2(getToken, baseUrl, args) {
|
|
5291
5363
|
return runTool(
|
|
5292
5364
|
() => apiJson(getToken, baseUrl, "GET", "/v1/parties", {
|
|
5293
|
-
params: {
|
|
5365
|
+
params: {
|
|
5366
|
+
q: args.query,
|
|
5367
|
+
kind: args.kind,
|
|
5368
|
+
product_id: args.product_id,
|
|
5369
|
+
scope: args.scope === "all" ? "all" : void 0,
|
|
5370
|
+
limit: args.limit,
|
|
5371
|
+
offset: args.offset
|
|
5372
|
+
}
|
|
5294
5373
|
})
|
|
5295
5374
|
);
|
|
5296
5375
|
}
|
|
@@ -5313,16 +5392,18 @@ var PARTY_FIELD_KEYS = [
|
|
|
5313
5392
|
"external_refs"
|
|
5314
5393
|
];
|
|
5315
5394
|
var PARTY_DESCRIPTION = [
|
|
5316
|
-
"Read, change or create one party. With `party_id` alone: the party with its roles
|
|
5317
|
-
"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
|
|
5318
|
-
"NOT FOR: its role on a contract (talonic_parties_set_role); combining duplicates (talonic_parties_merge).",
|
|
5395
|
+
"Read, change or create one party. With `party_id` alone: the party with where its letters go and why, its contracts (with its roles, the other parties and each contract's issues), the documents it appears in, its contacts (members) and the companies it is a contact of, duplicate candidates, other names, history and its CRM directory link (with candidates to pick from). `overview: true` leaves the long lists out and counts them (page them with talonic_parties_contracts, _documents, _history). With `party_id` and fields: changes those fields (the rest stay; a person's value beats every other source). Without `party_id`: creates a party; `display_name` is required (kind and salutation are inferred from it when not given).",
|
|
5396
|
+
"USE WHEN: checking a flagged 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 data misses before adding it to a contract with talonic_parties_set_role. Search first (talonic_parties_search) so you do not create a duplicate.",
|
|
5397
|
+
"NOT FOR: its role on a contract (talonic_parties_set_role); combining duplicates (talonic_parties_merge); other names (talonic_parties_names).",
|
|
5319
5398
|
"",
|
|
5320
|
-
"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).",
|
|
5321
|
-
"RETURNS: read { party, merged_into,
|
|
5399
|
+
"ARGS: `party_id` (omit to create), `overview` (read only), `product_id` (read only: only contracts of that data product); 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).",
|
|
5400
|
+
"RETURNS: read { party, merged_into, letters { party_id, display_name, address_lines[], reason_code, reason } | null, contracts[], documents[], members[] { id, function, party }, member_of[], duplicates[] { party_id, display_name, postcode, reason }, issues[], names[], history[], directory { active, link, entry, candidates[], crm_address, document_address }, directory_people[] } (overview: contracts without the long lists, plus counts { contracts, documents, history }); change or create: the party."
|
|
5322
5401
|
].join("\n");
|
|
5323
5402
|
var nullableText = (max) => z.string().max(max).nullable().optional();
|
|
5324
5403
|
var partyInputSchema = {
|
|
5325
5404
|
party_id: partyIdArg.optional().describe("The party to read or change; omit to create one."),
|
|
5405
|
+
overview: z.boolean().optional().describe("Read: leave the long lists out and count them instead."),
|
|
5406
|
+
product_id: zUuid().optional().describe("Read: only contracts of this data product."),
|
|
5326
5407
|
kind: z.enum(KINDS).optional().describe("Person, company, owners' association or unknown."),
|
|
5327
5408
|
display_name: z.string().min(1).max(300).optional().describe("Name as printed; required to create."),
|
|
5328
5409
|
salutation: z.enum(SALUTATIONS).nullable().optional().describe("Salutation; null clears it."),
|
|
@@ -5346,7 +5427,12 @@ function handleParty(getToken, baseUrl, args) {
|
|
|
5346
5427
|
if (args.party_id) {
|
|
5347
5428
|
const path = `/v1/parties/${args.party_id}`;
|
|
5348
5429
|
return runTool(
|
|
5349
|
-
() => changing ? apiJson(getToken, baseUrl, "PATCH", path, { body: fields }) : apiJson(getToken, baseUrl, "GET", path
|
|
5430
|
+
() => changing ? apiJson(getToken, baseUrl, "PATCH", path, { body: fields }) : apiJson(getToken, baseUrl, "GET", path, {
|
|
5431
|
+
params: {
|
|
5432
|
+
view: args.overview ? "overview" : void 0,
|
|
5433
|
+
product_id: args.product_id
|
|
5434
|
+
}
|
|
5435
|
+
})
|
|
5350
5436
|
);
|
|
5351
5437
|
}
|
|
5352
5438
|
if (typeof args.display_name !== "string" || !args.display_name.trim()) {
|
|
@@ -5357,18 +5443,20 @@ function handleParty(getToken, baseUrl, args) {
|
|
|
5357
5443
|
return runTool(() => apiJson(getToken, baseUrl, "POST", "/v1/parties", { body: fields }));
|
|
5358
5444
|
}
|
|
5359
5445
|
var SET_ROLE_DESCRIPTION = [
|
|
5360
|
-
"Add a role to a contract, or change one role row. With `
|
|
5446
|
+
"Add a role to a contract, or change one role row. With `product_id`, `row_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.",
|
|
5361
5447
|
"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).",
|
|
5448
|
+
CONTRACT_IS_A_ROW,
|
|
5362
5449
|
ROLES_EXPLAINED,
|
|
5363
5450
|
COMPUTED_RULE,
|
|
5364
5451
|
DECISION_RULE,
|
|
5365
|
-
"NOT FOR: confirming
|
|
5452
|
+
"NOT FOR: confirming several checked roles at once (talonic_parties_confirm); the party's own details (talonic_parties_party).",
|
|
5366
5453
|
"",
|
|
5367
|
-
"ARGS: add: `
|
|
5368
|
-
"RETURNS: the role row { id,
|
|
5454
|
+
"ARGS: add: `product_id`, `row_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).",
|
|
5455
|
+
"RETURNS: the role row { id, data_product_id, row_id, party_id, role, represents_id, valid_from, valid_to, enters_contract, state, confidence, evidence[], origin, decided_by, decided_at, note }."
|
|
5369
5456
|
].join("\n");
|
|
5370
5457
|
var setRoleInputSchema = {
|
|
5371
|
-
|
|
5458
|
+
product_id: productIdArg2.optional().describe("Add: the contract's data product."),
|
|
5459
|
+
row_id: rowIdArg2.optional().describe("Add: the contract's row id in that product."),
|
|
5372
5460
|
role_id: zUuid().optional().describe("Change: the role row (roles[].id from talonic_parties_contract)."),
|
|
5373
5461
|
party_id: partyIdArg.optional().describe("Add: the party; change: move the row to this party."),
|
|
5374
5462
|
role: z.enum(ROLES2).optional().describe("The role."),
|
|
@@ -5380,19 +5468,25 @@ var setRoleInputSchema = {
|
|
|
5380
5468
|
note: z.string().max(1e3).nullable().optional().describe("Why; where the decision comes from.")
|
|
5381
5469
|
};
|
|
5382
5470
|
function handleSetRole(getToken, baseUrl, args) {
|
|
5383
|
-
const {
|
|
5471
|
+
const { product_id, row_id, role_id, ...rest } = args;
|
|
5384
5472
|
const body = defined(rest);
|
|
5385
|
-
|
|
5473
|
+
const adding = product_id !== void 0 || row_id !== void 0;
|
|
5474
|
+
if (adding === !!role_id) {
|
|
5386
5475
|
return Promise.resolve(
|
|
5387
|
-
validationError(
|
|
5476
|
+
validationError(
|
|
5477
|
+
"pass product_id and row_id (with party_id and role) to add, or role_id to change."
|
|
5478
|
+
)
|
|
5388
5479
|
);
|
|
5389
5480
|
}
|
|
5390
|
-
if (
|
|
5481
|
+
if (adding) {
|
|
5482
|
+
if (!product_id || !row_id) {
|
|
5483
|
+
return Promise.resolve(validationError("adding a role needs both product_id and row_id."));
|
|
5484
|
+
}
|
|
5391
5485
|
if (!args.party_id || !args.role) {
|
|
5392
5486
|
return Promise.resolve(validationError("adding a role needs party_id and role."));
|
|
5393
5487
|
}
|
|
5394
5488
|
return runTool(
|
|
5395
|
-
() => apiJson(getToken, baseUrl, "POST",
|
|
5489
|
+
() => apiJson(getToken, baseUrl, "POST", `${rowPath(product_id, row_id)}/roles`, { body })
|
|
5396
5490
|
);
|
|
5397
5491
|
}
|
|
5398
5492
|
if (Object.keys(body).length === 0) {
|
|
@@ -5407,37 +5501,45 @@ function handleSetRole(getToken, baseUrl, args) {
|
|
|
5407
5501
|
);
|
|
5408
5502
|
}
|
|
5409
5503
|
var CONFIRM_DESCRIPTION2 = [
|
|
5410
|
-
|
|
5411
|
-
"USE WHEN: the user
|
|
5504
|
+
`Confirm several suggested roles the user checked, by their ids (up to ${CONFIRM_MAX_ROLES}): each is confirmed on its own, so one refused role never blocks the others. Confirming says a person checked them; it is the user's decision, so only call this when the user asked, and say first how many you will confirm.`,
|
|
5505
|
+
"USE WHEN: the user accepts the suggestions of one or more contracts after you showed them (role ids from talonic_parties_contract roles[].id, or talonic_parties_contracts).",
|
|
5506
|
+
"There is no confirm-by-confidence across the workspace: pick the roles to confirm from the contracts you read.",
|
|
5412
5507
|
DECISION_RULE,
|
|
5413
5508
|
"NOT FOR: rejecting or fixing one role (talonic_parties_set_role).",
|
|
5414
5509
|
"",
|
|
5415
|
-
|
|
5416
|
-
"RETURNS: {
|
|
5510
|
+
`ARGS: \`role_ids[]\` (1-${CONFIRM_MAX_ROLES}), \`note\` (say where the decision comes from; recorded on each role).`,
|
|
5511
|
+
"RETURNS: { confirmed, failed, rows[] { role_id, ok, role? (the confirmed row), error? } }."
|
|
5417
5512
|
].join("\n");
|
|
5418
5513
|
var confirmInputSchema2 = {
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
min_confidence: z.enum(["high", "medium", "low"]).optional().describe("Lowest confidence confirmed (default high)."),
|
|
5422
|
-
limit: z.number().int().min(1).max(5e3).optional().describe("At most this many (default 500)."),
|
|
5423
|
-
dry_run: z.boolean().optional().describe("Count only; nothing is confirmed.")
|
|
5514
|
+
role_ids: z.array(zUuid()).min(1).max(CONFIRM_MAX_ROLES).describe("The role rows to confirm (roles[].id from talonic_parties_contract)."),
|
|
5515
|
+
note: z.string().max(1e3).optional().describe("Why; where the decision comes from.")
|
|
5424
5516
|
};
|
|
5425
5517
|
function handleConfirm2(getToken, baseUrl, args) {
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5518
|
+
const ids = [...new Set(args.role_ids ?? [])];
|
|
5519
|
+
if (!ids.length) return Promise.resolve(validationError("pass at least one role id."));
|
|
5520
|
+
return runTool(async () => {
|
|
5521
|
+
const rows = [];
|
|
5522
|
+
for (const id of ids) {
|
|
5523
|
+
try {
|
|
5524
|
+
const role = await apiJson(getToken, baseUrl, "PATCH", `/v1/parties/roles/${id}`, {
|
|
5525
|
+
body: { state: "confirmed", ...args.note !== void 0 ? { note: args.note } : {} }
|
|
5526
|
+
});
|
|
5527
|
+
rows.push({ role_id: id, ok: true, role });
|
|
5528
|
+
} catch (err) {
|
|
5529
|
+
rows.push({
|
|
5530
|
+
role_id: id,
|
|
5531
|
+
ok: false,
|
|
5532
|
+
error: err instanceof Error ? err.message : String(err)
|
|
5533
|
+
});
|
|
5434
5534
|
}
|
|
5435
|
-
}
|
|
5436
|
-
|
|
5535
|
+
}
|
|
5536
|
+
const confirmed = rows.filter((r) => r.ok).length;
|
|
5537
|
+
return { confirmed, failed: rows.length - confirmed, rows };
|
|
5538
|
+
});
|
|
5437
5539
|
}
|
|
5438
5540
|
var MERGE_DESCRIPTION2 = [
|
|
5439
5541
|
"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.",
|
|
5440
|
-
"USE WHEN:
|
|
5542
|
+
"USE WHEN: talonic_parties_party lists duplicates[] and the user confirms they are the same party.",
|
|
5441
5543
|
"NOT FOR: two different parties with similar names; moving one role to another party (talonic_parties_set_role with role_id and party_id).",
|
|
5442
5544
|
"",
|
|
5443
5545
|
"ARGS: `party_id` (the one that goes), `into` (the survivor), `dry_run`.",
|
|
@@ -5458,76 +5560,215 @@ function handleMerge2(getToken, baseUrl, args) {
|
|
|
5458
5560
|
})
|
|
5459
5561
|
);
|
|
5460
5562
|
}
|
|
5563
|
+
var READ_STATES_BUSY = /* @__PURE__ */ new Set(["pending", "running"]);
|
|
5461
5564
|
var READ_DESCRIPTION = [
|
|
5462
|
-
"
|
|
5463
|
-
"USE WHEN:
|
|
5565
|
+
"Have one contract's documents read for its parties: the platform reads the documents in the background and adds every party and role it finds as a suggestion, with quotes, merged with what the contract's data already says. A read is extra work on the documents; ask for it only when the contract's data names too little (issues not_read, no_partner) or the user asked. A contract already queued or being read is not queued twice. With `status: true` only reports the read's state; without a contract, `status: true` reports the workspace's read queue. Pass `wait_seconds` to wait until the read is done or failed (polls every 5 s).",
|
|
5566
|
+
"USE WHEN: one contract's parties are missing or wrong and its data cannot fill them; then talonic_parties_contract to see the new suggestions.",
|
|
5567
|
+
CONTRACT_IS_A_ROW,
|
|
5464
5568
|
DECISION_RULE,
|
|
5465
|
-
"NOT FOR:
|
|
5569
|
+
"NOT FOR: filling every contract from the data products again (talonic_parties_sync); reading many contracts at once (ask for one at a time, only where needed).",
|
|
5466
5570
|
"",
|
|
5467
|
-
"ARGS: `
|
|
5468
|
-
"RETURNS:
|
|
5571
|
+
"ARGS: `product_id` + `row_id` (the contract), `status` (only report; nothing is queued), `wait_seconds` (0-600, default 0).",
|
|
5572
|
+
"RETURNS: queued { status: pending|running }; a contract's state { status, read_at, error, notes, read_with }; the queue (no contract) { reads { pending, running, done, failed }, rows, rows_read }. After a wait also { waited_ms, still_running } and `read` (the last state: done, failed with error, or still pending|running)."
|
|
5469
5573
|
].join("\n");
|
|
5470
5574
|
var readInputSchema = {
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
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}).`)
|
|
5478
|
-
};
|
|
5479
|
-
var busy = (s) => (s.counts?.["pending"] ?? 0) + (s.counts?.["running"] ?? 0) > 0;
|
|
5575
|
+
product_id: productIdArg2.optional().describe("The contract's data product."),
|
|
5576
|
+
row_id: rowIdArg2.optional().describe("The contract's row id in that product."),
|
|
5577
|
+
status: z.boolean().optional().describe("Only report; nothing is queued."),
|
|
5578
|
+
wait_seconds: z.number().min(0).max(READ_MAX_WAIT_S).optional().describe(`Seconds to wait for the read to finish (0-${READ_MAX_WAIT_S}).`)
|
|
5579
|
+
};
|
|
5580
|
+
var queueBusy = (s) => (s.reads?.["pending"] ?? 0) + (s.reads?.["running"] ?? 0) > 0;
|
|
5480
5581
|
function handleRead(getToken, baseUrl, args, deps = {}) {
|
|
5481
5582
|
const waitS = waitSeconds2(args.wait_seconds, READ_MAX_WAIT_S);
|
|
5482
|
-
const
|
|
5583
|
+
const hasRow = !!args.product_id && !!args.row_id;
|
|
5584
|
+
if (!!args.product_id !== !!args.row_id) {
|
|
5585
|
+
return Promise.resolve(validationError("a contract needs both product_id and row_id."));
|
|
5586
|
+
}
|
|
5587
|
+
if (!hasRow && !args.status) {
|
|
5588
|
+
return Promise.resolve(
|
|
5589
|
+
validationError(
|
|
5590
|
+
"pass product_id and row_id to read one contract, or status: true for the read queue. To fill every contract from the data, use talonic_parties_sync."
|
|
5591
|
+
)
|
|
5592
|
+
);
|
|
5593
|
+
}
|
|
5594
|
+
if (!hasRow) {
|
|
5595
|
+
const queue = () => apiJson(getToken, baseUrl, "GET", "/v1/parties/status");
|
|
5596
|
+
return runTool(async () => {
|
|
5597
|
+
if (waitS === 0) {
|
|
5598
|
+
const s = await queue();
|
|
5599
|
+
return { reads: s.reads, rows: s.rows, rows_read: s.rows_read };
|
|
5600
|
+
}
|
|
5601
|
+
const w = await waitUntil(queue, (s) => !queueBusy(s), waitS, deps);
|
|
5602
|
+
return {
|
|
5603
|
+
reads: w.last.reads,
|
|
5604
|
+
rows: w.last.rows,
|
|
5605
|
+
rows_read: w.last.rows_read,
|
|
5606
|
+
waited_ms: w.waited_ms,
|
|
5607
|
+
still_running: w.still_running,
|
|
5608
|
+
...w.poll_error ? { poll_error: w.poll_error } : {}
|
|
5609
|
+
};
|
|
5610
|
+
});
|
|
5611
|
+
}
|
|
5612
|
+
const path = rowPath(args.product_id, args.row_id);
|
|
5613
|
+
const rowRead = async () => (await apiJson(getToken, baseUrl, "GET", path)).read ?? null;
|
|
5483
5614
|
return runTool(async () => {
|
|
5484
|
-
let
|
|
5615
|
+
let queued = null;
|
|
5485
5616
|
if (!args.status) {
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
"/v1/parties/read",
|
|
5491
|
-
{
|
|
5492
|
-
body: {
|
|
5493
|
-
...args.contract_ids ? { contract_ids: args.contract_ids } : {},
|
|
5494
|
-
...args.only_unread !== void 0 ? { only_unread: args.only_unread } : {},
|
|
5495
|
-
...args.force !== void 0 ? { force: args.force } : {},
|
|
5496
|
-
...args.limit ? { limit: args.limit } : {},
|
|
5497
|
-
dry_run: args.dry_run ?? false
|
|
5498
|
-
}
|
|
5499
|
-
}
|
|
5500
|
-
);
|
|
5501
|
-
if (waitS === 0 || args.dry_run) return started;
|
|
5502
|
-
}
|
|
5503
|
-
const first = await readStatus();
|
|
5504
|
-
if (waitS === 0) return first;
|
|
5505
|
-
const sleep2 = deps.sleep ?? sleep;
|
|
5506
|
-
const now = deps.now ?? Date.now;
|
|
5507
|
-
const start = now();
|
|
5508
|
-
const deadline = start + waitS * 1e3;
|
|
5509
|
-
let status3 = first;
|
|
5510
|
-
let pollError;
|
|
5511
|
-
while (busy(status3) && now() < deadline) {
|
|
5512
|
-
await sleep2(Math.min(PARTIES_POLL_INTERVAL_MS, deadline - now()));
|
|
5513
|
-
try {
|
|
5514
|
-
status3 = await readStatus();
|
|
5515
|
-
} catch (err) {
|
|
5516
|
-
pollError = err instanceof Error ? err.message : String(err);
|
|
5517
|
-
break;
|
|
5518
|
-
}
|
|
5617
|
+
queued = await apiJson(getToken, baseUrl, "POST", `${path}/read`);
|
|
5618
|
+
if (waitS === 0) return queued;
|
|
5619
|
+
} else if (waitS === 0) {
|
|
5620
|
+
return await rowRead() ?? { status: null };
|
|
5519
5621
|
}
|
|
5520
|
-
const
|
|
5622
|
+
const w = await waitUntil(rowRead, (r) => !READ_STATES_BUSY.has(r?.status ?? ""), waitS, deps);
|
|
5623
|
+
const failed = w.last?.status === "failed";
|
|
5521
5624
|
return {
|
|
5522
|
-
...
|
|
5523
|
-
|
|
5524
|
-
waited_ms:
|
|
5525
|
-
still_running:
|
|
5526
|
-
...
|
|
5527
|
-
next:
|
|
5625
|
+
...queued ?? {},
|
|
5626
|
+
read: w.last,
|
|
5627
|
+
waited_ms: w.waited_ms,
|
|
5628
|
+
still_running: w.still_running,
|
|
5629
|
+
...w.poll_error ? { poll_error: w.poll_error } : {},
|
|
5630
|
+
next: w.still_running ? "Still reading: call talonic_parties_read with status: true (and wait_seconds) later." : failed ? "The read failed (read.error); tell the user. The contract keeps what its data says." : "Read done: open the contract with talonic_parties_contract."
|
|
5528
5631
|
};
|
|
5529
5632
|
});
|
|
5530
5633
|
}
|
|
5634
|
+
var SYNC_DESCRIPTION = [
|
|
5635
|
+
"Bring the contracts' parties in line with the workspace's data products now: every contract row is filled again from its data (mapped fields, the field registry, the Contracts app), new rows are registered and sure duplicates are merged. A full pass runs in the background; named `row_ids` are filled at once. Fills only make suggestions and never overwrite a person's decision. Pass `wait_seconds` to wait until the full pass finished (polls the status every 5 s).",
|
|
5636
|
+
"USE WHEN: new contracts or changed data should show now instead of at the next scheduled sync (every 15 minutes), or after the user changed group companies or the CRM directory.",
|
|
5637
|
+
"NOT FOR: reading one contract's documents (talonic_parties_read).",
|
|
5638
|
+
"",
|
|
5639
|
+
"ARGS: `row_ids[]` (only these contract rows, up to 5000; omit for a full pass), `wait_seconds` (0-600, default 0; full pass only).",
|
|
5640
|
+
"RETURNS: { started: true }; after a wait also { syncing, synced_at, rows, waited_ms, still_running }."
|
|
5641
|
+
].join("\n");
|
|
5642
|
+
var syncInputSchema = {
|
|
5643
|
+
row_ids: z.array(z.string().min(1).max(200)).min(1).max(5e3).optional().describe("Only these contract rows (contracts[].row.row_id); omit for a full pass."),
|
|
5644
|
+
wait_seconds: z.number().min(0).max(READ_MAX_WAIT_S).optional().describe(`Seconds to wait for a full pass to finish (0-${READ_MAX_WAIT_S}).`)
|
|
5645
|
+
};
|
|
5646
|
+
function handleSync(getToken, baseUrl, args, deps = {}) {
|
|
5647
|
+
const waitS = waitSeconds2(args.wait_seconds, READ_MAX_WAIT_S);
|
|
5648
|
+
return runTool(async () => {
|
|
5649
|
+
const started = await apiJson(
|
|
5650
|
+
getToken,
|
|
5651
|
+
baseUrl,
|
|
5652
|
+
"POST",
|
|
5653
|
+
"/v1/parties/sync",
|
|
5654
|
+
{ body: args.row_ids ? { row_ids: args.row_ids } : {} }
|
|
5655
|
+
);
|
|
5656
|
+
if (waitS === 0 || args.row_ids) return started;
|
|
5657
|
+
const w = await waitUntil(
|
|
5658
|
+
() => apiJson(getToken, baseUrl, "GET", "/v1/parties/status"),
|
|
5659
|
+
(s) => !s.syncing,
|
|
5660
|
+
waitS,
|
|
5661
|
+
deps
|
|
5662
|
+
);
|
|
5663
|
+
return {
|
|
5664
|
+
...started,
|
|
5665
|
+
syncing: w.last.syncing ?? false,
|
|
5666
|
+
synced_at: w.last.synced_at ?? null,
|
|
5667
|
+
rows: w.last.rows,
|
|
5668
|
+
waited_ms: w.waited_ms,
|
|
5669
|
+
still_running: w.still_running,
|
|
5670
|
+
...w.poll_error ? { poll_error: w.poll_error } : {}
|
|
5671
|
+
};
|
|
5672
|
+
});
|
|
5673
|
+
}
|
|
5674
|
+
var NAMES_DESCRIPTION = [
|
|
5675
|
+
"A party's other names: add an alias or a former name (with the day it ended), confirm or reject a suggested name, or remove a name a person added. Other names make the party findable under them (talonic_parties_search) and keep documents with an old name on the same party.",
|
|
5676
|
+
"USE WHEN: the user says a party is also called X, was renamed (former name with valid_to), or a suggested name in talonic_parties_party names[] is right or wrong.",
|
|
5677
|
+
"NOT FOR: the party's printed name (talonic_parties_party display_name); two parties that are one (talonic_parties_merge).",
|
|
5678
|
+
"",
|
|
5679
|
+
"ARGS: add: `party_id`, `name`, `kind` alias|former, `valid_to` (former only, YYYY-MM-DD), `note`; decide: `name_id` (names[].id from talonic_parties_party) and `state` confirmed|rejected; remove: `name_id` and `remove: true` (names from the data are rejected instead).",
|
|
5680
|
+
"RETURNS: add / decide: the name { id, party_id, name, kind, valid_to, state, source, decided_by, decided_at }; remove: { deleted: true }."
|
|
5681
|
+
].join("\n");
|
|
5682
|
+
var namesInputSchema = {
|
|
5683
|
+
party_id: partyIdArg.optional().describe("Add: the party."),
|
|
5684
|
+
name: z.string().min(1).max(300).optional().describe("Add: the other name."),
|
|
5685
|
+
kind: z.enum(["alias", "former"]).optional().describe("Add: alias (also called) or former (renamed)."),
|
|
5686
|
+
valid_to: dateArg.nullable().optional().describe("Add, former name: the day it ended."),
|
|
5687
|
+
note: z.string().max(500).nullable().optional().describe("Add: where this comes from."),
|
|
5688
|
+
name_id: zUuid().optional().describe("Decide or remove: the name (names[].id)."),
|
|
5689
|
+
state: z.enum(["confirmed", "rejected"]).optional().describe("Decide: confirmed or rejected."),
|
|
5690
|
+
remove: z.boolean().optional().describe("Remove: true deletes a name a person added.")
|
|
5691
|
+
};
|
|
5692
|
+
function handleNames(getToken, baseUrl, args) {
|
|
5693
|
+
if (args.name_id) {
|
|
5694
|
+
if (args.party_id || args.name !== void 0 || args.kind) {
|
|
5695
|
+
return Promise.resolve(
|
|
5696
|
+
validationError(
|
|
5697
|
+
"name_id goes with state (decide) or remove: true (remove), not with add fields."
|
|
5698
|
+
)
|
|
5699
|
+
);
|
|
5700
|
+
}
|
|
5701
|
+
if (!!args.remove === !!args.state) {
|
|
5702
|
+
return Promise.resolve(validationError("with name_id pass either state or remove: true."));
|
|
5703
|
+
}
|
|
5704
|
+
const path = `/v1/parties/names/${args.name_id}`;
|
|
5705
|
+
return runTool(
|
|
5706
|
+
() => args.remove ? apiJson(getToken, baseUrl, "DELETE", path) : apiJson(getToken, baseUrl, "PATCH", path, { body: { state: args.state } })
|
|
5707
|
+
);
|
|
5708
|
+
}
|
|
5709
|
+
if (!args.party_id || !args.name || !args.kind) {
|
|
5710
|
+
return Promise.resolve(
|
|
5711
|
+
validationError(
|
|
5712
|
+
"pass party_id, name and kind to add a name, or name_id to decide or remove one."
|
|
5713
|
+
)
|
|
5714
|
+
);
|
|
5715
|
+
}
|
|
5716
|
+
if (args.valid_to && args.kind !== "former") {
|
|
5717
|
+
return Promise.resolve(validationError("valid_to belongs to a former name only."));
|
|
5718
|
+
}
|
|
5719
|
+
return runTool(
|
|
5720
|
+
() => apiJson(getToken, baseUrl, "POST", `/v1/parties/${args.party_id}/names`, {
|
|
5721
|
+
body: defined({
|
|
5722
|
+
name: args.name,
|
|
5723
|
+
kind: args.kind,
|
|
5724
|
+
valid_to: args.valid_to,
|
|
5725
|
+
note: args.note
|
|
5726
|
+
})
|
|
5727
|
+
})
|
|
5728
|
+
);
|
|
5729
|
+
}
|
|
5730
|
+
var DIRECTORY_LINK_DESCRIPTION = [
|
|
5731
|
+
"Link a party to its entry in the workspace's CRM directory, or unlink it (`external_id: null`). A linked party shows the CRM's address, phone and parent company over the contract sources (a person's own edit still wins); a person's link or unlink is never redone by the automatic linking. The party's contracts are filled again with the new link.",
|
|
5732
|
+
"USE WHEN: talonic_parties_party shows directory.link.state pick (several CRM entries match: issue crm_pick) and the user names the right one from directory.candidates[], or a link is wrong.",
|
|
5733
|
+
"NOT FOR: which address letters use when the CRM's differs (talonic_parties_address_choice).",
|
|
5734
|
+
"",
|
|
5735
|
+
"ARGS: `party_id`, `external_id` (the CRM entry's id from directory.candidates[].external_id; null unlinks), `kind` company|contact (the entry's kind; default company).",
|
|
5736
|
+
"RETURNS: the party's directory link { state, kind, external_id, candidates[], odd_address, address_choice, decided_by }."
|
|
5737
|
+
].join("\n");
|
|
5738
|
+
var directoryLinkInputSchema = {
|
|
5739
|
+
party_id: partyIdArg,
|
|
5740
|
+
external_id: z.string().min(1).max(100).nullable().describe("The CRM entry's id (directory.candidates[].external_id); null unlinks."),
|
|
5741
|
+
kind: z.enum(["company", "contact"]).optional().describe("The entry's kind (default company).")
|
|
5742
|
+
};
|
|
5743
|
+
function handleDirectoryLink(getToken, baseUrl, args) {
|
|
5744
|
+
if (args.external_id === void 0) {
|
|
5745
|
+
return Promise.resolve(validationError("pass external_id, or null to unlink."));
|
|
5746
|
+
}
|
|
5747
|
+
return runTool(
|
|
5748
|
+
() => apiJson(getToken, baseUrl, "POST", `/v1/parties/${args.party_id}/directory-link`, {
|
|
5749
|
+
body: defined({ external_id: args.external_id, kind: args.kind })
|
|
5750
|
+
})
|
|
5751
|
+
);
|
|
5752
|
+
}
|
|
5753
|
+
var ADDRESS_CHOICE_DESCRIPTION = [
|
|
5754
|
+
"Choose which address a linked party's letters use when the CRM's address is far from the contract's (issue crm_address_differs): `crm` or `document`. The party's contracts are filled again with the choice; the automatic linking never changes it.",
|
|
5755
|
+
"USE WHEN: talonic_parties_party shows directory.crm_address and directory.document_address and the user says which is right.",
|
|
5756
|
+
"NOT FOR: typing a new address (talonic_parties_party with street, postcode, town).",
|
|
5757
|
+
"",
|
|
5758
|
+
"ARGS: `party_id`, `choice` crm|document.",
|
|
5759
|
+
"RETURNS: the party's directory link { state, kind, external_id, odd_address, address_choice, decided_by }."
|
|
5760
|
+
].join("\n");
|
|
5761
|
+
var addressChoiceInputSchema = {
|
|
5762
|
+
party_id: partyIdArg,
|
|
5763
|
+
choice: z.enum(["crm", "document"]).describe("crm: the CRM's address; document: the contract's.")
|
|
5764
|
+
};
|
|
5765
|
+
function handleAddressChoice(getToken, baseUrl, args) {
|
|
5766
|
+
return runTool(
|
|
5767
|
+
() => apiJson(getToken, baseUrl, "POST", `/v1/parties/${args.party_id}/address-choice`, {
|
|
5768
|
+
body: { choice: args.choice }
|
|
5769
|
+
})
|
|
5770
|
+
);
|
|
5771
|
+
}
|
|
5531
5772
|
var MEMBERS_DESCRIPTION = [
|
|
5532
5773
|
"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.",
|
|
5533
5774
|
"USE WHEN: the user names the person to write to at a company (e.g. the WEG's Verwalter contact), or a contact left.",
|
|
@@ -5566,8 +5807,8 @@ function handleMembers(getToken, baseUrl, args) {
|
|
|
5566
5807
|
);
|
|
5567
5808
|
}
|
|
5568
5809
|
var GROUP_COMPANIES_DESCRIPTION = [
|
|
5569
|
-
"Read the workspace's own companies (the group: lead company, subsidiaries, sisters), or replace them all with `companies`.
|
|
5570
|
-
"USE WHEN:
|
|
5810
|
+
"Read the workspace's own companies (the group: lead company, subsidiaries, sisters), or replace them all with `companies`. They tell our side from the contract partner: our own companies never become a contract partner. Replacing deletes every company not in the new list: read first, change, send the whole list, and only when the user asked.",
|
|
5811
|
+
"USE WHEN: one of our own companies shows up as a contract partner, or setting up the workspace.",
|
|
5571
5812
|
"NOT FOR: contract partners (talonic_parties_party).",
|
|
5572
5813
|
"",
|
|
5573
5814
|
"ARGS: none to read; `companies[] { name, parent? (another name in the list), relation? subsidiary|sister|parent }` to replace.",
|
|
@@ -5601,7 +5842,7 @@ async function probePartiesAccess(token, baseUrl) {
|
|
|
5601
5842
|
}
|
|
5602
5843
|
}
|
|
5603
5844
|
function registerPartiesTools(server, getToken, baseUrl) {
|
|
5604
|
-
const
|
|
5845
|
+
const tools2 = [
|
|
5605
5846
|
[
|
|
5606
5847
|
"talonic_parties_status",
|
|
5607
5848
|
"Contract parties status",
|
|
@@ -5612,20 +5853,12 @@ function registerPartiesTools(server, getToken, baseUrl) {
|
|
|
5612
5853
|
],
|
|
5613
5854
|
[
|
|
5614
5855
|
"talonic_parties_issues",
|
|
5615
|
-
"
|
|
5856
|
+
"Parties needing attention",
|
|
5616
5857
|
ISSUES_DESCRIPTION4,
|
|
5617
5858
|
issuesInputSchema2,
|
|
5618
5859
|
readOnly4,
|
|
5619
5860
|
(a) => handleIssues4(getToken, baseUrl, a)
|
|
5620
5861
|
],
|
|
5621
|
-
[
|
|
5622
|
-
"talonic_parties_contracts",
|
|
5623
|
-
"Contracts with their parties",
|
|
5624
|
-
CONTRACTS_DESCRIPTION,
|
|
5625
|
-
contractsInputSchema,
|
|
5626
|
-
readOnly4,
|
|
5627
|
-
(a) => handleContracts(getToken, baseUrl, a)
|
|
5628
|
-
],
|
|
5629
5862
|
[
|
|
5630
5863
|
"talonic_parties_contract",
|
|
5631
5864
|
"One contract's parties",
|
|
@@ -5634,6 +5867,30 @@ function registerPartiesTools(server, getToken, baseUrl) {
|
|
|
5634
5867
|
readOnly4,
|
|
5635
5868
|
(a) => handleContract2(getToken, baseUrl, a)
|
|
5636
5869
|
],
|
|
5870
|
+
[
|
|
5871
|
+
"talonic_parties_contracts",
|
|
5872
|
+
"A party's contracts",
|
|
5873
|
+
CONTRACTS_DESCRIPTION,
|
|
5874
|
+
sectionInputSchema,
|
|
5875
|
+
readOnly4,
|
|
5876
|
+
(a) => handlePartySection(getToken, baseUrl, "contracts", a)
|
|
5877
|
+
],
|
|
5878
|
+
[
|
|
5879
|
+
"talonic_parties_documents",
|
|
5880
|
+
"A party's documents",
|
|
5881
|
+
DOCUMENTS_DESCRIPTION,
|
|
5882
|
+
sectionInputSchema,
|
|
5883
|
+
readOnly4,
|
|
5884
|
+
(a) => handlePartySection(getToken, baseUrl, "documents", a)
|
|
5885
|
+
],
|
|
5886
|
+
[
|
|
5887
|
+
"talonic_parties_history",
|
|
5888
|
+
"A party's history",
|
|
5889
|
+
HISTORY_DESCRIPTION,
|
|
5890
|
+
sectionInputSchema,
|
|
5891
|
+
readOnly4,
|
|
5892
|
+
(a) => handlePartySection(getToken, baseUrl, "history", a)
|
|
5893
|
+
],
|
|
5637
5894
|
[
|
|
5638
5895
|
"talonic_parties_search",
|
|
5639
5896
|
"Search parties",
|
|
@@ -5651,6 +5908,32 @@ function registerPartiesTools(server, getToken, baseUrl) {
|
|
|
5651
5908
|
write4(false, true),
|
|
5652
5909
|
(a) => handleParty(getToken, baseUrl, a)
|
|
5653
5910
|
],
|
|
5911
|
+
[
|
|
5912
|
+
"talonic_parties_names",
|
|
5913
|
+
"A party's other names",
|
|
5914
|
+
NAMES_DESCRIPTION,
|
|
5915
|
+
namesInputSchema,
|
|
5916
|
+
// Removing a name deletes it; rejecting overrides a suggestion: destructive.
|
|
5917
|
+
write4(true, true),
|
|
5918
|
+
(a) => handleNames(getToken, baseUrl, a)
|
|
5919
|
+
],
|
|
5920
|
+
[
|
|
5921
|
+
"talonic_parties_directory_link",
|
|
5922
|
+
"Link a party to the CRM",
|
|
5923
|
+
DIRECTORY_LINK_DESCRIPTION,
|
|
5924
|
+
directoryLinkInputSchema,
|
|
5925
|
+
// Replaces or removes the party's link: destructive.
|
|
5926
|
+
write4(true, true),
|
|
5927
|
+
(a) => handleDirectoryLink(getToken, baseUrl, a)
|
|
5928
|
+
],
|
|
5929
|
+
[
|
|
5930
|
+
"talonic_parties_address_choice",
|
|
5931
|
+
"Choose a party's letter address",
|
|
5932
|
+
ADDRESS_CHOICE_DESCRIPTION,
|
|
5933
|
+
addressChoiceInputSchema,
|
|
5934
|
+
write4(true),
|
|
5935
|
+
(a) => handleAddressChoice(getToken, baseUrl, a)
|
|
5936
|
+
],
|
|
5654
5937
|
[
|
|
5655
5938
|
"talonic_parties_set_role",
|
|
5656
5939
|
"Add or change a contract role",
|
|
@@ -5662,7 +5945,7 @@ function registerPartiesTools(server, getToken, baseUrl) {
|
|
|
5662
5945
|
],
|
|
5663
5946
|
[
|
|
5664
5947
|
"talonic_parties_confirm",
|
|
5665
|
-
"Confirm
|
|
5948
|
+
"Confirm checked roles",
|
|
5666
5949
|
CONFIRM_DESCRIPTION2,
|
|
5667
5950
|
confirmInputSchema2,
|
|
5668
5951
|
write4(true),
|
|
@@ -5678,12 +5961,20 @@ function registerPartiesTools(server, getToken, baseUrl) {
|
|
|
5678
5961
|
],
|
|
5679
5962
|
[
|
|
5680
5963
|
"talonic_parties_read",
|
|
5681
|
-
"Read
|
|
5964
|
+
"Read one contract's parties",
|
|
5682
5965
|
READ_DESCRIPTION,
|
|
5683
5966
|
readInputSchema,
|
|
5684
5967
|
write4(true),
|
|
5685
5968
|
(a) => handleRead(getToken, baseUrl, a)
|
|
5686
5969
|
],
|
|
5970
|
+
[
|
|
5971
|
+
"talonic_parties_sync",
|
|
5972
|
+
"Refresh parties from the data",
|
|
5973
|
+
SYNC_DESCRIPTION,
|
|
5974
|
+
syncInputSchema,
|
|
5975
|
+
write4(true),
|
|
5976
|
+
(a) => handleSync(getToken, baseUrl, a)
|
|
5977
|
+
],
|
|
5687
5978
|
[
|
|
5688
5979
|
"talonic_parties_members",
|
|
5689
5980
|
"Company contacts",
|
|
@@ -5703,7 +5994,7 @@ function registerPartiesTools(server, getToken, baseUrl) {
|
|
|
5703
5994
|
(a) => handleGroupCompanies(getToken, baseUrl, a)
|
|
5704
5995
|
]
|
|
5705
5996
|
];
|
|
5706
|
-
for (const [name, title, description, inputSchema11, annotations, handler] of
|
|
5997
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools2) {
|
|
5707
5998
|
server.registerTool(
|
|
5708
5999
|
name,
|
|
5709
6000
|
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
@@ -5741,7 +6032,7 @@ var COMPANY_DESCRIPTION = "One portfolio company's KPI table: rows are KPIs (cAR
|
|
|
5741
6032
|
var CONFLICTS_DESCRIPTION = "Every conflict across all portfolio companies: the same KPI for the same period reported with different values by different documents. Each conflict lists the distinct values, the documents stating each (filename, locator, quote) and a one-line explanation (restatement, draft vs final, or unexplained: ask the company). Use this for 'where does my portfolio contradict itself'.";
|
|
5742
6033
|
var REFRESH_DESCRIPTION = "Read new or changed documents for KPIs (runs in the background, takes minutes, uses credits). Call only when the user asks to include new documents; then poll talonic_portfolio_companies until documents_read catches up.";
|
|
5743
6034
|
function registerPortfolioTools(server, getToken, baseUrl) {
|
|
5744
|
-
const
|
|
6035
|
+
const tools2 = [
|
|
5745
6036
|
[
|
|
5746
6037
|
"talonic_portfolio_companies",
|
|
5747
6038
|
"Portfolio companies",
|
|
@@ -5784,7 +6075,7 @@ function registerPortfolioTools(server, getToken, baseUrl) {
|
|
|
5784
6075
|
() => runTool(() => apiJson(getToken, baseUrl, "POST", "/v1/portfolio/refresh"))
|
|
5785
6076
|
]
|
|
5786
6077
|
];
|
|
5787
|
-
for (const [name, title, description, inputSchema11, annotations, handler] of
|
|
6078
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools2) {
|
|
5788
6079
|
server.registerTool(
|
|
5789
6080
|
name,
|
|
5790
6081
|
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
@@ -5830,7 +6121,7 @@ var RUNS_DESCRIPTION2 = "Runs across all processes, newest first: state (running
|
|
|
5830
6121
|
var WAITING_DESCRIPTION = "Sign-offs and forms waiting for the caller (the person behind the key): per process and step, how many items wait. Use talonic_process_status to see the items, then talonic_process_sign.";
|
|
5831
6122
|
var SIGN_DESCRIPTION = "Sign a sign-off step of a run for the caller: approve all waiting items, or only `items`. A step that offers choices needs `decision` (one of its choices). Allowed only where the caller is assigned to the step. Signing moves real work on: call only when the user decides.";
|
|
5832
6123
|
var GET_DESCRIPTION2 = "One process with its draft: fields, steps (id, kind, name, settings) and the arrows between them. Use it to see step ids before talonic_process_change with step_id, or to read what a process does.";
|
|
5833
|
-
var CREATE_DESCRIPTION2 = "Set up a new process as a DRAFT. Pass `description` in the user's own words (what comes in, what is read or checked, who decides, what goes out), or `workflow_json` with an exported n8n workflow to take it over. Nothing runs and nothing is sent until talonic_process_publish. The answer names what a person still has to choose (`stillOpen`, `questions`): tell the user those.
|
|
6124
|
+
var CREATE_DESCRIPTION2 = "Set up a new process as a DRAFT. Pass `description` in the user's own words (what comes in, what is read or checked, who decides, what goes out), or `workflow_json` with an exported n8n workflow to take it over. Nothing runs and nothing is sent until talonic_process_publish. The answer names what a person still has to choose (`stillOpen`, `questions`): tell the user those.";
|
|
5834
6125
|
var CHANGE_DESCRIPTION = "Change a process draft from an instruction in plain words: add, remove or reorder steps, change who decides, what is sent, any setting. With `step_id` only that step's settings change. Touches the draft only; the live version stays until talonic_process_publish. If the answer is `needs_confirmation`, NOTHING was saved: the change means fewer people or checks look at items. Tell the user exactly those points and ask; call again with `confirmed: true` only after they said yes, never on a first call.";
|
|
5835
6126
|
var CHECK_DESCRIPTION = "What a draft still needs before it can go live (`stillNeeded`, per step), every problem the check finds, and what publishing would change against the live version. Call before talonic_process_publish and tell the user what is open.";
|
|
5836
6127
|
var TEST_RUN_DESCRIPTION = "Run the DRAFT on real documents in a test copy: nothing is delivered, emailed or called. Steps not set up yet end the test (`endsAt`). Returns `processId` of the test copy and `runId`; follow with talonic_process_status on that processId.";
|
|
@@ -5845,7 +6136,7 @@ var SETUP_DESCRIPTION = "What processes of this workspace can use: who a step ca
|
|
|
5845
6136
|
var MAILBOX_OWNERSHIP_DESCRIPTION = "Say whether a connected mailbox is one person's own (`individual`: only that person may put it on a process) or the company's (`company`: everyone who builds processes may). A governance decision: call only when the user asks.";
|
|
5846
6137
|
var ADDRESS_DESCRIPTION = "The address other systems send items to (a webhook). Without `make` it only says whether one exists; the address itself is shown once, when made. With `make: true` it makes one and returns `path` to post to. An existing address is replaced only with `replace: true`: the old one stops working AT ONCE and whatever sends to it stops getting through, so ask the user first. `test: true` is the address of the test copy.";
|
|
5847
6138
|
function registerProcessesTools(server, getToken, baseUrl) {
|
|
5848
|
-
const
|
|
6139
|
+
const tools2 = [
|
|
5849
6140
|
[
|
|
5850
6141
|
"talonic_process_list",
|
|
5851
6142
|
"Processes",
|
|
@@ -6189,7 +6480,7 @@ function registerProcessesTools(server, getToken, baseUrl) {
|
|
|
6189
6480
|
)
|
|
6190
6481
|
]
|
|
6191
6482
|
];
|
|
6192
|
-
for (const [name, title, description, inputSchema11, annotations, handler] of
|
|
6483
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools2) {
|
|
6193
6484
|
server.registerTool(
|
|
6194
6485
|
name,
|
|
6195
6486
|
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
@@ -6364,7 +6655,7 @@ async function probeMasterRecordsAccess(token, baseUrl) {
|
|
|
6364
6655
|
}
|
|
6365
6656
|
}
|
|
6366
6657
|
function registerMasterRecordsTools(server, getToken, baseUrl) {
|
|
6367
|
-
const
|
|
6658
|
+
const tools2 = [
|
|
6368
6659
|
[
|
|
6369
6660
|
"talonic_master_records_config",
|
|
6370
6661
|
"Read the Master Records configuration",
|
|
@@ -6430,7 +6721,7 @@ function registerMasterRecordsTools(server, getToken, baseUrl) {
|
|
|
6430
6721
|
(a) => handleCrosswalk(getToken, baseUrl, a)
|
|
6431
6722
|
]
|
|
6432
6723
|
];
|
|
6433
|
-
for (const [name, title, description, inputSchema11, annotations, handler] of
|
|
6724
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools2) {
|
|
6434
6725
|
server.registerTool(
|
|
6435
6726
|
name,
|
|
6436
6727
|
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
@@ -6695,7 +6986,7 @@ async function probeSubmissionsAccess(token, baseUrl) {
|
|
|
6695
6986
|
}
|
|
6696
6987
|
}
|
|
6697
6988
|
function registerSubmissionsTools(server, getToken, baseUrl) {
|
|
6698
|
-
const
|
|
6989
|
+
const tools2 = [
|
|
6699
6990
|
[
|
|
6700
6991
|
"talonic_submissions_specs",
|
|
6701
6992
|
"Submission target structures",
|
|
@@ -6785,7 +7076,7 @@ function registerSubmissionsTools(server, getToken, baseUrl) {
|
|
|
6785
7076
|
(a) => handleExport(getToken, baseUrl, a)
|
|
6786
7077
|
]
|
|
6787
7078
|
];
|
|
6788
|
-
for (const [name, title, description, inputSchema11, annotations, handler] of
|
|
7079
|
+
for (const [name, title, description, inputSchema11, annotations, handler] of tools2) {
|
|
6789
7080
|
server.registerTool(
|
|
6790
7081
|
name,
|
|
6791
7082
|
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
@@ -6804,7 +7095,7 @@ var readOnly9 = {
|
|
|
6804
7095
|
idempotentHint: true,
|
|
6805
7096
|
openWorldHint: false
|
|
6806
7097
|
};
|
|
6807
|
-
var
|
|
7098
|
+
var DOCUMENTS_DESCRIPTION2 = [
|
|
6808
7099
|
"Find contracts and invoices in the workspace to build a price baseline from.",
|
|
6809
7100
|
"USE WHEN: picking the contract for talonic_price_baseline_extract or the invoice for talonic_price_baseline_compare.",
|
|
6810
7101
|
"NOT FOR: general document search across all content (talonic_search).",
|
|
@@ -7325,7 +7616,7 @@ function handleAssume(getToken, baseUrl, args) {
|
|
|
7325
7616
|
};
|
|
7326
7617
|
return args.action === "create" ? runTool(() => apiJson(getToken, baseUrl, "POST", "/v1/price-baseline/assumptions", { body })) : runTool(() => apiJson(getToken, baseUrl, "PUT", path(args.assumption_id), { body }));
|
|
7327
7618
|
}
|
|
7328
|
-
var
|
|
7619
|
+
var SYNC_DESCRIPTION2 = [
|
|
7329
7620
|
"Sync external price data now (BEHG, Bundesbank, Destatis, EEX via Energy-Charts, DWD degree days), or change how often a series syncs.",
|
|
7330
7621
|
"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.",
|
|
7331
7622
|
"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).",
|
|
@@ -7333,13 +7624,13 @@ var SYNC_DESCRIPTION = [
|
|
|
7333
7624
|
"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).",
|
|
7334
7625
|
"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."
|
|
7335
7626
|
].join("\n");
|
|
7336
|
-
var
|
|
7627
|
+
var syncInputSchema2 = {
|
|
7337
7628
|
keys: z.array(z.string().min(1)).max(50).optional().describe("Series keys to fetch now."),
|
|
7338
7629
|
key: z.string().min(1).max(120).optional().describe("Series whose schedule to change."),
|
|
7339
7630
|
sync_hours: z.number().int().min(1).max(2160).optional().describe("Sync interval in hours."),
|
|
7340
7631
|
active: z.boolean().optional().describe("false pauses syncing.")
|
|
7341
7632
|
};
|
|
7342
|
-
function
|
|
7633
|
+
function handleSync2(getToken, baseUrl, args) {
|
|
7343
7634
|
const schedule = args.key !== void 0 || args.sync_hours !== void 0 || args.active !== void 0;
|
|
7344
7635
|
if (schedule) {
|
|
7345
7636
|
if (args.keys?.length) {
|
|
@@ -7416,7 +7707,7 @@ async function probePriceBaselineAccess(token, baseUrl) {
|
|
|
7416
7707
|
}
|
|
7417
7708
|
}
|
|
7418
7709
|
function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
7419
|
-
const
|
|
7710
|
+
const write10 = (idempotent) => ({
|
|
7420
7711
|
readOnlyHint: false,
|
|
7421
7712
|
destructiveHint: false,
|
|
7422
7713
|
idempotentHint: idempotent,
|
|
@@ -7426,7 +7717,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7426
7717
|
"talonic_price_baseline_documents",
|
|
7427
7718
|
{
|
|
7428
7719
|
title: "Find contracts and invoices",
|
|
7429
|
-
description:
|
|
7720
|
+
description: DOCUMENTS_DESCRIPTION2,
|
|
7430
7721
|
inputSchema: documentsInputSchema,
|
|
7431
7722
|
annotations: readOnly9
|
|
7432
7723
|
},
|
|
@@ -7438,7 +7729,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7438
7729
|
title: "Build or enrich a price model from a contract",
|
|
7439
7730
|
description: EXTRACT_DESCRIPTION,
|
|
7440
7731
|
inputSchema: extractInputSchema,
|
|
7441
|
-
annotations:
|
|
7732
|
+
annotations: write10(false)
|
|
7442
7733
|
},
|
|
7443
7734
|
async (args) => handleExtract2(getToken, baseUrl, args)
|
|
7444
7735
|
);
|
|
@@ -7458,7 +7749,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7458
7749
|
title: "Edit or confirm a price model",
|
|
7459
7750
|
description: UPDATE_DESCRIPTION,
|
|
7460
7751
|
inputSchema: updateInputSchema,
|
|
7461
|
-
annotations:
|
|
7752
|
+
annotations: write10(true)
|
|
7462
7753
|
},
|
|
7463
7754
|
async (args) => handleUpdate(getToken, baseUrl, args)
|
|
7464
7755
|
);
|
|
@@ -7488,7 +7779,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7488
7779
|
title: "Check an invoice against the contract",
|
|
7489
7780
|
description: COMPARE_DESCRIPTION,
|
|
7490
7781
|
inputSchema: compareInputSchema,
|
|
7491
|
-
annotations:
|
|
7782
|
+
annotations: write10(false)
|
|
7492
7783
|
},
|
|
7493
7784
|
async (args) => handleCompare(getToken, baseUrl, args)
|
|
7494
7785
|
);
|
|
@@ -7518,7 +7809,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7518
7809
|
title: "Fetch public index values",
|
|
7519
7810
|
description: REFRESH_DESCRIPTION2,
|
|
7520
7811
|
inputSchema: refreshInputSchema,
|
|
7521
|
-
annotations: { ...
|
|
7812
|
+
annotations: { ...write10(true), openWorldHint: true }
|
|
7522
7813
|
},
|
|
7523
7814
|
async (args) => handleRefresh(getToken, baseUrl, args)
|
|
7524
7815
|
);
|
|
@@ -7528,7 +7819,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7528
7819
|
title: "Enter sourced index values",
|
|
7529
7820
|
description: MANUAL_DESCRIPTION,
|
|
7530
7821
|
inputSchema: manualInputSchema,
|
|
7531
|
-
annotations:
|
|
7822
|
+
annotations: write10(true)
|
|
7532
7823
|
},
|
|
7533
7824
|
async (args) => handleManual(getToken, baseUrl, args)
|
|
7534
7825
|
);
|
|
@@ -7558,7 +7849,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7558
7849
|
title: "Answer an open contract input",
|
|
7559
7850
|
description: ANSWER_DESCRIPTION,
|
|
7560
7851
|
inputSchema: answerInputSchema,
|
|
7561
|
-
annotations:
|
|
7852
|
+
annotations: write10(true)
|
|
7562
7853
|
},
|
|
7563
7854
|
async (args) => handleAnswer(getToken, baseUrl, args)
|
|
7564
7855
|
);
|
|
@@ -7578,7 +7869,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7578
7869
|
title: "Make, replace or withdraw an assumption",
|
|
7579
7870
|
description: ASSUME_DESCRIPTION,
|
|
7580
7871
|
inputSchema: assumeInputSchema,
|
|
7581
|
-
annotations: { ...
|
|
7872
|
+
annotations: { ...write10(false), destructiveHint: true }
|
|
7582
7873
|
},
|
|
7583
7874
|
async (args) => handleAssume(getToken, baseUrl, args)
|
|
7584
7875
|
);
|
|
@@ -7586,11 +7877,11 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7586
7877
|
"talonic_price_baseline_sync_series",
|
|
7587
7878
|
{
|
|
7588
7879
|
title: "Sync external price data",
|
|
7589
|
-
description:
|
|
7590
|
-
inputSchema:
|
|
7591
|
-
annotations: { ...
|
|
7880
|
+
description: SYNC_DESCRIPTION2,
|
|
7881
|
+
inputSchema: syncInputSchema2,
|
|
7882
|
+
annotations: { ...write10(true), openWorldHint: true }
|
|
7592
7883
|
},
|
|
7593
|
-
async (args) =>
|
|
7884
|
+
async (args) => handleSync2(getToken, baseUrl, args)
|
|
7594
7885
|
);
|
|
7595
7886
|
server.registerTool(
|
|
7596
7887
|
"talonic_price_baseline_imports",
|
|
@@ -7608,7 +7899,7 @@ function registerPriceBaselineTools(server, getToken, baseUrl) {
|
|
|
7608
7899
|
title: "Import contracts from data capture",
|
|
7609
7900
|
description: IMPORT_DESCRIPTION2,
|
|
7610
7901
|
inputSchema: importInputSchema2,
|
|
7611
|
-
annotations:
|
|
7902
|
+
annotations: write10(true)
|
|
7612
7903
|
},
|
|
7613
7904
|
async (args) => handleImport2(getToken, baseUrl, args)
|
|
7614
7905
|
);
|
|
@@ -7658,8 +7949,8 @@ var adminPayloadAccessInput = {
|
|
|
7658
7949
|
function apiUrl(baseUrl, path, query) {
|
|
7659
7950
|
const base = (baseUrl ?? DEFAULT_BASE3).replace(/\/$/, "");
|
|
7660
7951
|
const url = new URL(`${base}${path}`);
|
|
7661
|
-
for (const [
|
|
7662
|
-
if (value !== void 0 && value !== "") url.searchParams.set(
|
|
7952
|
+
for (const [key2, value] of Object.entries(query ?? {})) {
|
|
7953
|
+
if (value !== void 0 && value !== "") url.searchParams.set(key2, String(value));
|
|
7663
7954
|
}
|
|
7664
7955
|
return url.toString();
|
|
7665
7956
|
}
|
|
@@ -8004,65 +8295,576 @@ function registerAppsTools(server, getToken, baseUrl) {
|
|
|
8004
8295
|
async (args) => handleListApps(getToken, baseUrl, args)
|
|
8005
8296
|
);
|
|
8006
8297
|
}
|
|
8007
|
-
var
|
|
8008
|
-
var
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
"submitted",
|
|
8012
|
-
"released",
|
|
8013
|
-
"failed",
|
|
8014
|
-
"timed_out",
|
|
8015
|
-
"cancelled"
|
|
8016
|
-
];
|
|
8017
|
-
var PACKAGE_PAGE_LIMIT_MAX = 2e3;
|
|
8298
|
+
var APP_MODES = ["rules", "assisted", "external", "autonomous"];
|
|
8299
|
+
var REVIEW_KINDS = ["resolution", "approval", "data_request", "judgment"];
|
|
8300
|
+
var REVIEW_STATUSES = ["open", "assigned", "resolved", "expired", "cancelled"];
|
|
8301
|
+
var VERDICT_OUTCOMES = ["passed", "failed", "indeterminate", "not_applicable"];
|
|
8018
8302
|
var appId = zUuid().describe(
|
|
8019
|
-
"
|
|
8303
|
+
"App id: the UUID `id` from talonic_list_apps or talonic_create_app (not the app_\u2026 public id)."
|
|
8020
8304
|
);
|
|
8021
|
-
var
|
|
8022
|
-
|
|
8023
|
-
var status2 = z.enum(TASK_STATUSES2).optional().describe("Optional task-status filter.");
|
|
8024
|
-
var listLimit = z.number().int().min(1).max(100).optional().describe("Page size (default 50).");
|
|
8025
|
-
var cursor2 = z.string().min(1).optional().describe("Opaque cursor from pagination.next_cursor.");
|
|
8026
|
-
var packageCursor = z.string().min(1).optional().describe(
|
|
8027
|
-
"Opaque package cursor: package.first_cursor from the claim, then pagination.next_cursor. Omit for the first page."
|
|
8305
|
+
var runId = zUuid().describe(
|
|
8306
|
+
"App run UUID (run_id from talonic_run_app or talonic_list_app_runs)."
|
|
8028
8307
|
);
|
|
8029
|
-
var
|
|
8030
|
-
|
|
8308
|
+
var reviewId = zUuid().describe("Human Review UUID (id from talonic_list_app_reviews).");
|
|
8309
|
+
var limit2 = z.number().int().min(1).max(200).optional().describe("Page size (default 50, max 200).");
|
|
8310
|
+
var offset = z.number().int().min(0).optional().describe("Rows to skip before the page.");
|
|
8311
|
+
var jsonObject = () => z.record(z.string(), z.json());
|
|
8312
|
+
var READ_ONLY3 = {
|
|
8313
|
+
readOnlyHint: true,
|
|
8314
|
+
destructiveHint: false,
|
|
8315
|
+
idempotentHint: true,
|
|
8316
|
+
openWorldHint: false
|
|
8317
|
+
};
|
|
8318
|
+
var MUTATING2 = {
|
|
8319
|
+
readOnlyHint: false,
|
|
8320
|
+
destructiveHint: false,
|
|
8321
|
+
idempotentHint: false,
|
|
8322
|
+
openWorldHint: false
|
|
8323
|
+
};
|
|
8324
|
+
var appPath = (id, suffix = "") => `/v1/apps/${encodeURIComponent(id)}${suffix}`;
|
|
8325
|
+
var runPath = (id, suffix = "") => `/v1/runs/${encodeURIComponent(id)}${suffix}`;
|
|
8326
|
+
var reviewPath = (id, suffix = "") => `/v1/reviews/${encodeURIComponent(id)}${suffix}`;
|
|
8327
|
+
var get = (t, b, path, params) => runTool(() => apiJson(t, b, "GET", path, params ? { params } : {}));
|
|
8328
|
+
var send = (t, b, method, path, body) => runTool(() => apiJson(t, b, method, path, body === void 0 ? {} : { body }));
|
|
8329
|
+
function defined2(o) {
|
|
8330
|
+
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0));
|
|
8331
|
+
}
|
|
8332
|
+
var handleGetApp = (t, b, a) => get(t, b, appPath(a.app_id));
|
|
8333
|
+
var handleCreateApp = (t, b, a) => send(t, b, "POST", "/v1/apps", defined2({ ...a }));
|
|
8334
|
+
var handleSaveAppDraft = (t, b, a) => send(t, b, "PATCH", appPath(a.app_id), { content: a.content });
|
|
8335
|
+
var handleListAppVersions = (t, b, a) => get(t, b, appPath(a.app_id, "/versions"));
|
|
8336
|
+
var handlePublishApp = (t, b, a) => send(t, b, "POST", appPath(a.app_id, `/versions/${a.version}/publish`));
|
|
8337
|
+
var handleSetAppEnabled = (t, b, a, enabled) => send(t, b, "POST", appPath(a.app_id, enabled ? "/enable" : "/disable"));
|
|
8338
|
+
var handleRunApp = (t, b, a) => send(
|
|
8339
|
+
t,
|
|
8340
|
+
b,
|
|
8341
|
+
"POST",
|
|
8342
|
+
appPath(a.app_id, "/runs"),
|
|
8343
|
+
defined2({ input: a.input ?? {}, dry_run: a.dry_run, idempotency_key: a.idempotency_key })
|
|
8031
8344
|
);
|
|
8032
|
-
var
|
|
8033
|
-
|
|
8345
|
+
var handleListAppRuns = (t, b, a) => get(t, b, appPath(a.app_id, "/runs"), { limit: a.limit, offset: a.offset });
|
|
8346
|
+
async function handleGetAppRun(t, b, a) {
|
|
8347
|
+
return runTool(async () => {
|
|
8348
|
+
const run = await apiJson(t, b, "GET", runPath(a.run_id));
|
|
8349
|
+
if (!a.include_events) return run;
|
|
8350
|
+
const events = await apiJson(t, b, "GET", runPath(a.run_id, "/events"));
|
|
8351
|
+
return { run, events: events?.events ?? [] };
|
|
8352
|
+
});
|
|
8353
|
+
}
|
|
8354
|
+
var handleGetRunRecord = (t, b, a) => get(t, b, runPath(a.run_id, "/record"));
|
|
8355
|
+
var handleGetRunVerdicts = (t, b, a) => get(t, b, runPath(a.run_id, "/verdicts"), {
|
|
8356
|
+
rolled: a.rolled,
|
|
8357
|
+
auto: a.auto,
|
|
8358
|
+
rule: a.rule,
|
|
8359
|
+
status: a.status,
|
|
8360
|
+
limit: a.limit,
|
|
8361
|
+
cursor: a.cursor
|
|
8362
|
+
});
|
|
8363
|
+
var handleListAppReviews = (t, b, a) => get(t, b, "/v1/reviews", { ...a });
|
|
8364
|
+
var handleRaiseAppReview = (t, b, a) => {
|
|
8365
|
+
const { app_id, ...body } = a;
|
|
8366
|
+
return send(t, b, "POST", appPath(app_id, "/reviews"), defined2(body));
|
|
8367
|
+
};
|
|
8368
|
+
var handleResolveAppReview = (t, b, a) => send(
|
|
8369
|
+
t,
|
|
8370
|
+
b,
|
|
8371
|
+
"POST",
|
|
8372
|
+
reviewPath(a.review_id, "/resolve"),
|
|
8373
|
+
defined2({ values: a.values, feedback: a.feedback })
|
|
8034
8374
|
);
|
|
8035
|
-
var
|
|
8036
|
-
|
|
8375
|
+
var handleInterviewReview = (t, b, a) => send(
|
|
8376
|
+
t,
|
|
8377
|
+
b,
|
|
8378
|
+
"POST",
|
|
8379
|
+
reviewPath(a.review_id, "/interview"),
|
|
8380
|
+
defined2({ message: a.message, transcript: a.transcript })
|
|
8037
8381
|
);
|
|
8038
|
-
var
|
|
8039
|
-
|
|
8382
|
+
var handleListAppPrecedents = (t, b, a) => get(t, b, appPath(a.app_id, "/precedents"), {
|
|
8383
|
+
similar_to: a.similar_to ? JSON.stringify(a.similar_to) : void 0
|
|
8384
|
+
});
|
|
8385
|
+
var handleGetAppLogic = (t, b, a) => get(t, b, appPath(a.app_id, "/logic"));
|
|
8386
|
+
var handleGetAppFields = (t, b, a) => get(t, b, appPath(a.app_id, "/logic/fields"));
|
|
8387
|
+
var handleInterpretRules = (t, b, a) => send(
|
|
8388
|
+
t,
|
|
8389
|
+
b,
|
|
8390
|
+
"POST",
|
|
8391
|
+
appPath(a.app_id, "/logic/compile"),
|
|
8392
|
+
defined2({
|
|
8393
|
+
card_ids: a.card_ids && a.card_ids.length > 0 ? a.card_ids : void 0,
|
|
8394
|
+
guidance: a.guidance || void 0,
|
|
8395
|
+
locale: a.locale
|
|
8396
|
+
})
|
|
8040
8397
|
);
|
|
8041
|
-
var
|
|
8042
|
-
var
|
|
8043
|
-
var
|
|
8044
|
-
|
|
8398
|
+
var handleProposeEdit = (t, b, a) => send(t, b, "POST", appPath(a.app_id, "/edit-proposals"), { instruction: a.instruction });
|
|
8399
|
+
var handleApplyEdit = (t, b, a) => send(t, b, "POST", appPath(a.app_id, "/edit-proposals/apply"), { ops: a.ops });
|
|
8400
|
+
var handleGetAcceptance = (t, b, a) => get(t, b, appPath(a.app_id, "/acceptance"));
|
|
8401
|
+
var handleSaveAcceptance = (t, b, a) => send(
|
|
8402
|
+
t,
|
|
8403
|
+
b,
|
|
8404
|
+
"PUT",
|
|
8405
|
+
appPath(a.app_id, "/acceptance"),
|
|
8406
|
+
defined2({ cases: a.cases, tolerance: a.tolerance })
|
|
8045
8407
|
);
|
|
8046
|
-
var
|
|
8047
|
-
var
|
|
8048
|
-
var
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8408
|
+
var handleCheckAcceptance = (t, b, a) => get(t, b, appPath(a.app_id, "/acceptance/check"), { run_id: a.run_id });
|
|
8409
|
+
var BUILD_FLOW = "FLOW: talonic_create_app -> talonic_save_app_draft -> talonic_interpret_app_rules -> talonic_publish_app -> talonic_run_app (dry_run first) -> talonic_get_app_run / talonic_get_run_verdicts -> talonic_save_app_acceptance + talonic_check_app_acceptance -> talonic_enable_app.";
|
|
8410
|
+
var D = {
|
|
8411
|
+
get: [
|
|
8412
|
+
"Read one app's manifest: mode, active version, enabled state, contract (what it reads and acts on), output contract, thresholds, triggers, fallback.",
|
|
8413
|
+
"USE WHEN: inspecting an app before changing or running it. NOT FOR: the editable draft (talonic_get_app_logic) or listing apps (talonic_list_apps)."
|
|
8414
|
+
].join("\n"),
|
|
8415
|
+
create: [
|
|
8416
|
+
"Create a new app. It starts disabled with no versions; the slug can no longer change once a version is published.",
|
|
8417
|
+
"USE WHEN: the user asks to set up a new app. ARGS: slug (lowercase letters, digits, hyphens, 3-64 chars), display_name, mode, optional one-sentence description.",
|
|
8418
|
+
"Modes: rules (decides from written rules), assisted (rules with people confirming), external (an outside agent decides through the decision-task tools), autonomous (finds candidate rules in the app's data).",
|
|
8419
|
+
"RETURNS: the manifest; use its `id` (UUID) with every other app tool.",
|
|
8420
|
+
BUILD_FLOW
|
|
8421
|
+
].join("\n"),
|
|
8422
|
+
saveDraft: [
|
|
8423
|
+
"Create or replace the app's single draft version: logic (rule sentences, or the external connection), input bindings, output contract (JSON Schema 2020-12), thresholds, triggers, fallback. Drafts are the only versions that can change.",
|
|
8424
|
+
"USE WHEN: authoring configuration in full. For a plain-language change to an existing draft prefer talonic_propose_app_edit + talonic_apply_app_edit.",
|
|
8425
|
+
"ARGS: app_id, content (the full version content object; read the current one with talonic_get_app_logic). RETURNS: { version, status, content_hash }; pass version to talonic_publish_app."
|
|
8426
|
+
].join("\n"),
|
|
8427
|
+
versions: [
|
|
8428
|
+
"List an app's versions, newest first: version number, status (draft, published, superseded), content hash, published_at.",
|
|
8429
|
+
"USE WHEN: you need the draft's version number for talonic_publish_app, or to see what is live."
|
|
8430
|
+
].join("\n"),
|
|
8431
|
+
publish: [
|
|
8432
|
+
"Publish the app's draft: freezes it, makes it the active version (the previous one is superseded) and locks the slug on first publish.",
|
|
8433
|
+
"USE WHEN: the draft is tested (talonic_run_app with dry_run, talonic_check_app_acceptance) and the user wants it live. Publishing does not enable the app; call talonic_enable_app for triggers to fire.",
|
|
8434
|
+
"ARGS: app_id and the draft's version number (from talonic_save_app_draft or talonic_list_app_versions). A number that is not the current draft is HTTP 409."
|
|
8435
|
+
].join("\n"),
|
|
8436
|
+
enable: [
|
|
8437
|
+
"Enable an app so its triggers fire and it can be run. Needs a published version. Enabling an app that acts on outside systems needs a workspace owner (HTTP 403 otherwise).",
|
|
8438
|
+
"USE WHEN: the user asks to switch the app on. ARGS: app_id."
|
|
8439
|
+
].join("\n"),
|
|
8440
|
+
disable: [
|
|
8441
|
+
"Disable an app at once (the kill switch): triggers stop and open work is no longer offered. Past runs and records are kept.",
|
|
8442
|
+
"USE WHEN: the user asks to stop or pause an app. ARGS: app_id."
|
|
8443
|
+
].join("\n"),
|
|
8444
|
+
run: [
|
|
8445
|
+
"Start one run of an app's active version and return it. A rules app usually finishes in the call with its decision; an external app stops at awaiting_decision until its decision task is submitted.",
|
|
8446
|
+
"USE WHEN: testing or executing an app. Set dry_run:true first: a full trace with no side effects (no actions, no webhooks to outside systems).",
|
|
8447
|
+
"ARGS: app_id, optional input object, dry_run, idempotency_key (reusing a key returns the existing run instead of starting another). Consumes credits.",
|
|
8448
|
+
"NEXT: talonic_get_app_run for status and decision; talonic_get_run_verdicts for per-subject results."
|
|
8449
|
+
].join("\n"),
|
|
8450
|
+
listRuns: [
|
|
8451
|
+
"List an app's runs, newest first, with status, decision and who decided; `total` counts every run.",
|
|
8452
|
+
"ARGS: app_id, optional limit (max 200) and offset."
|
|
8453
|
+
].join("\n"),
|
|
8454
|
+
getRun: [
|
|
8455
|
+
"Read one run: status, decision, decided_by, thresholds applied, reviews raised, timing.",
|
|
8456
|
+
"USE WHEN: checking a run you started or found. include_events:true adds the run's journal (every event in order).",
|
|
8457
|
+
"NOT FOR: Spec/pipeline runs (talonic_get_run). ARGS: run_id, optional include_events."
|
|
8458
|
+
].join("\n"),
|
|
8459
|
+
record: [
|
|
8460
|
+
"Export a finished run's sealed decision record: the immutable, audit-ready result with its decision, who decided (rules, a person or an outside agent) and the evidence.",
|
|
8461
|
+
"USE WHEN: the user needs the final, auditable outcome. A run that has not finished has no record yet (HTTP 404). ARGS: run_id."
|
|
8462
|
+
].join("\n"),
|
|
8463
|
+
verdicts: [
|
|
8464
|
+
"Read a batch run's per-subject results: a summary plus one row per subject with its overall outcome, the auto flag, and each rule's outcome with reasons and evidence.",
|
|
8465
|
+
"USE WHEN: inspecting what a run decided per record. Single-decision runs have none (HTTP 404; use talonic_get_app_run).",
|
|
8466
|
+
"ARGS: run_id; optional rolled (overall outcome), auto, rule + status (always together), limit (max 200), cursor (from `next`)."
|
|
8467
|
+
].join("\n"),
|
|
8468
|
+
listReviews: [
|
|
8469
|
+
"List Human Reviews: questions apps raised for a person (approvals, missing data, judgment calls, exceptions), newest first, with `total`.",
|
|
8470
|
+
"USE WHEN: finding open reviews to answer, or checking the result of one already resolved (status 'resolved' shows its values). Omit app_id for the whole workspace.",
|
|
8471
|
+
"ARGS: optional app_id, status, kind, assignee_user_id, limit (max 200), offset."
|
|
8472
|
+
].join("\n"),
|
|
8473
|
+
raiseReview: [
|
|
8474
|
+
"Ask a person a question on an app instead of guessing: a Human Review with a JSON Schema for the answer.",
|
|
8475
|
+
"USE WHEN: a decision needs a person's input. ARGS: app_id, kind (resolution | approval | data_request | judgment), question, input_contract (JSON Schema the answer must satisfy), optional run_id, context, team_id.",
|
|
8476
|
+
"NEXT: the answer arrives through talonic_resolve_app_review (or the web app); read it with talonic_list_app_reviews status 'resolved'."
|
|
8477
|
+
].join("\n"),
|
|
8478
|
+
resolveReview: [
|
|
8479
|
+
"Answer a Human Review: values (validated against the review's input_contract) plus optional feedback that teaches the app (proposal_verdict correct | incorrect | partial, correction, generalize).",
|
|
8480
|
+
"USE WHEN: the user gives the answer. 'approval' reviews accept only a person's answer; an API key or agent is refused (HTTP 403). Needs operate access on the app.",
|
|
8481
|
+
"RETURNS: the resolved review with its values. ARGS: review_id, values, optional feedback."
|
|
8482
|
+
].join("\n"),
|
|
8483
|
+
interview: [
|
|
8484
|
+
"Hold one turn of a guided conversation on an open Human Review: send the reviewer's message and the earlier turns (the server keeps no state); get back a follow-up question or a readback with proposed answer values.",
|
|
8485
|
+
"ready:true only when the proposed values satisfy the review's input contract. Nothing is submitted: finish with talonic_resolve_app_review.",
|
|
8486
|
+
"ARGS: review_id, message, optional transcript [{ role: user | assistant, text }]."
|
|
8487
|
+
].join("\n"),
|
|
8488
|
+
precedents: [
|
|
8489
|
+
"List an app's precedents: past resolved reviews it reuses for similar future runs.",
|
|
8490
|
+
"ARGS: app_id, optional similar_to (match keys object) to narrow to similar cases. An app with none returns an empty list."
|
|
8491
|
+
].join("\n"),
|
|
8492
|
+
getLogic: [
|
|
8493
|
+
"Read an app's logic: the editable draft and the active published version, including each rule with its interpretation state and plain-language readback.",
|
|
8494
|
+
"USE WHEN: before editing, or to get the draft's full content for talonic_save_app_draft."
|
|
8495
|
+
].join("\n"),
|
|
8496
|
+
getFields: [
|
|
8497
|
+
"List the fields the app's rules can use, per bound data source. This is everything the app can see.",
|
|
8498
|
+
"USE WHEN: before writing or fixing rules, so they name fields that exist."
|
|
8499
|
+
].join("\n"),
|
|
8500
|
+
interpret: [
|
|
8501
|
+
"Turn the draft's pending rule sentences into checkable rules against the app's fields, and save the draft.",
|
|
8502
|
+
"ARGS: app_id; optional card_ids (default: all pending), guidance (plain language, e.g. 'the city is in shipper_city_state') for rules that stayed pending, locale for the readbacks.",
|
|
8503
|
+
"RETURNS: the rules plus warnings saying why any rule stayed pending."
|
|
8504
|
+
].join("\n"),
|
|
8505
|
+
proposeEdit: [
|
|
8506
|
+
"Turn a plain-language change request into typed edit operations on the app's rules (add, rewrite, delete, pause, resume, fallback, mode). Nothing is saved.",
|
|
8507
|
+
"USE WHEN: the user describes a change in words. Show the summary to the user, then apply the accepted ops with talonic_apply_app_edit."
|
|
8508
|
+
].join("\n"),
|
|
8509
|
+
applyEdit: [
|
|
8510
|
+
"Apply accepted edit operations from talonic_propose_app_edit to the draft. They are re-checked against the current draft; changed rules are interpreted again and warnings returned.",
|
|
8511
|
+
"ARGS: app_id, ops (from the proposal, unchanged)."
|
|
8512
|
+
].join("\n"),
|
|
8513
|
+
getAcceptance: [
|
|
8514
|
+
"Read the app's acceptance set: the labeled expected results a correct run must reproduce, and the accepted mismatch share. null when none is saved."
|
|
8515
|
+
].join("\n"),
|
|
8516
|
+
saveAcceptance: [
|
|
8517
|
+
"Replace the app's acceptance set: the expected results a correct run must reproduce, plus tolerance (accepted mismatch share, 0 to 1). This is the app's definition of done.",
|
|
8518
|
+
"ARGS: app_id, cases (per subject: subject_key + expected_outcome and/or expected_auto; for single-decision apps: expected_decision), optional tolerance (default 0)."
|
|
8519
|
+
].join("\n"),
|
|
8520
|
+
checkAcceptance: [
|
|
8521
|
+
"Score a run against the app's acceptance set by comparing recorded results: the same run always gets the same score. Returns score, pass/fail and each mismatch.",
|
|
8522
|
+
"USE WHEN: after talonic_run_app, to decide whether the app is ready to publish or still correct. ARGS: app_id, optional run_id (default: the latest completed run)."
|
|
8523
|
+
].join("\n")
|
|
8524
|
+
};
|
|
8525
|
+
var acceptanceCase = z.object({
|
|
8526
|
+
subject_key: z.string().min(1).max(256).optional(),
|
|
8527
|
+
expected_outcome: z.enum(VERDICT_OUTCOMES).optional(),
|
|
8528
|
+
expected_auto: z.boolean().optional(),
|
|
8529
|
+
expected_decision: z.string().min(1).max(64).optional(),
|
|
8530
|
+
note: z.string().max(300).optional()
|
|
8531
|
+
}).describe(
|
|
8532
|
+
"One expected result: subject_key + expected_outcome (and/or expected_auto) for batch apps, or expected_decision for single-decision apps."
|
|
8533
|
+
);
|
|
8534
|
+
function registerAppsToolset(server, getToken, baseUrl) {
|
|
8535
|
+
const t = getToken;
|
|
8536
|
+
const b = baseUrl;
|
|
8537
|
+
const reg = (name, title, description, inputSchema11, annotations, handler) => server.registerTool(
|
|
8538
|
+
name,
|
|
8539
|
+
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
8540
|
+
handler
|
|
8541
|
+
);
|
|
8542
|
+
reg(
|
|
8543
|
+
"talonic_create_app",
|
|
8544
|
+
"Create App",
|
|
8545
|
+
D.create,
|
|
8546
|
+
{
|
|
8547
|
+
slug: z.string().regex(/^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/).describe("Lowercase letters, digits and hyphens, 3-64 chars."),
|
|
8548
|
+
display_name: z.string().min(1).max(200),
|
|
8549
|
+
mode: z.enum(APP_MODES),
|
|
8550
|
+
description: z.string().max(2e3).optional().describe("One sentence about the app.")
|
|
8551
|
+
},
|
|
8552
|
+
MUTATING2,
|
|
8553
|
+
(a) => handleCreateApp(t, b, a)
|
|
8554
|
+
);
|
|
8555
|
+
reg(
|
|
8556
|
+
"talonic_get_app",
|
|
8557
|
+
"Get App",
|
|
8558
|
+
D.get,
|
|
8559
|
+
{ app_id: appId },
|
|
8560
|
+
READ_ONLY3,
|
|
8561
|
+
(a) => handleGetApp(t, b, a)
|
|
8562
|
+
);
|
|
8563
|
+
reg(
|
|
8564
|
+
"talonic_get_app_logic",
|
|
8565
|
+
"Get App Logic",
|
|
8566
|
+
D.getLogic,
|
|
8567
|
+
{ app_id: appId },
|
|
8568
|
+
READ_ONLY3,
|
|
8569
|
+
(a) => handleGetAppLogic(t, b, a)
|
|
8570
|
+
);
|
|
8571
|
+
reg(
|
|
8572
|
+
"talonic_get_app_fields",
|
|
8573
|
+
"Get App Fields",
|
|
8574
|
+
D.getFields,
|
|
8575
|
+
{ app_id: appId },
|
|
8576
|
+
READ_ONLY3,
|
|
8577
|
+
(a) => handleGetAppFields(t, b, a)
|
|
8578
|
+
);
|
|
8579
|
+
reg(
|
|
8580
|
+
"talonic_save_app_draft",
|
|
8581
|
+
"Save App Draft",
|
|
8582
|
+
D.saveDraft,
|
|
8583
|
+
{ app_id: appId, content: jsonObject().describe("Full version content object.") },
|
|
8584
|
+
MUTATING2,
|
|
8585
|
+
(a) => handleSaveAppDraft(t, b, a)
|
|
8586
|
+
);
|
|
8587
|
+
reg(
|
|
8588
|
+
"talonic_interpret_app_rules",
|
|
8589
|
+
"Interpret App Rules",
|
|
8590
|
+
D.interpret,
|
|
8591
|
+
{
|
|
8592
|
+
app_id: appId,
|
|
8593
|
+
card_ids: z.array(z.string().min(1).max(128)).max(50).optional().describe("Rule card ids; omit for all pending."),
|
|
8594
|
+
guidance: z.string().max(1e3).optional().describe("Plain-language hint for stuck rules."),
|
|
8595
|
+
locale: z.string().max(10).optional().describe("Language of reasons and readbacks, e.g. de.")
|
|
8596
|
+
},
|
|
8597
|
+
MUTATING2,
|
|
8598
|
+
(a) => handleInterpretRules(t, b, a)
|
|
8599
|
+
);
|
|
8600
|
+
reg(
|
|
8601
|
+
"talonic_propose_app_edit",
|
|
8602
|
+
"Propose App Edit",
|
|
8603
|
+
D.proposeEdit,
|
|
8604
|
+
{
|
|
8605
|
+
app_id: appId,
|
|
8606
|
+
instruction: z.string().min(8).max(2e3).describe("The change, in plain language.")
|
|
8607
|
+
},
|
|
8608
|
+
{ ...READ_ONLY3, idempotentHint: false },
|
|
8609
|
+
(a) => handleProposeEdit(t, b, a)
|
|
8610
|
+
);
|
|
8611
|
+
reg(
|
|
8612
|
+
"talonic_apply_app_edit",
|
|
8613
|
+
"Apply App Edit",
|
|
8614
|
+
D.applyEdit,
|
|
8615
|
+
{
|
|
8616
|
+
app_id: appId,
|
|
8617
|
+
ops: z.array(jsonObject()).min(1).max(20).describe("Accepted ops from the proposal.")
|
|
8618
|
+
},
|
|
8619
|
+
MUTATING2,
|
|
8620
|
+
(a) => handleApplyEdit(t, b, a)
|
|
8621
|
+
);
|
|
8622
|
+
reg(
|
|
8623
|
+
"talonic_list_app_versions",
|
|
8624
|
+
"List App Versions",
|
|
8625
|
+
D.versions,
|
|
8626
|
+
{ app_id: appId },
|
|
8627
|
+
READ_ONLY3,
|
|
8628
|
+
(a) => handleListAppVersions(t, b, a)
|
|
8629
|
+
);
|
|
8630
|
+
reg(
|
|
8631
|
+
"talonic_publish_app",
|
|
8632
|
+
"Publish App",
|
|
8633
|
+
D.publish,
|
|
8634
|
+
{ app_id: appId, version: z.number().int().min(1).describe("The draft's version number.") },
|
|
8635
|
+
MUTATING2,
|
|
8636
|
+
(a) => handlePublishApp(t, b, a)
|
|
8637
|
+
);
|
|
8638
|
+
reg(
|
|
8639
|
+
"talonic_enable_app",
|
|
8640
|
+
"Enable App",
|
|
8641
|
+
D.enable,
|
|
8642
|
+
{ app_id: appId },
|
|
8643
|
+
MUTATING2,
|
|
8644
|
+
(a) => handleSetAppEnabled(t, b, a, true)
|
|
8645
|
+
);
|
|
8646
|
+
reg(
|
|
8647
|
+
"talonic_disable_app",
|
|
8648
|
+
"Disable App",
|
|
8649
|
+
D.disable,
|
|
8650
|
+
{ app_id: appId },
|
|
8651
|
+
MUTATING2,
|
|
8652
|
+
(a) => handleSetAppEnabled(t, b, a, false)
|
|
8653
|
+
);
|
|
8654
|
+
reg(
|
|
8655
|
+
"talonic_get_app_acceptance",
|
|
8656
|
+
"Get App Acceptance Set",
|
|
8657
|
+
D.getAcceptance,
|
|
8658
|
+
{ app_id: appId },
|
|
8659
|
+
READ_ONLY3,
|
|
8660
|
+
(a) => handleGetAcceptance(t, b, a)
|
|
8661
|
+
);
|
|
8662
|
+
reg(
|
|
8663
|
+
"talonic_save_app_acceptance",
|
|
8664
|
+
"Save App Acceptance Set",
|
|
8665
|
+
D.saveAcceptance,
|
|
8666
|
+
{
|
|
8667
|
+
app_id: appId,
|
|
8668
|
+
cases: z.array(acceptanceCase).min(1).max(2e3),
|
|
8669
|
+
tolerance: z.number().min(0).max(1).optional().describe("Accepted mismatch share (default 0).")
|
|
8670
|
+
},
|
|
8671
|
+
MUTATING2,
|
|
8672
|
+
(a) => handleSaveAcceptance(t, b, a)
|
|
8673
|
+
);
|
|
8674
|
+
reg(
|
|
8675
|
+
"talonic_check_app_acceptance",
|
|
8676
|
+
"Check App Acceptance",
|
|
8677
|
+
D.checkAcceptance,
|
|
8678
|
+
{
|
|
8679
|
+
app_id: appId,
|
|
8680
|
+
run_id: zUuid().optional().describe("Run to score; default the latest completed run.")
|
|
8681
|
+
},
|
|
8682
|
+
READ_ONLY3,
|
|
8683
|
+
(a) => handleCheckAcceptance(t, b, a)
|
|
8684
|
+
);
|
|
8685
|
+
reg(
|
|
8686
|
+
"talonic_run_app",
|
|
8687
|
+
"Run App",
|
|
8688
|
+
D.run,
|
|
8689
|
+
{
|
|
8690
|
+
app_id: appId,
|
|
8691
|
+
input: jsonObject().optional().describe("Run input, checked against the app's input schema."),
|
|
8692
|
+
dry_run: z.boolean().optional().describe("Full trace, no side effects."),
|
|
8693
|
+
idempotency_key: z.string().min(1).max(64).optional()
|
|
8694
|
+
},
|
|
8695
|
+
MUTATING2,
|
|
8696
|
+
(a) => handleRunApp(t, b, a)
|
|
8697
|
+
);
|
|
8698
|
+
reg(
|
|
8699
|
+
"talonic_list_app_runs",
|
|
8700
|
+
"List App Runs",
|
|
8701
|
+
D.listRuns,
|
|
8702
|
+
{ app_id: appId, limit: limit2, offset },
|
|
8703
|
+
READ_ONLY3,
|
|
8704
|
+
(a) => handleListAppRuns(t, b, a)
|
|
8705
|
+
);
|
|
8706
|
+
reg(
|
|
8707
|
+
"talonic_get_app_run",
|
|
8708
|
+
"Get App Run",
|
|
8709
|
+
D.getRun,
|
|
8710
|
+
{ run_id: runId, include_events: z.boolean().optional() },
|
|
8711
|
+
READ_ONLY3,
|
|
8712
|
+
(a) => handleGetAppRun(t, b, a)
|
|
8713
|
+
);
|
|
8714
|
+
reg(
|
|
8715
|
+
"talonic_get_run_record",
|
|
8716
|
+
"Get Run Record",
|
|
8717
|
+
D.record,
|
|
8718
|
+
{ run_id: runId },
|
|
8719
|
+
READ_ONLY3,
|
|
8720
|
+
(a) => handleGetRunRecord(t, b, a)
|
|
8721
|
+
);
|
|
8722
|
+
reg(
|
|
8723
|
+
"talonic_get_run_verdicts",
|
|
8724
|
+
"Get Run Verdicts",
|
|
8725
|
+
D.verdicts,
|
|
8726
|
+
{
|
|
8727
|
+
run_id: runId,
|
|
8728
|
+
rolled: z.enum(VERDICT_OUTCOMES).optional().describe("Filter by overall outcome."),
|
|
8729
|
+
auto: z.boolean().optional().describe("Filter by the auto flag."),
|
|
8730
|
+
rule: z.string().min(1).max(128).optional().describe("Rule id; needs status."),
|
|
8731
|
+
status: z.enum(VERDICT_OUTCOMES).optional().describe("That rule's outcome; needs rule."),
|
|
8732
|
+
limit: limit2,
|
|
8733
|
+
cursor: z.string().min(1).max(512).optional().describe("`next` from the previous page.")
|
|
8734
|
+
},
|
|
8735
|
+
READ_ONLY3,
|
|
8736
|
+
(a) => handleGetRunVerdicts(t, b, a)
|
|
8737
|
+
);
|
|
8738
|
+
reg(
|
|
8739
|
+
"talonic_list_app_reviews",
|
|
8740
|
+
"List Human Reviews",
|
|
8741
|
+
D.listReviews,
|
|
8742
|
+
{
|
|
8743
|
+
app_id: appId.optional(),
|
|
8744
|
+
status: z.enum(REVIEW_STATUSES).optional(),
|
|
8745
|
+
kind: z.enum(REVIEW_KINDS).optional(),
|
|
8746
|
+
assignee_user_id: zUuid().optional().describe("Only reviews assigned to this user."),
|
|
8747
|
+
limit: limit2,
|
|
8748
|
+
offset
|
|
8749
|
+
},
|
|
8750
|
+
READ_ONLY3,
|
|
8751
|
+
(a) => handleListAppReviews(t, b, a)
|
|
8752
|
+
);
|
|
8753
|
+
reg(
|
|
8754
|
+
"talonic_raise_app_review",
|
|
8755
|
+
"Raise Human Review",
|
|
8756
|
+
D.raiseReview,
|
|
8757
|
+
{
|
|
8758
|
+
app_id: appId,
|
|
8759
|
+
run_id: runId.optional(),
|
|
8760
|
+
kind: z.enum(REVIEW_KINDS),
|
|
8761
|
+
question: z.string().min(1).max(4e3),
|
|
8762
|
+
context: jsonObject().optional(),
|
|
8763
|
+
input_contract: jsonObject().describe("JSON Schema the answer must satisfy."),
|
|
8764
|
+
team_id: zUuid().optional().describe("Review team to assign.")
|
|
8765
|
+
},
|
|
8766
|
+
MUTATING2,
|
|
8767
|
+
(a) => handleRaiseAppReview(t, b, a)
|
|
8768
|
+
);
|
|
8769
|
+
reg(
|
|
8770
|
+
"talonic_resolve_app_review",
|
|
8771
|
+
"Resolve Human Review",
|
|
8772
|
+
D.resolveReview,
|
|
8773
|
+
{
|
|
8774
|
+
review_id: reviewId,
|
|
8775
|
+
values: jsonObject().describe("Answer values matching the review's input_contract."),
|
|
8776
|
+
feedback: z.object({
|
|
8777
|
+
proposal_verdict: z.enum(["correct", "incorrect", "partial"]).optional(),
|
|
8778
|
+
correction: z.string().max(4e3).optional(),
|
|
8779
|
+
generalize: z.boolean().optional()
|
|
8780
|
+
}).optional().describe("Optional feedback that teaches the app.")
|
|
8781
|
+
},
|
|
8782
|
+
MUTATING2,
|
|
8783
|
+
(a) => handleResolveAppReview(t, b, a)
|
|
8784
|
+
);
|
|
8785
|
+
reg(
|
|
8786
|
+
"talonic_interview_app_review",
|
|
8787
|
+
"Interview Human Review",
|
|
8788
|
+
D.interview,
|
|
8789
|
+
{
|
|
8790
|
+
review_id: reviewId,
|
|
8791
|
+
message: z.string().min(1).max(4e3).describe("The reviewer's message for this turn."),
|
|
8792
|
+
transcript: z.array(z.object({ role: z.enum(["user", "assistant"]), text: z.string().max(2e3) })).max(20).optional().describe("Earlier turns, oldest first.")
|
|
8793
|
+
},
|
|
8794
|
+
{ ...READ_ONLY3, idempotentHint: false },
|
|
8795
|
+
(a) => handleInterviewReview(t, b, a)
|
|
8796
|
+
);
|
|
8797
|
+
reg(
|
|
8798
|
+
"talonic_list_app_precedents",
|
|
8799
|
+
"List App Precedents",
|
|
8800
|
+
D.precedents,
|
|
8801
|
+
{ app_id: appId, similar_to: jsonObject().optional().describe("Match keys of the case.") },
|
|
8802
|
+
READ_ONLY3,
|
|
8803
|
+
(a) => handleListAppPrecedents(t, b, a)
|
|
8804
|
+
);
|
|
8805
|
+
}
|
|
8806
|
+
function probeAppsToolsetAccess(token, baseUrl) {
|
|
8807
|
+
return probeAccessState(token, baseUrl, "/v1/apps");
|
|
8808
|
+
}
|
|
8809
|
+
var DECIDE_SCOPE = "apps:decide";
|
|
8810
|
+
var TASK_STATUSES2 = [
|
|
8811
|
+
"available",
|
|
8812
|
+
"claimed",
|
|
8813
|
+
"submitted",
|
|
8814
|
+
"released",
|
|
8815
|
+
"failed",
|
|
8816
|
+
"timed_out",
|
|
8817
|
+
"cancelled"
|
|
8818
|
+
];
|
|
8819
|
+
var PACKAGE_PAGE_LIMIT_MAX = 2e3;
|
|
8820
|
+
var appId2 = zUuid().describe(
|
|
8821
|
+
"Id of an External-mode app (from talonic_list_apps, where mode is 'external')."
|
|
8822
|
+
);
|
|
8823
|
+
var taskId2 = zUuid().describe("Decision task UUID.");
|
|
8824
|
+
var executionEpoch2 = z.number().int().min(1).max(2147483647).describe("Execution epoch returned by the successful claim. Stale epochs are rejected with 409.");
|
|
8825
|
+
var status2 = z.enum(TASK_STATUSES2).optional().describe("Optional task-status filter.");
|
|
8826
|
+
var listLimit = z.number().int().min(1).max(100).optional().describe("Page size (default 50).");
|
|
8827
|
+
var cursor2 = z.string().min(1).optional().describe("Opaque cursor from pagination.next_cursor.");
|
|
8828
|
+
var packageCursor = z.string().min(1).optional().describe(
|
|
8829
|
+
"Opaque package cursor: package.first_cursor from the claim, then pagination.next_cursor. Omit for the first page."
|
|
8830
|
+
);
|
|
8831
|
+
var packageLimit = z.number().int().min(1).max(PACKAGE_PAGE_LIMIT_MAX).optional().describe(
|
|
8832
|
+
`Records per page, 1 to ${PACKAGE_PAGE_LIMIT_MAX}. Defaults to the platform page size (package.page_size from the claim).`
|
|
8833
|
+
);
|
|
8834
|
+
var outcome = z.record(z.string(), z.json()).describe(
|
|
8835
|
+
"The decision, shaped by output_contract from the claim: for a plain JSON Schema contract the object that schema validates; for a verdict_matrix contract { subjects: [{ subject_key, rule_outcomes, auto?, detail? }] }; for a record_set contract its fields-and-rows envelope."
|
|
8836
|
+
);
|
|
8837
|
+
var evidence = z.array(z.string().min(1).max(512)).max(1e4).describe(
|
|
8838
|
+
"Provenance locators the decision relied on, each copied verbatim from the input package (or a db:/ref: locator the app holds a read grant on). Required; [] is accepted only when the app allows unevidenced decisions."
|
|
8839
|
+
);
|
|
8840
|
+
var rationale = z.string().min(1).max(4e3).describe(
|
|
8841
|
+
"Short decision rationale (a summary, never private chain-of-thought), up to 4,000 characters."
|
|
8842
|
+
);
|
|
8843
|
+
var confidence = z.number().min(0).max(1).optional().describe("Optional confidence from 0 to 1.");
|
|
8844
|
+
var serviceVersion = z.string().min(1).max(64).optional().describe("Optional build identifier of the deciding service; recorded as decided_by.label.");
|
|
8845
|
+
var failReason = z.string().min(1).max(2e3).describe(
|
|
8846
|
+
"Why the task cannot be decided, up to 2,000 characters. Recorded on the Human Review the fail raises."
|
|
8847
|
+
);
|
|
8848
|
+
var listInput2 = { app_id: appId2, status: status2, limit: listLimit, cursor: cursor2 };
|
|
8849
|
+
var idInput2 = { task_id: taskId2 };
|
|
8850
|
+
var packageInput = { task_id: taskId2, cursor: packageCursor, limit: packageLimit };
|
|
8851
|
+
var epochInput = { task_id: taskId2, execution_epoch: executionEpoch2 };
|
|
8852
|
+
var submitInput2 = {
|
|
8853
|
+
task_id: taskId2,
|
|
8854
|
+
execution_epoch: executionEpoch2,
|
|
8855
|
+
outcome,
|
|
8856
|
+
evidence,
|
|
8857
|
+
rationale,
|
|
8858
|
+
confidence,
|
|
8859
|
+
service_version: serviceVersion
|
|
8860
|
+
};
|
|
8861
|
+
var failInput = { task_id: taskId2, execution_epoch: executionEpoch2, reason: failReason };
|
|
8862
|
+
function taskPath(taskId3, suffix = "") {
|
|
8863
|
+
return `/v1/decision-tasks/${encodeURIComponent(taskId3)}${suffix}`;
|
|
8864
|
+
}
|
|
8865
|
+
function handleListDecisionTasks(getToken, baseUrl, args) {
|
|
8866
|
+
return runTool(
|
|
8867
|
+
() => apiJson(
|
|
8066
8868
|
getToken,
|
|
8067
8869
|
baseUrl,
|
|
8068
8870
|
"GET",
|
|
@@ -8118,12 +8920,12 @@ function handleFailDecisionTask(getToken, baseUrl, args) {
|
|
|
8118
8920
|
})
|
|
8119
8921
|
);
|
|
8120
8922
|
}
|
|
8121
|
-
var
|
|
8923
|
+
var READ_ONLY4 = {
|
|
8122
8924
|
readOnlyHint: true,
|
|
8123
8925
|
destructiveHint: false,
|
|
8124
8926
|
openWorldHint: false
|
|
8125
8927
|
};
|
|
8126
|
-
var
|
|
8928
|
+
var MUTATING3 = {
|
|
8127
8929
|
readOnlyHint: false,
|
|
8128
8930
|
destructiveHint: false,
|
|
8129
8931
|
openWorldHint: false
|
|
@@ -8193,9 +8995,9 @@ var DESCRIPTIONS2 = {
|
|
|
8193
8995
|
};
|
|
8194
8996
|
function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
8195
8997
|
const invocable = options.invocable !== false;
|
|
8196
|
-
const metaFor = (
|
|
8998
|
+
const metaFor = (key2) => ({
|
|
8197
8999
|
_meta: {
|
|
8198
|
-
...widgetToolMeta(
|
|
9000
|
+
...widgetToolMeta(key2),
|
|
8199
9001
|
...invocable ? {} : { "talonic/can_invoke": false, "talonic/required_scope": DECIDE_SCOPE }
|
|
8200
9002
|
}
|
|
8201
9003
|
});
|
|
@@ -8205,7 +9007,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8205
9007
|
title: "List Decision Tasks",
|
|
8206
9008
|
description: DESCRIPTIONS2.list,
|
|
8207
9009
|
inputSchema: listInput2,
|
|
8208
|
-
annotations: { title: "List Decision Tasks", ...
|
|
9010
|
+
annotations: { title: "List Decision Tasks", ...READ_ONLY4 },
|
|
8209
9011
|
...metaFor("listDecisionTasks")
|
|
8210
9012
|
},
|
|
8211
9013
|
async (args) => handleListDecisionTasks(getToken, baseUrl, args)
|
|
@@ -8216,7 +9018,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8216
9018
|
title: "Claim Decision Task",
|
|
8217
9019
|
description: DESCRIPTIONS2.claim,
|
|
8218
9020
|
inputSchema: idInput2,
|
|
8219
|
-
annotations: { title: "Claim Decision Task", ...
|
|
9021
|
+
annotations: { title: "Claim Decision Task", ...MUTATING3 },
|
|
8220
9022
|
...metaFor("claimDecisionTask")
|
|
8221
9023
|
},
|
|
8222
9024
|
async (args) => handleClaimDecisionTask(getToken, baseUrl, args)
|
|
@@ -8227,7 +9029,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8227
9029
|
title: "Read Decision Package",
|
|
8228
9030
|
description: DESCRIPTIONS2.package,
|
|
8229
9031
|
inputSchema: packageInput,
|
|
8230
|
-
annotations: { title: "Read Decision Package", ...
|
|
9032
|
+
annotations: { title: "Read Decision Package", ...READ_ONLY4 },
|
|
8231
9033
|
...metaFor("readDecisionPackage")
|
|
8232
9034
|
},
|
|
8233
9035
|
async (args) => handleReadDecisionPackage(getToken, baseUrl, args)
|
|
@@ -8238,7 +9040,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8238
9040
|
title: "Heartbeat Decision Task",
|
|
8239
9041
|
description: DESCRIPTIONS2.heartbeat,
|
|
8240
9042
|
inputSchema: epochInput,
|
|
8241
|
-
annotations: { title: "Heartbeat Decision Task", ...
|
|
9043
|
+
annotations: { title: "Heartbeat Decision Task", ...MUTATING3 },
|
|
8242
9044
|
...metaFor("heartbeatDecisionTask")
|
|
8243
9045
|
},
|
|
8244
9046
|
async (args) => handleHeartbeatDecisionTask(getToken, baseUrl, args)
|
|
@@ -8249,7 +9051,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8249
9051
|
title: "Submit Decision Task",
|
|
8250
9052
|
description: DESCRIPTIONS2.submit,
|
|
8251
9053
|
inputSchema: submitInput2,
|
|
8252
|
-
annotations: { title: "Submit Decision Task", ...
|
|
9054
|
+
annotations: { title: "Submit Decision Task", ...MUTATING3 },
|
|
8253
9055
|
...metaFor("submitDecisionTask")
|
|
8254
9056
|
},
|
|
8255
9057
|
async (args) => handleSubmitDecisionTask(getToken, baseUrl, args)
|
|
@@ -8260,7 +9062,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8260
9062
|
title: "Release Decision Task",
|
|
8261
9063
|
description: DESCRIPTIONS2.release,
|
|
8262
9064
|
inputSchema: epochInput,
|
|
8263
|
-
annotations: { title: "Release Decision Task", ...
|
|
9065
|
+
annotations: { title: "Release Decision Task", ...MUTATING3 },
|
|
8264
9066
|
...metaFor("releaseDecisionTask")
|
|
8265
9067
|
},
|
|
8266
9068
|
async (args) => handleReleaseDecisionTask(getToken, baseUrl, args)
|
|
@@ -8277,6 +9079,236 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8277
9079
|
async (args) => handleFailDecisionTask(getToken, baseUrl, args)
|
|
8278
9080
|
);
|
|
8279
9081
|
}
|
|
9082
|
+
|
|
9083
|
+
// src/tools/mining-driver.ts
|
|
9084
|
+
var appId3 = zUuid().describe(
|
|
9085
|
+
"Id (UUID) of an autonomous app, from talonic_list_apps where mode is 'autonomous'."
|
|
9086
|
+
);
|
|
9087
|
+
var runId2 = zUuid().describe(
|
|
9088
|
+
"The round's run id (run_id from talonic_mining_list_rounds, or the decision task's run_id)."
|
|
9089
|
+
);
|
|
9090
|
+
var executionEpoch3 = z.number().int().min(1).max(2147483647).describe("execution_epoch from talonic_claim_decision_task. A stale epoch is HTTP 409.");
|
|
9091
|
+
var toolName = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/).describe("A tool name from talonic_mining_list_round_tools.");
|
|
9092
|
+
var READ_ONLY5 = {
|
|
9093
|
+
readOnlyHint: true,
|
|
9094
|
+
destructiveHint: false,
|
|
9095
|
+
idempotentHint: true,
|
|
9096
|
+
openWorldHint: false
|
|
9097
|
+
};
|
|
9098
|
+
var MUTATING4 = {
|
|
9099
|
+
readOnlyHint: false,
|
|
9100
|
+
destructiveHint: false,
|
|
9101
|
+
idempotentHint: false,
|
|
9102
|
+
openWorldHint: false
|
|
9103
|
+
};
|
|
9104
|
+
var roundsPath = (app, suffix = "") => `/v1/apps/${encodeURIComponent(app)}/mining/rounds${suffix}`;
|
|
9105
|
+
var roundPath = (app, run, suffix = "") => roundsPath(app, `/${encodeURIComponent(run)}${suffix}`);
|
|
9106
|
+
var BUSY_BACKOFF_MS = [500, 1e3, 2e3, 4e3];
|
|
9107
|
+
var POLL_INTERVAL_MS = 2e3;
|
|
9108
|
+
var DEFAULT_WAIT_SECONDS = 25;
|
|
9109
|
+
var MAX_WAIT_SECONDS = 120;
|
|
9110
|
+
var realSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
9111
|
+
function isBusy(err) {
|
|
9112
|
+
if (!(err instanceof ApiHttpError) || err.status !== 409) return false;
|
|
9113
|
+
try {
|
|
9114
|
+
const body = JSON.parse(err.body);
|
|
9115
|
+
return (body.details?.refused ?? body.error?.details?.refused) === "busy";
|
|
9116
|
+
} catch {
|
|
9117
|
+
return /"refused"\s*:\s*"busy"/.test(err.body);
|
|
9118
|
+
}
|
|
9119
|
+
}
|
|
9120
|
+
var handleMiningListRounds = (t, b, a) => runTool(
|
|
9121
|
+
() => apiJson(t, b, "GET", roundsPath(a.app_id), { params: { limit: a.limit, offset: a.offset } })
|
|
9122
|
+
);
|
|
9123
|
+
var handleMiningGetRound = (t, b, a) => runTool(() => apiJson(t, b, "GET", roundPath(a.app_id, a.run_id)));
|
|
9124
|
+
var handleMiningStartRound = (t, b, a) => runTool(
|
|
9125
|
+
() => a.phase === "reconcile" ? apiJson(t, b, "POST", roundsPath(a.app_id, "/reconcile")) : apiJson(t, b, "POST", roundsPath(a.app_id), {
|
|
9126
|
+
body: {
|
|
9127
|
+
...a.phase ? { phase: a.phase } : {},
|
|
9128
|
+
...a.dry_run !== void 0 ? { dry_run: a.dry_run } : {}
|
|
9129
|
+
}
|
|
9130
|
+
})
|
|
9131
|
+
);
|
|
9132
|
+
var handleMiningListRoundTools = (t, b, a) => runTool(() => apiJson(t, b, "GET", roundPath(a.app_id, a.run_id, "/tools")));
|
|
9133
|
+
async function handleMiningCallRoundTool(t, b, a, timing = {}) {
|
|
9134
|
+
const sleep2 = timing.sleep ?? realSleep;
|
|
9135
|
+
const now = timing.now ?? Date.now;
|
|
9136
|
+
return runTool(async () => {
|
|
9137
|
+
const path = roundPath(a.app_id, a.run_id, `/tools/${encodeURIComponent(a.name)}`);
|
|
9138
|
+
const body = { execution_epoch: a.execution_epoch, input: a.input ?? {} };
|
|
9139
|
+
let answer;
|
|
9140
|
+
for (let attempt = 0; ; attempt++) {
|
|
9141
|
+
try {
|
|
9142
|
+
answer = await apiJson(t, b, "POST", path, { body });
|
|
9143
|
+
break;
|
|
9144
|
+
} catch (err) {
|
|
9145
|
+
const backoff = BUSY_BACKOFF_MS[attempt];
|
|
9146
|
+
if (!isBusy(err) || backoff === void 0) throw err;
|
|
9147
|
+
await sleep2(backoff);
|
|
9148
|
+
}
|
|
9149
|
+
}
|
|
9150
|
+
if (answer?.status !== "running" || !answer.call_id) return answer;
|
|
9151
|
+
const waitMs = Math.min(a.wait_seconds ?? DEFAULT_WAIT_SECONDS, MAX_WAIT_SECONDS) * 1e3;
|
|
9152
|
+
const deadline = now() + waitMs;
|
|
9153
|
+
const callId = answer.call_id;
|
|
9154
|
+
while (now() < deadline) {
|
|
9155
|
+
await sleep2(POLL_INTERVAL_MS);
|
|
9156
|
+
const polled = await apiJson(
|
|
9157
|
+
t,
|
|
9158
|
+
b,
|
|
9159
|
+
"GET",
|
|
9160
|
+
roundPath(a.app_id, a.run_id, `/tools/calls/${encodeURIComponent(callId)}`),
|
|
9161
|
+
{ params: { execution_epoch: a.execution_epoch } }
|
|
9162
|
+
);
|
|
9163
|
+
if (polled?.status !== "running") return polled;
|
|
9164
|
+
}
|
|
9165
|
+
return {
|
|
9166
|
+
call_id: callId,
|
|
9167
|
+
status: "running",
|
|
9168
|
+
next_step: "The call is still running. Poll talonic_mining_get_round_tool_call with this call_id; heartbeat the task if its lease is close to expiring."
|
|
9169
|
+
};
|
|
9170
|
+
});
|
|
9171
|
+
}
|
|
9172
|
+
var handleMiningGetRoundToolCall = (t, b, a) => runTool(
|
|
9173
|
+
() => apiJson(
|
|
9174
|
+
t,
|
|
9175
|
+
b,
|
|
9176
|
+
"GET",
|
|
9177
|
+
roundPath(a.app_id, a.run_id, `/tools/calls/${encodeURIComponent(a.call_id)}`),
|
|
9178
|
+
{
|
|
9179
|
+
params: { execution_epoch: a.execution_epoch }
|
|
9180
|
+
}
|
|
9181
|
+
)
|
|
9182
|
+
);
|
|
9183
|
+
var DRIVER_FLOW = "FLOW for a round waiting for an outside driver: talonic_list_decision_tasks (the app's tasks) -> talonic_claim_decision_task (keep execution_epoch) -> talonic_read_decision_package (the round's brief and tools) -> talonic_mining_list_round_tools -> talonic_mining_call_round_tool, repeatedly, with talonic_heartbeat_decision_task before the lease ends -> talonic_submit_decision_task with outcome { summary, protocol_feedback }, evidence [] and a one-line rationale.";
|
|
9184
|
+
var AUTH_NOTE2 = "AUTH: a tlnc_ key needs a per-app 'decide' grant (plus 'read' for the round reads); an OAuth connector session needs the apps:decide scope and a live workspace role of senior_member or above. A 403 names what is missing: tell the user, do not retry.";
|
|
9185
|
+
var D2 = {
|
|
9186
|
+
listRounds: [
|
|
9187
|
+
"List an autonomous app's rule-finding rounds, newest first: phase, status, what each found, and for a round waiting for an outside driver its task state (claimed by whom, lease, deadline). `total` counts every round.",
|
|
9188
|
+
"USE WHEN: finding a round to drive or checking progress. ARGS: app_id, optional limit (max 200), offset."
|
|
9189
|
+
].join("\n"),
|
|
9190
|
+
getRound: [
|
|
9191
|
+
"Read one rule-finding round: phase, status, budget, findings, candidate rules, summary, and the driver block for an externally driven round.",
|
|
9192
|
+
"ARGS: app_id, run_id."
|
|
9193
|
+
].join("\n"),
|
|
9194
|
+
startRound: [
|
|
9195
|
+
"Start a rule-finding round on an autonomous app. Without phase the app's plan picks the next one; reconcile reviews rules whose candidates lapsed (needs configure access). dry_run re-grades without searching.",
|
|
9196
|
+
"USE WHEN: the user asks to look for new rules now. Only one externally driven round per app can be open (HTTP 409 with the open task otherwise).",
|
|
9197
|
+
"RETURNS: { run_id, status, phase, \u2026 }. A round with an outside driver then waits for a claim: see talonic_list_decision_tasks."
|
|
9198
|
+
].join("\n"),
|
|
9199
|
+
listTools: [
|
|
9200
|
+
"List the tools you may call on a round you hold the claim on, with their inputs, the round's remaining budget and the retry rule for a busy round.",
|
|
9201
|
+
"USE WHEN: right after claiming the round's decision task, or to check remaining budget.",
|
|
9202
|
+
DRIVER_FLOW,
|
|
9203
|
+
AUTH_NOTE2
|
|
9204
|
+
].join("\n"),
|
|
9205
|
+
callTool: [
|
|
9206
|
+
"Call one round tool by name with its input, as the current claimant. The call runs under the app's grants and the round's budgets; a tool's own error comes back as is_error:true with a reason, not as a failure of this call.",
|
|
9207
|
+
"Busy rounds are retried for you. A call that runs long is polled for up to wait_seconds (default 25, max 120); if it is still running you get its call_id: poll talonic_mining_get_round_tool_call.",
|
|
9208
|
+
"Do not call tools on one round in parallel. close_round is not a tool here: close the round with talonic_submit_decision_task.",
|
|
9209
|
+
"ARGS: app_id, run_id, execution_epoch, name, input (object, default {}), optional wait_seconds. A stale or foreign claim or an expired lease is HTTP 409: claim again.",
|
|
9210
|
+
AUTH_NOTE2
|
|
9211
|
+
].join("\n"),
|
|
9212
|
+
getCall: [
|
|
9213
|
+
"Read a round tool call that was still running: status running | done, and its content and is_error once done. Only the round's current claimant can read it.",
|
|
9214
|
+
"ARGS: app_id, run_id, call_id, execution_epoch.",
|
|
9215
|
+
AUTH_NOTE2
|
|
9216
|
+
].join("\n")
|
|
9217
|
+
};
|
|
9218
|
+
function registerMiningDriverTools(server, getToken, baseUrl, options = {}) {
|
|
9219
|
+
const t = getToken;
|
|
9220
|
+
const b = baseUrl;
|
|
9221
|
+
const decideMeta = options.invocable === false ? { _meta: { "talonic/can_invoke": false, "talonic/required_scope": DECIDE_SCOPE } } : {};
|
|
9222
|
+
server.registerTool(
|
|
9223
|
+
"talonic_mining_list_rounds",
|
|
9224
|
+
{
|
|
9225
|
+
title: "List Mining Rounds",
|
|
9226
|
+
description: D2.listRounds,
|
|
9227
|
+
inputSchema: {
|
|
9228
|
+
app_id: appId3,
|
|
9229
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
9230
|
+
offset: z.number().int().min(0).optional()
|
|
9231
|
+
},
|
|
9232
|
+
annotations: { title: "List Mining Rounds", ...READ_ONLY5 }
|
|
9233
|
+
},
|
|
9234
|
+
(a) => handleMiningListRounds(t, b, a)
|
|
9235
|
+
);
|
|
9236
|
+
server.registerTool(
|
|
9237
|
+
"talonic_mining_get_round",
|
|
9238
|
+
{
|
|
9239
|
+
title: "Get Mining Round",
|
|
9240
|
+
description: D2.getRound,
|
|
9241
|
+
inputSchema: { app_id: appId3, run_id: runId2 },
|
|
9242
|
+
annotations: { title: "Get Mining Round", ...READ_ONLY5 }
|
|
9243
|
+
},
|
|
9244
|
+
(a) => handleMiningGetRound(t, b, a)
|
|
9245
|
+
);
|
|
9246
|
+
server.registerTool(
|
|
9247
|
+
"talonic_mining_start_round",
|
|
9248
|
+
{
|
|
9249
|
+
title: "Start Mining Round",
|
|
9250
|
+
description: D2.startRound,
|
|
9251
|
+
inputSchema: {
|
|
9252
|
+
app_id: appId3,
|
|
9253
|
+
phase: z.enum(["discovery", "hypothesis", "reconcile"]).optional(),
|
|
9254
|
+
dry_run: z.boolean().optional()
|
|
9255
|
+
},
|
|
9256
|
+
annotations: { title: "Start Mining Round", ...MUTATING4 }
|
|
9257
|
+
},
|
|
9258
|
+
(a) => handleMiningStartRound(t, b, a)
|
|
9259
|
+
);
|
|
9260
|
+
server.registerTool(
|
|
9261
|
+
"talonic_mining_list_round_tools",
|
|
9262
|
+
{
|
|
9263
|
+
title: "List Round Tools",
|
|
9264
|
+
description: D2.listTools,
|
|
9265
|
+
inputSchema: { app_id: appId3, run_id: runId2 },
|
|
9266
|
+
annotations: { title: "List Round Tools", ...READ_ONLY5 },
|
|
9267
|
+
...decideMeta
|
|
9268
|
+
},
|
|
9269
|
+
(a) => handleMiningListRoundTools(t, b, a)
|
|
9270
|
+
);
|
|
9271
|
+
server.registerTool(
|
|
9272
|
+
"talonic_mining_call_round_tool",
|
|
9273
|
+
{
|
|
9274
|
+
title: "Call Round Tool",
|
|
9275
|
+
description: D2.callTool,
|
|
9276
|
+
inputSchema: {
|
|
9277
|
+
app_id: appId3,
|
|
9278
|
+
run_id: runId2,
|
|
9279
|
+
execution_epoch: executionEpoch3,
|
|
9280
|
+
name: toolName,
|
|
9281
|
+
input: z.record(z.string(), z.json()).optional().describe("The tool's input object."),
|
|
9282
|
+
wait_seconds: z.number().int().min(0).max(MAX_WAIT_SECONDS).optional().describe(`Seconds to keep polling a long call (default ${DEFAULT_WAIT_SECONDS}).`)
|
|
9283
|
+
},
|
|
9284
|
+
annotations: { title: "Call Round Tool", ...MUTATING4 },
|
|
9285
|
+
...decideMeta
|
|
9286
|
+
},
|
|
9287
|
+
(a) => handleMiningCallRoundTool(t, b, a)
|
|
9288
|
+
);
|
|
9289
|
+
server.registerTool(
|
|
9290
|
+
"talonic_mining_get_round_tool_call",
|
|
9291
|
+
{
|
|
9292
|
+
title: "Get Round Tool Call",
|
|
9293
|
+
description: D2.getCall,
|
|
9294
|
+
inputSchema: {
|
|
9295
|
+
app_id: appId3,
|
|
9296
|
+
run_id: runId2,
|
|
9297
|
+
call_id: zUuid().describe("call_id from talonic_mining_call_round_tool."),
|
|
9298
|
+
execution_epoch: executionEpoch3
|
|
9299
|
+
},
|
|
9300
|
+
annotations: { title: "Get Round Tool Call", ...READ_ONLY5 },
|
|
9301
|
+
...decideMeta
|
|
9302
|
+
},
|
|
9303
|
+
(a) => handleMiningGetRoundToolCall(t, b, a)
|
|
9304
|
+
);
|
|
9305
|
+
}
|
|
9306
|
+
function probeMiningInUse(token, baseUrl) {
|
|
9307
|
+
return probeAccessState(token, baseUrl, "/v1/apps", (body) => {
|
|
9308
|
+
const apps = body?.apps;
|
|
9309
|
+
return Array.isArray(apps) && apps.some((a) => a?.mode === "autonomous");
|
|
9310
|
+
});
|
|
9311
|
+
}
|
|
8280
9312
|
var DESCRIPTION11 = [
|
|
8281
9313
|
"Get the OCR-converted markdown text of a document.",
|
|
8282
9314
|
"",
|
|
@@ -8343,8 +9375,8 @@ async function handleToMarkdown(talonic, args, opts = {}) {
|
|
|
8343
9375
|
retryable: false
|
|
8344
9376
|
});
|
|
8345
9377
|
}
|
|
8346
|
-
let
|
|
8347
|
-
if (!
|
|
9378
|
+
let documentId3 = args.document_id;
|
|
9379
|
+
if (!documentId3) {
|
|
8348
9380
|
const ingest = await talonic.extract({
|
|
8349
9381
|
...args.file_data !== void 0 ? {
|
|
8350
9382
|
file: Buffer.from(args.file_data, "base64"),
|
|
@@ -8354,9 +9386,9 @@ async function handleToMarkdown(talonic, args, opts = {}) {
|
|
|
8354
9386
|
...args.file_url !== void 0 ? { file_url: args.file_url } : {},
|
|
8355
9387
|
schema: INGEST_ONLY_SCHEMA
|
|
8356
9388
|
});
|
|
8357
|
-
|
|
9389
|
+
documentId3 = ingest.document.id;
|
|
8358
9390
|
}
|
|
8359
|
-
const result = await talonic.documents.getMarkdown(
|
|
9391
|
+
const result = await talonic.documents.getMarkdown(documentId3);
|
|
8360
9392
|
return jsonOk(result);
|
|
8361
9393
|
} catch (err) {
|
|
8362
9394
|
return toolError(err);
|
|
@@ -8579,18 +9611,22 @@ function unwrap(res) {
|
|
|
8579
9611
|
}
|
|
8580
9612
|
var documentIdsArg = z.array(zUuid()).max(1e3).optional().describe("Restrict to these document ids (hard filter, enforced server-side).");
|
|
8581
9613
|
var FIND_DESCRIPTION = [
|
|
8582
|
-
"Locate the REAL data behind a natural-language concept before querying anything:
|
|
9614
|
+
"Locate the REAL data behind a natural-language concept before querying anything: resolves a phrase ('payment volume per transaction', 'counterparty', 'Vertragslaufzeit') by meaning and by its words to the fields, values, documents and text passages that carry it \u2014 even when the field is captured under a different name.",
|
|
8583
9615
|
"",
|
|
8584
|
-
"USE WHEN: the user asks about a concept and you are not sure which field holds it, when talonic_list_fields / talonic_search came back empty or ambiguous, or when the answer may live in document prose rather than a captured cell.",
|
|
9616
|
+
"USE WHEN: the user asks about a concept and you are not sure which field holds it, when talonic_list_fields / talonic_search came back empty or ambiguous, or when the answer may live in document prose rather than a captured cell. Pass `account` whenever the question names one portfolio company (an account from talonic_list_accounts), so another company's figures cannot come back.",
|
|
8585
9617
|
"NOT FOR: reading a known field's values (talonic_field_values) or filtering by a known field (talonic_filter).",
|
|
8586
9618
|
"",
|
|
8587
|
-
"ARGS: `query` (the concept, in the user's words), optional `top_k` (1\u201325, default 10), `document_ids` (hard scope).",
|
|
8588
|
-
"RETURNS: four ranked groups \u2014 FIELDS (canonical_name, field ids/keys, maturity
|
|
9619
|
+
"ARGS: `query` (the concept, in the user's words), optional `concepts[]` (several concepts resolved to fields in one call; fields only, no text search), `top_k` (1\u201325, default 10), `document_ids` (hard scope), `account` (one account by name or alias, e.g. 'Filu'; narrows like document_ids; an unknown name returns an error listing the accounts).",
|
|
9620
|
+
"RETURNS: four ranked groups \u2014 FIELDS (canonical_name, field ids/keys, maturity, occurrence_count, sample values with their documents), VALUES, DOCUMENTS and PASSAGES \u2014 every item a ready handle for the next call. Read-only."
|
|
8589
9621
|
].join("\n");
|
|
8590
9622
|
var findDataInputSchema = {
|
|
8591
9623
|
query: z.string().min(1).describe("The natural-language concept to locate."),
|
|
9624
|
+
concepts: z.array(z.string().min(1).max(300)).min(1).max(50).optional().describe("Several concepts resolved to fields in one call (fields only, no text search)."),
|
|
8592
9625
|
top_k: z.number().int().min(1).max(25).optional().describe("Max results per group (default 10)."),
|
|
8593
|
-
document_ids: documentIdsArg
|
|
9626
|
+
document_ids: documentIdsArg,
|
|
9627
|
+
account: z.string().min(1).max(200).optional().describe(
|
|
9628
|
+
"Only the documents of this account (portfolio company), by name or alias, e.g. 'Filu'."
|
|
9629
|
+
)
|
|
8594
9630
|
};
|
|
8595
9631
|
async function handleFindData(getToken, baseUrl, args) {
|
|
8596
9632
|
return runTool(async () => {
|
|
@@ -8603,8 +9639,10 @@ async function handleFindData(getToken, baseUrl, args) {
|
|
|
8603
9639
|
body: {
|
|
8604
9640
|
args: {
|
|
8605
9641
|
query: args.query,
|
|
9642
|
+
...args.concepts?.length ? { concepts: args.concepts } : {},
|
|
8606
9643
|
...args.top_k !== void 0 ? { top_k: args.top_k } : {},
|
|
8607
|
-
...args.document_ids?.length ? { document_scope: args.document_ids } : {}
|
|
9644
|
+
...args.document_ids?.length ? { document_scope: args.document_ids } : {},
|
|
9645
|
+
...args.account?.trim() ? { account: args.account.trim() } : {}
|
|
8608
9646
|
}
|
|
8609
9647
|
}
|
|
8610
9648
|
}
|
|
@@ -8633,7 +9671,7 @@ async function handleListAgentTools(getToken, baseUrl, args) {
|
|
|
8633
9671
|
const onlyInvocable = args.only_invocable ?? true;
|
|
8634
9672
|
const includeSchemas = args.include_schemas ?? true;
|
|
8635
9673
|
const registry = (res.tools ?? []).filter((t) => !DEDICATED.has(t.name));
|
|
8636
|
-
const
|
|
9674
|
+
const tools2 = registry.filter((t) => !onlyInvocable || t.can_invoke).map((t) => {
|
|
8637
9675
|
const item = {
|
|
8638
9676
|
name: t.name,
|
|
8639
9677
|
description: t.description,
|
|
@@ -8645,7 +9683,7 @@ async function handleListAgentTools(getToken, baseUrl, args) {
|
|
|
8645
9683
|
return item;
|
|
8646
9684
|
});
|
|
8647
9685
|
return {
|
|
8648
|
-
tools,
|
|
9686
|
+
tools: tools2,
|
|
8649
9687
|
invocable_count: registry.filter((t) => t.can_invoke).length,
|
|
8650
9688
|
totalCount: registry.length
|
|
8651
9689
|
};
|
|
@@ -8813,7 +9851,7 @@ async function handleGetSpec(getToken, baseUrl, args) {
|
|
|
8813
9851
|
return { ...spec, versions: versions.data ?? [] };
|
|
8814
9852
|
});
|
|
8815
9853
|
}
|
|
8816
|
-
var
|
|
9854
|
+
var READ_ONLY6 = {
|
|
8817
9855
|
readOnlyHint: true,
|
|
8818
9856
|
destructiveHint: false,
|
|
8819
9857
|
idempotentHint: true,
|
|
@@ -8826,7 +9864,7 @@ function registerSpecTools(server, getToken, baseUrl) {
|
|
|
8826
9864
|
title: "List pipelines",
|
|
8827
9865
|
description: LIST_DESCRIPTION5,
|
|
8828
9866
|
inputSchema: listSpecsInputSchema,
|
|
8829
|
-
annotations: { title: "List pipelines", ...
|
|
9867
|
+
annotations: { title: "List pipelines", ...READ_ONLY6 },
|
|
8830
9868
|
_meta: widgetToolMeta("listSpecs")
|
|
8831
9869
|
},
|
|
8832
9870
|
async (args) => handleListSpecs(getToken, baseUrl, args)
|
|
@@ -8837,7 +9875,7 @@ function registerSpecTools(server, getToken, baseUrl) {
|
|
|
8837
9875
|
title: "Look up a pipeline",
|
|
8838
9876
|
description: GET_DESCRIPTION4,
|
|
8839
9877
|
inputSchema: getSpecInputSchema,
|
|
8840
|
-
annotations: { title: "Look up a pipeline", ...
|
|
9878
|
+
annotations: { title: "Look up a pipeline", ...READ_ONLY6 },
|
|
8841
9879
|
_meta: widgetToolMeta("getSpec")
|
|
8842
9880
|
},
|
|
8843
9881
|
async (args) => handleGetSpec(getToken, baseUrl, args)
|
|
@@ -9053,7 +10091,7 @@ async function handleGetRunResults(getToken, baseUrl, args) {
|
|
|
9053
10091
|
return { run_kind: kind, ...body };
|
|
9054
10092
|
});
|
|
9055
10093
|
}
|
|
9056
|
-
var
|
|
10094
|
+
var READ_ONLY7 = {
|
|
9057
10095
|
readOnlyHint: true,
|
|
9058
10096
|
destructiveHint: false,
|
|
9059
10097
|
idempotentHint: true,
|
|
@@ -9082,7 +10120,7 @@ function registerRunTools(server, getToken, baseUrl) {
|
|
|
9082
10120
|
title: "Check run progress",
|
|
9083
10121
|
description: GET_RUN_DESCRIPTION,
|
|
9084
10122
|
inputSchema: runRefInputSchema,
|
|
9085
|
-
annotations: { title: "Check run progress", ...
|
|
10123
|
+
annotations: { title: "Check run progress", ...READ_ONLY7 },
|
|
9086
10124
|
_meta: widgetToolMeta("getRun")
|
|
9087
10125
|
},
|
|
9088
10126
|
async (args) => handleGetRun(getToken, baseUrl, args)
|
|
@@ -9093,7 +10131,7 @@ function registerRunTools(server, getToken, baseUrl) {
|
|
|
9093
10131
|
title: "Read run results",
|
|
9094
10132
|
description: RESULTS_DESCRIPTION,
|
|
9095
10133
|
inputSchema: resultsInputSchema,
|
|
9096
|
-
annotations: { title: "Read run results", ...
|
|
10134
|
+
annotations: { title: "Read run results", ...READ_ONLY7 },
|
|
9097
10135
|
_meta: widgetToolMeta("getRunResults")
|
|
9098
10136
|
},
|
|
9099
10137
|
async (args) => handleGetRunResults(getToken, baseUrl, args)
|
|
@@ -9238,35 +10276,2145 @@ function registerAskTools(server, getToken, baseUrl) {
|
|
|
9238
10276
|
);
|
|
9239
10277
|
}
|
|
9240
10278
|
|
|
9241
|
-
//
|
|
9242
|
-
var
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
10279
|
+
// src/tools/_groups.ts
|
|
10280
|
+
var READ = {
|
|
10281
|
+
readOnlyHint: true,
|
|
10282
|
+
destructiveHint: false,
|
|
10283
|
+
idempotentHint: true,
|
|
10284
|
+
openWorldHint: false
|
|
10285
|
+
};
|
|
10286
|
+
var write9 = (idempotent, destructive2 = false) => ({
|
|
10287
|
+
readOnlyHint: false,
|
|
10288
|
+
destructiveHint: destructive2,
|
|
10289
|
+
idempotentHint: idempotent,
|
|
10290
|
+
openWorldHint: false
|
|
10291
|
+
});
|
|
10292
|
+
var camelToSnake = (s) => s.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
10293
|
+
function entries(map) {
|
|
10294
|
+
return Array.isArray(map) ? map.map((k) => [k, k]) : Object.entries(map);
|
|
10295
|
+
}
|
|
10296
|
+
function buildRequest(tool, args) {
|
|
10297
|
+
const space = tool.route.indexOf(" ");
|
|
10298
|
+
const method = tool.route.slice(0, space);
|
|
10299
|
+
const template = tool.route.slice(space + 1);
|
|
10300
|
+
const used = /* @__PURE__ */ new Set();
|
|
10301
|
+
const path = template.replace(/\{([A-Za-z0-9_]+)\}/g, (_m, name) => {
|
|
10302
|
+
const arg = camelToSnake(name);
|
|
10303
|
+
const value = args[arg];
|
|
10304
|
+
if (value === void 0 || value === null || value === "") {
|
|
10305
|
+
throw new Error(`Validation error: \`${arg}\` is required.`);
|
|
9259
10306
|
}
|
|
10307
|
+
used.add(arg);
|
|
10308
|
+
return encodeURIComponent(String(value));
|
|
9260
10309
|
});
|
|
10310
|
+
const params = {};
|
|
10311
|
+
for (const [arg, wire] of entries(tool.query ?? [])) {
|
|
10312
|
+
used.add(arg);
|
|
10313
|
+
const v = args[arg];
|
|
10314
|
+
if (v === void 0 || v === null) continue;
|
|
10315
|
+
params[wire] = Array.isArray(v) ? v.join(",") : v;
|
|
10316
|
+
}
|
|
10317
|
+
let body = void 0;
|
|
10318
|
+
if (tool.body === "rest") {
|
|
10319
|
+
const rest = {};
|
|
10320
|
+
for (const [k, v] of Object.entries(args)) if (!used.has(k) && v !== void 0) rest[k] = v;
|
|
10321
|
+
body = rest;
|
|
10322
|
+
} else if (tool.body) {
|
|
10323
|
+
const picked = {};
|
|
10324
|
+
for (const [arg, wire] of entries(tool.body)) {
|
|
10325
|
+
if (args[arg] !== void 0) picked[wire] = args[arg];
|
|
10326
|
+
}
|
|
10327
|
+
body = picked;
|
|
10328
|
+
} else if (method === "POST" || method === "PUT" || method === "PATCH") {
|
|
10329
|
+
body = {};
|
|
10330
|
+
}
|
|
10331
|
+
return { method, path, params, body };
|
|
9261
10332
|
}
|
|
9262
|
-
function
|
|
10333
|
+
function runGroupTool(tool, ctx, args) {
|
|
10334
|
+
if (tool.handler) return tool.handler(ctx, args);
|
|
10335
|
+
return runTool(async () => {
|
|
10336
|
+
const req = buildRequest(tool, args);
|
|
10337
|
+
return apiJson(ctx.getToken, ctx.baseUrl, req.method, req.path, {
|
|
10338
|
+
params: req.params,
|
|
10339
|
+
...req.body !== void 0 ? { body: req.body } : {}
|
|
10340
|
+
});
|
|
10341
|
+
});
|
|
10342
|
+
}
|
|
10343
|
+
function registerGroup(server, group, getToken, baseUrl) {
|
|
10344
|
+
const ctx = { getToken, baseUrl };
|
|
10345
|
+
for (const tool of group.tools) {
|
|
10346
|
+
server.registerTool(
|
|
10347
|
+
tool.name,
|
|
10348
|
+
{
|
|
10349
|
+
title: tool.title,
|
|
10350
|
+
description: tool.description,
|
|
10351
|
+
inputSchema: tool.inputSchema,
|
|
10352
|
+
annotations: { title: tool.title, ...tool.annotations }
|
|
10353
|
+
},
|
|
10354
|
+
async (args) => runGroupTool(tool, ctx, args ?? {})
|
|
10355
|
+
);
|
|
10356
|
+
}
|
|
10357
|
+
}
|
|
10358
|
+
function probeGroup(group, token, baseUrl) {
|
|
10359
|
+
return probeAccessState(token, baseUrl, group.probe.path, () => true, group.probe.params ?? {});
|
|
10360
|
+
}
|
|
10361
|
+
function describe(parts) {
|
|
9263
10362
|
return [
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
"
|
|
9268
|
-
|
|
9269
|
-
|
|
10363
|
+
parts.what,
|
|
10364
|
+
`USE WHEN: ${parts.use}`,
|
|
10365
|
+
...parts.not ? [`NOT FOR: ${parts.not}`] : [],
|
|
10366
|
+
"",
|
|
10367
|
+
`ARGS: ${parts.args ?? "none."}`,
|
|
10368
|
+
`RETURNS: ${parts.returns}`,
|
|
10369
|
+
...parts.errors ? [`ERRORS: ${parts.errors}`] : []
|
|
10370
|
+
].join("\n");
|
|
10371
|
+
}
|
|
10372
|
+
var SCOPES = [
|
|
10373
|
+
"extract",
|
|
10374
|
+
"read",
|
|
10375
|
+
"write",
|
|
10376
|
+
"operations",
|
|
10377
|
+
"billing",
|
|
10378
|
+
"delivery",
|
|
10379
|
+
"usage",
|
|
10380
|
+
"records_write"
|
|
10381
|
+
];
|
|
10382
|
+
var LIST_KEYS = describe({
|
|
10383
|
+
what: "List the workspace's API keys: name, scopes, masked prefix, active state, last use, creation, revocation and expiry. Never returns a secret. A workspace owner sees every key; anyone else sees only the keys they created.",
|
|
10384
|
+
use: "auditing which keys exist, finding the id of a key to revoke, or checking a key's scopes and expiry.",
|
|
10385
|
+
not: "creating a key (talonic_create_api_key); the workspace's credits and limits (talonic_get_account).",
|
|
10386
|
+
returns: "{ data[] { id, name, scopes[], masked_prefix, is_active, last_used, created_at, revoked_at, expires_at } }."
|
|
10387
|
+
});
|
|
10388
|
+
var CREATE_KEY = describe({
|
|
10389
|
+
what: "Create a new API key for this workspace. The secret is returned ONCE in `key` and can never be read again: hand it to the user straight away, tell them to store it, and never repeat it, summarize it, write it to a file or log, or pass it to another tool. A new key can only carry scopes the calling credential already holds (a key cannot widen its own access); billing, usage and records_write are granted only by an owner in the app. Ask the user before creating a key.",
|
|
10390
|
+
use: "the user asks for a new or narrower key, e.g. a read-only key for a dashboard, or a key that expires.",
|
|
10391
|
+
not: "rotating by revoking (talonic_revoke_api_key, after the new key is in place).",
|
|
10392
|
+
args: "`name` (1-255 characters, shown in listings), `scopes` (optional subset of extract, read, write, operations, billing, delivery, usage, records_write; omitted = the calling credential's own scopes), `expires_at` (optional ISO-8601 in the future; enterprise workspaces cap keys at 90 days).",
|
|
10393
|
+
returns: "{ id, name, key (the secret, shown once), masked_prefix, scopes[], created_at, expires_at, warning }.",
|
|
10394
|
+
errors: "403 scope_not_grantable when a requested scope is not held by the calling credential; 403 when key creation is managed by Talonic for this workspace."
|
|
10395
|
+
});
|
|
10396
|
+
var REVOKE_KEY = describe({
|
|
10397
|
+
what: "Revoke an API key: it stops working at once and cannot be turned back on. Anything still using it fails from the next request. Confirm the key (name, masked prefix) with the user before calling. A workspace owner can revoke any key; anyone else only their own.",
|
|
10398
|
+
use: "the user asks to revoke, rotate out or disable a key.",
|
|
10399
|
+
not: "listing keys (talonic_list_api_keys).",
|
|
10400
|
+
args: "`key_id` (UUID from talonic_list_api_keys).",
|
|
10401
|
+
returns: "{ id, revoked: true }.",
|
|
10402
|
+
errors: "404 key_not_found when no active key with that id is yours to revoke."
|
|
10403
|
+
});
|
|
10404
|
+
var GET_ACCOUNT = describe({
|
|
10405
|
+
what: "The workspace's account snapshot: plan (`tier`), status, credit balance (EUR) with any monthly allowance, daily request limits per area and today's usage against them.",
|
|
10406
|
+
use: "checking plan, limits or today's request counts, e.g. before a large batch or after a 429.",
|
|
10407
|
+
not: "credit spend by function (talonic_get_usage); buying credits (talonic_get_billing_upgrade_link).",
|
|
10408
|
+
returns: "{ tier, status, email_domain, created_at, credits { balance, currency, monthly_allowance, tier_resets_at }, daily_limits { extract, platform, ingest, operations }, usage_today { extract, platform, ingest, operations } }."
|
|
10409
|
+
});
|
|
10410
|
+
var LIST_WEBHOOKS = describe({
|
|
10411
|
+
what: "List the workspace's webhook configurations: target URL, subscribed event types, active state, the source they are limited to (if any). Never returns signing secrets.",
|
|
10412
|
+
use: "checking where events are sent, or finding a webhook id to change or delete.",
|
|
10413
|
+
not: "the events themselves (talonic_list_events); valid event type names (talonic_list_webhook_event_types).",
|
|
10414
|
+
returns: "{ data[] { id, url, events[], is_active, source_connection_id, created_at, updated_at } }."
|
|
10415
|
+
});
|
|
10416
|
+
var GET_WEBHOOK = describe({
|
|
10417
|
+
what: "One webhook configuration by id.",
|
|
10418
|
+
use: "reading one webhook's URL, events and state before changing it.",
|
|
10419
|
+
not: "listing every webhook (talonic_list_webhooks).",
|
|
10420
|
+
args: "`id` (UUID).",
|
|
10421
|
+
returns: "{ id, url, events[], is_active, source_connection_id, created_at, updated_at }."
|
|
10422
|
+
});
|
|
10423
|
+
var CREATE_WEBHOOK = describe({
|
|
10424
|
+
what: "Create a webhook: Talonic POSTs the chosen events to `url`, signed with `secret` when one is given (X-Talonic-Signature: sha256=<hex> over the raw body). Ask the user for the URL and confirm it before calling.",
|
|
10425
|
+
use: "the user wants Talonic to notify their system, e.g. when an extraction completes or fails.",
|
|
10426
|
+
not: "changing an existing webhook (talonic_update_webhook).",
|
|
10427
|
+
args: "`url` (https URL that accepts POST), `events` (event types, default extraction.complete and extraction.failed; see talonic_list_webhook_event_types), `secret` (optional signing secret the receiver verifies), `source_connection_id` (optional: only events of that source), `is_active` (default true).",
|
|
10428
|
+
returns: "{ id, url, events[], is_active, source_connection_id, created_at, updated_at }."
|
|
10429
|
+
});
|
|
10430
|
+
var UPDATE_WEBHOOK = describe({
|
|
10431
|
+
what: "Change a webhook: its URL, events, signing secret or active state. Only the fields sent change. Setting is_active false pauses deliveries without deleting the webhook.",
|
|
10432
|
+
use: "pointing a webhook elsewhere, changing its events, rotating its secret, or pausing / resuming it.",
|
|
10433
|
+
not: "removing it for good (talonic_delete_webhook).",
|
|
10434
|
+
args: "`id` (UUID), and any of `url`, `events`, `secret`, `is_active`.",
|
|
10435
|
+
returns: "{ id, url, events[], is_active, source_connection_id, created_at, updated_at }."
|
|
10436
|
+
});
|
|
10437
|
+
var DELETE_WEBHOOK = describe({
|
|
10438
|
+
what: "Delete a webhook configuration for good: its target stops receiving events at once. Confirm with the user first; to pause instead, use talonic_update_webhook with is_active false.",
|
|
10439
|
+
use: "the user asks to remove a webhook.",
|
|
10440
|
+
not: "pausing (talonic_update_webhook).",
|
|
10441
|
+
args: "`id` (UUID).",
|
|
10442
|
+
returns: "{ deleted: true, id }."
|
|
10443
|
+
});
|
|
10444
|
+
var EVENT_TYPES = describe({
|
|
10445
|
+
what: "The event types a webhook can subscribe to, with what each one means. There is no re-delivery of a past webhook call: to catch up on events a receiver missed, read them with talonic_list_events from a saved cursor.",
|
|
10446
|
+
use: "choosing `events` for talonic_create_webhook or talonic_update_webhook.",
|
|
10447
|
+
not: "the events that happened (talonic_list_events).",
|
|
10448
|
+
returns: "{ data[] { event, description } }."
|
|
10449
|
+
});
|
|
10450
|
+
var UPGRADE_LINK = describe({
|
|
10451
|
+
what: "A link where a person buys credits. This tool never buys anything: it returns a URL for the user to open and pay. Present the link and tell the user a human must complete the purchase; credits arrive seconds after payment. A workspace billed through a marketplace gets the marketplace page instead.",
|
|
10452
|
+
use: "the workspace ran out of credits (HTTP 402) or the user asks how to buy more.",
|
|
10453
|
+
not: "checking the balance (talonic_get_balance) or prices (talonic_get_pricing).",
|
|
10454
|
+
args: "`pack` (optional: 10, 50, 250 or 1000 EUR; default 50).",
|
|
10455
|
+
returns: "{ url, provider (stripe | dashboard | aws_marketplace), requires_human: true, pack?, message }."
|
|
10456
|
+
});
|
|
10457
|
+
var webhookFields = {
|
|
10458
|
+
url: z.string().url().describe("Receiver URL (https) that accepts POST."),
|
|
10459
|
+
events: z.array(z.string().min(1)).min(1).describe("Event types to send."),
|
|
10460
|
+
secret: z.string().min(1).describe("Signing secret the receiver verifies."),
|
|
10461
|
+
is_active: z.boolean().describe("false pauses deliveries.")
|
|
10462
|
+
};
|
|
10463
|
+
var adminGroup = {
|
|
10464
|
+
key: "admin",
|
|
10465
|
+
label: "Workspace administration",
|
|
10466
|
+
docsSlug: "admin-tools",
|
|
10467
|
+
probe: { path: "/v1/account/keys" },
|
|
10468
|
+
tools: [
|
|
10469
|
+
{
|
|
10470
|
+
name: "talonic_list_api_keys",
|
|
10471
|
+
title: "List API keys",
|
|
10472
|
+
description: LIST_KEYS,
|
|
10473
|
+
route: "GET /v1/account/keys",
|
|
10474
|
+
inputSchema: {},
|
|
10475
|
+
annotations: READ
|
|
10476
|
+
},
|
|
10477
|
+
{
|
|
10478
|
+
name: "talonic_create_api_key",
|
|
10479
|
+
title: "Create an API key",
|
|
10480
|
+
description: CREATE_KEY,
|
|
10481
|
+
route: "POST /v1/account/keys",
|
|
10482
|
+
inputSchema: {
|
|
10483
|
+
name: z.string().min(1).max(255).describe("Label shown in listings."),
|
|
10484
|
+
scopes: z.array(z.enum(SCOPES)).min(1).optional().describe("Subset of the calling credential's scopes; omitted = the same scopes."),
|
|
10485
|
+
expires_at: z.string().optional().describe("When the key stops working, ISO-8601 in the future.")
|
|
10486
|
+
},
|
|
10487
|
+
annotations: write9(false),
|
|
10488
|
+
body: ["name", "scopes", "expires_at"]
|
|
10489
|
+
},
|
|
10490
|
+
{
|
|
10491
|
+
name: "talonic_revoke_api_key",
|
|
10492
|
+
title: "Revoke an API key",
|
|
10493
|
+
description: REVOKE_KEY,
|
|
10494
|
+
route: "DELETE /v1/account/keys/{keyId}",
|
|
10495
|
+
inputSchema: { key_id: zUuid().describe("The key, from talonic_list_api_keys.") },
|
|
10496
|
+
annotations: write9(true, true)
|
|
10497
|
+
},
|
|
10498
|
+
{
|
|
10499
|
+
name: "talonic_get_account",
|
|
10500
|
+
title: "Account snapshot",
|
|
10501
|
+
description: GET_ACCOUNT,
|
|
10502
|
+
route: "GET /v1/account",
|
|
10503
|
+
inputSchema: {},
|
|
10504
|
+
annotations: READ
|
|
10505
|
+
},
|
|
10506
|
+
{
|
|
10507
|
+
name: "talonic_list_webhooks",
|
|
10508
|
+
title: "List webhooks",
|
|
10509
|
+
description: LIST_WEBHOOKS,
|
|
10510
|
+
route: "GET /v1/webhooks",
|
|
10511
|
+
inputSchema: {},
|
|
10512
|
+
annotations: READ
|
|
10513
|
+
},
|
|
10514
|
+
{
|
|
10515
|
+
name: "talonic_get_webhook",
|
|
10516
|
+
title: "One webhook",
|
|
10517
|
+
description: GET_WEBHOOK,
|
|
10518
|
+
route: "GET /v1/webhooks/{id}",
|
|
10519
|
+
inputSchema: { id: zUuid().describe("The webhook id.") },
|
|
10520
|
+
annotations: READ
|
|
10521
|
+
},
|
|
10522
|
+
{
|
|
10523
|
+
name: "talonic_create_webhook",
|
|
10524
|
+
title: "Create a webhook",
|
|
10525
|
+
description: CREATE_WEBHOOK,
|
|
10526
|
+
route: "POST /v1/webhooks",
|
|
10527
|
+
inputSchema: {
|
|
10528
|
+
url: webhookFields.url,
|
|
10529
|
+
events: webhookFields.events.optional(),
|
|
10530
|
+
secret: webhookFields.secret.optional(),
|
|
10531
|
+
source_connection_id: zUuid().optional().describe("Only events of this source."),
|
|
10532
|
+
is_active: webhookFields.is_active.optional()
|
|
10533
|
+
},
|
|
10534
|
+
annotations: write9(false),
|
|
10535
|
+
body: ["url", "events", "secret", "source_connection_id", "is_active"]
|
|
10536
|
+
},
|
|
10537
|
+
{
|
|
10538
|
+
name: "talonic_update_webhook",
|
|
10539
|
+
title: "Change a webhook",
|
|
10540
|
+
description: UPDATE_WEBHOOK,
|
|
10541
|
+
route: "PATCH /v1/webhooks/{id}",
|
|
10542
|
+
inputSchema: {
|
|
10543
|
+
id: zUuid().describe("The webhook id."),
|
|
10544
|
+
url: webhookFields.url.optional(),
|
|
10545
|
+
events: webhookFields.events.optional(),
|
|
10546
|
+
secret: webhookFields.secret.optional(),
|
|
10547
|
+
is_active: webhookFields.is_active.optional()
|
|
10548
|
+
},
|
|
10549
|
+
annotations: write9(true),
|
|
10550
|
+
body: ["url", "events", "secret", "is_active"]
|
|
10551
|
+
},
|
|
10552
|
+
{
|
|
10553
|
+
name: "talonic_delete_webhook",
|
|
10554
|
+
title: "Delete a webhook",
|
|
10555
|
+
description: DELETE_WEBHOOK,
|
|
10556
|
+
route: "DELETE /v1/webhooks/{id}",
|
|
10557
|
+
inputSchema: { id: zUuid().describe("The webhook id.") },
|
|
10558
|
+
annotations: write9(true, true)
|
|
10559
|
+
},
|
|
10560
|
+
{
|
|
10561
|
+
name: "talonic_list_webhook_event_types",
|
|
10562
|
+
title: "Webhook event types",
|
|
10563
|
+
description: EVENT_TYPES,
|
|
10564
|
+
route: "GET /v1/webhooks/events",
|
|
10565
|
+
inputSchema: {},
|
|
10566
|
+
annotations: READ
|
|
10567
|
+
},
|
|
10568
|
+
{
|
|
10569
|
+
name: "talonic_get_billing_upgrade_link",
|
|
10570
|
+
title: "Buy-credits link",
|
|
10571
|
+
description: UPGRADE_LINK,
|
|
10572
|
+
route: "GET /v1/billing/upgrade-link",
|
|
10573
|
+
inputSchema: {
|
|
10574
|
+
pack: z.enum(["10", "50", "250", "1000"]).optional().describe("Credit pack in EUR.")
|
|
10575
|
+
},
|
|
10576
|
+
annotations: READ,
|
|
10577
|
+
query: ["pack"]
|
|
10578
|
+
}
|
|
10579
|
+
]
|
|
10580
|
+
};
|
|
10581
|
+
var TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/i;
|
|
10582
|
+
var QUERY_ID_RE = /^[a-z][a-z0-9_]{0,63}$/;
|
|
10583
|
+
var OPS = [
|
|
10584
|
+
"eq",
|
|
10585
|
+
"neq",
|
|
10586
|
+
"in",
|
|
10587
|
+
"not_in",
|
|
10588
|
+
"is_null",
|
|
10589
|
+
"not_null",
|
|
10590
|
+
"gt",
|
|
10591
|
+
"gte",
|
|
10592
|
+
"lt",
|
|
10593
|
+
"lte",
|
|
10594
|
+
"contains_any",
|
|
10595
|
+
"contains_all"
|
|
10596
|
+
];
|
|
10597
|
+
var CATALOG = describe({
|
|
10598
|
+
what: "What talonic_aggregate can count in this workspace: every dataset with its fields (type, groupable, the filter operators it takes, whether it is a cost field), the measures, the group-by time buckets, the document scope keys, the limits (window days, queries per request, list values, buckets) and whether this workspace may read cost fields. Reads no data and is free.",
|
|
10599
|
+
use: "before the first talonic_aggregate call of a conversation, or when talonic_aggregate answered 400 invalid_aggregate.",
|
|
10600
|
+
not: "the numbers themselves (talonic_aggregate).",
|
|
10601
|
+
returns: "{ datasets[] { name, description, kind entity|event, document_scope, defaults[], fields[] { name, description, type, groupable, cost, ops[] } }, measures, group_by { time[], max, max_buckets }, scope_keys[], limits { max_window_days, max_queries, max_list_values, statement_timeout_ms, concurrency }, cost_visible }."
|
|
10602
|
+
});
|
|
10603
|
+
var AGGREGATE = describe({
|
|
10604
|
+
what: "Workspace metrics in one request: counts, sums, averages, minimums, maximums, medians and percentiles over a time window, optionally grouped by up to three fields or by UTC hour / day. Returns numbers only, never rows. Counts only documents this credential may see.",
|
|
10605
|
+
use: "a monitoring or dashboard question: documents received or failed in a window, documents missing a value, app verdicts by state, average or median cost per document, deliveries by outcome.",
|
|
10606
|
+
not: "reading documents or values (talonic_search, talonic_field_values); credit spend by function (talonic_get_usage). Call talonic_aggregate_catalog first for the dataset and field names.",
|
|
10607
|
+
args: "`from`, `to` ISO-8601 WITH an offset (e.g. 2026-11-05T12:00:00Z), half-open [from, to), at most the catalog's max_window_days (31 by default). `scope` (optional, applies to every document query): document_ids, tags / system_tags {any|all}, source_connection_ids, document_types (ids or names), client_batch_ids, roots_only, attachments_only. `queries[]` (1 to the catalog's max_queries, 20 by default): `id` (lowercase letters, digits, underscore; unique), `dataset`, `measure` (one name, or a list), `of` (the numeric field for sum / avg / min / max / median / pNN), `where[]` {field, op, value}, `group_by[]`.",
|
|
10608
|
+
returns: "{ window { from, to }, as_of, results { <id>: { dataset, kind, value | values (+ n) | groups[] { key, value | values }, groups_total } } }. A count over no rows is 0; an average, minimum or percentile over no rows is null. Cost fields are in US dollars.",
|
|
10609
|
+
errors: "400 invalid_aggregate names the allowed datasets / fields / measures; 403 cost_not_visible for cost fields when the workspace may not see costs; 422 aggregate_timeout names the dataset (narrow the window or scope); 429 another aggregate of this workspace is running (wait, then retry once)."
|
|
10610
|
+
});
|
|
10611
|
+
var whereSchema = z.object({
|
|
10612
|
+
field: z.string().min(1).describe("A field of the query's dataset (talonic_aggregate_catalog)."),
|
|
10613
|
+
op: z.enum(OPS).describe("Filter operator; the catalog lists which ones each field takes."),
|
|
10614
|
+
value: z.unknown().optional().describe("Omitted for is_null / not_null; a list for in, not_in, contains_any, contains_all.")
|
|
10615
|
+
});
|
|
10616
|
+
var querySchema = z.object({
|
|
10617
|
+
id: z.string().describe("Result key: starts with a lowercase letter; letters, digits, underscore."),
|
|
10618
|
+
dataset: z.string().min(1).describe("A catalog dataset, e.g. documents, app_verdicts, deliveries."),
|
|
10619
|
+
measure: z.union([z.string(), z.array(z.string()).min(1)]).describe("One measure (returns value) or a list (returns values plus n)."),
|
|
10620
|
+
of: z.string().optional().describe("Numeric field for sum, avg, min, max, median, p1-p99."),
|
|
10621
|
+
where: z.array(whereSchema).max(50).optional(),
|
|
10622
|
+
group_by: z.array(z.string()).optional().describe("Up to 3 groupable fields, or hour / day (UTC).")
|
|
10623
|
+
});
|
|
10624
|
+
var aggregateInputSchema = {
|
|
10625
|
+
from: z.string().describe("Window start, inclusive, ISO-8601 with offset."),
|
|
10626
|
+
to: z.string().describe("Window end, exclusive, ISO-8601 with offset."),
|
|
10627
|
+
scope: z.record(z.string(), z.unknown()).optional().describe(
|
|
10628
|
+
"Document selectors applied to every query: document_ids, tags, system_tags, source_connection_ids, document_types, client_batch_ids, roots_only, attachments_only."
|
|
10629
|
+
),
|
|
10630
|
+
queries: z.array(querySchema).min(1).describe("The numbers to compute; each result is keyed by its id.")
|
|
10631
|
+
};
|
|
10632
|
+
function checkAggregateArgs(args) {
|
|
10633
|
+
for (const key2 of ["from", "to"]) {
|
|
10634
|
+
const v = args[key2];
|
|
10635
|
+
if (typeof v !== "string" || !TIMESTAMP_RE.test(v)) {
|
|
10636
|
+
return `\`${key2}\` must be an ISO-8601 timestamp with an offset, e.g. 2026-11-05T12:00:00Z.`;
|
|
10637
|
+
}
|
|
10638
|
+
}
|
|
10639
|
+
if (Date.parse(args["to"]) <= Date.parse(args["from"])) {
|
|
10640
|
+
return "`to` must be after `from` (the window is [from, to)).";
|
|
10641
|
+
}
|
|
10642
|
+
const queries = args["queries"];
|
|
10643
|
+
if (!Array.isArray(queries) || queries.length === 0) return "`queries` needs at least one query.";
|
|
10644
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10645
|
+
for (const q of queries) {
|
|
10646
|
+
if (typeof q?.id !== "string" || !QUERY_ID_RE.test(q.id)) {
|
|
10647
|
+
return `query id ${JSON.stringify(q?.id)} must start with a lowercase letter and hold only lowercase letters, digits and underscores.`;
|
|
10648
|
+
}
|
|
10649
|
+
if (seen.has(q.id)) return `query id "${q.id}" is used twice; each result needs its own id.`;
|
|
10650
|
+
seen.add(q.id);
|
|
10651
|
+
}
|
|
10652
|
+
return null;
|
|
10653
|
+
}
|
|
10654
|
+
var aggregateTool = {
|
|
10655
|
+
name: "talonic_aggregate",
|
|
10656
|
+
title: "Workspace metrics",
|
|
10657
|
+
description: AGGREGATE,
|
|
10658
|
+
route: "POST /v1/aggregate",
|
|
10659
|
+
inputSchema: aggregateInputSchema,
|
|
10660
|
+
annotations: READ,
|
|
10661
|
+
body: ["from", "to", "scope", "queries"],
|
|
10662
|
+
handler: (ctx, args) => {
|
|
10663
|
+
const refusal = checkAggregateArgs(args);
|
|
10664
|
+
if (refusal) return Promise.resolve(validationError(refusal));
|
|
10665
|
+
return runGroupTool({ ...aggregateTool, handler: void 0 }, ctx, args);
|
|
10666
|
+
}
|
|
10667
|
+
};
|
|
10668
|
+
var aggregateGroup = {
|
|
10669
|
+
key: "aggregate",
|
|
10670
|
+
label: "Workspace metrics",
|
|
10671
|
+
docsSlug: "aggregate-tools",
|
|
10672
|
+
probe: { path: "/v1/aggregate/catalog" },
|
|
10673
|
+
tools: [
|
|
10674
|
+
{
|
|
10675
|
+
name: "talonic_aggregate_catalog",
|
|
10676
|
+
title: "What workspace metrics can count",
|
|
10677
|
+
description: CATALOG,
|
|
10678
|
+
route: "GET /v1/aggregate/catalog",
|
|
10679
|
+
inputSchema: {},
|
|
10680
|
+
annotations: READ
|
|
10681
|
+
},
|
|
10682
|
+
aggregateTool
|
|
10683
|
+
]
|
|
10684
|
+
};
|
|
10685
|
+
var COMPLIANCE_EXPORT_MAX_BYTES = 8 * 1024 * 1024;
|
|
10686
|
+
var docIds = (min, max, what) => z.array(zUuid()).min(min).max(max).describe(what);
|
|
10687
|
+
var pageArgs2 = {
|
|
10688
|
+
status: z.enum(["processing", "waiting", "completed", "error"]).optional().describe("Only evaluations with this status (an interrupted one shows error)."),
|
|
10689
|
+
limit: z.number().int().min(1).max(500).optional().describe("Page size; any of status / limit / offset asks for one page."),
|
|
10690
|
+
offset: z.number().int().min(0).optional().describe("Rows to skip, for paging.")
|
|
10691
|
+
};
|
|
10692
|
+
var epoch = z.number().int().min(1).describe("The execution_epoch talonic_compliance_claim_task returned.");
|
|
10693
|
+
async function handleComplianceExport(ctx, args, maxBytes = COMPLIANCE_EXPORT_MAX_BYTES) {
|
|
10694
|
+
const format = args["format"] ?? "xlsx";
|
|
10695
|
+
const params = { format, ...args["issues_only"] ? { issues: "true" } : {} };
|
|
10696
|
+
const path = "/v1/compliance/export";
|
|
10697
|
+
try {
|
|
10698
|
+
const file = await apiBinary(ctx.getToken, ctx.baseUrl, path, { params, maxBytes });
|
|
10699
|
+
const filename = file.filename ?? `compliance.${format}`;
|
|
10700
|
+
const meta = { filename, mime_type: file.mimeType, size: file.bytes.length, format };
|
|
10701
|
+
return {
|
|
10702
|
+
content: [
|
|
10703
|
+
{ type: "text", text: JSON.stringify(meta) },
|
|
10704
|
+
{
|
|
10705
|
+
type: "resource",
|
|
10706
|
+
resource: {
|
|
10707
|
+
uri: buildUrl(ctx.baseUrl, path, params),
|
|
10708
|
+
mimeType: file.mimeType,
|
|
10709
|
+
blob: file.bytes.toString("base64")
|
|
10710
|
+
}
|
|
10711
|
+
}
|
|
10712
|
+
],
|
|
10713
|
+
structuredContent: meta
|
|
10714
|
+
};
|
|
10715
|
+
} catch (err) {
|
|
10716
|
+
return toolError(err);
|
|
10717
|
+
}
|
|
10718
|
+
}
|
|
10719
|
+
var tools = [
|
|
10720
|
+
// ── Worklist and evidence ────────────────────────────────────────────────
|
|
10721
|
+
{
|
|
10722
|
+
name: "talonic_compliance_issues",
|
|
10723
|
+
title: "Compliance worklist",
|
|
10724
|
+
description: describe({
|
|
10725
|
+
what: "The worklist of failed checks: per document the rules it fails (and, with `unclear`, the rules whose verdict is unclear), with the framework each rule comes from.",
|
|
10726
|
+
use: "'what is not compliant', the starting point before opening one document's evaluation.",
|
|
10727
|
+
not: "the full verdict list with passes (talonic_compliance_list_evaluations); one document's reasons and quotes (talonic_compliance_get_document_evaluation).",
|
|
10728
|
+
args: "`unclear` (also list unclear verdicts).",
|
|
10729
|
+
returns: "{ data[] } one entry per document with its failing rules."
|
|
10730
|
+
}),
|
|
10731
|
+
route: "GET /v1/compliance/issues",
|
|
10732
|
+
inputSchema: {
|
|
10733
|
+
unclear: z.boolean().optional().describe("Also list rules whose verdict is unclear.")
|
|
10734
|
+
},
|
|
10735
|
+
annotations: READ,
|
|
10736
|
+
query: ["unclear"]
|
|
10737
|
+
},
|
|
10738
|
+
{
|
|
10739
|
+
name: "talonic_compliance_get_document_evaluation",
|
|
10740
|
+
title: "One document's compliance evaluation",
|
|
10741
|
+
description: describe({
|
|
10742
|
+
what: "A document's latest evaluation with every result: per rule the verdict (pass, fail, unclear, not_applicable), the reason, the quote from the document it rests on, whether it needs a person's check, and whether the evaluation is outdated.",
|
|
10743
|
+
use: "retrieving the evidence behind a failed check from talonic_compliance_issues, before deciding on a correction.",
|
|
10744
|
+
not: "a document set (talonic_compliance_get_set_evaluation).",
|
|
10745
|
+
args: "`document_id`.",
|
|
10746
|
+
returns: "{ evaluation } with its results; null when the document was never evaluated."
|
|
10747
|
+
}),
|
|
10748
|
+
route: "GET /v1/compliance/evaluations/documents/{documentId}",
|
|
10749
|
+
inputSchema: { document_id: zUuid().describe("The evaluated document.") },
|
|
10750
|
+
annotations: READ
|
|
10751
|
+
},
|
|
10752
|
+
{
|
|
10753
|
+
name: "talonic_compliance_list_evaluations",
|
|
10754
|
+
title: "Compliance evaluations",
|
|
10755
|
+
description: describe({
|
|
10756
|
+
what: "The latest evaluation of every document on the Evaluations list. Without paging arguments the whole list; with any of status / limit / offset one page with total and has_more.",
|
|
10757
|
+
use: "an overview of every evaluated document, or finding documents whose evaluation errored or is still running.",
|
|
10758
|
+
not: "only the failures (talonic_compliance_issues); counts only (talonic_compliance_evaluation_status).",
|
|
10759
|
+
args: "`status` processing|waiting|completed|error, `limit` 1-500, `offset`.",
|
|
10760
|
+
returns: "{ data[] } or a page { data[], total, has_more }."
|
|
10761
|
+
}),
|
|
10762
|
+
route: "GET /v1/compliance/evaluations",
|
|
10763
|
+
inputSchema: pageArgs2,
|
|
10764
|
+
annotations: READ,
|
|
10765
|
+
query: ["status", "limit", "offset"]
|
|
10766
|
+
},
|
|
10767
|
+
{
|
|
10768
|
+
name: "talonic_compliance_evaluation_status",
|
|
10769
|
+
title: "Compliance evaluation counts",
|
|
10770
|
+
description: describe({
|
|
10771
|
+
what: "Counts over the latest evaluations: processing, completed, error, outdated and failing.",
|
|
10772
|
+
use: "the headline ('how many documents fail'), or waiting until evaluations started with talonic_compliance_evaluate finish.",
|
|
10773
|
+
returns: "{ processing, completed, error, outdated, failing }."
|
|
10774
|
+
}),
|
|
10775
|
+
route: "GET /v1/compliance/evaluations/status",
|
|
10776
|
+
inputSchema: {},
|
|
10777
|
+
annotations: READ
|
|
10778
|
+
},
|
|
10779
|
+
{
|
|
10780
|
+
name: "talonic_compliance_export",
|
|
10781
|
+
title: "Export compliance verdicts",
|
|
10782
|
+
description: describe({
|
|
10783
|
+
what: `Download every verdict of the evaluated documents and document sets as a file (one row per rule and document or set: framework, rule, obligation, verdict, reason, quote, evaluated at, outdated), up to ${COMPLIANCE_EXPORT_MAX_BYTES / (1024 * 1024)} MB.`,
|
|
10784
|
+
use: "the user wants the results as a spreadsheet to share or file.",
|
|
10785
|
+
not: "reading results in the conversation (talonic_compliance_issues, talonic_compliance_get_document_evaluation).",
|
|
10786
|
+
args: "`format` xlsx (default) | csv, `issues_only` (only failed and unclear verdicts of the sets).",
|
|
10787
|
+
returns: "a text item { filename, mime_type, size, format } and a resource item { uri, mimeType, blob } with the file."
|
|
10788
|
+
}),
|
|
10789
|
+
route: "GET /v1/compliance/export",
|
|
10790
|
+
inputSchema: {
|
|
10791
|
+
format: z.enum(["xlsx", "csv"]).optional().describe("File format (default xlsx)."),
|
|
10792
|
+
issues_only: z.boolean().optional().describe("Only failed and unclear verdicts of the sets.")
|
|
10793
|
+
},
|
|
10794
|
+
annotations: READ,
|
|
10795
|
+
handler: (ctx, args) => handleComplianceExport(ctx, args)
|
|
10796
|
+
},
|
|
10797
|
+
// ── Evaluating ───────────────────────────────────────────────────────────
|
|
10798
|
+
{
|
|
10799
|
+
name: "talonic_compliance_evaluate",
|
|
10800
|
+
title: "Evaluate documents for compliance",
|
|
10801
|
+
description: describe({
|
|
10802
|
+
what: "Evaluate documents against every framework that is ON. Runs in the background; poll talonic_compliance_evaluation_status or talonic_compliance_get_document_evaluation.",
|
|
10803
|
+
use: "a document changed or a framework was switched ON and its verdicts are outdated; or after a correction, to check it took effect.",
|
|
10804
|
+
not: "documents not yet on the Evaluations list (talonic_compliance_add_documents adds and evaluates them).",
|
|
10805
|
+
args: "`document_ids` (1-500).",
|
|
10806
|
+
returns: "{ data[] } one started evaluation per document.",
|
|
10807
|
+
errors: "403 when the app is switched off for the workspace."
|
|
10808
|
+
}),
|
|
10809
|
+
route: "POST /v1/compliance/evaluations",
|
|
10810
|
+
inputSchema: { document_ids: docIds(1, 500, "Documents to evaluate.") },
|
|
10811
|
+
annotations: write9(false),
|
|
10812
|
+
body: ["document_ids"]
|
|
10813
|
+
},
|
|
10814
|
+
{
|
|
10815
|
+
name: "talonic_compliance_evaluate_all",
|
|
10816
|
+
title: "Evaluate every document that needs it",
|
|
10817
|
+
description: describe({
|
|
10818
|
+
what: "Evaluate every listed document whose evaluation is missing or outdated, oldest first. Run with dry_run first to see how many.",
|
|
10819
|
+
use: "bringing the whole list up to date after frameworks changed.",
|
|
10820
|
+
args: "`dry_run` (only count), `limit` 1-500 (the rest follow on the next call).",
|
|
10821
|
+
returns: "How many documents need it and how many were started."
|
|
10822
|
+
}),
|
|
10823
|
+
route: "POST /v1/compliance/evaluations/all",
|
|
10824
|
+
inputSchema: {
|
|
10825
|
+
dry_run: z.boolean().optional().describe("Only report how many would be evaluated."),
|
|
10826
|
+
limit: z.number().int().min(1).max(500).optional().describe("Evaluate at most this many.")
|
|
10827
|
+
},
|
|
10828
|
+
annotations: write9(false),
|
|
10829
|
+
body: ["dry_run", "limit"]
|
|
10830
|
+
},
|
|
10831
|
+
{
|
|
10832
|
+
name: "talonic_compliance_add_documents",
|
|
10833
|
+
title: "Add documents to compliance evaluations",
|
|
10834
|
+
description: describe({
|
|
10835
|
+
what: "Put workspace documents on the Evaluations list and evaluate them against the frameworks that are ON.",
|
|
10836
|
+
use: "the user wants documents checked that are not on the list yet.",
|
|
10837
|
+
args: "`document_ids` (1-500).",
|
|
10838
|
+
returns: "The documents added and the evaluations started."
|
|
10839
|
+
}),
|
|
10840
|
+
route: "POST /v1/compliance/evaluations/documents",
|
|
10841
|
+
inputSchema: { document_ids: docIds(1, 500, "Documents to add and evaluate.") },
|
|
10842
|
+
annotations: write9(true),
|
|
10843
|
+
body: ["document_ids"]
|
|
10844
|
+
},
|
|
10845
|
+
{
|
|
10846
|
+
name: "talonic_compliance_remove_document",
|
|
10847
|
+
title: "Take a document off the compliance list",
|
|
10848
|
+
description: describe({
|
|
10849
|
+
what: "Take a document off the Evaluations list together with its evaluations. The document itself stays in the workspace; adding it again re-evaluates it.",
|
|
10850
|
+
use: "a document was put on the list by mistake or no longer needs checking. Ask the user first.",
|
|
10851
|
+
args: "`document_id`.",
|
|
10852
|
+
returns: "Confirmation of the removal."
|
|
10853
|
+
}),
|
|
10854
|
+
route: "DELETE /v1/compliance/evaluations/documents/{documentId}",
|
|
10855
|
+
inputSchema: { document_id: zUuid().describe("The document to take off the list.") },
|
|
10856
|
+
annotations: write9(true, true)
|
|
10857
|
+
},
|
|
10858
|
+
// ── Frameworks ───────────────────────────────────────────────────────────
|
|
10859
|
+
{
|
|
10860
|
+
name: "talonic_compliance_list_frameworks",
|
|
10861
|
+
title: "Compliance frameworks",
|
|
10862
|
+
description: describe({
|
|
10863
|
+
what: "The frameworks (regulations, policies, contract standards held as workspace documents) with their status, whether each is ON, and their rule counts.",
|
|
10864
|
+
use: "which rules documents are checked against, or finding a framework's document_id.",
|
|
10865
|
+
not: "the rules themselves (talonic_compliance_framework_rules).",
|
|
10866
|
+
returns: "{ data[] } frameworks with document_id, name, status, active, rule counts."
|
|
10867
|
+
}),
|
|
10868
|
+
route: "GET /v1/compliance/frameworks",
|
|
10869
|
+
inputSchema: {},
|
|
10870
|
+
annotations: READ
|
|
10871
|
+
},
|
|
10872
|
+
{
|
|
10873
|
+
name: "talonic_compliance_framework_rules",
|
|
10874
|
+
title: "A framework's rules",
|
|
10875
|
+
description: describe({
|
|
10876
|
+
what: "The rules of one framework: code, text, obligation, section, what it applies to and its condition.",
|
|
10877
|
+
use: "explaining a failed verdict's rule, or picking rule ids for a rule set.",
|
|
10878
|
+
args: "`document_id` (the framework's document).",
|
|
10879
|
+
returns: "{ data[] } rules with their ids."
|
|
10880
|
+
}),
|
|
10881
|
+
route: "GET /v1/compliance/frameworks/{documentId}/rules",
|
|
10882
|
+
inputSchema: { document_id: zUuid().describe("The framework's document id.") },
|
|
10883
|
+
annotations: READ
|
|
10884
|
+
},
|
|
10885
|
+
{
|
|
10886
|
+
name: "talonic_compliance_add_frameworks",
|
|
10887
|
+
title: "Make documents compliance frameworks",
|
|
10888
|
+
description: describe({
|
|
10889
|
+
what: "Make existing workspace documents frameworks (a regulation, policy or standard to check other documents against). Their rules are then written from their text; switch a framework ON to check documents against it.",
|
|
10890
|
+
use: "the user uploaded a regulation or policy and wants documents checked against it.",
|
|
10891
|
+
args: "`document_ids` (1-50).",
|
|
10892
|
+
returns: "{ data[] } the new frameworks."
|
|
10893
|
+
}),
|
|
10894
|
+
route: "POST /v1/compliance/frameworks/from-documents",
|
|
10895
|
+
inputSchema: { document_ids: docIds(1, 50, "Workspace documents to make frameworks.") },
|
|
10896
|
+
annotations: write9(true),
|
|
10897
|
+
body: ["document_ids"]
|
|
10898
|
+
},
|
|
10899
|
+
{
|
|
10900
|
+
name: "talonic_compliance_set_framework_active",
|
|
10901
|
+
title: "Switch a framework ON or OFF",
|
|
10902
|
+
description: describe({
|
|
10903
|
+
what: "Turn a framework ON (its rules are in force for every evaluation) or OFF (they are not). Reversible; evaluations made before become outdated.",
|
|
10904
|
+
use: "a framework does not apply to the workspace's documents, or should now apply.",
|
|
10905
|
+
args: "`document_id`, `active`.",
|
|
10906
|
+
returns: "The framework with its new state."
|
|
10907
|
+
}),
|
|
10908
|
+
route: "POST /v1/compliance/frameworks/{documentId}/active",
|
|
10909
|
+
inputSchema: {
|
|
10910
|
+
document_id: zUuid().describe("The framework's document id."),
|
|
10911
|
+
active: z.boolean().describe("true = ON, false = OFF.")
|
|
10912
|
+
},
|
|
10913
|
+
annotations: write9(true),
|
|
10914
|
+
body: ["active"]
|
|
10915
|
+
},
|
|
10916
|
+
{
|
|
10917
|
+
name: "talonic_compliance_generate_rules",
|
|
10918
|
+
title: "Write a framework's rules again",
|
|
10919
|
+
description: describe({
|
|
10920
|
+
what: "Write the rules of a framework again from its text, replacing the current ones.",
|
|
10921
|
+
use: "a framework's rules are missing or the framework document was replaced. Ask the user first: rule sets that name the old rules lose them.",
|
|
10922
|
+
args: "`document_id`.",
|
|
10923
|
+
returns: "The framework with its status and rule counts."
|
|
10924
|
+
}),
|
|
10925
|
+
route: "POST /v1/compliance/frameworks/{documentId}/rules/generate",
|
|
10926
|
+
inputSchema: { document_id: zUuid().describe("The framework's document id.") },
|
|
10927
|
+
annotations: write9(false, true)
|
|
10928
|
+
},
|
|
10929
|
+
{
|
|
10930
|
+
name: "talonic_compliance_remove_framework",
|
|
10931
|
+
title: "Take a framework out of Compliance",
|
|
10932
|
+
description: describe({
|
|
10933
|
+
what: "Take a framework out of the app with its rules. The document stays in the workspace and can be made a framework again.",
|
|
10934
|
+
use: "the user no longer wants documents checked against it. Ask first; to pause it, switch it OFF instead.",
|
|
10935
|
+
args: "`document_id`.",
|
|
10936
|
+
returns: "Confirmation of the removal."
|
|
10937
|
+
}),
|
|
10938
|
+
route: "DELETE /v1/compliance/frameworks/{documentId}",
|
|
10939
|
+
inputSchema: { document_id: zUuid().describe("The framework's document id.") },
|
|
10940
|
+
annotations: write9(true, true)
|
|
10941
|
+
},
|
|
10942
|
+
// ── Discrepancy comparisons ──────────────────────────────────────────────
|
|
10943
|
+
{
|
|
10944
|
+
name: "talonic_compliance_list_comparisons",
|
|
10945
|
+
title: "Document comparisons",
|
|
10946
|
+
description: describe({
|
|
10947
|
+
what: "Comparisons of document batches for discrepancies (values that should agree across the documents but do not), newest first.",
|
|
10948
|
+
use: "finding an earlier comparison.",
|
|
10949
|
+
returns: "{ data[] } comparisons with id, status and counts."
|
|
10950
|
+
}),
|
|
10951
|
+
route: "GET /v1/compliance/discrepancy-runs",
|
|
10952
|
+
inputSchema: {},
|
|
10953
|
+
annotations: READ
|
|
10954
|
+
},
|
|
10955
|
+
{
|
|
10956
|
+
name: "talonic_compliance_get_comparison",
|
|
10957
|
+
title: "One document comparison",
|
|
10958
|
+
description: describe({
|
|
10959
|
+
what: "One comparison with every discrepancy found: the value, which documents disagree and where.",
|
|
10960
|
+
use: "reading the result of talonic_compliance_compare_documents.",
|
|
10961
|
+
args: "`run_id`.",
|
|
10962
|
+
returns: "The comparison with its status and discrepancies."
|
|
10963
|
+
}),
|
|
10964
|
+
route: "GET /v1/compliance/discrepancy-runs/{runId}",
|
|
10965
|
+
inputSchema: { run_id: zUuid().describe("The comparison id.") },
|
|
10966
|
+
annotations: READ
|
|
10967
|
+
},
|
|
10968
|
+
{
|
|
10969
|
+
name: "talonic_compliance_compare_documents",
|
|
10970
|
+
title: "Compare documents for discrepancies",
|
|
10971
|
+
description: describe({
|
|
10972
|
+
what: "Compare a batch of documents that belong together (an order, its invoice, its delivery note) for values that disagree. Runs in the background; read it with talonic_compliance_get_comparison.",
|
|
10973
|
+
use: "the user asks whether a set of documents is consistent.",
|
|
10974
|
+
args: "`document_ids` (2-50).",
|
|
10975
|
+
returns: "The new comparison with its id."
|
|
10976
|
+
}),
|
|
10977
|
+
route: "POST /v1/compliance/discrepancy-runs",
|
|
10978
|
+
inputSchema: { document_ids: docIds(2, 50, "The documents to compare.") },
|
|
10979
|
+
annotations: write9(false),
|
|
10980
|
+
body: ["document_ids"]
|
|
10981
|
+
},
|
|
10982
|
+
// ── Document sets ────────────────────────────────────────────────────────
|
|
10983
|
+
{
|
|
10984
|
+
name: "talonic_compliance_list_sets",
|
|
10985
|
+
title: "Compliance document sets",
|
|
10986
|
+
description: describe({
|
|
10987
|
+
what: "Document sets (documents judged as one whole, e.g. a contract with its annexes) with their documents and rule set.",
|
|
10988
|
+
use: "finding a set id, or checking which documents a set holds.",
|
|
10989
|
+
returns: "{ data[] } sets with id, name, documents, rule_set_id."
|
|
10990
|
+
}),
|
|
10991
|
+
route: "GET /v1/compliance/sets",
|
|
10992
|
+
inputSchema: {},
|
|
10993
|
+
annotations: READ
|
|
10994
|
+
},
|
|
10995
|
+
{
|
|
10996
|
+
name: "talonic_compliance_create_set",
|
|
10997
|
+
title: "Create a compliance document set",
|
|
10998
|
+
description: describe({
|
|
10999
|
+
what: "Create a document set picked by hand, judged against one rule set or, without one, every rule of the frameworks that are ON.",
|
|
11000
|
+
use: "documents only make sense together (a contract and its annexes).",
|
|
11001
|
+
args: "`name`, `document_ids` (2-100), `rule_set_id` (optional).",
|
|
11002
|
+
returns: "The new set."
|
|
11003
|
+
}),
|
|
11004
|
+
route: "POST /v1/compliance/sets",
|
|
11005
|
+
inputSchema: {
|
|
11006
|
+
name: z.string().min(1).max(200).describe("Set name."),
|
|
11007
|
+
document_ids: docIds(2, 100, "The set's documents."),
|
|
11008
|
+
rule_set_id: zUuid().nullable().optional().describe("Rule set to judge it against; omitted or null = every ON rule.")
|
|
11009
|
+
},
|
|
11010
|
+
annotations: write9(false),
|
|
11011
|
+
body: ["name", "document_ids", "rule_set_id"]
|
|
11012
|
+
},
|
|
11013
|
+
{
|
|
11014
|
+
name: "talonic_compliance_assembly_groups",
|
|
11015
|
+
title: "Groups to make compliance sets from",
|
|
11016
|
+
description: describe({
|
|
11017
|
+
what: "The assembly groups of the workspace's pipelines (documents grouped by a shared value, such as one order number) that sets can be made from.",
|
|
11018
|
+
use: "before talonic_compliance_create_sets_from_groups.",
|
|
11019
|
+
returns: "{ data[] } groups with pipeline_id, group_key and their documents."
|
|
11020
|
+
}),
|
|
11021
|
+
route: "GET /v1/compliance/sets/assembly-groups",
|
|
11022
|
+
inputSchema: {},
|
|
11023
|
+
annotations: READ
|
|
11024
|
+
},
|
|
11025
|
+
{
|
|
11026
|
+
name: "talonic_compliance_create_sets_from_groups",
|
|
11027
|
+
title: "Create compliance sets from groups",
|
|
11028
|
+
description: describe({
|
|
11029
|
+
what: "Create one document set per assembly group; the set follows the group as documents join it.",
|
|
11030
|
+
use: "every order (or case) should be judged as a whole.",
|
|
11031
|
+
args: "`groups[]` { pipeline_id, group_key } (1-100), `rule_set_id` (optional).",
|
|
11032
|
+
returns: "{ data[] } the new sets."
|
|
11033
|
+
}),
|
|
11034
|
+
route: "POST /v1/compliance/sets/from-assemblies",
|
|
11035
|
+
inputSchema: {
|
|
11036
|
+
groups: z.array(z.object({ pipeline_id: zUuid(), group_key: z.string().min(1).max(1e3) })).min(1).max(100).describe("Groups from talonic_compliance_assembly_groups."),
|
|
11037
|
+
rule_set_id: zUuid().nullable().optional().describe("Rule set to judge them against; omitted or null = every ON rule.")
|
|
11038
|
+
},
|
|
11039
|
+
annotations: write9(false),
|
|
11040
|
+
body: ["groups", "rule_set_id"]
|
|
11041
|
+
},
|
|
11042
|
+
{
|
|
11043
|
+
name: "talonic_compliance_update_set",
|
|
11044
|
+
title: "Edit a compliance document set",
|
|
11045
|
+
description: describe({
|
|
11046
|
+
what: "Rename a set, replace its documents (a group-following set becomes hand-picked) or change its rule set. Fields left out stay.",
|
|
11047
|
+
use: "a set is missing a document or should be judged against other rules.",
|
|
11048
|
+
args: "`set_id`, `name`, `document_ids` (2-100), `rule_set_id` (null = every ON rule).",
|
|
11049
|
+
returns: "The updated set."
|
|
11050
|
+
}),
|
|
11051
|
+
route: "PATCH /v1/compliance/sets/{setId}",
|
|
11052
|
+
inputSchema: {
|
|
11053
|
+
set_id: zUuid().describe("The set."),
|
|
11054
|
+
name: z.string().min(1).max(200).optional().describe("New set name."),
|
|
11055
|
+
document_ids: docIds(2, 100, "The set's documents (replaces them).").optional(),
|
|
11056
|
+
rule_set_id: zUuid().nullable().optional().describe("null = every ON rule; omitted = unchanged.")
|
|
11057
|
+
},
|
|
11058
|
+
annotations: write9(true),
|
|
11059
|
+
body: ["name", "document_ids", "rule_set_id"]
|
|
11060
|
+
},
|
|
11061
|
+
{
|
|
11062
|
+
name: "talonic_compliance_remove_set",
|
|
11063
|
+
title: "Remove a compliance document set",
|
|
11064
|
+
description: describe({
|
|
11065
|
+
what: "Remove a document set with its evaluations. The documents stay in the workspace.",
|
|
11066
|
+
use: "a set is no longer needed. Ask the user first.",
|
|
11067
|
+
args: "`set_id`.",
|
|
11068
|
+
returns: "Confirmation of the removal."
|
|
11069
|
+
}),
|
|
11070
|
+
route: "DELETE /v1/compliance/sets/{setId}",
|
|
11071
|
+
inputSchema: { set_id: zUuid().describe("The set.") },
|
|
11072
|
+
annotations: write9(true, true)
|
|
11073
|
+
},
|
|
11074
|
+
{
|
|
11075
|
+
name: "talonic_compliance_list_set_evaluations",
|
|
11076
|
+
title: "Compliance set evaluations",
|
|
11077
|
+
description: describe({
|
|
11078
|
+
what: "The latest evaluation of every document set. Without paging arguments the whole list; with any of status / limit / offset one page with total and has_more.",
|
|
11079
|
+
use: "an overview of how every set fares.",
|
|
11080
|
+
args: "`status` processing|waiting|completed|error, `limit` 1-500, `offset`.",
|
|
11081
|
+
returns: "{ data[] } or a page { data[], total, has_more }."
|
|
11082
|
+
}),
|
|
11083
|
+
route: "GET /v1/compliance/sets/evaluations",
|
|
11084
|
+
inputSchema: pageArgs2,
|
|
11085
|
+
annotations: READ,
|
|
11086
|
+
query: ["status", "limit", "offset"]
|
|
11087
|
+
},
|
|
11088
|
+
{
|
|
11089
|
+
name: "talonic_compliance_get_set_evaluation",
|
|
11090
|
+
title: "One set's compliance evaluation",
|
|
11091
|
+
description: describe({
|
|
11092
|
+
what: "A set's latest evaluation with every result: verdict, reason, and the quote with the member document it comes from.",
|
|
11093
|
+
use: "the evidence behind a set's failed check.",
|
|
11094
|
+
args: "`set_id`.",
|
|
11095
|
+
returns: "{ evaluation } with its results; null when never evaluated."
|
|
11096
|
+
}),
|
|
11097
|
+
route: "GET /v1/compliance/sets/{setId}/evaluation",
|
|
11098
|
+
inputSchema: { set_id: zUuid().describe("The set.") },
|
|
11099
|
+
annotations: READ
|
|
11100
|
+
},
|
|
11101
|
+
{
|
|
11102
|
+
name: "talonic_compliance_evaluate_sets",
|
|
11103
|
+
title: "Evaluate compliance document sets",
|
|
11104
|
+
description: describe({
|
|
11105
|
+
what: "Evaluate document sets, each as one whole, against their rule set. Runs in the background.",
|
|
11106
|
+
use: "a set changed or its verdicts are outdated.",
|
|
11107
|
+
args: "`set_ids` (1-100).",
|
|
11108
|
+
returns: "{ data[] } one started evaluation per set."
|
|
11109
|
+
}),
|
|
11110
|
+
route: "POST /v1/compliance/sets/evaluate",
|
|
11111
|
+
inputSchema: { set_ids: z.array(zUuid()).min(1).max(100).describe("Sets to evaluate.") },
|
|
11112
|
+
annotations: write9(false),
|
|
11113
|
+
body: ["set_ids"]
|
|
11114
|
+
},
|
|
11115
|
+
// ── Rule sets ────────────────────────────────────────────────────────────
|
|
11116
|
+
{
|
|
11117
|
+
name: "talonic_compliance_list_rule_sets",
|
|
11118
|
+
title: "Compliance rule sets",
|
|
11119
|
+
description: describe({
|
|
11120
|
+
what: "The workspace's rule sets: named selections of rules of the ON frameworks that a document set is judged against.",
|
|
11121
|
+
use: "finding a rule_set_id for a set.",
|
|
11122
|
+
returns: "{ data[] } rule sets with id, name, rule_ids."
|
|
11123
|
+
}),
|
|
11124
|
+
route: "GET /v1/compliance/rule-sets",
|
|
11125
|
+
inputSchema: {},
|
|
11126
|
+
annotations: READ
|
|
11127
|
+
},
|
|
11128
|
+
{
|
|
11129
|
+
name: "talonic_compliance_create_rule_set",
|
|
11130
|
+
title: "Create a compliance rule set",
|
|
11131
|
+
description: describe({
|
|
11132
|
+
what: "Create a named selection of rules (from talonic_compliance_framework_rules) to judge document sets against.",
|
|
11133
|
+
use: "only some rules apply to a kind of document set.",
|
|
11134
|
+
args: "`name`, `rule_ids` (1-1000).",
|
|
11135
|
+
returns: "The new rule set."
|
|
11136
|
+
}),
|
|
11137
|
+
route: "POST /v1/compliance/rule-sets",
|
|
11138
|
+
inputSchema: {
|
|
11139
|
+
name: z.string().min(1).max(200).describe("Rule set name."),
|
|
11140
|
+
rule_ids: z.array(zUuid()).min(1).max(1e3).describe("Rules of ON frameworks.")
|
|
11141
|
+
},
|
|
11142
|
+
annotations: write9(false),
|
|
11143
|
+
body: ["name", "rule_ids"]
|
|
11144
|
+
},
|
|
11145
|
+
{
|
|
11146
|
+
name: "talonic_compliance_update_rule_set",
|
|
11147
|
+
title: "Change a compliance rule set",
|
|
11148
|
+
description: describe({
|
|
11149
|
+
what: "Rename a rule set or replace its rules.",
|
|
11150
|
+
use: "a rule should be added to or dropped from what sets are judged against.",
|
|
11151
|
+
args: "`rule_set_id`, `name`, `rule_ids` (1-1000, replaces them).",
|
|
11152
|
+
returns: "The updated rule set."
|
|
11153
|
+
}),
|
|
11154
|
+
route: "PATCH /v1/compliance/rule-sets/{ruleSetId}",
|
|
11155
|
+
inputSchema: {
|
|
11156
|
+
rule_set_id: zUuid(),
|
|
11157
|
+
name: z.string().min(1).max(200).optional().describe("New rule set name."),
|
|
11158
|
+
rule_ids: z.array(zUuid()).min(1).max(1e3).optional().describe("The rules (replaces them).")
|
|
11159
|
+
},
|
|
11160
|
+
annotations: write9(true),
|
|
11161
|
+
body: ["name", "rule_ids"]
|
|
11162
|
+
},
|
|
11163
|
+
{
|
|
11164
|
+
name: "talonic_compliance_remove_rule_set",
|
|
11165
|
+
title: "Remove a compliance rule set",
|
|
11166
|
+
description: describe({
|
|
11167
|
+
what: "Remove a rule set. Sets that used it go back to every rule of the ON frameworks.",
|
|
11168
|
+
use: "a rule set is no longer needed. Ask the user first.",
|
|
11169
|
+
args: "`rule_set_id`.",
|
|
11170
|
+
returns: "Confirmation of the removal."
|
|
11171
|
+
}),
|
|
11172
|
+
route: "DELETE /v1/compliance/rule-sets/{ruleSetId}",
|
|
11173
|
+
inputSchema: { rule_set_id: zUuid() },
|
|
11174
|
+
annotations: write9(true, true)
|
|
11175
|
+
},
|
|
11176
|
+
// ── Who decides; the workspace agent's tasks ─────────────────────────────
|
|
11177
|
+
{
|
|
11178
|
+
name: "talonic_compliance_settings",
|
|
11179
|
+
title: "Who makes compliance decisions",
|
|
11180
|
+
description: describe({
|
|
11181
|
+
what: "Who makes the workspace's compliance decisions: `platform` (Talonic decides every verdict) or `external` (the workspace's own agent decides, through the compliance tasks).",
|
|
11182
|
+
use: "before working the task tools, or explaining why verdicts wait.",
|
|
11183
|
+
returns: "{ decider: platform | external }."
|
|
11184
|
+
}),
|
|
11185
|
+
route: "GET /v1/compliance/settings",
|
|
11186
|
+
inputSchema: {},
|
|
11187
|
+
annotations: READ
|
|
11188
|
+
},
|
|
11189
|
+
{
|
|
11190
|
+
name: "talonic_compliance_set_decider",
|
|
11191
|
+
title: "Switch who makes compliance decisions",
|
|
11192
|
+
description: describe({
|
|
11193
|
+
what: "Switch who makes the compliance decisions: `platform` or `external` (the workspace's own agent works the tasks). Reversible. The person behind the connection needs the Workspace settings permission.",
|
|
11194
|
+
use: "the user explicitly asks to hand decisions to their own agent, or back.",
|
|
11195
|
+
args: "`decider` platform|external.",
|
|
11196
|
+
returns: "The new setting.",
|
|
11197
|
+
errors: "403 without the Workspace settings permission."
|
|
11198
|
+
}),
|
|
11199
|
+
route: "PUT /v1/compliance/settings",
|
|
11200
|
+
inputSchema: {
|
|
11201
|
+
decider: z.enum(["platform", "external"]).describe("platform = Talonic decides; external = the workspace's own agent.")
|
|
11202
|
+
},
|
|
11203
|
+
annotations: write9(true),
|
|
11204
|
+
body: ["decider"]
|
|
11205
|
+
},
|
|
11206
|
+
{
|
|
11207
|
+
name: "talonic_compliance_list_tasks",
|
|
11208
|
+
title: "Compliance tasks for the workspace's agent",
|
|
11209
|
+
description: describe({
|
|
11210
|
+
what: "Decisions waiting for the workspace's own agent (only when the decider is external).",
|
|
11211
|
+
use: "an agent working the compliance decisions: pick a task, then talonic_compliance_claim_task.",
|
|
11212
|
+
args: "`status` open (default) | all, `limit` (default 100).",
|
|
11213
|
+
returns: "{ data[] } tasks with id, status, document or set, and lease state."
|
|
11214
|
+
}),
|
|
11215
|
+
route: "GET /v1/compliance/tasks",
|
|
11216
|
+
inputSchema: {
|
|
11217
|
+
status: z.enum(["open", "all"]).optional().describe("open (default) or all."),
|
|
11218
|
+
limit: z.number().int().min(1).max(1e3).optional().describe("Most tasks returned (default 100).")
|
|
11219
|
+
},
|
|
11220
|
+
annotations: READ,
|
|
11221
|
+
query: ["status", "limit"]
|
|
11222
|
+
},
|
|
11223
|
+
{
|
|
11224
|
+
name: "talonic_compliance_get_task",
|
|
11225
|
+
title: "One compliance task",
|
|
11226
|
+
description: describe({
|
|
11227
|
+
what: "One task's state (open, claimed, done) without its work package.",
|
|
11228
|
+
use: "checking a task before or after claiming it.",
|
|
11229
|
+
args: "`task_id`.",
|
|
11230
|
+
returns: "The task."
|
|
11231
|
+
}),
|
|
11232
|
+
route: "GET /v1/compliance/tasks/{taskId}",
|
|
11233
|
+
inputSchema: { task_id: zUuid() },
|
|
11234
|
+
annotations: READ
|
|
11235
|
+
},
|
|
11236
|
+
{
|
|
11237
|
+
name: "talonic_compliance_claim_task",
|
|
11238
|
+
title: "Claim a compliance task",
|
|
11239
|
+
description: describe({
|
|
11240
|
+
what: "Claim a task for this agent and read its work package: instructions, the input, and the JSON Schema the answer must match. The claim is a lease: renew it with talonic_compliance_heartbeat_task while working, hand it back with talonic_compliance_release_task, or answer with talonic_compliance_submit_task. A lapsed lease returns the task to open.",
|
|
11241
|
+
use: "starting work on one task from talonic_compliance_list_tasks.",
|
|
11242
|
+
args: "`task_id`.",
|
|
11243
|
+
returns: "{ task (with execution_epoch and the lease), instructions, input, output_schema, how_to_answer }. Keep execution_epoch for every later call.",
|
|
11244
|
+
errors: "409 when another agent holds the claim, the task is closed or not ready yet."
|
|
11245
|
+
}),
|
|
11246
|
+
route: "POST /v1/compliance/tasks/{taskId}/claim",
|
|
11247
|
+
inputSchema: { task_id: zUuid() },
|
|
11248
|
+
annotations: write9(false)
|
|
11249
|
+
},
|
|
11250
|
+
{
|
|
11251
|
+
name: "talonic_compliance_heartbeat_task",
|
|
11252
|
+
title: "Renew a compliance task claim",
|
|
11253
|
+
description: describe({
|
|
11254
|
+
what: "Renew the lease on a claimed task.",
|
|
11255
|
+
use: "work on a claimed task takes longer than its lease.",
|
|
11256
|
+
args: "`task_id`, `execution_epoch`.",
|
|
11257
|
+
returns: "The new lease expiry.",
|
|
11258
|
+
errors: "409 when the claim lapsed or was taken over (stop working on it)."
|
|
11259
|
+
}),
|
|
11260
|
+
route: "POST /v1/compliance/tasks/{taskId}/heartbeat",
|
|
11261
|
+
inputSchema: { task_id: zUuid(), execution_epoch: epoch },
|
|
11262
|
+
annotations: write9(true),
|
|
11263
|
+
body: ["execution_epoch"]
|
|
11264
|
+
},
|
|
11265
|
+
{
|
|
11266
|
+
name: "talonic_compliance_release_task",
|
|
11267
|
+
title: "Hand a compliance task back",
|
|
11268
|
+
description: describe({
|
|
11269
|
+
what: "Hand a claimed task back unanswered; it is open again for any agent.",
|
|
11270
|
+
use: "the agent cannot decide the task.",
|
|
11271
|
+
args: "`task_id`, `execution_epoch`.",
|
|
11272
|
+
returns: "The task, open again."
|
|
11273
|
+
}),
|
|
11274
|
+
route: "POST /v1/compliance/tasks/{taskId}/release",
|
|
11275
|
+
inputSchema: { task_id: zUuid(), execution_epoch: epoch },
|
|
11276
|
+
annotations: write9(true),
|
|
11277
|
+
body: ["execution_epoch"]
|
|
11278
|
+
},
|
|
11279
|
+
{
|
|
11280
|
+
name: "talonic_compliance_submit_task",
|
|
11281
|
+
title: "Answer a compliance task",
|
|
11282
|
+
description: describe({
|
|
11283
|
+
what: "Submit the answer to a claimed task. It is checked against the package's output_schema and stored exactly like a verdict Talonic makes itself.",
|
|
11284
|
+
use: "the agent has decided a claimed task.",
|
|
11285
|
+
args: "`task_id`, `execution_epoch`, `answer` (an object matching output_schema).",
|
|
11286
|
+
returns: "{ task, result }.",
|
|
11287
|
+
errors: "400 naming what is wrong when the answer does not match the schema; 409 without a live claim (lapsed, released or a stale epoch)."
|
|
11288
|
+
}),
|
|
11289
|
+
route: "POST /v1/compliance/tasks/{taskId}/submit",
|
|
11290
|
+
inputSchema: {
|
|
11291
|
+
task_id: zUuid(),
|
|
11292
|
+
execution_epoch: epoch,
|
|
11293
|
+
answer: z.record(z.string(), z.unknown()).describe("The answer, matching the package's output_schema.")
|
|
11294
|
+
},
|
|
11295
|
+
annotations: write9(false),
|
|
11296
|
+
body: ["execution_epoch", "answer"]
|
|
11297
|
+
}
|
|
11298
|
+
];
|
|
11299
|
+
var complianceGroup = {
|
|
11300
|
+
key: "compliance",
|
|
11301
|
+
label: "Compliance",
|
|
11302
|
+
docsSlug: "compliance-tools",
|
|
11303
|
+
probe: { path: "/v1/compliance/settings" },
|
|
11304
|
+
tools
|
|
11305
|
+
};
|
|
11306
|
+
var paging = {
|
|
11307
|
+
page: z.number().int().min(1).max(1e6).optional().describe("Page number, from 1."),
|
|
11308
|
+
limit: z.number().int().min(1).optional().describe("Rows per page (the desk caps it).")
|
|
11309
|
+
};
|
|
11310
|
+
var key = (what) => z.string().min(1).max(2e3).describe(`${what} as the desk lists it (no control characters).`);
|
|
11311
|
+
var team = z.string().max(2e3).optional().describe("One team's work only; all teams when left out.");
|
|
11312
|
+
var contractDeskGroup = {
|
|
11313
|
+
key: "contract_desk",
|
|
11314
|
+
label: "Contract Desk",
|
|
11315
|
+
docsSlug: "contract-desk-tools",
|
|
11316
|
+
probe: { path: "/v1/contract-desk/status" },
|
|
11317
|
+
tools: [
|
|
11318
|
+
{
|
|
11319
|
+
name: "talonic_contract_desk_status",
|
|
11320
|
+
title: "Contract Desk status",
|
|
11321
|
+
description: describe({
|
|
11322
|
+
what: "Whether the Contract Desk is ready: when it was last refreshed, whether a refresh is running, and how many sites, contracts and open items it holds.",
|
|
11323
|
+
use: "first call of a session, or after talonic_contract_desk_refresh to see it finish.",
|
|
11324
|
+
not: "the work itself (talonic_contract_desk_todo).",
|
|
11325
|
+
returns: "the desk's state: last refresh time and outcome, a running refresh, counts."
|
|
11326
|
+
}),
|
|
11327
|
+
route: "GET /v1/contract-desk/status",
|
|
11328
|
+
inputSchema: {},
|
|
11329
|
+
annotations: READ
|
|
11330
|
+
},
|
|
11331
|
+
{
|
|
11332
|
+
name: "talonic_contract_desk_refresh",
|
|
11333
|
+
title: "Refresh the Contract Desk",
|
|
11334
|
+
description: describe({
|
|
11335
|
+
what: "Start a refresh of the Contract Desk from its source apps now. Answers at once; talonic_contract_desk_status shows it running and its outcome. Needs the `run` permission and the app switched on.",
|
|
11336
|
+
use: "the source apps changed (new contracts, decisions made elsewhere) and the desk should show it before the next scheduled refresh.",
|
|
11337
|
+
not: "reading anything (every read tool shows the last refresh).",
|
|
11338
|
+
returns: "the refresh that was started (or the one already running)."
|
|
11339
|
+
}),
|
|
11340
|
+
route: "POST /v1/contract-desk/rebuild",
|
|
11341
|
+
inputSchema: {},
|
|
11342
|
+
annotations: write9(true)
|
|
11343
|
+
},
|
|
11344
|
+
{
|
|
11345
|
+
name: "talonic_contract_desk_sites",
|
|
11346
|
+
title: "Contract Desk sites",
|
|
11347
|
+
description: describe({
|
|
11348
|
+
what: "One page of sites with their contracts and open work, and the counts of the three filters.",
|
|
11349
|
+
use: "finding a site by number or name, or listing the sites with work due now or without documents.",
|
|
11350
|
+
not: "one site's contracts and items (talonic_contract_desk_get_site).",
|
|
11351
|
+
args: "`q` (words that must each occur in the site's number, name, contracts or partners), `filter` all|now|nodoc, `page`, `limit`.",
|
|
11352
|
+
returns: "{ data[] sites, total, page, limit, counts { all, now, nodoc } }."
|
|
11353
|
+
}),
|
|
11354
|
+
route: "GET /v1/contract-desk/sites",
|
|
11355
|
+
inputSchema: {
|
|
11356
|
+
q: z.string().max(500).optional().describe("Search words."),
|
|
11357
|
+
filter: z.enum(["all", "now", "nodoc"]).optional().describe("all, now (work due now) or nodoc (no documents)."),
|
|
11358
|
+
...paging
|
|
11359
|
+
},
|
|
11360
|
+
annotations: READ,
|
|
11361
|
+
query: ["q", "filter", "page", "limit"]
|
|
11362
|
+
},
|
|
11363
|
+
{
|
|
11364
|
+
name: "talonic_contract_desk_get_site",
|
|
11365
|
+
title: "One Contract Desk site",
|
|
11366
|
+
description: describe({
|
|
11367
|
+
what: "One site with its contracts and its site-level items.",
|
|
11368
|
+
use: "the user names a site, or after talonic_contract_desk_sites.",
|
|
11369
|
+
not: "one contract's values (talonic_contract_desk_get_contract).",
|
|
11370
|
+
args: "`key` the site key from talonic_contract_desk_sites.",
|
|
11371
|
+
returns: "the site, its contracts and its open items. 404 when the desk holds no such site."
|
|
11372
|
+
}),
|
|
11373
|
+
route: "GET /v1/contract-desk/sites/{key}",
|
|
11374
|
+
inputSchema: { key: key("The site key") },
|
|
11375
|
+
annotations: READ
|
|
11376
|
+
},
|
|
11377
|
+
{
|
|
11378
|
+
name: "talonic_contract_desk_contracts",
|
|
11379
|
+
title: "Contract Desk contracts",
|
|
11380
|
+
description: describe({
|
|
11381
|
+
what: "One page of contracts, searchable, for one partner or one site.",
|
|
11382
|
+
use: "finding a contract by number, name, partner, site or type.",
|
|
11383
|
+
not: "one contract's items and values (talonic_contract_desk_get_contract).",
|
|
11384
|
+
args: "`q` (words that must each occur in the contract's key, number, name, partner, site or type), `partner` (a partner_key, exact), `site` (a site key, exact), `page`, `limit`.",
|
|
11385
|
+
returns: "{ data[] contracts (crm_key, number, partner, site, type, open items), total, page, limit }."
|
|
11386
|
+
}),
|
|
11387
|
+
route: "GET /v1/contract-desk/contracts",
|
|
11388
|
+
inputSchema: {
|
|
11389
|
+
q: z.string().max(500).optional().describe("Search words."),
|
|
11390
|
+
partner: z.string().max(2e3).optional().describe("A partner_key, matched exactly."),
|
|
11391
|
+
site: z.string().max(2e3).optional().describe("A site key, matched exactly."),
|
|
11392
|
+
...paging
|
|
11393
|
+
},
|
|
11394
|
+
annotations: READ,
|
|
11395
|
+
query: ["q", "partner", "site", "page", "limit"]
|
|
11396
|
+
},
|
|
11397
|
+
{
|
|
11398
|
+
name: "talonic_contract_desk_get_contract",
|
|
11399
|
+
title: "One Contract Desk contract",
|
|
11400
|
+
description: describe({
|
|
11401
|
+
what: "One contract with its items and values: where the documents and the CRM agree or differ, and what is open.",
|
|
11402
|
+
use: "the evidence for a contract, or before deciding several items on one contract.",
|
|
11403
|
+
not: "the decision screen of one item (talonic_contract_desk_get_decision).",
|
|
11404
|
+
args: "`id` the contract's crm_key.",
|
|
11405
|
+
returns: "the contract with its values, items and documents. 404 when the desk holds no such contract."
|
|
11406
|
+
}),
|
|
11407
|
+
route: "GET /v1/contract-desk/contracts/{id}",
|
|
11408
|
+
inputSchema: { id: key("The contract's crm_key") },
|
|
11409
|
+
annotations: READ
|
|
11410
|
+
},
|
|
11411
|
+
{
|
|
11412
|
+
name: "talonic_contract_desk_dashboard",
|
|
11413
|
+
title: "Contract Desk dashboard",
|
|
11414
|
+
description: describe({
|
|
11415
|
+
what: "The Dashboard: work to do now and this month, open work by team, due dates by week, the busiest sites, the first batch, and the history.",
|
|
11416
|
+
use: "the headline ('how much is open, what is due this week, which team is behind').",
|
|
11417
|
+
not: "the items themselves (talonic_contract_desk_todo).",
|
|
11418
|
+
args: "`team` (optional).",
|
|
11419
|
+
returns: "the dashboard figures for the team, or all teams."
|
|
11420
|
+
}),
|
|
11421
|
+
route: "GET /v1/contract-desk/dashboard",
|
|
11422
|
+
inputSchema: { team },
|
|
11423
|
+
annotations: READ,
|
|
11424
|
+
query: ["team"]
|
|
11425
|
+
},
|
|
11426
|
+
{
|
|
11427
|
+
name: "talonic_contract_desk_quality",
|
|
11428
|
+
title: "Contract Desk data quality",
|
|
11429
|
+
description: describe({
|
|
11430
|
+
what: "The Data quality page: the required values and how many are still open, the attributes with the most open values, the documents, and how well documents link to contracts.",
|
|
11431
|
+
use: "a data quality question across the contract portfolio.",
|
|
11432
|
+
not: "one contract's values (talonic_contract_desk_get_contract).",
|
|
11433
|
+
returns: "the quality figures."
|
|
11434
|
+
}),
|
|
11435
|
+
route: "GET /v1/contract-desk/quality",
|
|
11436
|
+
inputSchema: {},
|
|
11437
|
+
annotations: READ
|
|
11438
|
+
},
|
|
11439
|
+
{
|
|
11440
|
+
name: "talonic_contract_desk_todo",
|
|
11441
|
+
title: "Contract Desk to do list",
|
|
11442
|
+
description: describe({
|
|
11443
|
+
what: "The To do list: per section (now, this month, later, no date) its item count and first batches of similar items, plus the decisions made today.",
|
|
11444
|
+
use: "starting work: pick a batch, then list its items with talonic_contract_desk_todo_items.",
|
|
11445
|
+
not: "one batch's items (talonic_contract_desk_todo_items).",
|
|
11446
|
+
args: "`team` (optional).",
|
|
11447
|
+
returns: "{ sections[] { section, count, batches[] { key, team, kind, count, \u2026 }, more }, decided_today, \u2026 }."
|
|
11448
|
+
}),
|
|
11449
|
+
route: "GET /v1/contract-desk/todo",
|
|
11450
|
+
inputSchema: { team },
|
|
11451
|
+
annotations: READ,
|
|
11452
|
+
query: ["team"]
|
|
11453
|
+
},
|
|
11454
|
+
{
|
|
11455
|
+
name: "talonic_contract_desk_todo_items",
|
|
11456
|
+
title: "Items of a Contract Desk batch",
|
|
11457
|
+
description: describe({
|
|
11458
|
+
what: "One page of the open items of a batch from the To do list.",
|
|
11459
|
+
use: "after talonic_contract_desk_todo, to get the item ids to open and decide.",
|
|
11460
|
+
not: "the evidence of one item (talonic_contract_desk_get_decision).",
|
|
11461
|
+
args: "`batch` (the batch key from talonic_contract_desk_todo, unchanged), `page`, `limit`.",
|
|
11462
|
+
returns: "{ batch | null, data[] items { id, kind, contract, site, due_date, \u2026 }, total, page, limit }. batch is null when the key names no items any more."
|
|
11463
|
+
}),
|
|
11464
|
+
route: "GET /v1/contract-desk/todo/items",
|
|
11465
|
+
inputSchema: {
|
|
11466
|
+
batch: z.string().min(1).max(2e3).describe("The batch key from talonic_contract_desk_todo."),
|
|
11467
|
+
...paging
|
|
11468
|
+
},
|
|
11469
|
+
annotations: READ,
|
|
11470
|
+
query: ["batch", "page", "limit"]
|
|
11471
|
+
},
|
|
11472
|
+
{
|
|
11473
|
+
name: "talonic_contract_desk_get_decision",
|
|
11474
|
+
title: "Evidence for one Contract Desk item",
|
|
11475
|
+
description: describe({
|
|
11476
|
+
what: "Everything the decision screen shows for one open item: the item, its contract and site, the question (for a value: what each document and the CRM say and the values to pick; for a key date: its day and the outcomes offered; for a process step: mark it handled), whether this connection may decide (`can_decide`), and the contract's letter if there is one.",
|
|
11477
|
+
use: "before talonic_contract_desk_decide, to show the user the evidence and the allowed actions.",
|
|
11478
|
+
not: "decided items (talonic_contract_desk_decisions).",
|
|
11479
|
+
args: "`id` the item id.",
|
|
11480
|
+
returns: "{ item, contract, site_name, can_decide, question { kind value|deadline|step, \u2026 } | null, letter }. question.mode `suggest` means the decision becomes a suggestion a colleague accepts. 404 unknown item; 409 gone when a decision already closed it."
|
|
11481
|
+
}),
|
|
11482
|
+
route: "GET /v1/contract-desk/items/{id}/decision",
|
|
11483
|
+
inputSchema: { id: zUuid().describe("The item id.") },
|
|
11484
|
+
annotations: READ
|
|
11485
|
+
},
|
|
11486
|
+
{
|
|
11487
|
+
name: "talonic_contract_desk_decide",
|
|
11488
|
+
title: "Decide a Contract Desk item",
|
|
11489
|
+
description: describe({
|
|
11490
|
+
what: "Decide one open item. The decision is recorded at the item's source app (set a value, report a value as missing to the CRM, mark a key date or step handled, record a notice outcome on the contract) and in the desk's log, under this connection. Run with dry_run first. Can be undone with talonic_contract_desk_undo while it is the item's latest decision.",
|
|
11491
|
+
use: "the user chose what an item should be after seeing talonic_contract_desk_get_decision.",
|
|
11492
|
+
not: "accepting a colleague's suggestion (done by a person in the app); changing teams (talonic_contract_desk_save_settings).",
|
|
11493
|
+
args: "`id` the item id; `action` set|crm_add|handled|notice_sent|renewal_declined|terminated (only those the item's question offers); `value` (for set only; may span lines); `note` (why, recorded at the source); `dry_run`.",
|
|
11494
|
+
returns: "{ status decided|suggested, dry_run, decision_id (null on a dry run), undoable, crm_report update|missing|null, revision }.",
|
|
11495
|
+
errors: "400 an action the item does not offer, set without a value, a value on another action; 403 without the edit permission; 409 the item changed."
|
|
11496
|
+
}),
|
|
11497
|
+
route: "POST /v1/contract-desk/items/{id}/decide",
|
|
11498
|
+
inputSchema: {
|
|
11499
|
+
id: zUuid().describe("The item id."),
|
|
11500
|
+
action: z.enum(["set", "crm_add", "handled", "notice_sent", "renewal_declined", "terminated"]).describe(
|
|
11501
|
+
"What to do; talonic_contract_desk_get_decision lists the ones this item offers."
|
|
11502
|
+
),
|
|
11503
|
+
value: z.string().optional().describe("The value to record; only with action set."),
|
|
11504
|
+
note: z.string().optional().describe("Why, in a few words."),
|
|
11505
|
+
dry_run: z.boolean().optional().describe("Preview only; nothing is recorded.")
|
|
11506
|
+
},
|
|
11507
|
+
annotations: write9(false),
|
|
11508
|
+
body: ["action", "value", "note", "dry_run"]
|
|
11509
|
+
},
|
|
11510
|
+
{
|
|
11511
|
+
name: "talonic_contract_desk_decisions",
|
|
11512
|
+
title: "Contract Desk decisions",
|
|
11513
|
+
description: describe({
|
|
11514
|
+
what: "The Decided list: decisions newest first, with who, what, the item and contract, and whether each can still be undone; plus today's count.",
|
|
11515
|
+
use: "reviewing what was decided, finding a decision to undo, or one contract's history.",
|
|
11516
|
+
not: "open items (talonic_contract_desk_todo).",
|
|
11517
|
+
args: "`mine` (only this connection's person), `crm_key` (one contract), `page`, `limit`.",
|
|
11518
|
+
returns: "{ data[] { id, at, by_name, mine, kind, action, value, note, status, item, contract, undoable, undone_at }, total, page, limit, today }."
|
|
11519
|
+
}),
|
|
11520
|
+
route: "GET /v1/contract-desk/decisions",
|
|
11521
|
+
inputSchema: {
|
|
11522
|
+
mine: z.boolean().optional().describe("Only the decisions of this connection's person."),
|
|
11523
|
+
crm_key: z.string().max(2e3).optional().describe("One contract's decisions."),
|
|
11524
|
+
...paging
|
|
11525
|
+
},
|
|
11526
|
+
annotations: READ,
|
|
11527
|
+
query: ["mine", "crm_key", "page", "limit"]
|
|
11528
|
+
},
|
|
11529
|
+
{
|
|
11530
|
+
name: "talonic_contract_desk_undo",
|
|
11531
|
+
title: "Undo a Contract Desk decision",
|
|
11532
|
+
description: describe({
|
|
11533
|
+
what: "Undo a decision at its source app and put the item back on the list. Only the latest decision of an item that is not open again can be undone.",
|
|
11534
|
+
use: "a decision was wrong; the id comes from talonic_contract_desk_decide (decision_id) or talonic_contract_desk_decisions.",
|
|
11535
|
+
not: "deciding again (talonic_contract_desk_decide after the undo).",
|
|
11536
|
+
args: "`id` the decision id.",
|
|
11537
|
+
returns: "the decision with undone_at set. 409 not_undoable otherwise."
|
|
11538
|
+
}),
|
|
11539
|
+
route: "POST /v1/contract-desk/decisions/{id}/undo",
|
|
11540
|
+
inputSchema: { id: zUuid().describe("The decision id.") },
|
|
11541
|
+
annotations: write9(false)
|
|
11542
|
+
},
|
|
11543
|
+
{
|
|
11544
|
+
name: "talonic_contract_desk_settings",
|
|
11545
|
+
title: "Contract Desk team setup",
|
|
11546
|
+
description: describe({
|
|
11547
|
+
what: "Which team gets which items: the team per item kind and per attribute, the defaults, the teams and kinds one can choose, and the attributes.",
|
|
11548
|
+
use: "before changing the setup, or to explain why an item went to a team.",
|
|
11549
|
+
not: "changing it (talonic_contract_desk_save_settings).",
|
|
11550
|
+
returns: "{ teams { kinds, fields }, defaults, choices { teams, kinds }, attributes[] }."
|
|
11551
|
+
}),
|
|
11552
|
+
route: "GET /v1/contract-desk/settings",
|
|
11553
|
+
inputSchema: {},
|
|
11554
|
+
annotations: READ
|
|
11555
|
+
},
|
|
11556
|
+
{
|
|
11557
|
+
name: "talonic_contract_desk_save_settings",
|
|
11558
|
+
title: "Change the Contract Desk team setup",
|
|
11559
|
+
description: describe({
|
|
11560
|
+
what: "Replace the whole team setup (the team per item kind and per attribute) and refresh the desk. Needs an Admin of the workspace.",
|
|
11561
|
+
use: "the user wants items routed to other teams. Read talonic_contract_desk_settings, change it, send it whole.",
|
|
11562
|
+
not: "partial edits: kinds and fields left out lose their team.",
|
|
11563
|
+
args: "`teams` { kinds { <kind>: <team> } for value, documents_missing, site_check, text_check, deadline; fields { <field_key>: <team> } }.",
|
|
11564
|
+
returns: "the saved setup. 400 for an unknown kind or team."
|
|
11565
|
+
}),
|
|
11566
|
+
route: "PUT /v1/contract-desk/settings",
|
|
11567
|
+
inputSchema: {
|
|
11568
|
+
teams: z.object({
|
|
11569
|
+
kinds: z.record(z.string(), z.string()).describe("<kind>: <team>."),
|
|
11570
|
+
fields: z.record(z.string(), z.string()).describe("<field_key>: <team>.")
|
|
11571
|
+
}).describe("The whole team setup.")
|
|
11572
|
+
},
|
|
11573
|
+
annotations: write9(true),
|
|
11574
|
+
body: ["teams"]
|
|
11575
|
+
}
|
|
11576
|
+
]
|
|
11577
|
+
};
|
|
11578
|
+
var pipelineId2 = zUuid().optional().describe("The pipeline (talonic_customs_declaration_pipelines); default: the workspace's first.");
|
|
11579
|
+
var customsDeclarationGroup = {
|
|
11580
|
+
key: "customs_declaration",
|
|
11581
|
+
label: "Customs declaration",
|
|
11582
|
+
docsSlug: "customs-declaration-tools",
|
|
11583
|
+
probe: { path: "/v1/customs-declaration/pipelines" },
|
|
11584
|
+
tools: [
|
|
11585
|
+
{
|
|
11586
|
+
name: "talonic_customs_declaration_pipelines",
|
|
11587
|
+
title: "Customs declaration pipelines",
|
|
11588
|
+
description: describe({
|
|
11589
|
+
what: "The pipelines whose Spec compares transport documents with a filed customs declaration.",
|
|
11590
|
+
use: "finding the pipeline_id the other customs tools take, when the workspace has more than one.",
|
|
11591
|
+
returns: "{ data[] } pipelines with id and name."
|
|
11592
|
+
}),
|
|
11593
|
+
route: "GET /v1/customs-declaration/pipelines",
|
|
11594
|
+
inputSchema: {},
|
|
11595
|
+
annotations: READ
|
|
11596
|
+
},
|
|
11597
|
+
{
|
|
11598
|
+
name: "talonic_customs_declaration_issues",
|
|
11599
|
+
title: "Customs declaration worklist",
|
|
11600
|
+
description: describe({
|
|
11601
|
+
what: "The worklist: orders with a failing check, with the checks that fail (message and fields concerned) and the fields where documents and declaration differ or a value is missing.",
|
|
11602
|
+
use: "'which declarations are not ready to file', the starting point before opening an order.",
|
|
11603
|
+
not: "every order including ready ones (talonic_customs_declaration_orders).",
|
|
11604
|
+
args: "`pipeline_id` (optional).",
|
|
11605
|
+
returns: "{ pipeline, read, available, truncated, data[] { lrn, record_document_id, sender, receiver, checks[] { id, message, fields }, differs[] } }. truncated = more orders exist than were read."
|
|
11606
|
+
}),
|
|
11607
|
+
route: "GET /v1/customs-declaration/issues",
|
|
11608
|
+
inputSchema: { pipeline_id: pipelineId2 },
|
|
11609
|
+
annotations: READ,
|
|
11610
|
+
query: ["pipeline_id"]
|
|
11611
|
+
},
|
|
11612
|
+
{
|
|
11613
|
+
name: "talonic_customs_declaration_orders",
|
|
11614
|
+
title: "Customs declaration orders",
|
|
11615
|
+
description: describe({
|
|
11616
|
+
what: "Orders of a pipeline with their field-by-field comparison (document value, declared value, state match / mismatch / missing) and checks; the evidence for one order's issues.",
|
|
11617
|
+
use: "retrieving the evidence behind an issue (filter with `q` = its LRN), or listing orders ready to file.",
|
|
11618
|
+
args: "`pipeline_id`, `status` ready|review, `q` (LRN, sender, receiver or plates contains), `page` and `limit` (1-200; either asks for one page).",
|
|
11619
|
+
returns: "{ pipeline, read, available, items[] { lrn, ready, sender, receiver, plates, record_document_id, comparison[], checks[] }, page? { page, limit, total, filtered } }."
|
|
11620
|
+
}),
|
|
11621
|
+
route: "GET /v1/customs-declaration/declarations",
|
|
11622
|
+
inputSchema: {
|
|
11623
|
+
pipeline_id: pipelineId2,
|
|
11624
|
+
status: z.enum(["ready", "review"]).optional().describe("ready = every check passes; review = at least one fails."),
|
|
11625
|
+
q: z.string().max(200).optional().describe("LRN, sender, receiver or plates contains."),
|
|
11626
|
+
page: z.number().int().min(1).optional().describe("Page number (asks for one page)."),
|
|
11627
|
+
limit: z.number().int().min(1).max(200).optional().describe("Orders per page, at most 200 (default 50).")
|
|
11628
|
+
},
|
|
11629
|
+
annotations: READ,
|
|
11630
|
+
query: ["pipeline_id", "status", "q", "page", "limit"]
|
|
11631
|
+
}
|
|
11632
|
+
]
|
|
11633
|
+
};
|
|
11634
|
+
var cursorArgs = {
|
|
11635
|
+
limit: z.number().int().min(1).max(100).optional().describe("Items per page (1-100, default 20)."),
|
|
11636
|
+
cursor: z.string().max(512).optional().describe("pagination.next_cursor of the previous page."),
|
|
11637
|
+
order: z.enum(["asc", "desc"]).optional().describe("By creation time; default desc (newest first)."),
|
|
11638
|
+
after: z.string().optional().describe("Only items created after this ISO-8601 timestamp."),
|
|
11639
|
+
before: z.string().optional().describe("Only items created before this ISO-8601 timestamp.")
|
|
11640
|
+
};
|
|
11641
|
+
var PAGE_QUERY = ["limit", "cursor", "order", "after", "before"];
|
|
11642
|
+
var PAGE_RETURNS = "pagination { total, limit, has_more, next_cursor }";
|
|
11643
|
+
var LIST_DOCUMENTS = describe({
|
|
11644
|
+
what: "List the workspace's documents, newest first, one page at a time, with filters. Only documents this connection may see are listed.",
|
|
11645
|
+
use: "browsing or counting documents by status, source, upload time or filename (e.g. 'which uploads failed today', 'the attachments of this email').",
|
|
11646
|
+
not: "finding documents by their content or a field value (talonic_search, talonic_filter); one document's details (talonic_get_document).",
|
|
11647
|
+
args: "`status` (e.g. completed, error, extracting), `source_id`, `source_type`, `search` (filename contains), `parent_id` (documents unpacked from one container: email attachments, archive members, packet parts), `relation` (why a document is nested, e.g. email_attachment), `top_level` (true: hide nested documents), `text_degraded` (true: only documents whose text could not be read verbatim), `after` / `before` (ISO-8601 creation time), `limit` 1-100 (default 20), `cursor`, `order` asc|desc.",
|
|
11648
|
+
returns: `{ data[] { id, filename, pages, size_bytes, mime_type, type_detected, status, error?, source { id, type }, parent?, field_count, created_at, links }, ${PAGE_RETURNS} }.`
|
|
11649
|
+
});
|
|
11650
|
+
var REEXTRACT = describe({
|
|
11651
|
+
what: "Read an existing document again and capture its values afresh, without uploading it again. Consumes credits like a new extraction. Answers at once with status processing; the document's earlier values are replaced when it finishes.",
|
|
11652
|
+
use: "the user asks to redo a document after its schema or setup changed, or a document came out wrong.",
|
|
11653
|
+
not: "extracting with a different schema now and returning the values (talonic_extract with document_id); a document that is still processing (wait, poll talonic_get_document).",
|
|
11654
|
+
args: "`document_id` (UUID).",
|
|
11655
|
+
returns: "{ id, status: 'processing', message, links }. Poll talonic_get_document until status is completed (or a failure status). Not idempotent and not deduplicated: on a timeout, check the document's status before calling again.",
|
|
11656
|
+
errors: "402 out of credits; 404 the document does not exist or this connection may not see it."
|
|
11657
|
+
});
|
|
11658
|
+
var DELETE_DOCUMENT = describe({
|
|
11659
|
+
what: "Delete one document from the workspace together with its captured values. Cannot be undone.",
|
|
11660
|
+
use: "the user explicitly asks to remove a specific document (a duplicate, a wrong upload, data that must go). Confirm the filename with the user before calling.",
|
|
11661
|
+
not: "hiding a document from a list or retagging it; deleting many documents at once without the user naming them.",
|
|
11662
|
+
args: "`document_id` (UUID).",
|
|
11663
|
+
returns: "{ deleted: true, id }.",
|
|
11664
|
+
errors: "404 the document does not exist, this connection may not see it, or it was only shared with the user (shared documents are read-only)."
|
|
11665
|
+
});
|
|
11666
|
+
var LIST_EXTRACTIONS = describe({
|
|
11667
|
+
what: "List extractions (one per document that has captured values), newest first, one page at a time.",
|
|
11668
|
+
use: "finding the documents with completed or failed captures in a time range, or the extraction of one document.",
|
|
11669
|
+
not: "the values of one extraction (talonic_get_extraction_data); searching by value (talonic_filter).",
|
|
11670
|
+
args: "`document_id` (UUID), `status` complete|failed, `after` / `before` (ISO-8601), `limit` 1-100, `cursor`, `order`.",
|
|
11671
|
+
returns: `{ data[] { id, document_id, status, field_count, created_at, links }, ${PAGE_RETURNS} }. An extraction's id equals its document's id.`
|
|
11672
|
+
});
|
|
11673
|
+
var GET_EXTRACTION = describe({
|
|
11674
|
+
what: "One extraction in full: its fields with values, types and confidence, and the document it belongs to.",
|
|
11675
|
+
use: "inspecting how a document's values were captured before correcting them.",
|
|
11676
|
+
not: "just the field \u2192 value map (talonic_get_extraction_data).",
|
|
11677
|
+
args: "`extraction_id` (UUID; the document id).",
|
|
11678
|
+
returns: "The extraction with its fields, confidence and links."
|
|
11679
|
+
});
|
|
11680
|
+
var GET_EXTRACTION_DATA = describe({
|
|
11681
|
+
what: "One extraction's values as a flat field \u2192 value map (JSON), or as a one-row CSV.",
|
|
11682
|
+
use: "handing a document's captured values to another system or comparing them with a source.",
|
|
11683
|
+
not: "confidence and field metadata (talonic_get_extraction); values across many documents (talonic_field_values).",
|
|
11684
|
+
args: "`extraction_id` (UUID; the document id), `format` json|csv (default json).",
|
|
11685
|
+
returns: "JSON: { <field>: value }. CSV: { format: 'csv', csv } (header row plus one value row)."
|
|
11686
|
+
});
|
|
11687
|
+
var CORRECT_EXTRACTION = describe({
|
|
11688
|
+
what: "Correct captured values of one extraction. Each correction is stored as a new version of the value, attributed to this connection; a value that a reviewer confirmed or that waits for approval is NOT overwritten and is reported in cells_skipped.",
|
|
11689
|
+
use: "the user tells you a captured value is wrong and gives the right one.",
|
|
11690
|
+
not: "changing which fields a schema has (talonic_update_schema); re-reading the whole document (talonic_reextract_document).",
|
|
11691
|
+
args: "`extraction_id` (UUID; the document id), `values` { <field_name>: corrected value } (only the fields to change).",
|
|
11692
|
+
returns: "The extraction, plus cells_written[] and cells_skipped[] (the corrections that were withheld, with why).",
|
|
11693
|
+
errors: "400 `values` is not an object; 403 a workspace-wide (master view) credential; 404 unknown or not visible."
|
|
11694
|
+
});
|
|
11695
|
+
var LIST_JOBS = describe({
|
|
11696
|
+
what: "List jobs (a schema run over a set of documents), newest first, one page at a time.",
|
|
11697
|
+
use: "checking what jobs exist, which are still running, or finding a job id.",
|
|
11698
|
+
not: "Spec runs (talonic_get_run); one job (talonic_get_job).",
|
|
11699
|
+
args: "`status` (e.g. pending, processing, completed, failed), `after` / `before` (ISO-8601), `limit` 1-100, `cursor`, `order`.",
|
|
11700
|
+
returns: `{ data[] { id, name, status, schema, document_count, created_at, completed_at, links }, ${PAGE_RETURNS} }.`
|
|
11701
|
+
});
|
|
11702
|
+
var GET_JOB = describe({
|
|
11703
|
+
what: "One job: status, progress, schema, timestamps, error if it failed.",
|
|
11704
|
+
use: "polling a job created with talonic_create_job until it completes.",
|
|
11705
|
+
not: "the job's extracted rows (talonic_get_job_results).",
|
|
11706
|
+
args: "`job_id` (UUID).",
|
|
11707
|
+
returns: "{ id, name, status, schema, document_count, created_at, completed_at, error?, links }."
|
|
11708
|
+
});
|
|
11709
|
+
var GET_JOB_RESULTS = describe({
|
|
11710
|
+
what: "A job's result rows: one row per document with the extracted values, row confidence and validation flags. Readable while the job still runs (rows appear as documents finish). Only documents this connection may see are included.",
|
|
11711
|
+
use: "reading what a job extracted, e.g. to build a table or check a few values.",
|
|
11712
|
+
not: "one document's values (talonic_get_extraction_data).",
|
|
11713
|
+
args: "`job_id` (UUID).",
|
|
11714
|
+
returns: "{ job_id, job_status, schema { id, name }, total_rows, data[] { id, document_id, filename, status, values, confidence, validation_flags } }."
|
|
11715
|
+
});
|
|
11716
|
+
var CREATE_JOB = describe({
|
|
11717
|
+
what: "Create and queue a job: run a saved schema over a set of documents and collect one row of values per document. Consumes credits per document processed.",
|
|
11718
|
+
use: "the user wants the same fields pulled from many existing documents into one table.",
|
|
11719
|
+
not: "one document (talonic_extract with document_id); running a configured Spec (talonic_run_spec).",
|
|
11720
|
+
args: "`schema_id` (UUID of a saved schema), `document_ids` (UUIDs) OR `all_documents: true` (every completed document of the workspace; confirm with the user and check the cost first, talonic_get_pricing), `name` (optional, at most 200 characters).",
|
|
11721
|
+
returns: "{ id, status: 'pending', message, links { self, results } }. Poll talonic_get_job; read rows with talonic_get_job_results. Not deduplicated: after a timeout, look for the job with talonic_list_jobs before creating another.",
|
|
11722
|
+
errors: "400 no completed documents; 402 out of credits; 404 unknown schema."
|
|
11723
|
+
});
|
|
11724
|
+
var CANCEL_JOB = describe({
|
|
11725
|
+
what: "Cancel a pending or running job. Documents already processed keep their rows; the job ends as failed with the error 'Cancelled via API'.",
|
|
11726
|
+
use: "the user wants to stop a job (wrong schema, wrong documents, too expensive).",
|
|
11727
|
+
args: "`job_id` (UUID).",
|
|
11728
|
+
returns: "The job with status failed. Safe to retry: a job that already ended (completed, failed or cancelled) answers 409 and is left unchanged.",
|
|
11729
|
+
errors: "404 unknown job; 409 the job already ended."
|
|
11730
|
+
});
|
|
11731
|
+
var UPDATE_SCHEMA = describe({
|
|
11732
|
+
what: "Change a saved schema: rename it, change its description, or REPLACE its field list. Sending `definition` or `fields` replaces every field: fields not resent are removed, so read it first (talonic_get_schema), change it, and send the whole list. Confirm removed fields with the user.",
|
|
11733
|
+
use: "the user wants to add, remove or retype fields of a saved schema, or rename it.",
|
|
11734
|
+
not: "creating a schema (talonic_save_schema); a schema managed by a Spec (refused with 409; change the Spec in the app instead).",
|
|
11735
|
+
args: "`schema_id` (UUID or SCH-\u2026 short id), `name` (at most 100 characters), `description` (null clears it), `definition` (JSON Schema: { properties { <field>: { type, description?, title? } }, required[] }) OR `fields[]` { field_name, display_name?, data_type?, description?, is_required? }.",
|
|
11736
|
+
returns: "The schema with its fields as a JSON Schema definition.",
|
|
11737
|
+
errors: "404 unknown schema; 409 the schema is managed by a Spec."
|
|
11738
|
+
});
|
|
11739
|
+
var DELETE_SCHEMA = describe({
|
|
11740
|
+
what: "Delete a saved schema. Cannot be undone. Documents already extracted with it keep their values.",
|
|
11741
|
+
use: "the user explicitly asks to remove a specific schema. Confirm the schema's name with the user before calling.",
|
|
11742
|
+
not: "a schema managed by a Spec (refused with 409).",
|
|
11743
|
+
args: "`schema_id` (UUID or SCH-\u2026 short id).",
|
|
11744
|
+
returns: "{ deleted: true, id }.",
|
|
11745
|
+
errors: "404 unknown schema; 409 the schema is managed by a Spec."
|
|
11746
|
+
});
|
|
11747
|
+
var documentId = { document_id: zUuid().describe("The document id.") };
|
|
11748
|
+
var extractionId = {
|
|
11749
|
+
extraction_id: zUuid().describe("The extraction id (the same as its document's id).")
|
|
11750
|
+
};
|
|
11751
|
+
var jobId = { job_id: zUuid().describe("The job id.") };
|
|
11752
|
+
var schemaId = {
|
|
11753
|
+
schema_id: z.string().min(1).max(64).describe("The schema's UUID or SCH-XXXXXXXX short id.")
|
|
11754
|
+
};
|
|
11755
|
+
var schemaFieldSchema = z.object({
|
|
11756
|
+
field_name: z.string().min(1).describe("Machine name of the field."),
|
|
11757
|
+
display_name: z.string().optional(),
|
|
11758
|
+
data_type: z.string().optional().describe("string (default), number, boolean, date, \u2026"),
|
|
11759
|
+
description: z.string().optional(),
|
|
11760
|
+
is_required: z.boolean().optional()
|
|
11761
|
+
});
|
|
11762
|
+
var getExtractionData = {
|
|
11763
|
+
name: "talonic_get_extraction_data",
|
|
11764
|
+
title: "One extraction's values",
|
|
11765
|
+
description: GET_EXTRACTION_DATA,
|
|
11766
|
+
route: "GET /v1/extractions/{extractionId}/data",
|
|
11767
|
+
inputSchema: {
|
|
11768
|
+
...extractionId,
|
|
11769
|
+
format: z.enum(["json", "csv"]).optional().describe("json (default) or csv.")
|
|
11770
|
+
},
|
|
11771
|
+
annotations: READ,
|
|
11772
|
+
handler: async (ctx, args) => {
|
|
11773
|
+
const id = args["extraction_id"];
|
|
11774
|
+
if (args["format"] !== "csv") {
|
|
11775
|
+
return runGroupTool({ ...getExtractionData, handler: void 0 }, ctx, args);
|
|
11776
|
+
}
|
|
11777
|
+
return runTool(async () => {
|
|
11778
|
+
const url = buildUrl(ctx.baseUrl, `/v1/extractions/${encodeURIComponent(String(id))}/data`, {
|
|
11779
|
+
format: "csv"
|
|
11780
|
+
});
|
|
11781
|
+
const res = await resolveFetch(ctx.getToken)(url, {
|
|
11782
|
+
method: "GET",
|
|
11783
|
+
headers: { Authorization: `Bearer ${ctx.getToken()}`, Accept: "text/csv" }
|
|
11784
|
+
});
|
|
11785
|
+
if (!res.ok) throw await apiHttpError(res);
|
|
11786
|
+
return { format: "csv", csv: await res.text() };
|
|
11787
|
+
});
|
|
11788
|
+
}
|
|
11789
|
+
};
|
|
11790
|
+
var createJob = {
|
|
11791
|
+
name: "talonic_create_job",
|
|
11792
|
+
title: "Create a job over documents",
|
|
11793
|
+
description: CREATE_JOB,
|
|
11794
|
+
route: "POST /v1/jobs",
|
|
11795
|
+
inputSchema: {
|
|
11796
|
+
schema_id: zUuid().describe("UUID of the saved schema to run."),
|
|
11797
|
+
document_ids: z.array(zUuid()).min(1).max(1e4).optional().describe("The documents to process."),
|
|
11798
|
+
all_documents: z.boolean().optional().describe("true: every completed document of the workspace (instead of document_ids)."),
|
|
11799
|
+
name: z.string().max(200).optional().describe("A name for the job.")
|
|
11800
|
+
},
|
|
11801
|
+
annotations: write9(false),
|
|
11802
|
+
body: ["schema_id", "document_ids", "name"],
|
|
11803
|
+
handler: (ctx, args) => {
|
|
11804
|
+
const ids = args["document_ids"];
|
|
11805
|
+
const all = args["all_documents"] === true;
|
|
11806
|
+
if (ids?.length && all) {
|
|
11807
|
+
return Promise.resolve(
|
|
11808
|
+
validationError("pass `document_ids` or `all_documents: true`, not both.")
|
|
11809
|
+
);
|
|
11810
|
+
}
|
|
11811
|
+
if (!ids?.length && !all) {
|
|
11812
|
+
return Promise.resolve(
|
|
11813
|
+
validationError(
|
|
11814
|
+
"name the documents (`document_ids`) or pass `all_documents: true` to run over every completed document."
|
|
11815
|
+
)
|
|
11816
|
+
);
|
|
11817
|
+
}
|
|
11818
|
+
return runGroupTool({ ...createJob, handler: void 0 }, ctx, args);
|
|
11819
|
+
}
|
|
11820
|
+
};
|
|
11821
|
+
var dataManagementGroup = {
|
|
11822
|
+
key: "data_management",
|
|
11823
|
+
label: "Documents, extractions, jobs and schemas",
|
|
11824
|
+
docsSlug: "data-management-tools",
|
|
11825
|
+
probe: { path: "/v1/documents", params: { limit: 1 } },
|
|
11826
|
+
tools: [
|
|
11827
|
+
{
|
|
11828
|
+
name: "talonic_list_documents",
|
|
11829
|
+
title: "List documents",
|
|
11830
|
+
description: LIST_DOCUMENTS,
|
|
11831
|
+
route: "GET /v1/documents",
|
|
11832
|
+
inputSchema: {
|
|
11833
|
+
status: z.string().max(32).optional().describe("Only documents with this status."),
|
|
11834
|
+
source_id: zUuid().optional().describe("Only documents from this source."),
|
|
11835
|
+
source_type: z.string().max(64).optional().describe("Only documents from this kind of source."),
|
|
11836
|
+
search: z.string().max(200).optional().describe("Filename contains (case-insensitive)."),
|
|
11837
|
+
parent_id: zUuid().optional().describe("Only documents unpacked from this container document."),
|
|
11838
|
+
relation: z.string().max(32).optional().describe("Only nested documents of this kind, e.g. email_attachment."),
|
|
11839
|
+
top_level: z.boolean().optional().describe("true: hide documents nested in another."),
|
|
11840
|
+
text_degraded: z.boolean().optional().describe(
|
|
11841
|
+
"true: only documents whose text was not read verbatim; false: only those that were."
|
|
11842
|
+
),
|
|
11843
|
+
...cursorArgs
|
|
11844
|
+
},
|
|
11845
|
+
annotations: READ,
|
|
11846
|
+
query: [
|
|
11847
|
+
"status",
|
|
11848
|
+
"source_id",
|
|
11849
|
+
"source_type",
|
|
11850
|
+
"search",
|
|
11851
|
+
"parent_id",
|
|
11852
|
+
"relation",
|
|
11853
|
+
"top_level",
|
|
11854
|
+
"text_degraded",
|
|
11855
|
+
...PAGE_QUERY
|
|
11856
|
+
]
|
|
11857
|
+
},
|
|
11858
|
+
{
|
|
11859
|
+
name: "talonic_reextract_document",
|
|
11860
|
+
title: "Re-extract a document",
|
|
11861
|
+
description: REEXTRACT,
|
|
11862
|
+
route: "POST /v1/documents/{documentId}/re-extract",
|
|
11863
|
+
inputSchema: documentId,
|
|
11864
|
+
annotations: write9(false)
|
|
11865
|
+
},
|
|
11866
|
+
{
|
|
11867
|
+
name: "talonic_delete_document",
|
|
11868
|
+
title: "Delete a document",
|
|
11869
|
+
description: DELETE_DOCUMENT,
|
|
11870
|
+
route: "DELETE /v1/documents/{documentId}",
|
|
11871
|
+
inputSchema: documentId,
|
|
11872
|
+
annotations: write9(true, true)
|
|
11873
|
+
},
|
|
11874
|
+
{
|
|
11875
|
+
name: "talonic_list_extractions",
|
|
11876
|
+
title: "List extractions",
|
|
11877
|
+
description: LIST_EXTRACTIONS,
|
|
11878
|
+
route: "GET /v1/extractions",
|
|
11879
|
+
inputSchema: {
|
|
11880
|
+
document_id: zUuid().optional().describe("Only the extraction of this document."),
|
|
11881
|
+
status: z.enum(["complete", "failed"]).optional(),
|
|
11882
|
+
...cursorArgs
|
|
11883
|
+
},
|
|
11884
|
+
annotations: READ,
|
|
11885
|
+
query: ["document_id", "status", ...PAGE_QUERY]
|
|
11886
|
+
},
|
|
11887
|
+
{
|
|
11888
|
+
name: "talonic_get_extraction",
|
|
11889
|
+
title: "One extraction",
|
|
11890
|
+
description: GET_EXTRACTION,
|
|
11891
|
+
route: "GET /v1/extractions/{extractionId}",
|
|
11892
|
+
inputSchema: extractionId,
|
|
11893
|
+
annotations: READ
|
|
11894
|
+
},
|
|
11895
|
+
getExtractionData,
|
|
11896
|
+
{
|
|
11897
|
+
name: "talonic_correct_extraction",
|
|
11898
|
+
title: "Correct extracted values",
|
|
11899
|
+
description: CORRECT_EXTRACTION,
|
|
11900
|
+
route: "PATCH /v1/extractions/{extractionId}/data",
|
|
11901
|
+
inputSchema: {
|
|
11902
|
+
...extractionId,
|
|
11903
|
+
values: z.record(z.string(), z.unknown()).describe("{ <field_name>: corrected value } for the fields to change.")
|
|
11904
|
+
},
|
|
11905
|
+
annotations: write9(true),
|
|
11906
|
+
handler: (ctx, args) => {
|
|
11907
|
+
const values = args["values"];
|
|
11908
|
+
if (!values || typeof values !== "object" || Array.isArray(values)) {
|
|
11909
|
+
return Promise.resolve(validationError("`values` must be an object of field \u2192 value."));
|
|
11910
|
+
}
|
|
11911
|
+
if (Object.keys(values).length === 0) {
|
|
11912
|
+
return Promise.resolve(validationError("`values` names no field to correct."));
|
|
11913
|
+
}
|
|
11914
|
+
return runTool(
|
|
11915
|
+
() => apiJson(
|
|
11916
|
+
ctx.getToken,
|
|
11917
|
+
ctx.baseUrl,
|
|
11918
|
+
"PATCH",
|
|
11919
|
+
`/v1/extractions/${encodeURIComponent(String(args["extraction_id"]))}/data`,
|
|
11920
|
+
{ body: values }
|
|
11921
|
+
)
|
|
11922
|
+
);
|
|
11923
|
+
}
|
|
11924
|
+
},
|
|
11925
|
+
{
|
|
11926
|
+
name: "talonic_list_jobs",
|
|
11927
|
+
title: "List jobs",
|
|
11928
|
+
description: LIST_JOBS,
|
|
11929
|
+
route: "GET /v1/jobs",
|
|
11930
|
+
inputSchema: {
|
|
11931
|
+
status: z.string().max(32).optional().describe("Only jobs with this status."),
|
|
11932
|
+
...cursorArgs
|
|
11933
|
+
},
|
|
11934
|
+
annotations: READ,
|
|
11935
|
+
query: ["status", ...PAGE_QUERY]
|
|
11936
|
+
},
|
|
11937
|
+
{
|
|
11938
|
+
name: "talonic_get_job",
|
|
11939
|
+
title: "One job",
|
|
11940
|
+
description: GET_JOB,
|
|
11941
|
+
route: "GET /v1/jobs/{jobId}",
|
|
11942
|
+
inputSchema: jobId,
|
|
11943
|
+
annotations: READ
|
|
11944
|
+
},
|
|
11945
|
+
{
|
|
11946
|
+
name: "talonic_get_job_results",
|
|
11947
|
+
title: "A job's result rows",
|
|
11948
|
+
description: GET_JOB_RESULTS,
|
|
11949
|
+
route: "GET /v1/jobs/{jobId}/results",
|
|
11950
|
+
inputSchema: jobId,
|
|
11951
|
+
annotations: READ
|
|
11952
|
+
},
|
|
11953
|
+
createJob,
|
|
11954
|
+
{
|
|
11955
|
+
name: "talonic_cancel_job",
|
|
11956
|
+
title: "Cancel a job",
|
|
11957
|
+
description: CANCEL_JOB,
|
|
11958
|
+
route: "POST /v1/jobs/{jobId}/cancel",
|
|
11959
|
+
inputSchema: jobId,
|
|
11960
|
+
annotations: write9(true)
|
|
11961
|
+
},
|
|
11962
|
+
{
|
|
11963
|
+
name: "talonic_update_schema",
|
|
11964
|
+
title: "Change a saved schema",
|
|
11965
|
+
description: UPDATE_SCHEMA,
|
|
11966
|
+
route: "PUT /v1/schemas/{schemaId}",
|
|
11967
|
+
inputSchema: {
|
|
11968
|
+
...schemaId,
|
|
11969
|
+
name: z.string().min(1).max(100).optional().describe("New name."),
|
|
11970
|
+
description: z.string().nullable().optional().describe("New description; null clears it."),
|
|
11971
|
+
definition: z.object({
|
|
11972
|
+
properties: z.record(z.string(), z.record(z.string(), z.unknown())),
|
|
11973
|
+
required: z.array(z.string()).optional()
|
|
11974
|
+
}).optional().describe("The complete new field list as a JSON Schema object. Replaces every field."),
|
|
11975
|
+
fields: z.array(schemaFieldSchema).min(1).optional().describe("The complete new field list as rows. Replaces every field.")
|
|
11976
|
+
},
|
|
11977
|
+
annotations: write9(true, true),
|
|
11978
|
+
body: ["name", "description", "definition", "fields"],
|
|
11979
|
+
handler: (ctx, args) => {
|
|
11980
|
+
if (args["definition"] !== void 0 && args["fields"] !== void 0) {
|
|
11981
|
+
return Promise.resolve(validationError("send `definition` or `fields`, not both."));
|
|
11982
|
+
}
|
|
11983
|
+
const changes = ["name", "description", "definition", "fields"].filter(
|
|
11984
|
+
(k) => args[k] !== void 0
|
|
11985
|
+
);
|
|
11986
|
+
if (changes.length === 0) {
|
|
11987
|
+
return Promise.resolve(
|
|
11988
|
+
validationError("nothing to change: pass name, description, definition or fields.")
|
|
11989
|
+
);
|
|
11990
|
+
}
|
|
11991
|
+
const req = buildRequest(
|
|
11992
|
+
{
|
|
11993
|
+
route: "PUT /v1/schemas/{schemaId}",
|
|
11994
|
+
body: ["name", "description", "definition", "fields"]
|
|
11995
|
+
},
|
|
11996
|
+
args
|
|
11997
|
+
);
|
|
11998
|
+
return runTool(
|
|
11999
|
+
() => apiJson(ctx.getToken, ctx.baseUrl, req.method, req.path, { body: req.body })
|
|
12000
|
+
);
|
|
12001
|
+
}
|
|
12002
|
+
},
|
|
12003
|
+
{
|
|
12004
|
+
name: "talonic_delete_schema",
|
|
12005
|
+
title: "Delete a saved schema",
|
|
12006
|
+
description: DELETE_SCHEMA,
|
|
12007
|
+
route: "DELETE /v1/schemas/{schemaId}",
|
|
12008
|
+
inputSchema: schemaId,
|
|
12009
|
+
annotations: write9(true, true)
|
|
12010
|
+
}
|
|
12011
|
+
]
|
|
12012
|
+
};
|
|
12013
|
+
var LIST_EVENTS = describe({
|
|
12014
|
+
what: "Read the workspace's event feed: document extractions, run completions and failures, review verdicts and delivery outcomes, the same events webhooks are sent from. Only events about documents this credential may see are returned.",
|
|
12015
|
+
use: "catching up on what happened since a point in time or since a saved cursor (a poller, a missed webhook), or answering 'what finished / failed recently'.",
|
|
12016
|
+
not: "configuring webhooks (talonic_list_webhooks and its siblings, for workspace admins); workspace totals over a window (talonic_aggregate).",
|
|
12017
|
+
args: "`after` (an event id or a saved `next_cursor`: returns strictly newer events OLDEST FIRST; resume with the returned next_cursor), `since` (ISO-8601 lower bound on created_at), `event_type` (one type or a list), `limit` 1-200 (default 50), `offset` (newest-first listing only, ignored with `after`).",
|
|
12018
|
+
returns: "{ data[] { id, event_type, payload, created_at }, total, limit, offset, next_cursor }. next_cursor is null only at the end of the feed; on the newest-first listing it is the highest id on the page, so a poller can switch to `after` from there."
|
|
12019
|
+
});
|
|
12020
|
+
var eventsGroup = {
|
|
12021
|
+
key: "events",
|
|
12022
|
+
label: "Events",
|
|
12023
|
+
docsSlug: "events-tools",
|
|
12024
|
+
probe: { path: "/v1/events", params: { limit: 1 } },
|
|
12025
|
+
tools: [
|
|
12026
|
+
{
|
|
12027
|
+
name: "talonic_list_events",
|
|
12028
|
+
title: "Workspace event feed",
|
|
12029
|
+
description: LIST_EVENTS,
|
|
12030
|
+
route: "GET /v1/events",
|
|
12031
|
+
inputSchema: {
|
|
12032
|
+
after: z.string().max(64).optional().describe(
|
|
12033
|
+
"Resume point: a saved next_cursor or an event id. Returns newer events, oldest first."
|
|
12034
|
+
),
|
|
12035
|
+
since: z.string().optional().describe("Only events created at or after this ISO-8601 timestamp."),
|
|
12036
|
+
event_type: z.union([z.string(), z.array(z.string())]).optional().describe("One event type, or several (sent comma-separated)."),
|
|
12037
|
+
limit: z.number().int().min(1).max(200).optional().describe("Events per page (default 50)."),
|
|
12038
|
+
offset: z.number().int().min(0).optional().describe("Events to skip on the newest-first listing; ignored with `after`.")
|
|
12039
|
+
},
|
|
12040
|
+
annotations: READ,
|
|
12041
|
+
query: ["after", "since", "event_type", "limit", "offset"]
|
|
12042
|
+
}
|
|
12043
|
+
]
|
|
12044
|
+
};
|
|
12045
|
+
var moneyFoundGroup = {
|
|
12046
|
+
key: "money_found",
|
|
12047
|
+
label: "Money Found",
|
|
12048
|
+
docsSlug: "money-found-tools",
|
|
12049
|
+
probe: { path: "/v1/money-found/reviews" },
|
|
12050
|
+
tools: [
|
|
12051
|
+
{
|
|
12052
|
+
name: "talonic_money_found_ledger",
|
|
12053
|
+
title: "Money Found ledger",
|
|
12054
|
+
description: describe({
|
|
12055
|
+
what: "The whole lever ledger: per lever (a kind of recoverable amount, such as a charge the contract allows but the invoices leave off) its rows, each with its key, party and agreement, the amount, its `tier` (e.g. potential) and `state`, the explanation, and the quotes and documents it rests on, plus the ledger totals in the ledger currency.",
|
|
12056
|
+
use: "'how much money is there to recover', or finding one row (lever id and row key) and the evidence behind it.",
|
|
12057
|
+
not: "what to ask the customer for (talonic_money_found_evidence_requests).",
|
|
12058
|
+
returns: "{ currency, as_of, levers[] { id, name, rows[] { key, party, agreement, tier, state, detail, \u2026 } }, potential_total, resolved_total, estimated_total, held_for_review_total, not_finding_total, \u2026 }. Large; ask the user which lever or party matters before reading every row aloud."
|
|
12059
|
+
}),
|
|
12060
|
+
route: "GET /v1/money-found/levers",
|
|
12061
|
+
inputSchema: {},
|
|
12062
|
+
annotations: READ
|
|
12063
|
+
},
|
|
12064
|
+
{
|
|
12065
|
+
name: "talonic_money_found_evidence_requests",
|
|
12066
|
+
title: "Money Found evidence requests",
|
|
12067
|
+
description: describe({
|
|
12068
|
+
what: "What to ask the customer's receivables team for: the open potential rows that need a confirmation, grouped by cost unit and framework number, largest first, each item with its lever id and row key, invoice type, period, amount and the question to ask.",
|
|
12069
|
+
use: "preparing the request for confirmations that turn potential rows into owed ones.",
|
|
12070
|
+
not: "the ledger itself (talonic_money_found_ledger).",
|
|
12071
|
+
returns: "{ currency, groups[] { cost_unit, framework_number, customer, contracts[], total, items[] { lever_id, row_key, invoice_type, period, ask, amount, contract } } }."
|
|
12072
|
+
}),
|
|
12073
|
+
route: "GET /v1/money-found/evidence-requests",
|
|
12074
|
+
inputSchema: {},
|
|
12075
|
+
annotations: READ
|
|
12076
|
+
},
|
|
12077
|
+
{
|
|
12078
|
+
name: "talonic_money_found_reviews",
|
|
12079
|
+
title: "Money Found re-reviews",
|
|
12080
|
+
description: describe({
|
|
12081
|
+
what: "Re-reviews of contract price rows: per row its status (queued, running, done), the outcome, and the suggested price where a contract price was read again.",
|
|
12082
|
+
use: "after talonic_money_found_review_row or talonic_money_found_review_all, to read the outcome.",
|
|
12083
|
+
returns: "The re-reviews with their counts and suggested prices."
|
|
12084
|
+
}),
|
|
12085
|
+
route: "GET /v1/money-found/reviews",
|
|
12086
|
+
inputSchema: {},
|
|
12087
|
+
annotations: READ
|
|
12088
|
+
},
|
|
12089
|
+
{
|
|
12090
|
+
name: "talonic_money_found_review_row",
|
|
12091
|
+
title: "Re-review one Money Found row",
|
|
12092
|
+
description: describe({
|
|
12093
|
+
what: "Queue a re-review of one contract price row: its contract price is checked again against the documents; the ledger changes only when the review finds a different price.",
|
|
12094
|
+
use: "the user doubts a row's amount or its price, or a contract was replaced.",
|
|
12095
|
+
args: "`lever_id`, `key` (the row key from talonic_money_found_ledger).",
|
|
12096
|
+
returns: "{ review } the queued review.",
|
|
12097
|
+
errors: "404 when the lever or row does not exist; 403 when the app is switched off."
|
|
12098
|
+
}),
|
|
12099
|
+
route: "POST /v1/money-found/rows/{leverId}/{key}/review",
|
|
12100
|
+
inputSchema: {
|
|
12101
|
+
lever_id: z.string().min(1).max(200).describe("The lever id of the row."),
|
|
12102
|
+
key: z.string().min(1).max(1e3).describe("The row key.")
|
|
12103
|
+
},
|
|
12104
|
+
annotations: write9(true)
|
|
12105
|
+
},
|
|
12106
|
+
{
|
|
12107
|
+
name: "talonic_money_found_review_all",
|
|
12108
|
+
title: "Re-review every pending Money Found row",
|
|
12109
|
+
description: describe({
|
|
12110
|
+
what: "Queue a re-review of every contract price row not reviewed since its check changed.",
|
|
12111
|
+
use: "bringing the whole ledger up to date after many documents arrived.",
|
|
12112
|
+
returns: "How many reviews were queued."
|
|
12113
|
+
}),
|
|
12114
|
+
route: "POST /v1/money-found/reviews/run",
|
|
12115
|
+
inputSchema: {},
|
|
12116
|
+
annotations: write9(true)
|
|
12117
|
+
}
|
|
12118
|
+
]
|
|
12119
|
+
};
|
|
12120
|
+
var folderId = zUuid().describe("The folder id (talonic_transport_folders_list or _worklist).");
|
|
12121
|
+
var documentId2 = zUuid().describe("The document id, from the folder's documents.");
|
|
12122
|
+
var loadKey = z.string().min(1).max(200).describe("The load key, from the folder's loads.");
|
|
12123
|
+
var DETAIL_RETURNS = "the folder as talonic_transport_folders_get returns it, after the change: { id, folder_key, status, loads[] { key, verdict complete|check|missing, flags[], comparison[], handover[], confirmed }, documents[] { id, type, status auto|manual|folder|internal|review|pending, load_key, suggested_load_key, candidates[] }, \u2026 }.";
|
|
12124
|
+
var HANDOVER_MAX_BYTES = 8 * 1024 * 1024;
|
|
12125
|
+
var handoverTool = {
|
|
12126
|
+
name: "talonic_transport_folders_handover",
|
|
12127
|
+
title: "Customer document set of a load",
|
|
12128
|
+
description: describe({
|
|
12129
|
+
what: "The customer document set of one load: one PDF with one document per required type (the copy the recipient confirmed where there is one), returned as an embedded PDF file (up to 8 MB), plus the archive filing values per document (`index`).",
|
|
12130
|
+
use: "the user wants the papers to send with the invoice for a load, usually after talonic_transport_folders_confirm_load.",
|
|
12131
|
+
not: "the folder's matching (talonic_transport_folders_get).",
|
|
12132
|
+
args: "`folder_id`, `load_key`.",
|
|
12133
|
+
returns: "a text item { filename, size, index[] } and a resource item { uri, mimeType application/pdf, blob }. 422 when the load has no document to hand over."
|
|
12134
|
+
}),
|
|
12135
|
+
route: "GET /v1/transport-folders/{folderId}/loads/{loadKey}/handover",
|
|
12136
|
+
inputSchema: { folder_id: folderId, load_key: loadKey },
|
|
12137
|
+
annotations: READ,
|
|
12138
|
+
handler: async (ctx, args) => {
|
|
12139
|
+
try {
|
|
12140
|
+
const req = buildRequest(handoverTool, args);
|
|
12141
|
+
const r = await apiJson(
|
|
12142
|
+
ctx.getToken,
|
|
12143
|
+
ctx.baseUrl,
|
|
12144
|
+
req.method,
|
|
12145
|
+
req.path
|
|
12146
|
+
);
|
|
12147
|
+
const meta = {
|
|
12148
|
+
filename: r.filename,
|
|
12149
|
+
size: Math.floor((r.pdf_base64?.length ?? 0) * 3 / 4),
|
|
12150
|
+
index: r.index
|
|
12151
|
+
};
|
|
12152
|
+
if (meta.size > HANDOVER_MAX_BYTES) {
|
|
12153
|
+
return toolError(
|
|
12154
|
+
new Error(
|
|
12155
|
+
`The document set is ${meta.size} bytes, over the ${HANDOVER_MAX_BYTES}-byte limit for a tool result. Download it from the Transport Folders app instead.`
|
|
12156
|
+
)
|
|
12157
|
+
);
|
|
12158
|
+
}
|
|
12159
|
+
const result = {
|
|
12160
|
+
content: [
|
|
12161
|
+
{ type: "text", text: JSON.stringify(meta) },
|
|
12162
|
+
{
|
|
12163
|
+
type: "resource",
|
|
12164
|
+
resource: {
|
|
12165
|
+
uri: buildUrl(ctx.baseUrl, req.path),
|
|
12166
|
+
mimeType: "application/pdf",
|
|
12167
|
+
blob: r.pdf_base64
|
|
12168
|
+
}
|
|
12169
|
+
}
|
|
12170
|
+
],
|
|
12171
|
+
structuredContent: meta
|
|
12172
|
+
};
|
|
12173
|
+
return result;
|
|
12174
|
+
} catch (err) {
|
|
12175
|
+
return toolError(err);
|
|
12176
|
+
}
|
|
12177
|
+
}
|
|
12178
|
+
};
|
|
12179
|
+
var transportFoldersGroup = {
|
|
12180
|
+
key: "transport_folders",
|
|
12181
|
+
label: "Transport Folders",
|
|
12182
|
+
docsSlug: "transport-folders-tools",
|
|
12183
|
+
probe: { path: "/v1/transport-folders/settings" },
|
|
12184
|
+
tools: [
|
|
12185
|
+
{
|
|
12186
|
+
name: "talonic_transport_folders_list",
|
|
12187
|
+
title: "Transport folders",
|
|
12188
|
+
description: describe({
|
|
12189
|
+
what: "Every transport folder (one scanned packet per transport) with its transport number, status (complete, check, missing, review, no_loads, processing) and load counts, and whether the app is set up.",
|
|
12190
|
+
use: "an overview of the folders, or finding one by transport number.",
|
|
12191
|
+
not: "only what needs a person (talonic_transport_folders_worklist); one folder's loads and documents (talonic_transport_folders_get).",
|
|
12192
|
+
returns: "{ configured, data[] { id, folder_key, status, loads, documents, \u2026 } }."
|
|
12193
|
+
}),
|
|
12194
|
+
route: "GET /v1/transport-folders",
|
|
12195
|
+
inputSchema: {},
|
|
12196
|
+
annotations: READ
|
|
12197
|
+
},
|
|
12198
|
+
{
|
|
12199
|
+
name: "talonic_transport_folders_worklist",
|
|
12200
|
+
title: "Transport Folders worklist",
|
|
12201
|
+
description: describe({
|
|
12202
|
+
what: "Everything that needs a person, across all folders: loads that are not complete and documents not assigned to a load.",
|
|
12203
|
+
use: "starting work; each entry names its folder for talonic_transport_folders_get.",
|
|
12204
|
+
not: "all folders (talonic_transport_folders_list).",
|
|
12205
|
+
returns: "{ loads[] { folder_id, load_key, verdict, flags, \u2026 }, documents[] { folder_id, document_id, type, suggested_load_key, \u2026 }, type_labels }."
|
|
12206
|
+
}),
|
|
12207
|
+
route: "GET /v1/transport-folders/worklist",
|
|
12208
|
+
inputSchema: {},
|
|
12209
|
+
annotations: READ
|
|
12210
|
+
},
|
|
12211
|
+
{
|
|
12212
|
+
name: "talonic_transport_folders_get",
|
|
12213
|
+
title: "One transport folder",
|
|
12214
|
+
description: describe({
|
|
12215
|
+
what: "One folder with its loads and matched documents: per load its verdict, what is missing, the record compared with the documents (naming the source document of each value) and whether it is confirmed; per document its type, the load it belongs to and why, or the candidate loads and a suggestion when it waits for a person.",
|
|
12216
|
+
use: "the evidence before assigning a document or confirming a load.",
|
|
12217
|
+
not: "where a value sits on the page (talonic_transport_folders_boxes).",
|
|
12218
|
+
args: "`folder_id`.",
|
|
12219
|
+
returns: DETAIL_RETURNS
|
|
12220
|
+
}),
|
|
12221
|
+
route: "GET /v1/transport-folders/{folderId}",
|
|
12222
|
+
inputSchema: { folder_id: folderId },
|
|
12223
|
+
annotations: READ
|
|
12224
|
+
},
|
|
12225
|
+
{
|
|
12226
|
+
name: "talonic_transport_folders_boxes",
|
|
12227
|
+
title: "Where a document's values sit",
|
|
12228
|
+
description: describe({
|
|
12229
|
+
what: "Where each captured value of one document sits on its pages (boxes as page fractions), as far as already located.",
|
|
12230
|
+
use: "pointing the user to the value on the scan.",
|
|
12231
|
+
not: "locating values that have no box yet (talonic_transport_folders_locate_document).",
|
|
12232
|
+
args: "`folder_id`, `document_id`.",
|
|
12233
|
+
returns: "{ document_id, pages[], boxes[] { field, value, page, x, y, w, h } }."
|
|
12234
|
+
}),
|
|
12235
|
+
route: "GET /v1/transport-folders/{folderId}/documents/{documentId}/boxes",
|
|
12236
|
+
inputSchema: { folder_id: folderId, document_id: documentId2 },
|
|
12237
|
+
annotations: READ
|
|
12238
|
+
},
|
|
12239
|
+
{
|
|
12240
|
+
name: "talonic_transport_folders_locate_document",
|
|
12241
|
+
title: "Locate a document's values",
|
|
12242
|
+
description: describe({
|
|
12243
|
+
what: "Find where each captured value of one document sits on its page images and keep the boxes. Does nothing when the values were already located. Needs the app switched on.",
|
|
12244
|
+
use: "talonic_transport_folders_boxes came back without boxes.",
|
|
12245
|
+
not: "a whole folder (talonic_transport_folders_locate_folder).",
|
|
12246
|
+
args: "`folder_id`, `document_id`.",
|
|
12247
|
+
returns: "the document's boxes, as talonic_transport_folders_boxes returns them."
|
|
12248
|
+
}),
|
|
12249
|
+
route: "POST /v1/transport-folders/{folderId}/documents/{documentId}/locate",
|
|
12250
|
+
inputSchema: { folder_id: folderId, document_id: documentId2 },
|
|
12251
|
+
annotations: write9(true)
|
|
12252
|
+
},
|
|
12253
|
+
{
|
|
12254
|
+
name: "talonic_transport_folders_locate_folder",
|
|
12255
|
+
title: "Locate a folder's values",
|
|
12256
|
+
description: describe({
|
|
12257
|
+
what: "Find where the captured values of every document of a folder sit on the page images. Documents already located are skipped. Needs the app switched on.",
|
|
12258
|
+
use: "before going through a folder's documents on screen.",
|
|
12259
|
+
not: "one document (talonic_transport_folders_locate_document).",
|
|
12260
|
+
args: "`folder_id`.",
|
|
12261
|
+
returns: "per document whether boxes are now stored."
|
|
12262
|
+
}),
|
|
12263
|
+
route: "POST /v1/transport-folders/{folderId}/locate",
|
|
12264
|
+
inputSchema: { folder_id: folderId },
|
|
12265
|
+
annotations: write9(true)
|
|
12266
|
+
},
|
|
12267
|
+
{
|
|
12268
|
+
name: "talonic_transport_folders_assign",
|
|
12269
|
+
title: "Assign a document to a load",
|
|
12270
|
+
description: describe({
|
|
12271
|
+
what: "Record which load a document belongs to, or that it belongs to no load (`load_key` null). A person's assignment wins over the matching. Undo with talonic_transport_folders_unassign.",
|
|
12272
|
+
use: "a document waits for review, or was matched to the wrong load.",
|
|
12273
|
+
not: "confirming the load (talonic_transport_folders_confirm_load).",
|
|
12274
|
+
args: "`folder_id`, `document_id`, `load_key` (a load of this folder, or null for no load).",
|
|
12275
|
+
returns: DETAIL_RETURNS,
|
|
12276
|
+
errors: "400 load_key is not a load of this folder; 404 document not in this folder."
|
|
12277
|
+
}),
|
|
12278
|
+
route: "POST /v1/transport-folders/{folderId}/documents/{documentId}/assign",
|
|
12279
|
+
inputSchema: {
|
|
12280
|
+
folder_id: folderId,
|
|
12281
|
+
document_id: documentId2,
|
|
12282
|
+
load_key: z.string().max(200).nullable().describe("The load the document belongs to; null = it belongs to no load.")
|
|
12283
|
+
},
|
|
12284
|
+
annotations: write9(true),
|
|
12285
|
+
body: ["load_key"]
|
|
12286
|
+
},
|
|
12287
|
+
{
|
|
12288
|
+
name: "talonic_transport_folders_unassign",
|
|
12289
|
+
title: "Withdraw a document's assignment",
|
|
12290
|
+
description: describe({
|
|
12291
|
+
what: "Withdraw a person's assignment of a document, so the matching decides again.",
|
|
12292
|
+
use: "an assignment made with talonic_transport_folders_assign was wrong.",
|
|
12293
|
+
args: "`folder_id`, `document_id`.",
|
|
12294
|
+
returns: DETAIL_RETURNS
|
|
12295
|
+
}),
|
|
12296
|
+
route: "DELETE /v1/transport-folders/{folderId}/documents/{documentId}/assign",
|
|
12297
|
+
inputSchema: { folder_id: folderId, document_id: documentId2 },
|
|
12298
|
+
annotations: write9(true)
|
|
12299
|
+
},
|
|
12300
|
+
{
|
|
12301
|
+
name: "talonic_transport_folders_confirm_load",
|
|
12302
|
+
title: "Confirm a load",
|
|
12303
|
+
description: describe({
|
|
12304
|
+
what: "Confirm a load as ready to invoice and hand its customer document set over. Records who confirmed and which documents. Needs the app switched on. Undo with talonic_transport_folders_unconfirm_load.",
|
|
12305
|
+
use: "the load's verdict is complete, or the user checked it and accepts it.",
|
|
12306
|
+
not: "getting the PDF (talonic_transport_folders_handover).",
|
|
12307
|
+
args: "`folder_id`, `load_key`.",
|
|
12308
|
+
returns: DETAIL_RETURNS
|
|
12309
|
+
}),
|
|
12310
|
+
route: "POST /v1/transport-folders/{folderId}/loads/{loadKey}/confirm",
|
|
12311
|
+
inputSchema: { folder_id: folderId, load_key: loadKey },
|
|
12312
|
+
annotations: write9(true)
|
|
12313
|
+
},
|
|
12314
|
+
{
|
|
12315
|
+
name: "talonic_transport_folders_unconfirm_load",
|
|
12316
|
+
title: "Withdraw a load's confirmation",
|
|
12317
|
+
description: describe({
|
|
12318
|
+
what: "Withdraw the confirmation of a load.",
|
|
12319
|
+
use: "a load was confirmed by mistake.",
|
|
12320
|
+
args: "`folder_id`, `load_key`.",
|
|
12321
|
+
returns: DETAIL_RETURNS
|
|
12322
|
+
}),
|
|
12323
|
+
route: "DELETE /v1/transport-folders/{folderId}/loads/{loadKey}/confirm",
|
|
12324
|
+
inputSchema: { folder_id: folderId, load_key: loadKey },
|
|
12325
|
+
annotations: write9(true)
|
|
12326
|
+
},
|
|
12327
|
+
handoverTool,
|
|
12328
|
+
{
|
|
12329
|
+
name: "talonic_transport_folders_settings",
|
|
12330
|
+
title: "Transport Folders settings",
|
|
12331
|
+
description: describe({
|
|
12332
|
+
what: "The app's settings (the Spec whose results describe the documents, the reference table holding the loads, the pattern that reads the transport number from a filename, matching overrides) and what they can be set to (the workspace's Specs and ready reference tables).",
|
|
12333
|
+
use: "setting up the app, or explaining why a folder has no loads.",
|
|
12334
|
+
not: "changing them (talonic_transport_folders_save_settings).",
|
|
12335
|
+
returns: "{ settings, pipelines[] { id, name, status }, reference_tables[] { id, name, row_count } }."
|
|
12336
|
+
}),
|
|
12337
|
+
route: "GET /v1/transport-folders/settings",
|
|
12338
|
+
inputSchema: {},
|
|
12339
|
+
annotations: READ
|
|
12340
|
+
},
|
|
12341
|
+
{
|
|
12342
|
+
name: "talonic_transport_folders_save_settings",
|
|
12343
|
+
title: "Change Transport Folders settings",
|
|
12344
|
+
description: describe({
|
|
12345
|
+
what: "Change the app's settings. Only the keys sent change; null clears one. Needs an Admin of the workspace.",
|
|
12346
|
+
use: "setting up the app or pointing it at another Spec or reference table.",
|
|
12347
|
+
args: "`pipeline_id` (from talonic_transport_folders_settings pipelines), `reference_data_id`, `folder_key_pattern` (a regular expression whose first group is the transport number), `matcher` (overrides of column names, field names, document type lists).",
|
|
12348
|
+
returns: "the settings and choices, as talonic_transport_folders_settings returns them. 400 for an invalid pattern."
|
|
12349
|
+
}),
|
|
12350
|
+
route: "PUT /v1/transport-folders/settings",
|
|
12351
|
+
inputSchema: {
|
|
12352
|
+
pipeline_id: zUuid().nullable().optional().describe("The Spec run whose results describe the documents."),
|
|
12353
|
+
reference_data_id: zUuid().nullable().optional().describe("The reference table holding the loads."),
|
|
12354
|
+
folder_key_pattern: z.string().max(200).nullable().optional().describe("Regular expression; its first group is the transport number in a filename."),
|
|
12355
|
+
matcher: z.record(z.string(), z.unknown()).nullable().optional().describe("Overrides of the matching defaults.")
|
|
12356
|
+
},
|
|
12357
|
+
annotations: write9(true),
|
|
12358
|
+
body: ["pipeline_id", "reference_data_id", "folder_key_pattern", "matcher"]
|
|
12359
|
+
}
|
|
12360
|
+
]
|
|
12361
|
+
};
|
|
12362
|
+
|
|
12363
|
+
// src/tools/tool-groups.ts
|
|
12364
|
+
var TOOL_GROUPS = [
|
|
12365
|
+
dataManagementGroup,
|
|
12366
|
+
eventsGroup,
|
|
12367
|
+
aggregateGroup,
|
|
12368
|
+
adminGroup,
|
|
12369
|
+
contractDeskGroup,
|
|
12370
|
+
transportFoldersGroup,
|
|
12371
|
+
complianceGroup,
|
|
12372
|
+
moneyFoundGroup,
|
|
12373
|
+
customsDeclarationGroup
|
|
12374
|
+
];
|
|
12375
|
+
TOOL_GROUPS.map((g) => g.key);
|
|
12376
|
+
async function probeToolGroups(token, baseUrl) {
|
|
12377
|
+
const answers = await Promise.all(
|
|
12378
|
+
TOOL_GROUPS.map((g) => probeGroup(g, token, baseUrl).catch(() => false))
|
|
12379
|
+
);
|
|
12380
|
+
return TOOL_GROUPS.filter((_, i) => answers[i] === true).map((g) => g.key);
|
|
12381
|
+
}
|
|
12382
|
+
function registerToolGroups(server, keys, getToken, baseUrl) {
|
|
12383
|
+
const wanted = new Set(keys);
|
|
12384
|
+
for (const group of TOOL_GROUPS) {
|
|
12385
|
+
if (wanted.has(group.key)) registerGroup(server, group, getToken, baseUrl);
|
|
12386
|
+
}
|
|
12387
|
+
}
|
|
12388
|
+
|
|
12389
|
+
// package.json
|
|
12390
|
+
var package_default = {
|
|
12391
|
+
version: "0.1.105"};
|
|
12392
|
+
|
|
12393
|
+
// src/version.ts
|
|
12394
|
+
var VERSION = package_default.version;
|
|
12395
|
+
var SERVER_NAME = "talonic";
|
|
12396
|
+
|
|
12397
|
+
// src/server-factory.ts
|
|
12398
|
+
function makeTaggedFetch(getClientName, baseFetch = fetch) {
|
|
12399
|
+
return ((input, init) => {
|
|
12400
|
+
try {
|
|
12401
|
+
const headers = new Headers(init?.headers);
|
|
12402
|
+
const cn = getClientName();
|
|
12403
|
+
headers.set("user-agent", `talonic-mcp/${VERSION}${cn ? ` ${cn}` : ""}`);
|
|
12404
|
+
return baseFetch(input, { ...init, headers });
|
|
12405
|
+
} catch {
|
|
12406
|
+
return baseFetch(input, init);
|
|
12407
|
+
}
|
|
12408
|
+
});
|
|
12409
|
+
}
|
|
12410
|
+
function buildServerInstructions(opts) {
|
|
12411
|
+
return [
|
|
12412
|
+
"Talonic turns unstructured documents (PDFs, scans, images, DOCX, emails) into",
|
|
12413
|
+
"schema-validated JSON with per-field confidence scores and source provenance, and",
|
|
12414
|
+
"answers questions about the documents in the user's Talonic workspace.",
|
|
12415
|
+
"Which tool for which question:",
|
|
12416
|
+
"(0) any question about what the documents contain (counts, totals, duplicates,",
|
|
12417
|
+
"comparisons, anomalies) -> talonic_ask FIRST, in one call; do not explore fields,",
|
|
9270
12418
|
"schemas, specs or SQL to answer it yourself;",
|
|
9271
12419
|
"(1) a document by name or keyword -> talonic_search (literal keywords: one short term",
|
|
9272
12420
|
"or an exact filename; on an empty result retry with a shorter keyword), then use the",
|
|
@@ -9303,6 +12451,16 @@ function buildServerInstructions(opts) {
|
|
|
9303
12451
|
"apps:decide consent and a senior_member role or above; on HTTP 403 tell the user",
|
|
9304
12452
|
"which consent or role is missing instead of retrying."
|
|
9305
12453
|
] : [],
|
|
12454
|
+
...opts.includeAppsToolset ? [
|
|
12455
|
+
"To build an app: talonic_create_app -> talonic_save_app_draft ->",
|
|
12456
|
+
"talonic_interpret_app_rules -> talonic_publish_app -> talonic_run_app (dry_run first) ->",
|
|
12457
|
+
"talonic_get_app_run or talonic_get_run_verdicts -> talonic_check_app_acceptance.",
|
|
12458
|
+
"Human Reviews: talonic_list_app_reviews -> talonic_resolve_app_review."
|
|
12459
|
+
] : [],
|
|
12460
|
+
...opts.includeMiningDriverTools ? [
|
|
12461
|
+
"A rule-finding round waiting for an outside driver is claimed and closed with the",
|
|
12462
|
+
"decision-task tools; in between, call its tools with talonic_mining_call_round_tool."
|
|
12463
|
+
] : [],
|
|
9306
12464
|
"Tools that change workspace data (saving schemas, app updates, decisions) should only",
|
|
9307
12465
|
"be called when the user asked for that change. Every error ends with a 'Next step'",
|
|
9308
12466
|
"line: follow it.",
|
|
@@ -9366,7 +12524,9 @@ function createServer(options) {
|
|
|
9366
12524
|
instructions: buildServerInstructions({
|
|
9367
12525
|
includeGenericExecutor: options.includeGenericExecutor !== false,
|
|
9368
12526
|
includeAgentTaskTools: options.includeAgentTaskTools !== false,
|
|
9369
|
-
includeDecisionTaskTools: options.includeDecisionTaskTools !== false
|
|
12527
|
+
includeDecisionTaskTools: options.includeDecisionTaskTools !== false,
|
|
12528
|
+
includeAppsToolset: options.includeAppsToolset === true,
|
|
12529
|
+
includeMiningDriverTools: options.includeMiningDriverTools === true
|
|
9370
12530
|
})
|
|
9371
12531
|
}
|
|
9372
12532
|
);
|
|
@@ -9408,6 +12568,14 @@ function createServer(options) {
|
|
|
9408
12568
|
invocable: options.decisionTasksInvocable !== false
|
|
9409
12569
|
});
|
|
9410
12570
|
}
|
|
12571
|
+
if (options.includeAppsToolset) {
|
|
12572
|
+
registerAppsToolset(server, rawToken, baseUrl);
|
|
12573
|
+
}
|
|
12574
|
+
if (options.includeMiningDriverTools) {
|
|
12575
|
+
registerMiningDriverTools(server, rawToken, baseUrl, {
|
|
12576
|
+
invocable: options.decisionTasksInvocable !== false
|
|
12577
|
+
});
|
|
12578
|
+
}
|
|
9411
12579
|
if (options.includeGrowthTools) {
|
|
9412
12580
|
registerGrowthTools(server, rawToken, baseUrl);
|
|
9413
12581
|
}
|
|
@@ -9441,6 +12609,9 @@ function createServer(options) {
|
|
|
9441
12609
|
if (options.includePriceBaselineTools) {
|
|
9442
12610
|
registerPriceBaselineTools(server, rawToken, baseUrl);
|
|
9443
12611
|
}
|
|
12612
|
+
if (options.toolGroups?.length) {
|
|
12613
|
+
registerToolGroups(server, options.toolGroups, rawToken, baseUrl);
|
|
12614
|
+
}
|
|
9444
12615
|
registerSchemasResource(server, getTalonic);
|
|
9445
12616
|
registerWebhooksResource(server, rawToken, baseUrl);
|
|
9446
12617
|
registerWidgets(server);
|
|
@@ -9504,7 +12675,10 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
|
|
|
9504
12675
|
includeSubmissionsTools,
|
|
9505
12676
|
includePriceBaselineTools,
|
|
9506
12677
|
includePortfolioTools,
|
|
9507
|
-
includeProcessesTools
|
|
12678
|
+
includeProcessesTools,
|
|
12679
|
+
appsToolsetAnswer,
|
|
12680
|
+
miningAnswer,
|
|
12681
|
+
toolGroups
|
|
9508
12682
|
] = await Promise.all([
|
|
9509
12683
|
probeGrowthAccess(apiKey, baseUrl),
|
|
9510
12684
|
probeAgentTaskAdminAccess(apiKey, baseUrl),
|
|
@@ -9516,8 +12690,13 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
|
|
|
9516
12690
|
probeSubmissionsAccess(apiKey, baseUrl),
|
|
9517
12691
|
probePriceBaselineAccess(apiKey, baseUrl),
|
|
9518
12692
|
probePortfolioAccess(apiKey, baseUrl),
|
|
9519
|
-
probeProcessesAccess(apiKey, baseUrl)
|
|
12693
|
+
probeProcessesAccess(apiKey, baseUrl),
|
|
12694
|
+
probeAppsToolsetAccess(apiKey, baseUrl),
|
|
12695
|
+
probeMiningInUse(apiKey, baseUrl),
|
|
12696
|
+
probeToolGroups(apiKey, baseUrl)
|
|
9520
12697
|
]);
|
|
12698
|
+
const includeAppsToolset = appsToolsetAnswer === true;
|
|
12699
|
+
const includeMiningDriverTools = miningAnswer === true;
|
|
9521
12700
|
const server = createServer({
|
|
9522
12701
|
apiKey,
|
|
9523
12702
|
...baseUrl ? { baseUrl } : {},
|
|
@@ -9531,7 +12710,10 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
|
|
|
9531
12710
|
includeSubmissionsTools,
|
|
9532
12711
|
includePriceBaselineTools,
|
|
9533
12712
|
includePortfolioTools,
|
|
9534
|
-
includeProcessesTools
|
|
12713
|
+
includeProcessesTools,
|
|
12714
|
+
includeAppsToolset,
|
|
12715
|
+
includeMiningDriverTools,
|
|
12716
|
+
toolGroups
|
|
9535
12717
|
});
|
|
9536
12718
|
const transport = new StdioServerTransport();
|
|
9537
12719
|
await server.connect(transport);
|