@talonic/mcp 0.1.104 → 0.1.106
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 +111 -1
- package/dist/content.d.ts +22 -2
- package/dist/content.js +5701 -5988
- package/dist/content.js.map +1 -1
- package/dist/http-server.js +862 -87
- package/dist/http-server.js.map +1 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +836 -82
- package/dist/index.js.map +1 -1
- package/dist/server.js +853 -82
- package/dist/server.js.map +1 -1
- package/package.json +2 -1
package/dist/server.js
CHANGED
|
@@ -2432,7 +2432,7 @@ var inputSchema = {
|
|
|
2432
2432
|
instructions: z.string().optional().describe(
|
|
2433
2433
|
"Natural-language guidance for the extractor, e.g. 'Focus on the billing section. Amounts are in EUR.'"
|
|
2434
2434
|
),
|
|
2435
|
-
include_markdown: z.boolean().optional().describe("
|
|
2435
|
+
include_markdown: z.boolean().optional().describe("Also return the document's full text as markdown, alongside the fields."),
|
|
2436
2436
|
include_provenance: z.boolean().optional().describe(
|
|
2437
2437
|
"Include per-field provenance (source_text, section, page) showing where each value was found in the document."
|
|
2438
2438
|
)
|
|
@@ -2481,7 +2481,7 @@ var outputSchema = {
|
|
|
2481
2481
|
document: z.string().optional(),
|
|
2482
2482
|
dashboard: z.string().optional()
|
|
2483
2483
|
}).optional().describe("URLs for self, document, and human-readable dashboard view."),
|
|
2484
|
-
markdown: z.string().optional().describe("
|
|
2484
|
+
markdown: z.string().optional().describe("The document's full text as markdown. Present only when `include_markdown: true`."),
|
|
2485
2485
|
cost: z.object({
|
|
2486
2486
|
costCredits: z.number().describe("Credits consumed by this call."),
|
|
2487
2487
|
costEur: z.number().describe("Approximate EUR cost of this call."),
|
|
@@ -2757,7 +2757,7 @@ function registerGetBalance(server, getTalonic) {
|
|
|
2757
2757
|
var DESCRIPTION4 = [
|
|
2758
2758
|
"Read Talonic's machine-readable credit pricing catalog: fixed per-unit rates so you can predict spend BEFORE running anything.",
|
|
2759
2759
|
"",
|
|
2760
|
-
"USE WHEN: estimating the cost of
|
|
2760
|
+
"USE WHEN: estimating the cost of planned work (reading documents, extracting fields, matching records), or answering a pricing question. Public \u2014 works without spending credits.",
|
|
2761
2761
|
"NOT FOR: the workspace's current balance (use talonic_get_balance) or what it has already spent (use talonic_get_usage).",
|
|
2762
2762
|
"ARGS: none.",
|
|
2763
2763
|
"RETURNS: currency, credits_per_eur, multipliers (e.g. batch 0.5x), and units[] \u2014 each { unit, label, credits, eur, free }."
|
|
@@ -2809,7 +2809,7 @@ function registerGetPricing(server, getTalonic) {
|
|
|
2809
2809
|
var DESCRIPTION5 = [
|
|
2810
2810
|
"Read the workspace's per-function credit consumption over a trailing window: where the credits actually went.",
|
|
2811
2811
|
"",
|
|
2812
|
-
"USE WHEN: the user asks what they have spent credits on, or you want to see which
|
|
2812
|
+
"USE WHEN: the user asks what they have spent credits on, or you want to see which kind of work (reading documents, structuring data, answering questions) takes most of the credits.",
|
|
2813
2813
|
"NOT FOR: the remaining balance (use talonic_get_balance) or per-unit rates (use talonic_get_pricing).",
|
|
2814
2814
|
"ARGS: days (optional, default 30, clamped 1-365).",
|
|
2815
2815
|
"RETURNS: period_days, total_credits, and by_function[] \u2014 each { operation_type, operations, credits }, highest spend first."
|
|
@@ -3907,10 +3907,10 @@ function handleImport(getToken, baseUrl, args) {
|
|
|
3907
3907
|
if (!!args.all === !!args.document_ids?.length)
|
|
3908
3908
|
return Promise.resolve(validationError("Pass either `all: true` or `document_ids`, not both."));
|
|
3909
3909
|
if (args.all) {
|
|
3910
|
-
const { query, contract_keys, only_priced, limit:
|
|
3910
|
+
const { query, contract_keys, only_priced, limit: limit3, dry_run } = args;
|
|
3911
3911
|
return runTool(
|
|
3912
3912
|
() => apiJson(getToken, baseUrl, "POST", "/v1/contracts/import/all", {
|
|
3913
|
-
body: { query, contract_keys, only_priced, limit:
|
|
3913
|
+
body: { query, contract_keys, only_priced, limit: limit3, dry_run }
|
|
3914
3914
|
})
|
|
3915
3915
|
);
|
|
3916
3916
|
}
|
|
@@ -7926,7 +7926,7 @@ var outputValue = z.object({
|
|
|
7926
7926
|
var outputs = z.record(z.string().min(1), outputValue).describe(
|
|
7927
7927
|
"Output field key to { value, confidence?, reasoning?, escalate?, quote?, document_id? }. Use only declared fields."
|
|
7928
7928
|
);
|
|
7929
|
-
var pipelineId = zUuid().optional().describe("Optional
|
|
7929
|
+
var pipelineId = zUuid().optional().describe("Optional run UUID: only that run's tasks.");
|
|
7930
7930
|
var listInput = { status, limit, cursor, pipeline_id: pipelineId };
|
|
7931
7931
|
var idInput = { task_id: taskId };
|
|
7932
7932
|
var heartbeatInput = { task_id: taskId, execution_epoch: executionEpoch };
|
|
@@ -8089,39 +8089,39 @@ var MUTATING = {
|
|
|
8089
8089
|
};
|
|
8090
8090
|
var DESCRIPTIONS = {
|
|
8091
8091
|
list: [
|
|
8092
|
-
"List
|
|
8092
|
+
"List the agent tasks waiting in this workspace: checks a Spec hands to an outside agent (your agent) instead of a person, one per document.",
|
|
8093
8093
|
"",
|
|
8094
|
-
"USE WHEN: looking for
|
|
8094
|
+
"USE WHEN: looking for work for your agent to do; begin with status 'available'. To take a batch from one run (e.g. 'take 10 tasks of run X'), list with pipeline_id and status 'available', then claim each with talonic_claim_agent_task; a task another agent took returns HTTP 409, so skip it and take the next.",
|
|
8095
8095
|
"NOT FOR: reading the immutable task payload (use talonic_get_agent_task) or taking a lease (use talonic_claim_agent_task).",
|
|
8096
8096
|
"ARGS: optional status, pipeline_id, limit, and cursor. RETURNS: metadata only plus pagination.next_cursor."
|
|
8097
8097
|
].join("\n"),
|
|
8098
8098
|
get: [
|
|
8099
|
-
"
|
|
8099
|
+
"Read one agent task: its fixed input, instructions, and the output fields it expects. Each read is recorded against the task.",
|
|
8100
8100
|
"",
|
|
8101
8101
|
"USE WHEN: inspecting a listed task before deciding whether to process it.",
|
|
8102
8102
|
"NOT FOR: acquiring the task (use talonic_claim_agent_task) or returning results (use talonic_submit_agent_task).",
|
|
8103
8103
|
"ARGS: task_id. RETURNS: metadata, input_snapshot, output_contract, instructions, and timeout_fallthrough."
|
|
8104
8104
|
].join("\n"),
|
|
8105
8105
|
claim: [
|
|
8106
|
-
"Claim an available
|
|
8106
|
+
"Claim an available agent task so no one else works on it, or reclaim it after its lease expires.",
|
|
8107
8107
|
"",
|
|
8108
8108
|
"USE WHEN: ready to process a task. Save the returned execution_epoch and lease_expires_at.",
|
|
8109
8109
|
"NOT FOR: merely inspecting work (use talonic_get_agent_task) or extending an active lease (use talonic_heartbeat_agent_task).",
|
|
8110
8110
|
"A conflicting live claim returns HTTP 409. A successful claim returns the task payload: input_snapshot, instructions, and output_contract, whose entries carry each field's Spec rules (description) and allowed codes (enumValues). Review the documents against those rules."
|
|
8111
8111
|
].join("\n"),
|
|
8112
8112
|
heartbeat: [
|
|
8113
|
-
"Extend the lease on a claimed
|
|
8113
|
+
"Extend the lease on a claimed agent task so you keep it while you work.",
|
|
8114
8114
|
"",
|
|
8115
8115
|
"USE WHEN: processing may continue past lease_expires_at; heartbeat before expiry using the epoch from claim.",
|
|
8116
8116
|
"NOT FOR: acquiring a task (use talonic_claim_agent_task) or submitting finished outputs (use talonic_submit_agent_task).",
|
|
8117
8117
|
"ARGS: task_id and execution_epoch. Stale or foreign claims return HTTP 409."
|
|
8118
8118
|
].join("\n"),
|
|
8119
8119
|
submit: [
|
|
8120
|
-
"Submit
|
|
8120
|
+
"Submit the output fields for a claimed agent task; the document then continues through its Spec.",
|
|
8121
8121
|
"",
|
|
8122
8122
|
"USE WHEN: processing is complete and every required output in output_contract is ready.",
|
|
8123
8123
|
"NOT FOR: undeclared fields or partial lease maintenance (use talonic_heartbeat_agent_task).",
|
|
8124
|
-
"ARGS: task_id, execution_epoch, outputs keyed exactly by declared field key, and optional summary.
|
|
8124
|
+
"ARGS: task_id, execution_epoch, outputs keyed exactly by declared field key, and optional summary. Talonic checks every field and type before writing anything: all are saved or none."
|
|
8125
8125
|
].join("\n")
|
|
8126
8126
|
};
|
|
8127
8127
|
function registerAgentTaskTools(server, getToken, baseUrl) {
|
|
@@ -8295,6 +8295,517 @@ function registerAppsTools(server, getToken, baseUrl) {
|
|
|
8295
8295
|
async (args) => handleListApps(getToken, baseUrl, args)
|
|
8296
8296
|
);
|
|
8297
8297
|
}
|
|
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"];
|
|
8302
|
+
var appId = zUuid().describe(
|
|
8303
|
+
"App id: the UUID `id` from talonic_list_apps or talonic_create_app (not the app_\u2026 public id)."
|
|
8304
|
+
);
|
|
8305
|
+
var runId = zUuid().describe(
|
|
8306
|
+
"App run UUID (run_id from talonic_run_app or talonic_list_app_runs)."
|
|
8307
|
+
);
|
|
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 })
|
|
8344
|
+
);
|
|
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 })
|
|
8374
|
+
);
|
|
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 })
|
|
8381
|
+
);
|
|
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
|
+
})
|
|
8397
|
+
);
|
|
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 })
|
|
8407
|
+
);
|
|
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
|
+
}
|
|
8298
8809
|
var DECIDE_SCOPE = "apps:decide";
|
|
8299
8810
|
var TASK_STATUSES2 = [
|
|
8300
8811
|
"available",
|
|
@@ -8306,7 +8817,7 @@ var TASK_STATUSES2 = [
|
|
|
8306
8817
|
"cancelled"
|
|
8307
8818
|
];
|
|
8308
8819
|
var PACKAGE_PAGE_LIMIT_MAX = 2e3;
|
|
8309
|
-
var
|
|
8820
|
+
var appId2 = zUuid().describe(
|
|
8310
8821
|
"Id of an External-mode app (from talonic_list_apps, where mode is 'external')."
|
|
8311
8822
|
);
|
|
8312
8823
|
var taskId2 = zUuid().describe("Decision task UUID.");
|
|
@@ -8334,7 +8845,7 @@ var serviceVersion = z.string().min(1).max(64).optional().describe("Optional bui
|
|
|
8334
8845
|
var failReason = z.string().min(1).max(2e3).describe(
|
|
8335
8846
|
"Why the task cannot be decided, up to 2,000 characters. Recorded on the Human Review the fail raises."
|
|
8336
8847
|
);
|
|
8337
|
-
var listInput2 = { app_id:
|
|
8848
|
+
var listInput2 = { app_id: appId2, status: status2, limit: listLimit, cursor: cursor2 };
|
|
8338
8849
|
var idInput2 = { task_id: taskId2 };
|
|
8339
8850
|
var packageInput = { task_id: taskId2, cursor: packageCursor, limit: packageLimit };
|
|
8340
8851
|
var epochInput = { task_id: taskId2, execution_epoch: executionEpoch2 };
|
|
@@ -8409,12 +8920,12 @@ function handleFailDecisionTask(getToken, baseUrl, args) {
|
|
|
8409
8920
|
})
|
|
8410
8921
|
);
|
|
8411
8922
|
}
|
|
8412
|
-
var
|
|
8923
|
+
var READ_ONLY4 = {
|
|
8413
8924
|
readOnlyHint: true,
|
|
8414
8925
|
destructiveHint: false,
|
|
8415
8926
|
openWorldHint: false
|
|
8416
8927
|
};
|
|
8417
|
-
var
|
|
8928
|
+
var MUTATING3 = {
|
|
8418
8929
|
readOnlyHint: false,
|
|
8419
8930
|
destructiveHint: false,
|
|
8420
8931
|
openWorldHint: false
|
|
@@ -8427,10 +8938,10 @@ var DESTRUCTIVE = {
|
|
|
8427
8938
|
var AUTH_NOTE = "AUTH: a tlnc_ key needs a per-app 'decide' grant; an OAuth connector session needs the apps:decide scope (consented at connect) and a live workspace role of senior_member or above. A 403 (decide_grant_required, insufficient_scope, insufficient_tier) names what is missing \u2014 tell the user, do not retry.";
|
|
8428
8939
|
var DESCRIPTIONS2 = {
|
|
8429
8940
|
list: [
|
|
8430
|
-
"List one External-mode app's decision tasks (runs
|
|
8941
|
+
"List one External-mode app's decision tasks (runs waiting for an outside agent to decide), newest first.",
|
|
8431
8942
|
"",
|
|
8432
8943
|
"USE WHEN: looking for decisions to make for an app; begin with status 'available'. This is the polling alternative to the app.decision_task.offered webhook.",
|
|
8433
|
-
"NOT FOR:
|
|
8944
|
+
"NOT FOR: agent tasks on documents in a Spec (use talonic_list_agent_tasks), reading a task's input package (claim it, then talonic_read_decision_package), or taking a lease (talonic_claim_decision_task).",
|
|
8434
8945
|
"ARGS: app_id, optional status, limit, cursor. RETURNS: task metadata only (id, run_id, status, execution_epoch, lease and sla_deadline_at timing) plus pagination.next_cursor.",
|
|
8435
8946
|
AUTH_NOTE
|
|
8436
8947
|
].join("\n"),
|
|
@@ -8442,7 +8953,7 @@ var DESCRIPTIONS2 = {
|
|
|
8442
8953
|
AUTH_NOTE
|
|
8443
8954
|
].join("\n"),
|
|
8444
8955
|
package: [
|
|
8445
|
-
"Read one page of a claimed decision task's
|
|
8956
|
+
"Read one page of a claimed decision task's fixed input: the records the decision must be made from, each with the locator to cite as evidence. Only the current claimant may read it; each page read is recorded on the run.",
|
|
8446
8957
|
"",
|
|
8447
8958
|
"USE WHEN: after a successful claim, walking pages from package.first_cursor while pagination.has_more is true. The first page also carries the source documents list. A mining_round package is one record { system_prompt, first_turn, tools }.",
|
|
8448
8959
|
"NOT FOR: unclaimed tasks (HTTP 409; claim first) or listing tasks (talonic_list_decision_tasks).",
|
|
@@ -8458,7 +8969,7 @@ var DESCRIPTIONS2 = {
|
|
|
8458
8969
|
AUTH_NOTE
|
|
8459
8970
|
].join("\n"),
|
|
8460
8971
|
submit: [
|
|
8461
|
-
"Submit the decision for a claimed decision task;
|
|
8972
|
+
"Submit the decision for a claimed decision task; Talonic checks it before saving anything, then the run continues.",
|
|
8462
8973
|
"",
|
|
8463
8974
|
"USE WHEN: the decision is final. outcome must satisfy output_contract from the claim (plain JSON Schema, or the verdict_matrix / record_set envelope), evidence lists the package locators relied on (verbatim; [] only if the app allows unevidenced decisions), rationale is a short summary. Rejections are HTTP 422 with the reason and change nothing; the task stays claimed under your epoch, so fix and resubmit before the lease ends.",
|
|
8464
8975
|
"NOT FOR: giving the task back undecided (talonic_release_decision_task) or declaring it undecidable (talonic_fail_decision_task). Stale epoch is HTTP 409.",
|
|
@@ -8474,7 +8985,7 @@ var DESCRIPTIONS2 = {
|
|
|
8474
8985
|
AUTH_NOTE
|
|
8475
8986
|
].join("\n"),
|
|
8476
8987
|
fail: [
|
|
8477
|
-
"Report that the claimed decision task cannot be decided:
|
|
8988
|
+
"Report that the claimed decision task cannot be decided: sends it to a person for review with your reason AND applies the app's declared fallback policy (rules decide, hold for review, or fail the run).",
|
|
8478
8989
|
"",
|
|
8479
8990
|
"USE WHEN: the package is insufficient or contradictory and no claimant could decide it. This ends the task (status 'failed').",
|
|
8480
8991
|
"NOT FOR: temporary give-backs (talonic_release_decision_task) or a decision you can make with low confidence (submit it with confidence set).",
|
|
@@ -8496,7 +9007,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8496
9007
|
title: "List Decision Tasks",
|
|
8497
9008
|
description: DESCRIPTIONS2.list,
|
|
8498
9009
|
inputSchema: listInput2,
|
|
8499
|
-
annotations: { title: "List Decision Tasks", ...
|
|
9010
|
+
annotations: { title: "List Decision Tasks", ...READ_ONLY4 },
|
|
8500
9011
|
...metaFor("listDecisionTasks")
|
|
8501
9012
|
},
|
|
8502
9013
|
async (args) => handleListDecisionTasks(getToken, baseUrl, args)
|
|
@@ -8507,7 +9018,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8507
9018
|
title: "Claim Decision Task",
|
|
8508
9019
|
description: DESCRIPTIONS2.claim,
|
|
8509
9020
|
inputSchema: idInput2,
|
|
8510
|
-
annotations: { title: "Claim Decision Task", ...
|
|
9021
|
+
annotations: { title: "Claim Decision Task", ...MUTATING3 },
|
|
8511
9022
|
...metaFor("claimDecisionTask")
|
|
8512
9023
|
},
|
|
8513
9024
|
async (args) => handleClaimDecisionTask(getToken, baseUrl, args)
|
|
@@ -8518,7 +9029,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8518
9029
|
title: "Read Decision Package",
|
|
8519
9030
|
description: DESCRIPTIONS2.package,
|
|
8520
9031
|
inputSchema: packageInput,
|
|
8521
|
-
annotations: { title: "Read Decision Package", ...
|
|
9032
|
+
annotations: { title: "Read Decision Package", ...READ_ONLY4 },
|
|
8522
9033
|
...metaFor("readDecisionPackage")
|
|
8523
9034
|
},
|
|
8524
9035
|
async (args) => handleReadDecisionPackage(getToken, baseUrl, args)
|
|
@@ -8529,7 +9040,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8529
9040
|
title: "Heartbeat Decision Task",
|
|
8530
9041
|
description: DESCRIPTIONS2.heartbeat,
|
|
8531
9042
|
inputSchema: epochInput,
|
|
8532
|
-
annotations: { title: "Heartbeat Decision Task", ...
|
|
9043
|
+
annotations: { title: "Heartbeat Decision Task", ...MUTATING3 },
|
|
8533
9044
|
...metaFor("heartbeatDecisionTask")
|
|
8534
9045
|
},
|
|
8535
9046
|
async (args) => handleHeartbeatDecisionTask(getToken, baseUrl, args)
|
|
@@ -8540,7 +9051,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8540
9051
|
title: "Submit Decision Task",
|
|
8541
9052
|
description: DESCRIPTIONS2.submit,
|
|
8542
9053
|
inputSchema: submitInput2,
|
|
8543
|
-
annotations: { title: "Submit Decision Task", ...
|
|
9054
|
+
annotations: { title: "Submit Decision Task", ...MUTATING3 },
|
|
8544
9055
|
...metaFor("submitDecisionTask")
|
|
8545
9056
|
},
|
|
8546
9057
|
async (args) => handleSubmitDecisionTask(getToken, baseUrl, args)
|
|
@@ -8551,7 +9062,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8551
9062
|
title: "Release Decision Task",
|
|
8552
9063
|
description: DESCRIPTIONS2.release,
|
|
8553
9064
|
inputSchema: epochInput,
|
|
8554
|
-
annotations: { title: "Release Decision Task", ...
|
|
9065
|
+
annotations: { title: "Release Decision Task", ...MUTATING3 },
|
|
8555
9066
|
...metaFor("releaseDecisionTask")
|
|
8556
9067
|
},
|
|
8557
9068
|
async (args) => handleReleaseDecisionTask(getToken, baseUrl, args)
|
|
@@ -8568,8 +9079,238 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8568
9079
|
async (args) => handleFailDecisionTask(getToken, baseUrl, args)
|
|
8569
9080
|
);
|
|
8570
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
|
+
}
|
|
8571
9312
|
var DESCRIPTION11 = [
|
|
8572
|
-
"Get the
|
|
9313
|
+
"Get the full text of a document as markdown, including scanned pages.",
|
|
8573
9314
|
"",
|
|
8574
9315
|
"USE WHEN: the user wants the full text \u2014 'what does it say', summarise, or translate a document.",
|
|
8575
9316
|
"NOT FOR: specific structured fields (use talonic_extract with a schema).",
|
|
@@ -8594,7 +9335,7 @@ var inputSchema10 = {
|
|
|
8594
9335
|
};
|
|
8595
9336
|
var outputSchema11 = {
|
|
8596
9337
|
document_id: z.string().describe("ID of the document the markdown was extracted from."),
|
|
8597
|
-
markdown: z.string().describe("
|
|
9338
|
+
markdown: z.string().describe("The document's full text as markdown."),
|
|
8598
9339
|
cost: z.object({
|
|
8599
9340
|
costCredits: z.number(),
|
|
8600
9341
|
costEur: z.number(),
|
|
@@ -8675,11 +9416,11 @@ function registerToMarkdown(server, getTalonic, opts = {}) {
|
|
|
8675
9416
|
}
|
|
8676
9417
|
var MATURITIES = ["core", "proven", "candidate"];
|
|
8677
9418
|
var maturityArg = z.enum(MATURITIES).optional().describe(
|
|
8678
|
-
"Filter by maturity: `core` (
|
|
9419
|
+
"Filter by maturity: `core` (established and trusted, safe to build on), `proven` (recurring, stable id), `candidate` (seen recently, may still be merged or renamed)."
|
|
8679
9420
|
);
|
|
8680
9421
|
var fieldIdArg = zUuid().optional().describe("Field UUID (from talonic_list_fields / talonic_search).");
|
|
8681
9422
|
var fieldNameArg = z.string().min(1).optional().describe(
|
|
8682
|
-
"Field NAME instead of an id \u2014
|
|
9423
|
+
"Field NAME instead of an id \u2014 matched against the field's name, other spellings and synonyms, including fields that were merged into it. Use the user's wording ('Invoice No', 'Vertragsnummer')."
|
|
8683
9424
|
);
|
|
8684
9425
|
async function resolveFieldId(getToken, baseUrl, args) {
|
|
8685
9426
|
if (args.field_id) return { id: args.field_id };
|
|
@@ -8692,18 +9433,20 @@ async function resolveFieldId(getToken, baseUrl, args) {
|
|
|
8692
9433
|
};
|
|
8693
9434
|
}
|
|
8694
9435
|
var LIST_DESCRIPTION4 = [
|
|
8695
|
-
"List the workspace's
|
|
9436
|
+
"List the fields your workspace's documents carry (vendor name, invoice total, notice period \u2026), each with a stable id, how established it is (maturity), data type, synonyms and how often it occurs.",
|
|
8696
9437
|
"",
|
|
8697
9438
|
"USE WHEN: you need to know WHAT data exists before querying it, want to pick the right concept for a question, or need the exact field id for talonic_get_field / talonic_field_values.",
|
|
8698
|
-
"NOT FOR: locating a specific document (talonic_search) or filtering documents by a value (talonic_filter). Not a warm-up before answering a question about the documents: call talonic_ask for that.
|
|
9439
|
+
"NOT FOR: locating a specific document (talonic_search) or filtering documents by a value (talonic_filter). Not a warm-up before answering a question about the documents: call talonic_ask for that. Many fields are one-off candidates; pass maturity core or proven unless the user asks for candidates.",
|
|
8699
9440
|
"",
|
|
8700
|
-
"ARGS: `search` (case-insensitive contains on name), `maturity` (core | proven | candidate \u2014 prefer `core`/`proven` for anything you will build on), `include_superseded` (default false:
|
|
9441
|
+
"ARGS: `search` (case-insensitive contains on name), `maturity` (core | proven | candidate \u2014 prefer `core`/`proven` for anything you will build on), `include_superseded` (default false: fields merged into another are hidden so you never see two ids for one field), `limit`, `cursor`.",
|
|
8701
9442
|
"RETURNS: data[] of { id, canonical_name, display_name, data_type, maturity, tier, synonyms, description, occurrence_count, superseded_by, links } plus cursor pagination."
|
|
8702
9443
|
].join("\n");
|
|
8703
9444
|
var listFieldsInputSchema = {
|
|
8704
9445
|
search: z.string().optional().describe("Case-insensitive contains match on canonical_name / display_name."),
|
|
8705
9446
|
maturity: maturityArg,
|
|
8706
|
-
include_superseded: z.boolean().optional().describe(
|
|
9447
|
+
include_superseded: z.boolean().optional().describe(
|
|
9448
|
+
"Include fields merged into another one (they carry `superseded_by`). Default false."
|
|
9449
|
+
),
|
|
8707
9450
|
limit: z.number().int().min(1).max(100).optional().describe("Page size (default 20, max 100)."),
|
|
8708
9451
|
cursor: z.string().optional().describe("Opaque cursor from pagination.next_cursor.")
|
|
8709
9452
|
};
|
|
@@ -8721,20 +9464,18 @@ async function handleListFields(getToken, baseUrl, args) {
|
|
|
8721
9464
|
);
|
|
8722
9465
|
}
|
|
8723
9466
|
var GET_DESCRIPTION3 = [
|
|
8724
|
-
"
|
|
9467
|
+
"Describe one field: what it means, its synonyms and other names, maturity, where it occurs (document and occurrence counts, first and last seen, which document types), its values (top values with counts, distinct count, examples), which schemas use it, and the fields merged into it (superseded_by).",
|
|
8725
9468
|
"",
|
|
8726
|
-
"USE WHEN: you must decide whether a field is the right
|
|
9469
|
+
"USE WHEN: you must decide whether a field is the right one for a question, need example values or the value shape before writing a filter, or hold a field NAME from the user and need the field behind it.",
|
|
8727
9470
|
"NOT FOR: listing many fields (talonic_list_fields) or reading every value (talonic_field_values).",
|
|
8728
9471
|
"",
|
|
8729
|
-
"ARGS: exactly one of `field_id` or `name`.
|
|
9472
|
+
"ARGS: exactly one of `field_id` or `name`. A name is matched against field names, other spellings and synonyms and followed to the current field; `resolution` says how it matched. `include_history: true` adds the field's history (merges, renames, maturity changes).",
|
|
8730
9473
|
"RETURNS: the card { id, canonical_name, maturity, data_type, definition, identity, occurrence, values, usage, links } plus `resolution` when a name was given and `history` when requested."
|
|
8731
9474
|
].join("\n");
|
|
8732
9475
|
var getFieldInputSchema = {
|
|
8733
9476
|
field_id: fieldIdArg,
|
|
8734
9477
|
name: fieldNameArg,
|
|
8735
|
-
include_history: z.boolean().optional().describe(
|
|
8736
|
-
"Append the concept's curation history (tier changes, merges, renames), newest first."
|
|
8737
|
-
)
|
|
9478
|
+
include_history: z.boolean().optional().describe("Add the field's history (maturity changes, merges, renames), newest first.")
|
|
8738
9479
|
};
|
|
8739
9480
|
async function handleGetField(getToken, baseUrl, args) {
|
|
8740
9481
|
if (!args.field_id && !args.name) return validationError("Provide `field_id` or `name`.");
|
|
@@ -8762,9 +9503,9 @@ async function handleGetField(getToken, baseUrl, args) {
|
|
|
8762
9503
|
});
|
|
8763
9504
|
}
|
|
8764
9505
|
var VALUES_DESCRIPTION = [
|
|
8765
|
-
"Read a field's CURRENT VALUES across documents, with
|
|
9506
|
+
"Read a field's CURRENT VALUES across documents, with evidence: one row per value, with the document id, filename and type, the value, its confidence, the label it appeared under in the document, the exact source text, and how the label was matched to this field (`resolved_by`).",
|
|
8766
9507
|
"",
|
|
8767
|
-
"USE WHEN: the user asks 'what are all the X across my documents', you need to tabulate or
|
|
9508
|
+
"USE WHEN: the user asks 'what are all the X across my documents', you need to tabulate or total one field across all documents, or you want the evidence (source text + document) behind a value.",
|
|
8768
9509
|
"NOT FOR: multi-field row-shaped queries over documents (talonic_filter) or one document's full field set (talonic_get_document).",
|
|
8769
9510
|
"",
|
|
8770
9511
|
"ARGS: exactly one of `field_id` or `name`; optional `document_id` (one document), `value` (case-insensitive contains filter), `limit` (max 100), `cursor`.",
|
|
@@ -8870,13 +9611,13 @@ function unwrap(res) {
|
|
|
8870
9611
|
}
|
|
8871
9612
|
var documentIdsArg = z.array(zUuid()).max(1e3).optional().describe("Restrict to these document ids (hard filter, enforced server-side).");
|
|
8872
9613
|
var FIND_DESCRIPTION = [
|
|
8873
|
-
"
|
|
9614
|
+
"Find where the data behind a concept lives before querying anything: turns a phrase ('payment volume per transaction', 'counterparty', 'Vertragslaufzeit') into the fields, values, documents and text passages that carry it, matching what it means as well as its words, even when the field has a different name.",
|
|
8874
9615
|
"",
|
|
8875
|
-
"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
|
|
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 sit in a document's text rather than in a field. Pass `account` whenever the question names one portfolio company (an account from talonic_list_accounts), so another company's figures cannot come back.",
|
|
8876
9617
|
"NOT FOR: reading a known field's values (talonic_field_values) or filtering by a known field (talonic_filter).",
|
|
8877
9618
|
"",
|
|
8878
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).",
|
|
8879
|
-
"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
|
|
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 ready to pass to the next call. Read-only."
|
|
8880
9621
|
].join("\n");
|
|
8881
9622
|
var findDataInputSchema = {
|
|
8882
9623
|
query: z.string().min(1).describe("The natural-language concept to locate."),
|
|
@@ -8911,14 +9652,14 @@ async function handleFindData(getToken, baseUrl, args) {
|
|
|
8911
9652
|
}
|
|
8912
9653
|
var DEDICATED = /* @__PURE__ */ new Set(["find_data"]);
|
|
8913
9654
|
var LIST_TOOLS_DESCRIPTION = [
|
|
8914
|
-
"List
|
|
9655
|
+
"List Talonic's data tools: read-only look-ups and queries over the workspace (find_data, describe_data, query_data for a read-only SQL query over the extracted data, get_document_markdown, workspace_overview, \u2026), each with its input schema and whether THIS credential may call it.",
|
|
8915
9656
|
"Target API: https://talonic.com/docs/api (GET /v1/agent/tools).",
|
|
8916
9657
|
"",
|
|
8917
9658
|
"USE WHEN: you want a capability talonic_* tools do not cover directly (e.g. SQL over the structured data, a workspace overview, cohort discovery) \u2014 list here, then call talonic_invoke_agent_tool with the tool name and its args.",
|
|
8918
|
-
"NOT FOR: answering the user's question about their documents \u2014 call talonic_ask, which
|
|
9659
|
+
"NOT FOR: answering the user's question about their documents \u2014 call talonic_ask, which answers in one call with citations. Also not for discovering fields (talonic_find_data) or documents (talonic_search).",
|
|
8919
9660
|
"",
|
|
8920
9661
|
"ARGS: `only_invocable` (default true \u2014 hide tools this credential cannot run), `include_schemas` (default true \u2014 include each tool's JSON input schema).",
|
|
8921
|
-
"RETURNS: { tools[] of { name, description, impact, capability, can_invoke, input_schema? }, invocable_count, totalCount }.
|
|
9662
|
+
"RETURNS: { tools[] of { name, description, impact, capability, can_invoke, input_schema? }, invocable_count, totalCount }. Data tools that already have their own talonic_* tool (find_data) are left out; call the dedicated tool."
|
|
8922
9663
|
].join("\n");
|
|
8923
9664
|
var listAgentToolsInputSchema = {
|
|
8924
9665
|
only_invocable: z.boolean().optional().describe("Hide tools this credential cannot invoke. Default true."),
|
|
@@ -8949,12 +9690,12 @@ async function handleListAgentTools(getToken, baseUrl, args) {
|
|
|
8949
9690
|
});
|
|
8950
9691
|
}
|
|
8951
9692
|
var INVOKE_DESCRIPTION = [
|
|
8952
|
-
"
|
|
8953
|
-
"READ-ONLY FOR EVERY CREDENTIAL: the platform runs each caller of this route, API key or OAuth session alike, as its least-privilege viewer role, which grants only the
|
|
8954
|
-
"Target API: Talonic
|
|
9693
|
+
"Run ONE named data tool directly and get its exact output (e.g. `query_data` for a read-only SQL SELECT over the extracted data, `describe_data` for the queryable field list, `get_document_markdown` to read a document's text).",
|
|
9694
|
+
"READ-ONLY FOR EVERY CREDENTIAL: the platform runs each caller of this route, API key or OAuth session alike, as its least-privilege viewer role, which grants only the read-only data tools (capability `data.read`). Tools that write are never invocable here, however you connected, so this tool reads and never changes workspace data.",
|
|
9695
|
+
"Target API: Talonic data tools \u2014 https://talonic.com/docs/api (POST /v1/agent/tools/{name}/invoke; input schemas from talonic_list_agent_tools).",
|
|
8955
9696
|
"",
|
|
8956
9697
|
"USE WHEN: talonic_list_agent_tools showed a tool with can_invoke: true that does what you need. Pass exactly the `args` its input_schema declares.",
|
|
8957
|
-
"NOT FOR: answering a question about the documents (talonic_ask
|
|
9698
|
+
"NOT FOR: answering a question about the documents (talonic_ask returns one cited answer). Use this only for a query the user asked for, or when talonic_ask could not answer.",
|
|
8958
9699
|
"",
|
|
8959
9700
|
"ARGS: `name` (tool name), `args` (object matching the tool's input_schema), optional `document_ids` (hard scope for scope-aware tools).",
|
|
8960
9701
|
"RETURNS: { tool, result (the tool's parsed output), citations?, artifacts?, cards? }. Denied capabilities come back as an error naming the capability required; the platform re-checks every call."
|
|
@@ -9062,15 +9803,15 @@ function registerAgentRegistryTools(server, getToken, baseUrl, opts = {}) {
|
|
|
9062
9803
|
);
|
|
9063
9804
|
}
|
|
9064
9805
|
var LIST_DESCRIPTION5 = [
|
|
9065
|
-
"List the workspace's Specs. A Spec is a saved
|
|
9806
|
+
"List the workspace's Specs. A Spec is a saved way of reading one kind of document: the fields it produces and the steps (reading, checks, look-ups, reviews) that fill them; talonic_run_spec runs it over documents. Each row: id, name, description, schema_id (the schema the run's output rows follow \u2014 a DIFFERENT id from the Spec's), version / materialized_version (the published version runs use; null = never published), field_count, node_count, timestamps.",
|
|
9066
9807
|
"",
|
|
9067
|
-
"USE WHEN: the user wants to run 'their
|
|
9808
|
+
"USE WHEN: the user wants to run 'their invoice Spec' / 'our contract set-up', or you need a spec_id for talonic_run_spec / talonic_get_spec.",
|
|
9068
9809
|
"NOT FOR: ad-hoc extraction schemas (talonic_list_schemas) or discovering fields (talonic_list_fields). Not a warm-up before answering a question about the documents: call talonic_ask for that.",
|
|
9069
9810
|
"ARGS: optional `search` (name contains, case-insensitive), `limit` (1\u2013100, default 20), `cursor` (from pagination.next_cursor), `order` (asc|desc by updated_at).",
|
|
9070
9811
|
"RETURNS: { data[] of { id, name, description, schema_id, version, materialized_version, materialized_at, field_count, node_count, created_at, updated_at, links }, pagination { total, limit, has_more, next_cursor } }."
|
|
9071
9812
|
].join("\n");
|
|
9072
9813
|
var GET_DESCRIPTION4 = [
|
|
9073
|
-
"Get one Spec's structure: identity and version state, the schema its output rows follow, `nodes[]` (the
|
|
9814
|
+
"Get one Spec's structure: identity and version state, the schema its output rows follow, `nodes[]` (the steps as the user set them up, in editing order), `phases[]` (the same steps in the order a run carries them out; one check can appear more than once, so the two lists can differ), and `fields[]` (Spec field \u2194 schema field).",
|
|
9074
9815
|
"",
|
|
9075
9816
|
"USE WHEN: you need to explain what a run will do, confirm a Spec is published (`version` non-null) before talonic_run_spec, or map field names to keys.",
|
|
9076
9817
|
"NOT FOR: listing Specs (talonic_list_specs) or starting a run (talonic_run_spec).",
|
|
@@ -9110,7 +9851,7 @@ async function handleGetSpec(getToken, baseUrl, args) {
|
|
|
9110
9851
|
return { ...spec, versions: versions.data ?? [] };
|
|
9111
9852
|
});
|
|
9112
9853
|
}
|
|
9113
|
-
var
|
|
9854
|
+
var READ_ONLY6 = {
|
|
9114
9855
|
readOnlyHint: true,
|
|
9115
9856
|
destructiveHint: false,
|
|
9116
9857
|
idempotentHint: true,
|
|
@@ -9120,10 +9861,10 @@ function registerSpecTools(server, getToken, baseUrl) {
|
|
|
9120
9861
|
server.registerTool(
|
|
9121
9862
|
"talonic_list_specs",
|
|
9122
9863
|
{
|
|
9123
|
-
title: "List
|
|
9864
|
+
title: "List Specs",
|
|
9124
9865
|
description: LIST_DESCRIPTION5,
|
|
9125
9866
|
inputSchema: listSpecsInputSchema,
|
|
9126
|
-
annotations: { title: "List
|
|
9867
|
+
annotations: { title: "List Specs", ...READ_ONLY6 },
|
|
9127
9868
|
_meta: widgetToolMeta("listSpecs")
|
|
9128
9869
|
},
|
|
9129
9870
|
async (args) => handleListSpecs(getToken, baseUrl, args)
|
|
@@ -9131,10 +9872,10 @@ function registerSpecTools(server, getToken, baseUrl) {
|
|
|
9131
9872
|
server.registerTool(
|
|
9132
9873
|
"talonic_get_spec",
|
|
9133
9874
|
{
|
|
9134
|
-
title: "Look up a
|
|
9875
|
+
title: "Look up a Spec",
|
|
9135
9876
|
description: GET_DESCRIPTION4,
|
|
9136
9877
|
inputSchema: getSpecInputSchema,
|
|
9137
|
-
annotations: { title: "Look up a
|
|
9878
|
+
annotations: { title: "Look up a Spec", ...READ_ONLY6 },
|
|
9138
9879
|
_meta: widgetToolMeta("getSpec")
|
|
9139
9880
|
},
|
|
9140
9881
|
async (args) => handleGetSpec(getToken, baseUrl, args)
|
|
@@ -9147,15 +9888,15 @@ function mapRunStatus(raw) {
|
|
|
9147
9888
|
return "processing";
|
|
9148
9889
|
}
|
|
9149
9890
|
var RUN_DESCRIPTION3 = [
|
|
9150
|
-
"Run
|
|
9891
|
+
"Run one of the workspace's Specs over documents, in one call, and get one structured row per document. Two inputs: `document_ids` (documents already in the workspace; for a new file, first talonic_request_upload \u2192 poll talonic_get_document until completed) OR `file_urls` (public https files, max 20; Talonic fetches and reads them first). Consumes credits.",
|
|
9151
9892
|
"",
|
|
9152
|
-
"USE WHEN: the user wants to 'run the invoice
|
|
9893
|
+
"USE WHEN: the user wants to 'run the invoice Spec on these documents', process files through their Spec, or produce the Spec's structured rows.",
|
|
9153
9894
|
"NOT FOR: one-off extraction with an ad-hoc schema (talonic_extract), or checking progress (talonic_get_run) / reading rows (talonic_get_run_results).",
|
|
9154
|
-
"ARGS: `spec_id` (talonic_list_specs); exactly one of `document_ids[]` (1\u2013500) or `file_urls[]` (1\u201320, https); optional `name`, `pipeline_mode` (`new` default | `append` to the Spec's
|
|
9895
|
+
"ARGS: `spec_id` (talonic_list_specs); exactly one of `document_ids[]` (1\u2013500) or `file_urls[]` (1\u201320, https); optional `name`, `pipeline_mode` (`new` default | `append` to the Spec's current run); `batch_id` and flat `metadata` only with file_urls.",
|
|
9155
9896
|
"RETURNS: RunEnvelope { run_kind ('pipeline'|'run'), run_id, pipeline_id, spec_id, status ('processing'|'completed'|'failed'), raw_status, input_count, documents?, message?, links }. Then poll talonic_get_run with the `pipeline_id` when run_kind is 'pipeline', or with the `run_id` when it is 'run', every 5\u201310 s until status is completed/failed, then talonic_get_run_results."
|
|
9156
9897
|
].join("\n");
|
|
9157
9898
|
var GET_RUN_DESCRIPTION = [
|
|
9158
|
-
"Poll a Spec run started by talonic_run_spec: normalised status plus document
|
|
9899
|
+
"Poll a Spec run started by talonic_run_spec: normalised status plus progress per document and, for run_kind 'pipeline', per step.",
|
|
9159
9900
|
"",
|
|
9160
9901
|
"USE WHEN: waiting for a run to finish \u2014 poll every 5\u201310 s; stop on `completed` or `failed`.",
|
|
9161
9902
|
"NOT FOR: reading the structured rows (talonic_get_run_results) or starting a run (talonic_run_spec).",
|
|
@@ -9163,7 +9904,7 @@ var GET_RUN_DESCRIPTION = [
|
|
|
9163
9904
|
"RETURNS: { run_kind, run_id, pipeline_id, spec_id, status, raw_status, input_count?, progress { total_documents, completed_documents, error_documents, phases?[] }, documents?[], error_message?, created_at, updated_at }."
|
|
9164
9905
|
].join("\n");
|
|
9165
9906
|
var RESULTS_DESCRIPTION = [
|
|
9166
|
-
"Read a Spec run's structured rows \u2014 one row per document with the Spec's fields as clean values (held
|
|
9907
|
+
"Read a Spec run's structured rows \u2014 one row per document with the Spec's fields as clean values (values held for review come back null), plus the column definitions.",
|
|
9167
9908
|
"",
|
|
9168
9909
|
"USE WHEN: talonic_get_run reports `completed` (partial rows are also readable while `processing`).",
|
|
9169
9910
|
"NOT FOR: progress (talonic_get_run) or per-field provenance of a single value (include: ['provenance'] here, or talonic_field_values).",
|
|
@@ -9179,7 +9920,7 @@ var runSpecInputSchema = {
|
|
|
9179
9920
|
document_ids: documentIdsArg2,
|
|
9180
9921
|
file_urls: fileUrlsArg,
|
|
9181
9922
|
name: z.string().min(1).max(200).optional().describe("Display name for the run."),
|
|
9182
|
-
pipeline_mode: z.enum(["new", "append"]).optional().describe("`new` (default) or `append` to the Spec's
|
|
9923
|
+
pipeline_mode: z.enum(["new", "append"]).optional().describe("`new` (default) or `append` to the Spec's current run."),
|
|
9183
9924
|
batch_id: z.string().min(1).max(200).optional().describe("Caller grouping key (file_urls path only)."),
|
|
9184
9925
|
metadata: metadataArg
|
|
9185
9926
|
};
|
|
@@ -9189,7 +9930,7 @@ var runRefInputSchema = {
|
|
|
9189
9930
|
};
|
|
9190
9931
|
var resultsInputSchema = {
|
|
9191
9932
|
run_id: uuid.optional().describe(
|
|
9192
|
-
"The RunEnvelope's run_id. Alone: a run_kind 'run' submission (/v1/run). With pipeline_id:
|
|
9933
|
+
"The RunEnvelope's run_id. Alone: a run_kind 'run' submission (/v1/run). With pipeline_id: only the rows of that submission."
|
|
9193
9934
|
),
|
|
9194
9935
|
pipeline_id: uuid.optional().describe(
|
|
9195
9936
|
"The RunEnvelope's pipeline_id (run_kind 'pipeline'); rows come from /v1/pipelines/{id}/results."
|
|
@@ -9350,7 +10091,7 @@ async function handleGetRunResults(getToken, baseUrl, args) {
|
|
|
9350
10091
|
return { run_kind: kind, ...body };
|
|
9351
10092
|
});
|
|
9352
10093
|
}
|
|
9353
|
-
var
|
|
10094
|
+
var READ_ONLY7 = {
|
|
9354
10095
|
readOnlyHint: true,
|
|
9355
10096
|
destructiveHint: false,
|
|
9356
10097
|
idempotentHint: true,
|
|
@@ -9360,11 +10101,11 @@ function registerRunTools(server, getToken, baseUrl) {
|
|
|
9360
10101
|
server.registerTool(
|
|
9361
10102
|
"talonic_run_spec",
|
|
9362
10103
|
{
|
|
9363
|
-
title: "Run a
|
|
10104
|
+
title: "Run a Spec",
|
|
9364
10105
|
description: RUN_DESCRIPTION3,
|
|
9365
10106
|
inputSchema: runSpecInputSchema,
|
|
9366
10107
|
annotations: {
|
|
9367
|
-
title: "Run a
|
|
10108
|
+
title: "Run a Spec",
|
|
9368
10109
|
readOnlyHint: false,
|
|
9369
10110
|
destructiveHint: false,
|
|
9370
10111
|
openWorldHint: true
|
|
@@ -9379,7 +10120,7 @@ function registerRunTools(server, getToken, baseUrl) {
|
|
|
9379
10120
|
title: "Check run progress",
|
|
9380
10121
|
description: GET_RUN_DESCRIPTION,
|
|
9381
10122
|
inputSchema: runRefInputSchema,
|
|
9382
|
-
annotations: { title: "Check run progress", ...
|
|
10123
|
+
annotations: { title: "Check run progress", ...READ_ONLY7 },
|
|
9383
10124
|
_meta: widgetToolMeta("getRun")
|
|
9384
10125
|
},
|
|
9385
10126
|
async (args) => handleGetRun(getToken, baseUrl, args)
|
|
@@ -9390,7 +10131,7 @@ function registerRunTools(server, getToken, baseUrl) {
|
|
|
9390
10131
|
title: "Read run results",
|
|
9391
10132
|
description: RESULTS_DESCRIPTION,
|
|
9392
10133
|
inputSchema: resultsInputSchema,
|
|
9393
|
-
annotations: { title: "Read run results", ...
|
|
10134
|
+
annotations: { title: "Read run results", ...READ_ONLY7 },
|
|
9394
10135
|
_meta: widgetToolMeta("getRunResults")
|
|
9395
10136
|
},
|
|
9396
10137
|
async (args) => handleGetRunResults(getToken, baseUrl, args)
|
|
@@ -9401,9 +10142,9 @@ var ASK_DEFAULT_WAIT_S = 45;
|
|
|
9401
10142
|
var ASK_MAX_WAIT_S = 55;
|
|
9402
10143
|
var POLL_HINT = "still processing \u2014 call talonic_get_answer with this ask_id in a few seconds";
|
|
9403
10144
|
var ASK_DESCRIPTION = [
|
|
9404
|
-
"Ask a natural-language question over the workspace's documents and get a cited, verified answer (markdown).
|
|
10145
|
+
"Ask a natural-language question over the workspace's documents and get a cited, verified answer (markdown). Talonic looks across the extracted data and the documents' text, backs every claim that matters with a quote from a source document, and checks the answer before returning it. Consumes credits.",
|
|
9405
10146
|
"",
|
|
9406
|
-
"USE WHEN (the default for questions): the user asks anything about what their documents contain \u2014 counts, totals, duplicates, comparisons, anomalies ('which vendors invoiced us twice in May?'), or a summary across documents. One call replaces exploring fields, schemas,
|
|
10147
|
+
"USE WHEN (the default for questions): the user asks anything about what their documents contain \u2014 counts, totals, duplicates, comparisons, anomalies ('which vendors invoiced us twice in May?'), or a summary across documents. One call replaces exploring fields, schemas, Specs and queries yourself; skip that exploration.",
|
|
9407
10148
|
"NOT FOR: reading a known field's values (talonic_field_values, free) or filtering documents by a known value (talonic_filter, free); locating which field holds a concept (talonic_find_data).",
|
|
9408
10149
|
"ARGS: `question`; optional `scope` { document_ids[], schema_id, pipeline_id, data_product_id, document_type, source_id, tags[], ingested_after, ingested_before } (ANDed), `conversation_id` (continue a thread), `output_format` { instruction, template }, `wait_seconds` (0\u201355, default 45).",
|
|
9409
10150
|
"RETURNS: { ask_id, status ('completed'|'processing'|'error'), conversation_id, answer (markdown), citations[] { quote, document_id, kind, filename, app_url }, verification { verdict, checks_total, checks_unsupported, correction }, usage { tokens, credits_charged }, tool_calls, artifacts[], waited_ms }. If status is still 'processing' after the wait, call talonic_get_answer with the ask_id."
|
|
@@ -9420,7 +10161,7 @@ var uuid2 = zUuid();
|
|
|
9420
10161
|
var scopeSchema = z.object({
|
|
9421
10162
|
document_ids: z.array(uuid2).max(500).optional().describe("Only these documents."),
|
|
9422
10163
|
schema_id: uuid2.optional().describe("Only documents extracted with this schema."),
|
|
9423
|
-
pipeline_id: uuid2.optional().describe("Only documents of this
|
|
10164
|
+
pipeline_id: uuid2.optional().describe("Only documents of this Spec run."),
|
|
9424
10165
|
data_product_id: uuid2.optional().describe(
|
|
9425
10166
|
"Only documents of this data product (a curated document collection; rarely needed)."
|
|
9426
10167
|
),
|
|
@@ -9433,11 +10174,13 @@ var scopeSchema = z.object({
|
|
|
9433
10174
|
var askInputSchema = {
|
|
9434
10175
|
question: z.string().min(1).max(4e3).describe("The question, in the user's words."),
|
|
9435
10176
|
scope: scopeSchema,
|
|
9436
|
-
conversation_id: uuid2.optional().describe("Continue this conversation;
|
|
10177
|
+
conversation_id: uuid2.optional().describe("Continue this conversation; earlier questions and answers are taken into account."),
|
|
9437
10178
|
output_format: z.object({
|
|
9438
10179
|
instruction: z.string().max(1e3).optional(),
|
|
9439
10180
|
template: z.string().max(4e3).optional()
|
|
9440
|
-
}).optional().describe(
|
|
10181
|
+
}).optional().describe(
|
|
10182
|
+
"Shape the answer's layout (a table, a list, a template); never changes which sources it rests on."
|
|
10183
|
+
),
|
|
9441
10184
|
wait_seconds: z.number().int().min(0).max(ASK_MAX_WAIT_S).optional().describe(
|
|
9442
10185
|
`Seconds to wait for the answer before returning 'processing' (default ${ASK_DEFAULT_WAIT_S}, max ${ASK_MAX_WAIT_S}).`
|
|
9443
10186
|
)
|
|
@@ -11647,7 +12390,7 @@ function registerToolGroups(server, keys, getToken, baseUrl) {
|
|
|
11647
12390
|
|
|
11648
12391
|
// package.json
|
|
11649
12392
|
var package_default = {
|
|
11650
|
-
version: "0.1.
|
|
12393
|
+
version: "0.1.106"};
|
|
11651
12394
|
|
|
11652
12395
|
// src/version.ts
|
|
11653
12396
|
var VERSION = package_default.version;
|
|
@@ -11710,6 +12453,16 @@ function buildServerInstructions(opts) {
|
|
|
11710
12453
|
"apps:decide consent and a senior_member role or above; on HTTP 403 tell the user",
|
|
11711
12454
|
"which consent or role is missing instead of retrying."
|
|
11712
12455
|
] : [],
|
|
12456
|
+
...opts.includeAppsToolset ? [
|
|
12457
|
+
"To build an app: talonic_create_app -> talonic_save_app_draft ->",
|
|
12458
|
+
"talonic_interpret_app_rules -> talonic_publish_app -> talonic_run_app (dry_run first) ->",
|
|
12459
|
+
"talonic_get_app_run or talonic_get_run_verdicts -> talonic_check_app_acceptance.",
|
|
12460
|
+
"Human Reviews: talonic_list_app_reviews -> talonic_resolve_app_review."
|
|
12461
|
+
] : [],
|
|
12462
|
+
...opts.includeMiningDriverTools ? [
|
|
12463
|
+
"A rule-finding round waiting for an outside driver is claimed and closed with the",
|
|
12464
|
+
"decision-task tools; in between, call its tools with talonic_mining_call_round_tool."
|
|
12465
|
+
] : [],
|
|
11713
12466
|
"Tools that change workspace data (saving schemas, app updates, decisions) should only",
|
|
11714
12467
|
"be called when the user asked for that change. Every error ends with a 'Next step'",
|
|
11715
12468
|
"line: follow it.",
|
|
@@ -11773,7 +12526,9 @@ function createServer(options) {
|
|
|
11773
12526
|
instructions: buildServerInstructions({
|
|
11774
12527
|
includeGenericExecutor: options.includeGenericExecutor !== false,
|
|
11775
12528
|
includeAgentTaskTools: options.includeAgentTaskTools !== false,
|
|
11776
|
-
includeDecisionTaskTools: options.includeDecisionTaskTools !== false
|
|
12529
|
+
includeDecisionTaskTools: options.includeDecisionTaskTools !== false,
|
|
12530
|
+
includeAppsToolset: options.includeAppsToolset === true,
|
|
12531
|
+
includeMiningDriverTools: options.includeMiningDriverTools === true
|
|
11777
12532
|
})
|
|
11778
12533
|
}
|
|
11779
12534
|
);
|
|
@@ -11815,6 +12570,14 @@ function createServer(options) {
|
|
|
11815
12570
|
invocable: options.decisionTasksInvocable !== false
|
|
11816
12571
|
});
|
|
11817
12572
|
}
|
|
12573
|
+
if (options.includeAppsToolset) {
|
|
12574
|
+
registerAppsToolset(server, rawToken, baseUrl);
|
|
12575
|
+
}
|
|
12576
|
+
if (options.includeMiningDriverTools) {
|
|
12577
|
+
registerMiningDriverTools(server, rawToken, baseUrl, {
|
|
12578
|
+
invocable: options.decisionTasksInvocable !== false
|
|
12579
|
+
});
|
|
12580
|
+
}
|
|
11818
12581
|
if (options.includeGrowthTools) {
|
|
11819
12582
|
registerGrowthTools(server, rawToken, baseUrl);
|
|
11820
12583
|
}
|
|
@@ -11915,6 +12678,8 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
|
|
|
11915
12678
|
includePriceBaselineTools,
|
|
11916
12679
|
includePortfolioTools,
|
|
11917
12680
|
includeProcessesTools,
|
|
12681
|
+
appsToolsetAnswer,
|
|
12682
|
+
miningAnswer,
|
|
11918
12683
|
toolGroups
|
|
11919
12684
|
] = await Promise.all([
|
|
11920
12685
|
probeGrowthAccess(apiKey, baseUrl),
|
|
@@ -11928,8 +12693,12 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
|
|
|
11928
12693
|
probePriceBaselineAccess(apiKey, baseUrl),
|
|
11929
12694
|
probePortfolioAccess(apiKey, baseUrl),
|
|
11930
12695
|
probeProcessesAccess(apiKey, baseUrl),
|
|
12696
|
+
probeAppsToolsetAccess(apiKey, baseUrl),
|
|
12697
|
+
probeMiningInUse(apiKey, baseUrl),
|
|
11931
12698
|
probeToolGroups(apiKey, baseUrl)
|
|
11932
12699
|
]);
|
|
12700
|
+
const includeAppsToolset = appsToolsetAnswer === true;
|
|
12701
|
+
const includeMiningDriverTools = miningAnswer === true;
|
|
11933
12702
|
const server = createServer({
|
|
11934
12703
|
apiKey,
|
|
11935
12704
|
...baseUrl ? { baseUrl } : {},
|
|
@@ -11944,6 +12713,8 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
|
|
|
11944
12713
|
includePriceBaselineTools,
|
|
11945
12714
|
includePortfolioTools,
|
|
11946
12715
|
includeProcessesTools,
|
|
12716
|
+
includeAppsToolset,
|
|
12717
|
+
includeMiningDriverTools,
|
|
11947
12718
|
toolGroups
|
|
11948
12719
|
});
|
|
11949
12720
|
const transport = new StdioServerTransport();
|