@talonic/mcp 0.1.104 → 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 +8 -0
- package/dist/content.js +1910 -11
- package/dist/content.js.map +1 -1
- package/dist/http-server.js +794 -24
- package/dist/http-server.js.map +1 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +772 -20
- package/dist/index.js.map +1 -1
- package/dist/server.js +789 -20
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3879,10 +3879,10 @@ function handleImport(getToken, baseUrl, args) {
|
|
|
3879
3879
|
if (!!args.all === !!args.document_ids?.length)
|
|
3880
3880
|
return Promise.resolve(validationError("Pass either `all: true` or `document_ids`, not both."));
|
|
3881
3881
|
if (args.all) {
|
|
3882
|
-
const { query, contract_keys, only_priced, limit:
|
|
3882
|
+
const { query, contract_keys, only_priced, limit: limit3, dry_run } = args;
|
|
3883
3883
|
return runTool(
|
|
3884
3884
|
() => apiJson(getToken, baseUrl, "POST", "/v1/contracts/import/all", {
|
|
3885
|
-
body: { query, contract_keys, only_priced, limit:
|
|
3885
|
+
body: { query, contract_keys, only_priced, limit: limit3, dry_run }
|
|
3886
3886
|
})
|
|
3887
3887
|
);
|
|
3888
3888
|
}
|
|
@@ -8157,6 +8157,514 @@ function registerAppsTools(server, getToken, baseUrl) {
|
|
|
8157
8157
|
async (args) => handleListApps(getToken, baseUrl, args)
|
|
8158
8158
|
);
|
|
8159
8159
|
}
|
|
8160
|
+
var APP_MODES = ["rules", "assisted", "external", "autonomous"];
|
|
8161
|
+
var REVIEW_KINDS = ["resolution", "approval", "data_request", "judgment"];
|
|
8162
|
+
var REVIEW_STATUSES = ["open", "assigned", "resolved", "expired", "cancelled"];
|
|
8163
|
+
var VERDICT_OUTCOMES = ["passed", "failed", "indeterminate", "not_applicable"];
|
|
8164
|
+
var appId = zUuid().describe(
|
|
8165
|
+
"App id: the UUID `id` from talonic_list_apps or talonic_create_app (not the app_\u2026 public id)."
|
|
8166
|
+
);
|
|
8167
|
+
var runId = zUuid().describe(
|
|
8168
|
+
"App run UUID (run_id from talonic_run_app or talonic_list_app_runs)."
|
|
8169
|
+
);
|
|
8170
|
+
var reviewId = zUuid().describe("Human Review UUID (id from talonic_list_app_reviews).");
|
|
8171
|
+
var limit2 = z.number().int().min(1).max(200).optional().describe("Page size (default 50, max 200).");
|
|
8172
|
+
var offset = z.number().int().min(0).optional().describe("Rows to skip before the page.");
|
|
8173
|
+
var jsonObject = () => z.record(z.string(), z.json());
|
|
8174
|
+
var READ_ONLY3 = {
|
|
8175
|
+
readOnlyHint: true,
|
|
8176
|
+
destructiveHint: false,
|
|
8177
|
+
idempotentHint: true,
|
|
8178
|
+
openWorldHint: false
|
|
8179
|
+
};
|
|
8180
|
+
var MUTATING2 = {
|
|
8181
|
+
readOnlyHint: false,
|
|
8182
|
+
destructiveHint: false,
|
|
8183
|
+
idempotentHint: false,
|
|
8184
|
+
openWorldHint: false
|
|
8185
|
+
};
|
|
8186
|
+
var appPath = (id, suffix = "") => `/v1/apps/${encodeURIComponent(id)}${suffix}`;
|
|
8187
|
+
var runPath = (id, suffix = "") => `/v1/runs/${encodeURIComponent(id)}${suffix}`;
|
|
8188
|
+
var reviewPath = (id, suffix = "") => `/v1/reviews/${encodeURIComponent(id)}${suffix}`;
|
|
8189
|
+
var get = (t, b, path, params) => runTool(() => apiJson(t, b, "GET", path, params ? { params } : {}));
|
|
8190
|
+
var send = (t, b, method, path, body) => runTool(() => apiJson(t, b, method, path, body === void 0 ? {} : { body }));
|
|
8191
|
+
function defined2(o) {
|
|
8192
|
+
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0));
|
|
8193
|
+
}
|
|
8194
|
+
var handleGetApp = (t, b, a) => get(t, b, appPath(a.app_id));
|
|
8195
|
+
var handleCreateApp = (t, b, a) => send(t, b, "POST", "/v1/apps", defined2({ ...a }));
|
|
8196
|
+
var handleSaveAppDraft = (t, b, a) => send(t, b, "PATCH", appPath(a.app_id), { content: a.content });
|
|
8197
|
+
var handleListAppVersions = (t, b, a) => get(t, b, appPath(a.app_id, "/versions"));
|
|
8198
|
+
var handlePublishApp = (t, b, a) => send(t, b, "POST", appPath(a.app_id, `/versions/${a.version}/publish`));
|
|
8199
|
+
var handleSetAppEnabled = (t, b, a, enabled) => send(t, b, "POST", appPath(a.app_id, enabled ? "/enable" : "/disable"));
|
|
8200
|
+
var handleRunApp = (t, b, a) => send(
|
|
8201
|
+
t,
|
|
8202
|
+
b,
|
|
8203
|
+
"POST",
|
|
8204
|
+
appPath(a.app_id, "/runs"),
|
|
8205
|
+
defined2({ input: a.input ?? {}, dry_run: a.dry_run, idempotency_key: a.idempotency_key })
|
|
8206
|
+
);
|
|
8207
|
+
var handleListAppRuns = (t, b, a) => get(t, b, appPath(a.app_id, "/runs"), { limit: a.limit, offset: a.offset });
|
|
8208
|
+
async function handleGetAppRun(t, b, a) {
|
|
8209
|
+
return runTool(async () => {
|
|
8210
|
+
const run = await apiJson(t, b, "GET", runPath(a.run_id));
|
|
8211
|
+
if (!a.include_events) return run;
|
|
8212
|
+
const events = await apiJson(t, b, "GET", runPath(a.run_id, "/events"));
|
|
8213
|
+
return { run, events: events?.events ?? [] };
|
|
8214
|
+
});
|
|
8215
|
+
}
|
|
8216
|
+
var handleGetRunRecord = (t, b, a) => get(t, b, runPath(a.run_id, "/record"));
|
|
8217
|
+
var handleGetRunVerdicts = (t, b, a) => get(t, b, runPath(a.run_id, "/verdicts"), {
|
|
8218
|
+
rolled: a.rolled,
|
|
8219
|
+
auto: a.auto,
|
|
8220
|
+
rule: a.rule,
|
|
8221
|
+
status: a.status,
|
|
8222
|
+
limit: a.limit,
|
|
8223
|
+
cursor: a.cursor
|
|
8224
|
+
});
|
|
8225
|
+
var handleListAppReviews = (t, b, a) => get(t, b, "/v1/reviews", { ...a });
|
|
8226
|
+
var handleRaiseAppReview = (t, b, a) => {
|
|
8227
|
+
const { app_id, ...body } = a;
|
|
8228
|
+
return send(t, b, "POST", appPath(app_id, "/reviews"), defined2(body));
|
|
8229
|
+
};
|
|
8230
|
+
var handleResolveAppReview = (t, b, a) => send(
|
|
8231
|
+
t,
|
|
8232
|
+
b,
|
|
8233
|
+
"POST",
|
|
8234
|
+
reviewPath(a.review_id, "/resolve"),
|
|
8235
|
+
defined2({ values: a.values, feedback: a.feedback })
|
|
8236
|
+
);
|
|
8237
|
+
var handleInterviewReview = (t, b, a) => send(
|
|
8238
|
+
t,
|
|
8239
|
+
b,
|
|
8240
|
+
"POST",
|
|
8241
|
+
reviewPath(a.review_id, "/interview"),
|
|
8242
|
+
defined2({ message: a.message, transcript: a.transcript })
|
|
8243
|
+
);
|
|
8244
|
+
var handleListAppPrecedents = (t, b, a) => get(t, b, appPath(a.app_id, "/precedents"), {
|
|
8245
|
+
similar_to: a.similar_to ? JSON.stringify(a.similar_to) : void 0
|
|
8246
|
+
});
|
|
8247
|
+
var handleGetAppLogic = (t, b, a) => get(t, b, appPath(a.app_id, "/logic"));
|
|
8248
|
+
var handleGetAppFields = (t, b, a) => get(t, b, appPath(a.app_id, "/logic/fields"));
|
|
8249
|
+
var handleInterpretRules = (t, b, a) => send(
|
|
8250
|
+
t,
|
|
8251
|
+
b,
|
|
8252
|
+
"POST",
|
|
8253
|
+
appPath(a.app_id, "/logic/compile"),
|
|
8254
|
+
defined2({
|
|
8255
|
+
card_ids: a.card_ids && a.card_ids.length > 0 ? a.card_ids : void 0,
|
|
8256
|
+
guidance: a.guidance || void 0,
|
|
8257
|
+
locale: a.locale
|
|
8258
|
+
})
|
|
8259
|
+
);
|
|
8260
|
+
var handleProposeEdit = (t, b, a) => send(t, b, "POST", appPath(a.app_id, "/edit-proposals"), { instruction: a.instruction });
|
|
8261
|
+
var handleApplyEdit = (t, b, a) => send(t, b, "POST", appPath(a.app_id, "/edit-proposals/apply"), { ops: a.ops });
|
|
8262
|
+
var handleGetAcceptance = (t, b, a) => get(t, b, appPath(a.app_id, "/acceptance"));
|
|
8263
|
+
var handleSaveAcceptance = (t, b, a) => send(
|
|
8264
|
+
t,
|
|
8265
|
+
b,
|
|
8266
|
+
"PUT",
|
|
8267
|
+
appPath(a.app_id, "/acceptance"),
|
|
8268
|
+
defined2({ cases: a.cases, tolerance: a.tolerance })
|
|
8269
|
+
);
|
|
8270
|
+
var handleCheckAcceptance = (t, b, a) => get(t, b, appPath(a.app_id, "/acceptance/check"), { run_id: a.run_id });
|
|
8271
|
+
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.";
|
|
8272
|
+
var D = {
|
|
8273
|
+
get: [
|
|
8274
|
+
"Read one app's manifest: mode, active version, enabled state, contract (what it reads and acts on), output contract, thresholds, triggers, fallback.",
|
|
8275
|
+
"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)."
|
|
8276
|
+
].join("\n"),
|
|
8277
|
+
create: [
|
|
8278
|
+
"Create a new app. It starts disabled with no versions; the slug can no longer change once a version is published.",
|
|
8279
|
+
"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.",
|
|
8280
|
+
"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).",
|
|
8281
|
+
"RETURNS: the manifest; use its `id` (UUID) with every other app tool.",
|
|
8282
|
+
BUILD_FLOW
|
|
8283
|
+
].join("\n"),
|
|
8284
|
+
saveDraft: [
|
|
8285
|
+
"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.",
|
|
8286
|
+
"USE WHEN: authoring configuration in full. For a plain-language change to an existing draft prefer talonic_propose_app_edit + talonic_apply_app_edit.",
|
|
8287
|
+
"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."
|
|
8288
|
+
].join("\n"),
|
|
8289
|
+
versions: [
|
|
8290
|
+
"List an app's versions, newest first: version number, status (draft, published, superseded), content hash, published_at.",
|
|
8291
|
+
"USE WHEN: you need the draft's version number for talonic_publish_app, or to see what is live."
|
|
8292
|
+
].join("\n"),
|
|
8293
|
+
publish: [
|
|
8294
|
+
"Publish the app's draft: freezes it, makes it the active version (the previous one is superseded) and locks the slug on first publish.",
|
|
8295
|
+
"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.",
|
|
8296
|
+
"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."
|
|
8297
|
+
].join("\n"),
|
|
8298
|
+
enable: [
|
|
8299
|
+
"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).",
|
|
8300
|
+
"USE WHEN: the user asks to switch the app on. ARGS: app_id."
|
|
8301
|
+
].join("\n"),
|
|
8302
|
+
disable: [
|
|
8303
|
+
"Disable an app at once (the kill switch): triggers stop and open work is no longer offered. Past runs and records are kept.",
|
|
8304
|
+
"USE WHEN: the user asks to stop or pause an app. ARGS: app_id."
|
|
8305
|
+
].join("\n"),
|
|
8306
|
+
run: [
|
|
8307
|
+
"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.",
|
|
8308
|
+
"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).",
|
|
8309
|
+
"ARGS: app_id, optional input object, dry_run, idempotency_key (reusing a key returns the existing run instead of starting another). Consumes credits.",
|
|
8310
|
+
"NEXT: talonic_get_app_run for status and decision; talonic_get_run_verdicts for per-subject results."
|
|
8311
|
+
].join("\n"),
|
|
8312
|
+
listRuns: [
|
|
8313
|
+
"List an app's runs, newest first, with status, decision and who decided; `total` counts every run.",
|
|
8314
|
+
"ARGS: app_id, optional limit (max 200) and offset."
|
|
8315
|
+
].join("\n"),
|
|
8316
|
+
getRun: [
|
|
8317
|
+
"Read one run: status, decision, decided_by, thresholds applied, reviews raised, timing.",
|
|
8318
|
+
"USE WHEN: checking a run you started or found. include_events:true adds the run's journal (every event in order).",
|
|
8319
|
+
"NOT FOR: Spec/pipeline runs (talonic_get_run). ARGS: run_id, optional include_events."
|
|
8320
|
+
].join("\n"),
|
|
8321
|
+
record: [
|
|
8322
|
+
"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.",
|
|
8323
|
+
"USE WHEN: the user needs the final, auditable outcome. A run that has not finished has no record yet (HTTP 404). ARGS: run_id."
|
|
8324
|
+
].join("\n"),
|
|
8325
|
+
verdicts: [
|
|
8326
|
+
"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.",
|
|
8327
|
+
"USE WHEN: inspecting what a run decided per record. Single-decision runs have none (HTTP 404; use talonic_get_app_run).",
|
|
8328
|
+
"ARGS: run_id; optional rolled (overall outcome), auto, rule + status (always together), limit (max 200), cursor (from `next`)."
|
|
8329
|
+
].join("\n"),
|
|
8330
|
+
listReviews: [
|
|
8331
|
+
"List Human Reviews: questions apps raised for a person (approvals, missing data, judgment calls, exceptions), newest first, with `total`.",
|
|
8332
|
+
"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.",
|
|
8333
|
+
"ARGS: optional app_id, status, kind, assignee_user_id, limit (max 200), offset."
|
|
8334
|
+
].join("\n"),
|
|
8335
|
+
raiseReview: [
|
|
8336
|
+
"Ask a person a question on an app instead of guessing: a Human Review with a JSON Schema for the answer.",
|
|
8337
|
+
"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.",
|
|
8338
|
+
"NEXT: the answer arrives through talonic_resolve_app_review (or the web app); read it with talonic_list_app_reviews status 'resolved'."
|
|
8339
|
+
].join("\n"),
|
|
8340
|
+
resolveReview: [
|
|
8341
|
+
"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).",
|
|
8342
|
+
"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.",
|
|
8343
|
+
"RETURNS: the resolved review with its values. ARGS: review_id, values, optional feedback."
|
|
8344
|
+
].join("\n"),
|
|
8345
|
+
interview: [
|
|
8346
|
+
"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.",
|
|
8347
|
+
"ready:true only when the proposed values satisfy the review's input contract. Nothing is submitted: finish with talonic_resolve_app_review.",
|
|
8348
|
+
"ARGS: review_id, message, optional transcript [{ role: user | assistant, text }]."
|
|
8349
|
+
].join("\n"),
|
|
8350
|
+
precedents: [
|
|
8351
|
+
"List an app's precedents: past resolved reviews it reuses for similar future runs.",
|
|
8352
|
+
"ARGS: app_id, optional similar_to (match keys object) to narrow to similar cases. An app with none returns an empty list."
|
|
8353
|
+
].join("\n"),
|
|
8354
|
+
getLogic: [
|
|
8355
|
+
"Read an app's logic: the editable draft and the active published version, including each rule with its interpretation state and plain-language readback.",
|
|
8356
|
+
"USE WHEN: before editing, or to get the draft's full content for talonic_save_app_draft."
|
|
8357
|
+
].join("\n"),
|
|
8358
|
+
getFields: [
|
|
8359
|
+
"List the fields the app's rules can use, per bound data source. This is everything the app can see.",
|
|
8360
|
+
"USE WHEN: before writing or fixing rules, so they name fields that exist."
|
|
8361
|
+
].join("\n"),
|
|
8362
|
+
interpret: [
|
|
8363
|
+
"Turn the draft's pending rule sentences into checkable rules against the app's fields, and save the draft.",
|
|
8364
|
+
"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.",
|
|
8365
|
+
"RETURNS: the rules plus warnings saying why any rule stayed pending."
|
|
8366
|
+
].join("\n"),
|
|
8367
|
+
proposeEdit: [
|
|
8368
|
+
"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.",
|
|
8369
|
+
"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."
|
|
8370
|
+
].join("\n"),
|
|
8371
|
+
applyEdit: [
|
|
8372
|
+
"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.",
|
|
8373
|
+
"ARGS: app_id, ops (from the proposal, unchanged)."
|
|
8374
|
+
].join("\n"),
|
|
8375
|
+
getAcceptance: [
|
|
8376
|
+
"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."
|
|
8377
|
+
].join("\n"),
|
|
8378
|
+
saveAcceptance: [
|
|
8379
|
+
"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.",
|
|
8380
|
+
"ARGS: app_id, cases (per subject: subject_key + expected_outcome and/or expected_auto; for single-decision apps: expected_decision), optional tolerance (default 0)."
|
|
8381
|
+
].join("\n"),
|
|
8382
|
+
checkAcceptance: [
|
|
8383
|
+
"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.",
|
|
8384
|
+
"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)."
|
|
8385
|
+
].join("\n")
|
|
8386
|
+
};
|
|
8387
|
+
var acceptanceCase = z.object({
|
|
8388
|
+
subject_key: z.string().min(1).max(256).optional(),
|
|
8389
|
+
expected_outcome: z.enum(VERDICT_OUTCOMES).optional(),
|
|
8390
|
+
expected_auto: z.boolean().optional(),
|
|
8391
|
+
expected_decision: z.string().min(1).max(64).optional(),
|
|
8392
|
+
note: z.string().max(300).optional()
|
|
8393
|
+
}).describe(
|
|
8394
|
+
"One expected result: subject_key + expected_outcome (and/or expected_auto) for batch apps, or expected_decision for single-decision apps."
|
|
8395
|
+
);
|
|
8396
|
+
function registerAppsToolset(server, getToken, baseUrl) {
|
|
8397
|
+
const t = getToken;
|
|
8398
|
+
const b = baseUrl;
|
|
8399
|
+
const reg = (name, title, description, inputSchema11, annotations, handler) => server.registerTool(
|
|
8400
|
+
name,
|
|
8401
|
+
{ title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
|
|
8402
|
+
handler
|
|
8403
|
+
);
|
|
8404
|
+
reg(
|
|
8405
|
+
"talonic_create_app",
|
|
8406
|
+
"Create App",
|
|
8407
|
+
D.create,
|
|
8408
|
+
{
|
|
8409
|
+
slug: z.string().regex(/^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/).describe("Lowercase letters, digits and hyphens, 3-64 chars."),
|
|
8410
|
+
display_name: z.string().min(1).max(200),
|
|
8411
|
+
mode: z.enum(APP_MODES),
|
|
8412
|
+
description: z.string().max(2e3).optional().describe("One sentence about the app.")
|
|
8413
|
+
},
|
|
8414
|
+
MUTATING2,
|
|
8415
|
+
(a) => handleCreateApp(t, b, a)
|
|
8416
|
+
);
|
|
8417
|
+
reg(
|
|
8418
|
+
"talonic_get_app",
|
|
8419
|
+
"Get App",
|
|
8420
|
+
D.get,
|
|
8421
|
+
{ app_id: appId },
|
|
8422
|
+
READ_ONLY3,
|
|
8423
|
+
(a) => handleGetApp(t, b, a)
|
|
8424
|
+
);
|
|
8425
|
+
reg(
|
|
8426
|
+
"talonic_get_app_logic",
|
|
8427
|
+
"Get App Logic",
|
|
8428
|
+
D.getLogic,
|
|
8429
|
+
{ app_id: appId },
|
|
8430
|
+
READ_ONLY3,
|
|
8431
|
+
(a) => handleGetAppLogic(t, b, a)
|
|
8432
|
+
);
|
|
8433
|
+
reg(
|
|
8434
|
+
"talonic_get_app_fields",
|
|
8435
|
+
"Get App Fields",
|
|
8436
|
+
D.getFields,
|
|
8437
|
+
{ app_id: appId },
|
|
8438
|
+
READ_ONLY3,
|
|
8439
|
+
(a) => handleGetAppFields(t, b, a)
|
|
8440
|
+
);
|
|
8441
|
+
reg(
|
|
8442
|
+
"talonic_save_app_draft",
|
|
8443
|
+
"Save App Draft",
|
|
8444
|
+
D.saveDraft,
|
|
8445
|
+
{ app_id: appId, content: jsonObject().describe("Full version content object.") },
|
|
8446
|
+
MUTATING2,
|
|
8447
|
+
(a) => handleSaveAppDraft(t, b, a)
|
|
8448
|
+
);
|
|
8449
|
+
reg(
|
|
8450
|
+
"talonic_interpret_app_rules",
|
|
8451
|
+
"Interpret App Rules",
|
|
8452
|
+
D.interpret,
|
|
8453
|
+
{
|
|
8454
|
+
app_id: appId,
|
|
8455
|
+
card_ids: z.array(z.string().min(1).max(128)).max(50).optional().describe("Rule card ids; omit for all pending."),
|
|
8456
|
+
guidance: z.string().max(1e3).optional().describe("Plain-language hint for stuck rules."),
|
|
8457
|
+
locale: z.string().max(10).optional().describe("Language of reasons and readbacks, e.g. de.")
|
|
8458
|
+
},
|
|
8459
|
+
MUTATING2,
|
|
8460
|
+
(a) => handleInterpretRules(t, b, a)
|
|
8461
|
+
);
|
|
8462
|
+
reg(
|
|
8463
|
+
"talonic_propose_app_edit",
|
|
8464
|
+
"Propose App Edit",
|
|
8465
|
+
D.proposeEdit,
|
|
8466
|
+
{
|
|
8467
|
+
app_id: appId,
|
|
8468
|
+
instruction: z.string().min(8).max(2e3).describe("The change, in plain language.")
|
|
8469
|
+
},
|
|
8470
|
+
{ ...READ_ONLY3, idempotentHint: false },
|
|
8471
|
+
(a) => handleProposeEdit(t, b, a)
|
|
8472
|
+
);
|
|
8473
|
+
reg(
|
|
8474
|
+
"talonic_apply_app_edit",
|
|
8475
|
+
"Apply App Edit",
|
|
8476
|
+
D.applyEdit,
|
|
8477
|
+
{
|
|
8478
|
+
app_id: appId,
|
|
8479
|
+
ops: z.array(jsonObject()).min(1).max(20).describe("Accepted ops from the proposal.")
|
|
8480
|
+
},
|
|
8481
|
+
MUTATING2,
|
|
8482
|
+
(a) => handleApplyEdit(t, b, a)
|
|
8483
|
+
);
|
|
8484
|
+
reg(
|
|
8485
|
+
"talonic_list_app_versions",
|
|
8486
|
+
"List App Versions",
|
|
8487
|
+
D.versions,
|
|
8488
|
+
{ app_id: appId },
|
|
8489
|
+
READ_ONLY3,
|
|
8490
|
+
(a) => handleListAppVersions(t, b, a)
|
|
8491
|
+
);
|
|
8492
|
+
reg(
|
|
8493
|
+
"talonic_publish_app",
|
|
8494
|
+
"Publish App",
|
|
8495
|
+
D.publish,
|
|
8496
|
+
{ app_id: appId, version: z.number().int().min(1).describe("The draft's version number.") },
|
|
8497
|
+
MUTATING2,
|
|
8498
|
+
(a) => handlePublishApp(t, b, a)
|
|
8499
|
+
);
|
|
8500
|
+
reg(
|
|
8501
|
+
"talonic_enable_app",
|
|
8502
|
+
"Enable App",
|
|
8503
|
+
D.enable,
|
|
8504
|
+
{ app_id: appId },
|
|
8505
|
+
MUTATING2,
|
|
8506
|
+
(a) => handleSetAppEnabled(t, b, a, true)
|
|
8507
|
+
);
|
|
8508
|
+
reg(
|
|
8509
|
+
"talonic_disable_app",
|
|
8510
|
+
"Disable App",
|
|
8511
|
+
D.disable,
|
|
8512
|
+
{ app_id: appId },
|
|
8513
|
+
MUTATING2,
|
|
8514
|
+
(a) => handleSetAppEnabled(t, b, a, false)
|
|
8515
|
+
);
|
|
8516
|
+
reg(
|
|
8517
|
+
"talonic_get_app_acceptance",
|
|
8518
|
+
"Get App Acceptance Set",
|
|
8519
|
+
D.getAcceptance,
|
|
8520
|
+
{ app_id: appId },
|
|
8521
|
+
READ_ONLY3,
|
|
8522
|
+
(a) => handleGetAcceptance(t, b, a)
|
|
8523
|
+
);
|
|
8524
|
+
reg(
|
|
8525
|
+
"talonic_save_app_acceptance",
|
|
8526
|
+
"Save App Acceptance Set",
|
|
8527
|
+
D.saveAcceptance,
|
|
8528
|
+
{
|
|
8529
|
+
app_id: appId,
|
|
8530
|
+
cases: z.array(acceptanceCase).min(1).max(2e3),
|
|
8531
|
+
tolerance: z.number().min(0).max(1).optional().describe("Accepted mismatch share (default 0).")
|
|
8532
|
+
},
|
|
8533
|
+
MUTATING2,
|
|
8534
|
+
(a) => handleSaveAcceptance(t, b, a)
|
|
8535
|
+
);
|
|
8536
|
+
reg(
|
|
8537
|
+
"talonic_check_app_acceptance",
|
|
8538
|
+
"Check App Acceptance",
|
|
8539
|
+
D.checkAcceptance,
|
|
8540
|
+
{
|
|
8541
|
+
app_id: appId,
|
|
8542
|
+
run_id: zUuid().optional().describe("Run to score; default the latest completed run.")
|
|
8543
|
+
},
|
|
8544
|
+
READ_ONLY3,
|
|
8545
|
+
(a) => handleCheckAcceptance(t, b, a)
|
|
8546
|
+
);
|
|
8547
|
+
reg(
|
|
8548
|
+
"talonic_run_app",
|
|
8549
|
+
"Run App",
|
|
8550
|
+
D.run,
|
|
8551
|
+
{
|
|
8552
|
+
app_id: appId,
|
|
8553
|
+
input: jsonObject().optional().describe("Run input, checked against the app's input schema."),
|
|
8554
|
+
dry_run: z.boolean().optional().describe("Full trace, no side effects."),
|
|
8555
|
+
idempotency_key: z.string().min(1).max(64).optional()
|
|
8556
|
+
},
|
|
8557
|
+
MUTATING2,
|
|
8558
|
+
(a) => handleRunApp(t, b, a)
|
|
8559
|
+
);
|
|
8560
|
+
reg(
|
|
8561
|
+
"talonic_list_app_runs",
|
|
8562
|
+
"List App Runs",
|
|
8563
|
+
D.listRuns,
|
|
8564
|
+
{ app_id: appId, limit: limit2, offset },
|
|
8565
|
+
READ_ONLY3,
|
|
8566
|
+
(a) => handleListAppRuns(t, b, a)
|
|
8567
|
+
);
|
|
8568
|
+
reg(
|
|
8569
|
+
"talonic_get_app_run",
|
|
8570
|
+
"Get App Run",
|
|
8571
|
+
D.getRun,
|
|
8572
|
+
{ run_id: runId, include_events: z.boolean().optional() },
|
|
8573
|
+
READ_ONLY3,
|
|
8574
|
+
(a) => handleGetAppRun(t, b, a)
|
|
8575
|
+
);
|
|
8576
|
+
reg(
|
|
8577
|
+
"talonic_get_run_record",
|
|
8578
|
+
"Get Run Record",
|
|
8579
|
+
D.record,
|
|
8580
|
+
{ run_id: runId },
|
|
8581
|
+
READ_ONLY3,
|
|
8582
|
+
(a) => handleGetRunRecord(t, b, a)
|
|
8583
|
+
);
|
|
8584
|
+
reg(
|
|
8585
|
+
"talonic_get_run_verdicts",
|
|
8586
|
+
"Get Run Verdicts",
|
|
8587
|
+
D.verdicts,
|
|
8588
|
+
{
|
|
8589
|
+
run_id: runId,
|
|
8590
|
+
rolled: z.enum(VERDICT_OUTCOMES).optional().describe("Filter by overall outcome."),
|
|
8591
|
+
auto: z.boolean().optional().describe("Filter by the auto flag."),
|
|
8592
|
+
rule: z.string().min(1).max(128).optional().describe("Rule id; needs status."),
|
|
8593
|
+
status: z.enum(VERDICT_OUTCOMES).optional().describe("That rule's outcome; needs rule."),
|
|
8594
|
+
limit: limit2,
|
|
8595
|
+
cursor: z.string().min(1).max(512).optional().describe("`next` from the previous page.")
|
|
8596
|
+
},
|
|
8597
|
+
READ_ONLY3,
|
|
8598
|
+
(a) => handleGetRunVerdicts(t, b, a)
|
|
8599
|
+
);
|
|
8600
|
+
reg(
|
|
8601
|
+
"talonic_list_app_reviews",
|
|
8602
|
+
"List Human Reviews",
|
|
8603
|
+
D.listReviews,
|
|
8604
|
+
{
|
|
8605
|
+
app_id: appId.optional(),
|
|
8606
|
+
status: z.enum(REVIEW_STATUSES).optional(),
|
|
8607
|
+
kind: z.enum(REVIEW_KINDS).optional(),
|
|
8608
|
+
assignee_user_id: zUuid().optional().describe("Only reviews assigned to this user."),
|
|
8609
|
+
limit: limit2,
|
|
8610
|
+
offset
|
|
8611
|
+
},
|
|
8612
|
+
READ_ONLY3,
|
|
8613
|
+
(a) => handleListAppReviews(t, b, a)
|
|
8614
|
+
);
|
|
8615
|
+
reg(
|
|
8616
|
+
"talonic_raise_app_review",
|
|
8617
|
+
"Raise Human Review",
|
|
8618
|
+
D.raiseReview,
|
|
8619
|
+
{
|
|
8620
|
+
app_id: appId,
|
|
8621
|
+
run_id: runId.optional(),
|
|
8622
|
+
kind: z.enum(REVIEW_KINDS),
|
|
8623
|
+
question: z.string().min(1).max(4e3),
|
|
8624
|
+
context: jsonObject().optional(),
|
|
8625
|
+
input_contract: jsonObject().describe("JSON Schema the answer must satisfy."),
|
|
8626
|
+
team_id: zUuid().optional().describe("Review team to assign.")
|
|
8627
|
+
},
|
|
8628
|
+
MUTATING2,
|
|
8629
|
+
(a) => handleRaiseAppReview(t, b, a)
|
|
8630
|
+
);
|
|
8631
|
+
reg(
|
|
8632
|
+
"talonic_resolve_app_review",
|
|
8633
|
+
"Resolve Human Review",
|
|
8634
|
+
D.resolveReview,
|
|
8635
|
+
{
|
|
8636
|
+
review_id: reviewId,
|
|
8637
|
+
values: jsonObject().describe("Answer values matching the review's input_contract."),
|
|
8638
|
+
feedback: z.object({
|
|
8639
|
+
proposal_verdict: z.enum(["correct", "incorrect", "partial"]).optional(),
|
|
8640
|
+
correction: z.string().max(4e3).optional(),
|
|
8641
|
+
generalize: z.boolean().optional()
|
|
8642
|
+
}).optional().describe("Optional feedback that teaches the app.")
|
|
8643
|
+
},
|
|
8644
|
+
MUTATING2,
|
|
8645
|
+
(a) => handleResolveAppReview(t, b, a)
|
|
8646
|
+
);
|
|
8647
|
+
reg(
|
|
8648
|
+
"talonic_interview_app_review",
|
|
8649
|
+
"Interview Human Review",
|
|
8650
|
+
D.interview,
|
|
8651
|
+
{
|
|
8652
|
+
review_id: reviewId,
|
|
8653
|
+
message: z.string().min(1).max(4e3).describe("The reviewer's message for this turn."),
|
|
8654
|
+
transcript: z.array(z.object({ role: z.enum(["user", "assistant"]), text: z.string().max(2e3) })).max(20).optional().describe("Earlier turns, oldest first.")
|
|
8655
|
+
},
|
|
8656
|
+
{ ...READ_ONLY3, idempotentHint: false },
|
|
8657
|
+
(a) => handleInterviewReview(t, b, a)
|
|
8658
|
+
);
|
|
8659
|
+
reg(
|
|
8660
|
+
"talonic_list_app_precedents",
|
|
8661
|
+
"List App Precedents",
|
|
8662
|
+
D.precedents,
|
|
8663
|
+
{ app_id: appId, similar_to: jsonObject().optional().describe("Match keys of the case.") },
|
|
8664
|
+
READ_ONLY3,
|
|
8665
|
+
(a) => handleListAppPrecedents(t, b, a)
|
|
8666
|
+
);
|
|
8667
|
+
}
|
|
8160
8668
|
var DECIDE_SCOPE = "apps:decide";
|
|
8161
8669
|
var TASK_STATUSES2 = [
|
|
8162
8670
|
"available",
|
|
@@ -8168,7 +8676,7 @@ var TASK_STATUSES2 = [
|
|
|
8168
8676
|
"cancelled"
|
|
8169
8677
|
];
|
|
8170
8678
|
var PACKAGE_PAGE_LIMIT_MAX = 2e3;
|
|
8171
|
-
var
|
|
8679
|
+
var appId2 = zUuid().describe(
|
|
8172
8680
|
"Id of an External-mode app (from talonic_list_apps, where mode is 'external')."
|
|
8173
8681
|
);
|
|
8174
8682
|
var taskId2 = zUuid().describe("Decision task UUID.");
|
|
@@ -8196,7 +8704,7 @@ var serviceVersion = z.string().min(1).max(64).optional().describe("Optional bui
|
|
|
8196
8704
|
var failReason = z.string().min(1).max(2e3).describe(
|
|
8197
8705
|
"Why the task cannot be decided, up to 2,000 characters. Recorded on the Human Review the fail raises."
|
|
8198
8706
|
);
|
|
8199
|
-
var listInput2 = { app_id:
|
|
8707
|
+
var listInput2 = { app_id: appId2, status: status2, limit: listLimit, cursor: cursor2 };
|
|
8200
8708
|
var idInput2 = { task_id: taskId2 };
|
|
8201
8709
|
var packageInput = { task_id: taskId2, cursor: packageCursor, limit: packageLimit };
|
|
8202
8710
|
var epochInput = { task_id: taskId2, execution_epoch: executionEpoch2 };
|
|
@@ -8271,12 +8779,12 @@ function handleFailDecisionTask(getToken, baseUrl, args) {
|
|
|
8271
8779
|
})
|
|
8272
8780
|
);
|
|
8273
8781
|
}
|
|
8274
|
-
var
|
|
8782
|
+
var READ_ONLY4 = {
|
|
8275
8783
|
readOnlyHint: true,
|
|
8276
8784
|
destructiveHint: false,
|
|
8277
8785
|
openWorldHint: false
|
|
8278
8786
|
};
|
|
8279
|
-
var
|
|
8787
|
+
var MUTATING3 = {
|
|
8280
8788
|
readOnlyHint: false,
|
|
8281
8789
|
destructiveHint: false,
|
|
8282
8790
|
openWorldHint: false
|
|
@@ -8358,7 +8866,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8358
8866
|
title: "List Decision Tasks",
|
|
8359
8867
|
description: DESCRIPTIONS2.list,
|
|
8360
8868
|
inputSchema: listInput2,
|
|
8361
|
-
annotations: { title: "List Decision Tasks", ...
|
|
8869
|
+
annotations: { title: "List Decision Tasks", ...READ_ONLY4 },
|
|
8362
8870
|
...metaFor("listDecisionTasks")
|
|
8363
8871
|
},
|
|
8364
8872
|
async (args) => handleListDecisionTasks(getToken, baseUrl, args)
|
|
@@ -8369,7 +8877,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8369
8877
|
title: "Claim Decision Task",
|
|
8370
8878
|
description: DESCRIPTIONS2.claim,
|
|
8371
8879
|
inputSchema: idInput2,
|
|
8372
|
-
annotations: { title: "Claim Decision Task", ...
|
|
8880
|
+
annotations: { title: "Claim Decision Task", ...MUTATING3 },
|
|
8373
8881
|
...metaFor("claimDecisionTask")
|
|
8374
8882
|
},
|
|
8375
8883
|
async (args) => handleClaimDecisionTask(getToken, baseUrl, args)
|
|
@@ -8380,7 +8888,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8380
8888
|
title: "Read Decision Package",
|
|
8381
8889
|
description: DESCRIPTIONS2.package,
|
|
8382
8890
|
inputSchema: packageInput,
|
|
8383
|
-
annotations: { title: "Read Decision Package", ...
|
|
8891
|
+
annotations: { title: "Read Decision Package", ...READ_ONLY4 },
|
|
8384
8892
|
...metaFor("readDecisionPackage")
|
|
8385
8893
|
},
|
|
8386
8894
|
async (args) => handleReadDecisionPackage(getToken, baseUrl, args)
|
|
@@ -8391,7 +8899,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8391
8899
|
title: "Heartbeat Decision Task",
|
|
8392
8900
|
description: DESCRIPTIONS2.heartbeat,
|
|
8393
8901
|
inputSchema: epochInput,
|
|
8394
|
-
annotations: { title: "Heartbeat Decision Task", ...
|
|
8902
|
+
annotations: { title: "Heartbeat Decision Task", ...MUTATING3 },
|
|
8395
8903
|
...metaFor("heartbeatDecisionTask")
|
|
8396
8904
|
},
|
|
8397
8905
|
async (args) => handleHeartbeatDecisionTask(getToken, baseUrl, args)
|
|
@@ -8402,7 +8910,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8402
8910
|
title: "Submit Decision Task",
|
|
8403
8911
|
description: DESCRIPTIONS2.submit,
|
|
8404
8912
|
inputSchema: submitInput2,
|
|
8405
|
-
annotations: { title: "Submit Decision Task", ...
|
|
8913
|
+
annotations: { title: "Submit Decision Task", ...MUTATING3 },
|
|
8406
8914
|
...metaFor("submitDecisionTask")
|
|
8407
8915
|
},
|
|
8408
8916
|
async (args) => handleSubmitDecisionTask(getToken, baseUrl, args)
|
|
@@ -8413,7 +8921,7 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8413
8921
|
title: "Release Decision Task",
|
|
8414
8922
|
description: DESCRIPTIONS2.release,
|
|
8415
8923
|
inputSchema: epochInput,
|
|
8416
|
-
annotations: { title: "Release Decision Task", ...
|
|
8924
|
+
annotations: { title: "Release Decision Task", ...MUTATING3 },
|
|
8417
8925
|
...metaFor("releaseDecisionTask")
|
|
8418
8926
|
},
|
|
8419
8927
|
async (args) => handleReleaseDecisionTask(getToken, baseUrl, args)
|
|
@@ -8430,6 +8938,230 @@ function registerDecisionTaskTools(server, getToken, baseUrl, options = {}) {
|
|
|
8430
8938
|
async (args) => handleFailDecisionTask(getToken, baseUrl, args)
|
|
8431
8939
|
);
|
|
8432
8940
|
}
|
|
8941
|
+
|
|
8942
|
+
// src/tools/mining-driver.ts
|
|
8943
|
+
var appId3 = zUuid().describe(
|
|
8944
|
+
"Id (UUID) of an autonomous app, from talonic_list_apps where mode is 'autonomous'."
|
|
8945
|
+
);
|
|
8946
|
+
var runId2 = zUuid().describe(
|
|
8947
|
+
"The round's run id (run_id from talonic_mining_list_rounds, or the decision task's run_id)."
|
|
8948
|
+
);
|
|
8949
|
+
var executionEpoch3 = z.number().int().min(1).max(2147483647).describe("execution_epoch from talonic_claim_decision_task. A stale epoch is HTTP 409.");
|
|
8950
|
+
var toolName = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/).describe("A tool name from talonic_mining_list_round_tools.");
|
|
8951
|
+
var READ_ONLY5 = {
|
|
8952
|
+
readOnlyHint: true,
|
|
8953
|
+
destructiveHint: false,
|
|
8954
|
+
idempotentHint: true,
|
|
8955
|
+
openWorldHint: false
|
|
8956
|
+
};
|
|
8957
|
+
var MUTATING4 = {
|
|
8958
|
+
readOnlyHint: false,
|
|
8959
|
+
destructiveHint: false,
|
|
8960
|
+
idempotentHint: false,
|
|
8961
|
+
openWorldHint: false
|
|
8962
|
+
};
|
|
8963
|
+
var roundsPath = (app, suffix = "") => `/v1/apps/${encodeURIComponent(app)}/mining/rounds${suffix}`;
|
|
8964
|
+
var roundPath = (app, run, suffix = "") => roundsPath(app, `/${encodeURIComponent(run)}${suffix}`);
|
|
8965
|
+
var BUSY_BACKOFF_MS = [500, 1e3, 2e3, 4e3];
|
|
8966
|
+
var POLL_INTERVAL_MS = 2e3;
|
|
8967
|
+
var DEFAULT_WAIT_SECONDS = 25;
|
|
8968
|
+
var MAX_WAIT_SECONDS = 120;
|
|
8969
|
+
var realSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
8970
|
+
function isBusy(err) {
|
|
8971
|
+
if (!(err instanceof ApiHttpError) || err.status !== 409) return false;
|
|
8972
|
+
try {
|
|
8973
|
+
const body = JSON.parse(err.body);
|
|
8974
|
+
return (body.details?.refused ?? body.error?.details?.refused) === "busy";
|
|
8975
|
+
} catch {
|
|
8976
|
+
return /"refused"\s*:\s*"busy"/.test(err.body);
|
|
8977
|
+
}
|
|
8978
|
+
}
|
|
8979
|
+
var handleMiningListRounds = (t, b, a) => runTool(
|
|
8980
|
+
() => apiJson(t, b, "GET", roundsPath(a.app_id), { params: { limit: a.limit, offset: a.offset } })
|
|
8981
|
+
);
|
|
8982
|
+
var handleMiningGetRound = (t, b, a) => runTool(() => apiJson(t, b, "GET", roundPath(a.app_id, a.run_id)));
|
|
8983
|
+
var handleMiningStartRound = (t, b, a) => runTool(
|
|
8984
|
+
() => a.phase === "reconcile" ? apiJson(t, b, "POST", roundsPath(a.app_id, "/reconcile")) : apiJson(t, b, "POST", roundsPath(a.app_id), {
|
|
8985
|
+
body: {
|
|
8986
|
+
...a.phase ? { phase: a.phase } : {},
|
|
8987
|
+
...a.dry_run !== void 0 ? { dry_run: a.dry_run } : {}
|
|
8988
|
+
}
|
|
8989
|
+
})
|
|
8990
|
+
);
|
|
8991
|
+
var handleMiningListRoundTools = (t, b, a) => runTool(() => apiJson(t, b, "GET", roundPath(a.app_id, a.run_id, "/tools")));
|
|
8992
|
+
async function handleMiningCallRoundTool(t, b, a, timing = {}) {
|
|
8993
|
+
const sleep2 = timing.sleep ?? realSleep;
|
|
8994
|
+
const now = timing.now ?? Date.now;
|
|
8995
|
+
return runTool(async () => {
|
|
8996
|
+
const path = roundPath(a.app_id, a.run_id, `/tools/${encodeURIComponent(a.name)}`);
|
|
8997
|
+
const body = { execution_epoch: a.execution_epoch, input: a.input ?? {} };
|
|
8998
|
+
let answer;
|
|
8999
|
+
for (let attempt = 0; ; attempt++) {
|
|
9000
|
+
try {
|
|
9001
|
+
answer = await apiJson(t, b, "POST", path, { body });
|
|
9002
|
+
break;
|
|
9003
|
+
} catch (err) {
|
|
9004
|
+
const backoff = BUSY_BACKOFF_MS[attempt];
|
|
9005
|
+
if (!isBusy(err) || backoff === void 0) throw err;
|
|
9006
|
+
await sleep2(backoff);
|
|
9007
|
+
}
|
|
9008
|
+
}
|
|
9009
|
+
if (answer?.status !== "running" || !answer.call_id) return answer;
|
|
9010
|
+
const waitMs = Math.min(a.wait_seconds ?? DEFAULT_WAIT_SECONDS, MAX_WAIT_SECONDS) * 1e3;
|
|
9011
|
+
const deadline = now() + waitMs;
|
|
9012
|
+
const callId = answer.call_id;
|
|
9013
|
+
while (now() < deadline) {
|
|
9014
|
+
await sleep2(POLL_INTERVAL_MS);
|
|
9015
|
+
const polled = await apiJson(
|
|
9016
|
+
t,
|
|
9017
|
+
b,
|
|
9018
|
+
"GET",
|
|
9019
|
+
roundPath(a.app_id, a.run_id, `/tools/calls/${encodeURIComponent(callId)}`),
|
|
9020
|
+
{ params: { execution_epoch: a.execution_epoch } }
|
|
9021
|
+
);
|
|
9022
|
+
if (polled?.status !== "running") return polled;
|
|
9023
|
+
}
|
|
9024
|
+
return {
|
|
9025
|
+
call_id: callId,
|
|
9026
|
+
status: "running",
|
|
9027
|
+
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."
|
|
9028
|
+
};
|
|
9029
|
+
});
|
|
9030
|
+
}
|
|
9031
|
+
var handleMiningGetRoundToolCall = (t, b, a) => runTool(
|
|
9032
|
+
() => apiJson(
|
|
9033
|
+
t,
|
|
9034
|
+
b,
|
|
9035
|
+
"GET",
|
|
9036
|
+
roundPath(a.app_id, a.run_id, `/tools/calls/${encodeURIComponent(a.call_id)}`),
|
|
9037
|
+
{
|
|
9038
|
+
params: { execution_epoch: a.execution_epoch }
|
|
9039
|
+
}
|
|
9040
|
+
)
|
|
9041
|
+
);
|
|
9042
|
+
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.";
|
|
9043
|
+
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.";
|
|
9044
|
+
var D2 = {
|
|
9045
|
+
listRounds: [
|
|
9046
|
+
"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.",
|
|
9047
|
+
"USE WHEN: finding a round to drive or checking progress. ARGS: app_id, optional limit (max 200), offset."
|
|
9048
|
+
].join("\n"),
|
|
9049
|
+
getRound: [
|
|
9050
|
+
"Read one rule-finding round: phase, status, budget, findings, candidate rules, summary, and the driver block for an externally driven round.",
|
|
9051
|
+
"ARGS: app_id, run_id."
|
|
9052
|
+
].join("\n"),
|
|
9053
|
+
startRound: [
|
|
9054
|
+
"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.",
|
|
9055
|
+
"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).",
|
|
9056
|
+
"RETURNS: { run_id, status, phase, \u2026 }. A round with an outside driver then waits for a claim: see talonic_list_decision_tasks."
|
|
9057
|
+
].join("\n"),
|
|
9058
|
+
listTools: [
|
|
9059
|
+
"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.",
|
|
9060
|
+
"USE WHEN: right after claiming the round's decision task, or to check remaining budget.",
|
|
9061
|
+
DRIVER_FLOW,
|
|
9062
|
+
AUTH_NOTE2
|
|
9063
|
+
].join("\n"),
|
|
9064
|
+
callTool: [
|
|
9065
|
+
"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.",
|
|
9066
|
+
"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.",
|
|
9067
|
+
"Do not call tools on one round in parallel. close_round is not a tool here: close the round with talonic_submit_decision_task.",
|
|
9068
|
+
"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.",
|
|
9069
|
+
AUTH_NOTE2
|
|
9070
|
+
].join("\n"),
|
|
9071
|
+
getCall: [
|
|
9072
|
+
"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.",
|
|
9073
|
+
"ARGS: app_id, run_id, call_id, execution_epoch.",
|
|
9074
|
+
AUTH_NOTE2
|
|
9075
|
+
].join("\n")
|
|
9076
|
+
};
|
|
9077
|
+
function registerMiningDriverTools(server, getToken, baseUrl, options = {}) {
|
|
9078
|
+
const t = getToken;
|
|
9079
|
+
const b = baseUrl;
|
|
9080
|
+
const decideMeta = options.invocable === false ? { _meta: { "talonic/can_invoke": false, "talonic/required_scope": DECIDE_SCOPE } } : {};
|
|
9081
|
+
server.registerTool(
|
|
9082
|
+
"talonic_mining_list_rounds",
|
|
9083
|
+
{
|
|
9084
|
+
title: "List Mining Rounds",
|
|
9085
|
+
description: D2.listRounds,
|
|
9086
|
+
inputSchema: {
|
|
9087
|
+
app_id: appId3,
|
|
9088
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
9089
|
+
offset: z.number().int().min(0).optional()
|
|
9090
|
+
},
|
|
9091
|
+
annotations: { title: "List Mining Rounds", ...READ_ONLY5 }
|
|
9092
|
+
},
|
|
9093
|
+
(a) => handleMiningListRounds(t, b, a)
|
|
9094
|
+
);
|
|
9095
|
+
server.registerTool(
|
|
9096
|
+
"talonic_mining_get_round",
|
|
9097
|
+
{
|
|
9098
|
+
title: "Get Mining Round",
|
|
9099
|
+
description: D2.getRound,
|
|
9100
|
+
inputSchema: { app_id: appId3, run_id: runId2 },
|
|
9101
|
+
annotations: { title: "Get Mining Round", ...READ_ONLY5 }
|
|
9102
|
+
},
|
|
9103
|
+
(a) => handleMiningGetRound(t, b, a)
|
|
9104
|
+
);
|
|
9105
|
+
server.registerTool(
|
|
9106
|
+
"talonic_mining_start_round",
|
|
9107
|
+
{
|
|
9108
|
+
title: "Start Mining Round",
|
|
9109
|
+
description: D2.startRound,
|
|
9110
|
+
inputSchema: {
|
|
9111
|
+
app_id: appId3,
|
|
9112
|
+
phase: z.enum(["discovery", "hypothesis", "reconcile"]).optional(),
|
|
9113
|
+
dry_run: z.boolean().optional()
|
|
9114
|
+
},
|
|
9115
|
+
annotations: { title: "Start Mining Round", ...MUTATING4 }
|
|
9116
|
+
},
|
|
9117
|
+
(a) => handleMiningStartRound(t, b, a)
|
|
9118
|
+
);
|
|
9119
|
+
server.registerTool(
|
|
9120
|
+
"talonic_mining_list_round_tools",
|
|
9121
|
+
{
|
|
9122
|
+
title: "List Round Tools",
|
|
9123
|
+
description: D2.listTools,
|
|
9124
|
+
inputSchema: { app_id: appId3, run_id: runId2 },
|
|
9125
|
+
annotations: { title: "List Round Tools", ...READ_ONLY5 },
|
|
9126
|
+
...decideMeta
|
|
9127
|
+
},
|
|
9128
|
+
(a) => handleMiningListRoundTools(t, b, a)
|
|
9129
|
+
);
|
|
9130
|
+
server.registerTool(
|
|
9131
|
+
"talonic_mining_call_round_tool",
|
|
9132
|
+
{
|
|
9133
|
+
title: "Call Round Tool",
|
|
9134
|
+
description: D2.callTool,
|
|
9135
|
+
inputSchema: {
|
|
9136
|
+
app_id: appId3,
|
|
9137
|
+
run_id: runId2,
|
|
9138
|
+
execution_epoch: executionEpoch3,
|
|
9139
|
+
name: toolName,
|
|
9140
|
+
input: z.record(z.string(), z.json()).optional().describe("The tool's input object."),
|
|
9141
|
+
wait_seconds: z.number().int().min(0).max(MAX_WAIT_SECONDS).optional().describe(`Seconds to keep polling a long call (default ${DEFAULT_WAIT_SECONDS}).`)
|
|
9142
|
+
},
|
|
9143
|
+
annotations: { title: "Call Round Tool", ...MUTATING4 },
|
|
9144
|
+
...decideMeta
|
|
9145
|
+
},
|
|
9146
|
+
(a) => handleMiningCallRoundTool(t, b, a)
|
|
9147
|
+
);
|
|
9148
|
+
server.registerTool(
|
|
9149
|
+
"talonic_mining_get_round_tool_call",
|
|
9150
|
+
{
|
|
9151
|
+
title: "Get Round Tool Call",
|
|
9152
|
+
description: D2.getCall,
|
|
9153
|
+
inputSchema: {
|
|
9154
|
+
app_id: appId3,
|
|
9155
|
+
run_id: runId2,
|
|
9156
|
+
call_id: zUuid().describe("call_id from talonic_mining_call_round_tool."),
|
|
9157
|
+
execution_epoch: executionEpoch3
|
|
9158
|
+
},
|
|
9159
|
+
annotations: { title: "Get Round Tool Call", ...READ_ONLY5 },
|
|
9160
|
+
...decideMeta
|
|
9161
|
+
},
|
|
9162
|
+
(a) => handleMiningGetRoundToolCall(t, b, a)
|
|
9163
|
+
);
|
|
9164
|
+
}
|
|
8433
9165
|
var DESCRIPTION11 = [
|
|
8434
9166
|
"Get the OCR-converted markdown text of a document.",
|
|
8435
9167
|
"",
|
|
@@ -8972,7 +9704,7 @@ async function handleGetSpec(getToken, baseUrl, args) {
|
|
|
8972
9704
|
return { ...spec, versions: versions.data ?? [] };
|
|
8973
9705
|
});
|
|
8974
9706
|
}
|
|
8975
|
-
var
|
|
9707
|
+
var READ_ONLY6 = {
|
|
8976
9708
|
readOnlyHint: true,
|
|
8977
9709
|
destructiveHint: false,
|
|
8978
9710
|
idempotentHint: true,
|
|
@@ -8985,7 +9717,7 @@ function registerSpecTools(server, getToken, baseUrl) {
|
|
|
8985
9717
|
title: "List pipelines",
|
|
8986
9718
|
description: LIST_DESCRIPTION5,
|
|
8987
9719
|
inputSchema: listSpecsInputSchema,
|
|
8988
|
-
annotations: { title: "List pipelines", ...
|
|
9720
|
+
annotations: { title: "List pipelines", ...READ_ONLY6 },
|
|
8989
9721
|
_meta: widgetToolMeta("listSpecs")
|
|
8990
9722
|
},
|
|
8991
9723
|
async (args) => handleListSpecs(getToken, baseUrl, args)
|
|
@@ -8996,7 +9728,7 @@ function registerSpecTools(server, getToken, baseUrl) {
|
|
|
8996
9728
|
title: "Look up a pipeline",
|
|
8997
9729
|
description: GET_DESCRIPTION4,
|
|
8998
9730
|
inputSchema: getSpecInputSchema,
|
|
8999
|
-
annotations: { title: "Look up a pipeline", ...
|
|
9731
|
+
annotations: { title: "Look up a pipeline", ...READ_ONLY6 },
|
|
9000
9732
|
_meta: widgetToolMeta("getSpec")
|
|
9001
9733
|
},
|
|
9002
9734
|
async (args) => handleGetSpec(getToken, baseUrl, args)
|
|
@@ -9212,7 +9944,7 @@ async function handleGetRunResults(getToken, baseUrl, args) {
|
|
|
9212
9944
|
return { run_kind: kind, ...body };
|
|
9213
9945
|
});
|
|
9214
9946
|
}
|
|
9215
|
-
var
|
|
9947
|
+
var READ_ONLY7 = {
|
|
9216
9948
|
readOnlyHint: true,
|
|
9217
9949
|
destructiveHint: false,
|
|
9218
9950
|
idempotentHint: true,
|
|
@@ -9241,7 +9973,7 @@ function registerRunTools(server, getToken, baseUrl) {
|
|
|
9241
9973
|
title: "Check run progress",
|
|
9242
9974
|
description: GET_RUN_DESCRIPTION,
|
|
9243
9975
|
inputSchema: runRefInputSchema,
|
|
9244
|
-
annotations: { title: "Check run progress", ...
|
|
9976
|
+
annotations: { title: "Check run progress", ...READ_ONLY7 },
|
|
9245
9977
|
_meta: widgetToolMeta("getRun")
|
|
9246
9978
|
},
|
|
9247
9979
|
async (args) => handleGetRun(getToken, baseUrl, args)
|
|
@@ -9252,7 +9984,7 @@ function registerRunTools(server, getToken, baseUrl) {
|
|
|
9252
9984
|
title: "Read run results",
|
|
9253
9985
|
description: RESULTS_DESCRIPTION,
|
|
9254
9986
|
inputSchema: resultsInputSchema,
|
|
9255
|
-
annotations: { title: "Read run results", ...
|
|
9987
|
+
annotations: { title: "Read run results", ...READ_ONLY7 },
|
|
9256
9988
|
_meta: widgetToolMeta("getRunResults")
|
|
9257
9989
|
},
|
|
9258
9990
|
async (args) => handleGetRunResults(getToken, baseUrl, args)
|
|
@@ -11500,7 +12232,7 @@ function registerToolGroups(server, keys, getToken, baseUrl) {
|
|
|
11500
12232
|
|
|
11501
12233
|
// package.json
|
|
11502
12234
|
var package_default = {
|
|
11503
|
-
version: "0.1.
|
|
12235
|
+
version: "0.1.105"};
|
|
11504
12236
|
|
|
11505
12237
|
// src/version.ts
|
|
11506
12238
|
var VERSION = package_default.version;
|
|
@@ -11563,6 +12295,16 @@ function buildServerInstructions(opts) {
|
|
|
11563
12295
|
"apps:decide consent and a senior_member role or above; on HTTP 403 tell the user",
|
|
11564
12296
|
"which consent or role is missing instead of retrying."
|
|
11565
12297
|
] : [],
|
|
12298
|
+
...opts.includeAppsToolset ? [
|
|
12299
|
+
"To build an app: talonic_create_app -> talonic_save_app_draft ->",
|
|
12300
|
+
"talonic_interpret_app_rules -> talonic_publish_app -> talonic_run_app (dry_run first) ->",
|
|
12301
|
+
"talonic_get_app_run or talonic_get_run_verdicts -> talonic_check_app_acceptance.",
|
|
12302
|
+
"Human Reviews: talonic_list_app_reviews -> talonic_resolve_app_review."
|
|
12303
|
+
] : [],
|
|
12304
|
+
...opts.includeMiningDriverTools ? [
|
|
12305
|
+
"A rule-finding round waiting for an outside driver is claimed and closed with the",
|
|
12306
|
+
"decision-task tools; in between, call its tools with talonic_mining_call_round_tool."
|
|
12307
|
+
] : [],
|
|
11566
12308
|
"Tools that change workspace data (saving schemas, app updates, decisions) should only",
|
|
11567
12309
|
"be called when the user asked for that change. Every error ends with a 'Next step'",
|
|
11568
12310
|
"line: follow it.",
|
|
@@ -11626,7 +12368,9 @@ function createServer(options) {
|
|
|
11626
12368
|
instructions: buildServerInstructions({
|
|
11627
12369
|
includeGenericExecutor: options.includeGenericExecutor !== false,
|
|
11628
12370
|
includeAgentTaskTools: options.includeAgentTaskTools !== false,
|
|
11629
|
-
includeDecisionTaskTools: options.includeDecisionTaskTools !== false
|
|
12371
|
+
includeDecisionTaskTools: options.includeDecisionTaskTools !== false,
|
|
12372
|
+
includeAppsToolset: options.includeAppsToolset === true,
|
|
12373
|
+
includeMiningDriverTools: options.includeMiningDriverTools === true
|
|
11630
12374
|
})
|
|
11631
12375
|
}
|
|
11632
12376
|
);
|
|
@@ -11668,6 +12412,14 @@ function createServer(options) {
|
|
|
11668
12412
|
invocable: options.decisionTasksInvocable !== false
|
|
11669
12413
|
});
|
|
11670
12414
|
}
|
|
12415
|
+
if (options.includeAppsToolset) {
|
|
12416
|
+
registerAppsToolset(server, rawToken, baseUrl);
|
|
12417
|
+
}
|
|
12418
|
+
if (options.includeMiningDriverTools) {
|
|
12419
|
+
registerMiningDriverTools(server, rawToken, baseUrl, {
|
|
12420
|
+
invocable: options.decisionTasksInvocable !== false
|
|
12421
|
+
});
|
|
12422
|
+
}
|
|
11671
12423
|
if (options.includeGrowthTools) {
|
|
11672
12424
|
registerGrowthTools(server, rawToken, baseUrl);
|
|
11673
12425
|
}
|