clearotron 0.7.0 → 0.8.0-beta.0
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/THIRD-PARTY-NOTICES.md +71 -2
- package/build-info.json +2 -2
- package/demo/multi-country-focus-search/run/common-law-grid.json +1 -1
- package/docs/CLIENT-MCP.md +17 -0
- package/docs/assets/README.md +19 -3
- package/docs/assets/portal-clearance-report.jpg +0 -0
- package/docs/assets/portal-conflict-landscape.jpg +0 -0
- package/docs/assets/portal-new-clearance.png +0 -0
- package/driver/CHANGELOG.md +48 -0
- package/driver/config-inventory.mjs +15 -2
- package/driver/dev-portal.mjs +2 -0
- package/driver/effort-model.mjs +34 -4
- package/driver/engine/CONTRACT.md +8 -0
- package/driver/engine/anthropic-agent.mjs +74 -16
- package/driver/engine/jx-turn.mjs +11 -3
- package/driver/engine/openai-agent.mjs +33 -7
- package/driver/engine/run-choices.mjs +28 -7
- package/driver/engine/speed.mjs +107 -0
- package/driver/enqueue-schema.mjs +8 -0
- package/driver/enqueue.mjs +14 -2
- package/driver/jx-units.mjs +2 -2
- package/driver/jx.mjs +1 -1
- package/driver/knockout-plain-language.mjs +96 -0
- package/driver/ladder/attempt-record.mjs +14 -2
- package/driver/ladder/dispatch.mjs +2 -2
- package/driver/ladder/form-repair.mjs +1 -1
- package/driver/ladder/stage.mjs +7 -1
- package/driver/mark-logos.mjs +6 -1
- package/driver/order-receipt.mjs +184 -0
- package/driver/package.json +4 -1
- package/driver/picture-shrink-worker.mjs +21 -0
- package/driver/picture-thumbnail.mjs +132 -0
- package/driver/pipeline-knockout.mjs +14 -0
- package/driver/portal-confirmation.mjs +3 -0
- package/driver/portal-report.mjs +44 -1
- package/driver/portal-routes/run.mjs +19 -9
- package/driver/portal-runs.mjs +118 -63
- package/driver/portal-service.mjs +17 -2
- package/driver/predelivery-lint.mjs +3 -3
- package/driver/progress.mjs +33 -5
- package/driver/publish/column-queries.mjs +86 -0
- package/driver/publish/index.mjs +4 -4
- package/driver/publish/knockout.mjs +35 -8
- package/driver/publish/page-shell.mjs +5 -1
- package/driver/publish/read-document.mjs +3 -0
- package/driver/publish/render-knockout.mjs +61 -16
- package/driver/publish/render.mjs +171 -30
- package/driver/publish/search-depth.mjs +45 -1
- package/driver/publish/strings.mjs +23 -0
- package/driver/publish/templates/report.css +73 -0
- package/driver/research-answers.mjs +17 -6
- package/driver/research-checks.mjs +22 -4
- package/driver/research-records.mjs +81 -0
- package/driver/run-quote.mjs +3 -0
- package/driver/run-speed.mjs +89 -0
- package/driver/runner.mjs +50 -21
- package/driver/saved-register-pages.mjs +23 -22
- package/driver/stage-freshness.mjs +5 -0
- package/driver/stages.mjs +2 -2
- package/driver/steps/open-run.mjs +12 -1
- package/driver/suite-census.json +199 -37
- package/driver/tokens.mjs +3 -0
- package/driver/urgent-count.mjs +54 -0
- package/driver/usage-ledger.mjs +8 -2
- package/driver/web-pictures.mjs +532 -0
- package/mcp-server/CHANGELOG.md +16 -0
- package/mcp-server/lib/document-reads.mjs +28 -0
- package/mcp-server/lib/events.mjs +21 -12
- package/mcp-server/lib/findings.mjs +2 -1
- package/mcp-server/lib/knockout.mjs +3 -2
- package/mcp-server/lib/ops.mjs +103 -6
- package/mcp-server/lib/options.mjs +4 -0
- package/mcp-server/lib/plan.mjs +38 -4
- package/mcp-server/lib/result-shapes.mjs +66 -0
- package/mcp-server/lib/runs.mjs +46 -44
- package/mcp-server/lib/urgent.mjs +29 -0
- package/mcp-server/package.json +1 -1
- package/mcp-server/result-shapes.json +2978 -0
- package/mcp-server/server.mjs +67 -14
- package/package.json +4 -1
- package/portal-ui/dist/assets/{index-qNDhqCw9.js → index-DEkVU2FD.js} +1909 -766
- package/portal-ui/dist/assets/{index-CxAkJXIT.css → index-W6SAoDkS.css} +238 -1
- package/portal-ui/dist/index.html +2 -2
- package/portal-ui/package.json +1 -1
- package/providers/jx/src/turn-envelope.mjs +3 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/providers/signa/src/core.js +54 -12
- package/scripts/README.md +3 -0
- package/scripts/e2e-first-time.mjs +2 -2
- package/scripts/mint-result-shapes.mjs +199 -0
- package/scripts/readme-pictures.mjs +227 -0
- package/scripts/render-check.mjs +4 -1
- package/scripts/report-sections-render-check.mjs +191 -0
- package/scripts/settings-render-check.mjs +68 -11
- package/shared/brand.mjs +8 -0
- package/skills/clearotron-account/SKILL.md +24 -0
- package/skills/clearotron-ops/SKILL.md +23 -9
package/mcp-server/server.mjs
CHANGED
|
@@ -30,7 +30,7 @@ import { existsSync, readdirSync } from "node:fs";
|
|
|
30
30
|
import { join, basename } from "node:path";
|
|
31
31
|
import { fileURLToPath } from "node:url";
|
|
32
32
|
|
|
33
|
-
import { enumerateRuns, resolveRun, runAccountKey, runOrganisation, runProfileFacts, productIdentityFor, unreadableRunsReason } from "./lib/runs.mjs";
|
|
33
|
+
import { enumerateRuns, queuedOrders, resolveRun, runAccountKey, runOrganisation, runProfileFacts, productIdentityFor, unreadableRunsReason } from "./lib/runs.mjs";
|
|
34
34
|
import { ORDERABLE_PRODUCTS } from "../driver/search-policy.mjs";
|
|
35
35
|
import { demoServing } from "./demo-mode.mjs";
|
|
36
36
|
import { DEMO_SWAPS, demoText, demoGuidance } from "./lib/demo-texts.mjs"; // — a demo names no tool it withholds
|
|
@@ -69,7 +69,8 @@ import { buildBrief } from "./lib/brief.mjs";
|
|
|
69
69
|
import { providerUsage } from "./lib/usage.mjs";
|
|
70
70
|
import { coverage, artifactStatus } from "./lib/coverage.mjs";
|
|
71
71
|
import { trace } from "./lib/trace.mjs";
|
|
72
|
-
import { REGISTER_AXES, STAGE_ORDER, parseFront, parseSections, paths, compareCmd, loadProfiles, loadProjects, config } from "./lib/driver.mjs";
|
|
72
|
+
import { REGISTER_AXES, STAGE_ORDER, parseFront, parseSections, paths, compareCmd, loadProfiles, loadProjects, config, reportIdentityFor } from "./lib/driver.mjs";
|
|
73
|
+
import { RUN_STATES } from "../driver/portal-runs.mjs"; // the one list of run states the portal folds and the connector passes through
|
|
73
74
|
import { readCapped, mimeFor } from "./lib/util.mjs";
|
|
74
75
|
import { readEvents, projectTimeline } from "./lib/events.mjs";
|
|
75
76
|
import { tokenize, scoreLine } from "./lib/lexsearch.mjs";
|
|
@@ -79,6 +80,8 @@ import { authorize, visibleTools, USER_ARTIFACTS, ACCOUNT_ARTIFACTS, accountMayR
|
|
|
79
80
|
// this file already loads, so there is nothing here for a lazy import to save.
|
|
80
81
|
import { accountRun, accountTrace, accountTimeline, accountFinding, accountFindingList,
|
|
81
82
|
accountWhatIfPlan, accountWhatIfQueued, accountWhatIfResult, CLIENT_FAILURE_NOTE as clientFailureNote } from "./lib/audit-view.mjs";
|
|
83
|
+
import { outputSchemaFor, structuredResult, structuredRefusal } from "./lib/result-shapes.mjs";
|
|
84
|
+
import { withDocumentReads } from "./lib/document-reads.mjs"; // which report document version a call read // each tool's declared result (mcp-server/result-shapes.json)
|
|
82
85
|
import { scrubMarkdown, scrubBody, scrubFrontMatter, scrubCards } from "./lib/scrub.mjs";
|
|
83
86
|
import { evidenceRecords, searchLog, coverageStatement, registrationGoods, deliveredRegistration } from "./lib/evidence.mjs";
|
|
84
87
|
// The knockout lane's projections. Every audit tool below branches on `isKnockoutRun` because the
|
|
@@ -247,6 +250,30 @@ function runSummary(run) {
|
|
|
247
250
|
};
|
|
248
251
|
}
|
|
249
252
|
|
|
253
|
+
/**
|
|
254
|
+
* An order no worker has claimed, as a run-list row: the run row's fields, with what an order has not got yet set to
|
|
255
|
+
* null. Its step is the portal's own words for the same order (driver/portal-runs.mjs queuedStep). No queue position:
|
|
256
|
+
* this list is filtered to the caller's companies after it is built, and a position counted before that filter
|
|
257
|
+
* would tell one company how much work another has queued.
|
|
258
|
+
*/
|
|
259
|
+
function queuedSummary(o) {
|
|
260
|
+
const none = { sent: false, messageId: null, sentAt: null };
|
|
261
|
+
return {
|
|
262
|
+
...(demoServing() ? { demo: DEMO_LABEL } : {}),
|
|
263
|
+
runId: o.runId, slug: null, codename: null, date: o.queuedAt.slice(0, 10), agent: o.agent,
|
|
264
|
+
client: { key: o.account, name: null },
|
|
265
|
+
project: o.projectKey ? { key: o.projectKey, name: o.projectKey } : null,
|
|
266
|
+
product: o.product ? reportIdentityFor(o.product).identity ?? null : null,
|
|
267
|
+
state: "queued", location: "queue", tier: null, caption: null, url: null,
|
|
268
|
+
markName: o.markName, ref: o.ref, classes: o.classes,
|
|
269
|
+
step: o.step,
|
|
270
|
+
startedAt: null, updatedAt: o.queuedAt, deliveredAt: null,
|
|
271
|
+
failedStage: null, reason: null, resetsAt: null, recoveryResumesAt: null, parkedKind: null, terminalKind: null,
|
|
272
|
+
sendPending: false, sent: false,
|
|
273
|
+
channels: { email: none, whatsapp: none },
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
250
277
|
function channelState(runDir) {
|
|
251
278
|
const legacySent = existsSync(join(runDir, ".sent"));
|
|
252
279
|
let receipts = {};
|
|
@@ -295,7 +322,12 @@ const tools = {
|
|
|
295
322
|
workReadError: readError(config.workspaceRoot),
|
|
296
323
|
});
|
|
297
324
|
if (unreadable) throw new Error(unreadable);
|
|
298
|
-
let out = enumerateRuns({ agent, state, slug, mark }).map(runSummary);
|
|
325
|
+
let out = enumerateRuns({ agent, state, slug, mark, listed: true }).map(runSummary);
|
|
326
|
+
// AN ACCEPTED ORDER IS LISTED BEFORE A WORKER STARTS IT, as the portal lists it. A slug names a started run,
|
|
327
|
+
// so a slug filter leaves orders out; a state filter keeps them only when it asks for `queued`. Merged by time
|
|
328
|
+
// into the newest-first list, where a stable sort keeps every run where it was.
|
|
329
|
+
if (!slug && (state == null || state === "queued"))
|
|
330
|
+
out = [...out, ...queuedOrders({ agent, mark }).map(queuedSummary)].sort((x, y) => String(y.updatedAt ?? "").localeCompare(String(x.updatedAt ?? "")));
|
|
299
331
|
if (sendPending === true || sendPending === false) out = out.filter((r) => r.sendPending === sendPending);
|
|
300
332
|
const cap = limit ?? (sendPending === true ? out.length : 50);
|
|
301
333
|
return out.slice(0, cap);
|
|
@@ -519,7 +551,7 @@ const tools = {
|
|
|
519
551
|
},
|
|
520
552
|
decision_timeline({ runId }) {
|
|
521
553
|
const run = mustRun(runId);
|
|
522
|
-
const { timeline, verdictHistory } = projectTimeline(readEvents(run.runDir), run.P);
|
|
554
|
+
const { timeline, verdictHistory } = projectTimeline(readEvents(run.runDir), run.P, { steps: run.status?.steps });
|
|
523
555
|
// Honest: the risk ladder is only recoverable if the DIGEST itself has a prior snapshot;
|
|
524
556
|
// a generic _history dir for some OTHER stage does not make register-findings diffable.
|
|
525
557
|
const riskLadderAvailable = listArtifactVersions(run.P, run.runDir, "register-digest", null).length > 1;
|
|
@@ -538,7 +570,7 @@ const tools = {
|
|
|
538
570
|
// `since` is a stable seq cursor (number, from a prior call) OR an ISO timestamp (the first/human call).
|
|
539
571
|
const sinceSeq = (typeof since === "number" || (typeof since === "string" && /^\d+$/.test(since.trim()))) ? Number(since) : null;
|
|
540
572
|
const sinceTs = sinceSeq == null ? (since ?? null) : null;
|
|
541
|
-
const { timeline } = projectTimeline(readEvents(run.runDir), run.P, { sinceTs, sinceSeq });
|
|
573
|
+
const { timeline } = projectTimeline(readEvents(run.runDir), run.P, { sinceTs, sinceSeq, steps: run.status?.steps });
|
|
542
574
|
const cursor = timeline.length ? timeline[timeline.length - 1].seq : (sinceSeq ?? null);
|
|
543
575
|
let changes = timeline;
|
|
544
576
|
if (Array.isArray(kinds) && kinds.length) changes = changes.filter((c) => kinds.includes(c.kind));
|
|
@@ -683,7 +715,7 @@ const TOOL_DEFS = [
|
|
|
683
715
|
// recipient is a lawyer who layers advice on top, and a tool description promising advice is how it
|
|
684
716
|
// comes back. The brief names WHICH PRODUCT the run was instead, resolved from the registry.
|
|
685
717
|
{ name: "brief", description: "START HERE for any 'what do you have on X / what did the search find' question — ONE plain-language briefing of a run, in the client-voiced wording (which search product this run was, overall risk in plain words, each conflict in 1–2 plain sentences, any conditions on the result). Facts, never advice. No internal stage names, no risk-formula codes, no model names. Reach for the audit tools (get_run, trace, decision_timeline, get_telemetry) only when the user asks HOW the system reached a conclusion.", inputSchema: { type: "object", properties: { ...runIdProp }, required: ["runId"] } },
|
|
686
|
-
{ name: "list_runs", description: "List the searches this session can see (in progress and finished), newest first. A session may hold more than one client, so the list is NOT one client's: every row names the client it was run for, and the project where there is one. TO FIND ONE CLIENT'S SEARCHES, pass `mark` with the client's name — the same name-shaped filter reads the client and the project as well as the mark. TO FIND A SEARCH BY THE NAME IT CLEARED, pass `mark` — the stored identifier is a longer prefixed slug a client has never seen, so a bare mark name will not match `slug`. If a filtered call comes back empty, list unfiltered and read down the mark names before telling anyone there is nothing there. States: 'postponed' = paused on a provider cap and resuming by itself (resetsAt); 'recovering' = backing off and retrying (recoveryResumesAt); 'parked-for-human' = interrupted mid-search, resumes on the next activation. sendPending:true is the authoritative list of finished searches still owed their delivery notification. Follow up with brief for a plain-language summary of one search.", inputSchema: { type: "object", properties: { agent: { type: "string" }, state: { type: "string", enum: [
|
|
718
|
+
{ name: "list_runs", description: "List the searches this session can see (in progress and finished), newest first. A session may hold more than one client, so the list is NOT one client's: every row names the client it was run for, and the project where there is one. TO FIND ONE CLIENT'S SEARCHES, pass `mark` with the client's name — the same name-shaped filter reads the client and the project as well as the mark. TO FIND A SEARCH BY THE NAME IT CLEARED, pass `mark` — the stored identifier is a longer prefixed slug a client has never seen, so a bare mark name will not match `slug`. If a filtered call comes back empty, list unfiltered and read down the mark names before telling anyone there is nothing there. States: 'postponed' = paused on a provider cap and resuming by itself (resetsAt); 'recovering' = backing off and retrying (recoveryResumesAt); 'parked-for-human' = interrupted mid-search, resumes on the next activation. sendPending:true is the authoritative list of finished searches still owed their delivery notification. Follow up with brief for a plain-language summary of one search.", inputSchema: { type: "object", properties: { agent: { type: "string" }, state: { type: "string", enum: [...RUN_STATES] }, mark: { type: "string", description: "Find a search by NAME: the mark it cleared, the client it was run for, the project it was run under, or the identifier — case-insensitively, on part of the word. This is the parameter a name-shaped question wants, whichever of those names the asker holds." }, slug: { type: "string", description: "EXACT identifier match, for a caller that already holds one. A mark name is not a slug — use `mark`." }, sendPending: { type: "boolean", description: "true = only searches still owed a delivery notification; false = only already-settled ones." }, limit: { type: "number" } } } },
|
|
687
719
|
{ name: "list_profiles", description: "List the customer ACCOUNTS the firm runs clearotron clearances for (key + name + industry + their PROJECTS) — the roster the intake step resolves a job's profileKey (and optional projectKey) against. profileKey selects that customer's marketplaces, default classes/jurisdictions, report format and risk posture; a project (spec 62) is an engagement UNDER a customer that overlays its own marketplaces/classes/sector/posture. Resolve by JUDGMENT (explicit name, misspelling, or implicit reference); OMIT profileKey for a new/unknown customer (uses the neutral generic profile — a customer who does not exist here yet never blocks a search; tell the requester it is running under the neutral profile, and that their own company can be set up in the portal if they want its framework, territories and marketplaces applied instead); set projectKey only when the request names a specific project in that customer's projects[], else OMIT it (runs on the customer profile); never pick a profile from the sender's email domain. Read-only.", inputSchema: { type: "object", properties: {} } },
|
|
688
720
|
{ name: "get_run", description: "ENGINEERING/AUDIT view — full run mechanics: status, every pipeline stage (trigger/outcome), failover facts, artifact validity, and a coverage summary. Use when the user asks how the run executed; for 'what did it find', call brief instead.", inputSchema: { type: "object", properties: { ...runIdProp }, required: ["runId"] } },
|
|
689
721
|
{ name: "read_artifact", description: "Read a run artifact's raw text (or one '# Section', or its front-matter). For briefing a person, the report is the plain-language layer; the rest are internal working documents. Names: report, audit, narrative, registerFindings, commonLaw, placement, matterContext, variantManifest, skepticFlags, seniorEyeReview, caseLaw, clientSummary (internal cover-note source; ops only), a register axis (e.g. primary-sweep), status.json, run.jsonl.", inputSchema: { type: "object", properties: { ...runIdProp, name: { type: "string" }, section: { type: "string", description: "Return only this '# Section'." }, frontMatterOnly: { type: "boolean" } }, required: ["runId", "name"] } },
|
|
@@ -707,9 +739,9 @@ const TOOL_DEFS = [
|
|
|
707
739
|
// ---- Option discovery + the free preview (NO ops token; both accountSafe, both write nothing —
|
|
708
740
|
// a client connector's first two calls) ----
|
|
709
741
|
{ name: "describe_options", description: "START HERE before composing a search — the option space, for free. Returns the four searches this deployment can actually run — each with the geography it accepts, how many names it reads, its turnaround, whether it carries the case-law reading, whether the native-language investigation is optional or automatic, and a plain note when one is unavailable — plus the combination rules the servers enforce (territories, native-language routing, marketplaces, classes, names per search), and — for a client connector — YOUR OWN account: its key (the profileKey plan_run and start_run require), its projects, its saved searches (the recipeKey slugs) and what is left of today's allowance. Omit profileKey to be answered about your own account(s); pass it to ask about a specific one. Reserves nothing, spends nothing, starts nothing. Then: plan_run (free) with the arguments you intend, and start_run with the SAME arguments.", inputSchema: { type: "object", properties: { profileKey: { type: "string", description: "OPTIONAL: the customer ACCOUNT key to describe. Omit it to be answered about the account(s) this session holds — that is how a client connector discovers the key it must pass to plan_run/start_run." } } } },
|
|
710
|
-
{ name: "plan_run", description: "FREE PREVIEW — resolve what a search WOULD do and return it, spending nothing and queueing nothing. Takes the SAME arguments as start_run. Use this BEFORE start_run whenever the requester has not already confirmed the specifics: it reports the PRODUCT that resolves and WHERE it came from (their request, the account default, a saved search, or the territories themselves), the territories and marketplaces that would ACTUALLY be searched, the turnaround, and any blockers as questions to put back. Show the result to the requester; then call start_run with the SAME arguments to actually run it. Nothing here reserves or holds anything.", inputSchema: { type: "object", properties: { markName: { type: "string", description: "The mark (single-mark form). REQUIRED unless marks[] is given." }, marks: { type: "array", items: { type: "object", properties: { name: { type: "string" }, classes: { type: "array", items: { type: "number" } }, ref: { type: "string" } }, required: ["name"] } }, classes: { type: "array", items: { type: "number" } }, goods: { type: "string" }, jurisdictions: { type: "array", items: { type: "string" }, description: JURISDICTIONS_DESC }, platforms: { type: "array", items: { type: "string" } }, customer: { type: "string" }, profileKey: { type: "string", description: "The customer ACCOUNT key (see list_profiles). OMIT it for a new or unknown client and the search runs under the neutral generic profile, which is never a reason to refuse a search — offer that and the portal route (their own company, with its own framework and territories) in the same reply. On a session whose access names accounts, omitting it needs the generic profile to be one of them; when it is not, the refusal says so and names what the session does hold (see describe_options)." }, projectKey: { type: "string" }, forwarder: { type: "string", description: "Requester/reply-routing key — same as start_run, so the preview describes the job that would actually be built. Account sessions may omit it — it is stamped from your verified identity." }, forwarderEmail: { type: "string" }, ref: { type: "string" }, product: { type: "string", enum: ORDERABLE_PRODUCTS, description: PRODUCT_DESC }, nativeLanguage: { type: "boolean", description: "OPTIONAL, and only on a multi-country-focus-search: the native-language investigation. Send TRUE or omit the field — FALSE IS REFUSED, not honoured: the toggle only ever added, so there is nothing for false to switch off, and accepting it would let you believe you had removed a reading that runs anyway. It runs AUTOMATICALLY on a full-country-search and is not part of the other two, so asking for it there is refused rather than accepted and ignored. It routes on territory — the scope must name one it covers." }, worldwide: { type: "boolean", description: "Search EVERYWHERE, and refuse to be narrowed by the account's own default territories. This is not the same as omitting jurisdictions, which means \"whatever the account says\" — the two used to be indistinguishable on this wire, which is how a request that bought everywhere ran an account's seven countries. Never send \"Worldwide\" as a jurisdictions entry." }, recipeKey: { type: "string" }, upfrontInstructions: { type: "string" }, deadline: { type: "string" }, deliveryRoute: { type: "string", enum: ["email", "portal"], description: "OPTIONAL: how the delivered packet leaves — email (default). \"portal\" is reserved for the portal delivery lane and CLARIFIES at admission until it ships (never a silent no-op) — so the preview BLOCKS it here rather than describing a job start_run could not run." }, commercialFlexibility: { type: "string" }, priorUse: { type: "string" }, campaignShape: { type: "string", description: "Campaign-shape FACTS from the request/client — how the mark will be deployed: standalone brand vs flavour/sub-brand under a NAMED house mark; seasonal/limited vs permanent; launch scale. Verbatim facts only — the engine records them on the matter frame instead of inferring a launch shape." }, customerUnknown: { type: "boolean" } }, required: ["forwarder"] } },
|
|
742
|
+
{ name: "plan_run", description: "FREE PREVIEW — resolve what a search WOULD do and return it, spending nothing and queueing nothing. Takes the SAME arguments as start_run. Use this BEFORE start_run whenever the requester has not already confirmed the specifics: it reports the PRODUCT that resolves and WHERE it came from (their request, the account default, a saved search, or the territories themselves), the territories and marketplaces that would ACTUALLY be searched, the turnaround, and any blockers as questions to put back. Show the result to the requester; then call start_run with the SAME arguments to actually run it. Nothing here reserves or holds anything.", inputSchema: { type: "object", properties: { markName: { type: "string", description: "The mark (single-mark form). REQUIRED unless marks[] is given." }, marks: { type: "array", items: { type: "object", properties: { name: { type: "string" }, classes: { type: "array", items: { type: "number" } }, ref: { type: "string" } }, required: ["name"] } }, classes: { type: "array", items: { type: "number" } }, goods: { type: "string" }, jurisdictions: { type: "array", items: { type: "string" }, description: JURISDICTIONS_DESC }, platforms: { type: "array", items: { type: "string" } }, customer: { type: "string" }, profileKey: { type: "string", description: "The customer ACCOUNT key (see list_profiles). OMIT it for a new or unknown client and the search runs under the neutral generic profile, which is never a reason to refuse a search — offer that and the portal route (their own company, with its own framework and territories) in the same reply. On a session whose access names accounts, omitting it needs the generic profile to be one of them; when it is not, the refusal says so and names what the session does hold (see describe_options)." }, projectKey: { type: "string" }, forwarder: { type: "string", description: "Requester/reply-routing key — same as start_run, so the preview describes the job that would actually be built. Account sessions may omit it — it is stamped from your verified identity." }, forwarderEmail: { type: "string" }, ref: { type: "string" }, product: { type: "string", enum: ORDERABLE_PRODUCTS, description: PRODUCT_DESC }, urgent: { type: "boolean" }, nativeLanguage: { type: "boolean", description: "OPTIONAL, and only on a multi-country-focus-search: the native-language investigation. Send TRUE or omit the field — FALSE IS REFUSED, not honoured: the toggle only ever added, so there is nothing for false to switch off, and accepting it would let you believe you had removed a reading that runs anyway. It runs AUTOMATICALLY on a full-country-search and is not part of the other two, so asking for it there is refused rather than accepted and ignored. It routes on territory — the scope must name one it covers." }, worldwide: { type: "boolean", description: "Search EVERYWHERE, and refuse to be narrowed by the account's own default territories. This is not the same as omitting jurisdictions, which means \"whatever the account says\" — the two used to be indistinguishable on this wire, which is how a request that bought everywhere ran an account's seven countries. Never send \"Worldwide\" as a jurisdictions entry." }, recipeKey: { type: "string" }, upfrontInstructions: { type: "string" }, deadline: { type: "string" }, deliveryRoute: { type: "string", enum: ["email", "portal"], description: "OPTIONAL: how the delivered packet leaves — email (default). \"portal\" is reserved for the portal delivery lane and CLARIFIES at admission until it ships (never a silent no-op) — so the preview BLOCKS it here rather than describing a job start_run could not run." }, commercialFlexibility: { type: "string" }, priorUse: { type: "string" }, campaignShape: { type: "string", description: "Campaign-shape FACTS from the request/client — how the mark will be deployed: standalone brand vs flavour/sub-brand under a NAMED house mark; seasonal/limited vs permanent; launch scale. Verbatim facts only — the engine records them on the matter frame instead of inferring a launch shape." }, customerUnknown: { type: "boolean" } }, required: ["forwarder"] } },
|
|
711
743
|
// ---- OPS write-face (requires an ops token; never exposed to a user/internal session) ----
|
|
712
|
-
{ name: "start_run", description: "OPS-ONLY. Enqueue a NEW clearance/search run the driver will pick up. Provide markName (or marks[] for a batch) + forwarder (and ideally classes/goods/customer/profileKey/ref). Returns the queue id + slug; the runId/codename is assigned when the runner claims it — poll list_runs (by markName) or run_changes for progress. Spends real money once it runs.", inputSchema: { type: "object", properties: { agent: { type: "string", description: "Which agent workspace's queue. An assistant passes its own agent id: the run's events name the queue's agent, and a courier takes only its own. Omitted, the job goes to the deployment default (CLEAROTRON_QUEUE_DIR or the default agent's queue — docs/INTAKE.md), which on a box with more than one assistant may be another one's." }, markName: { type: "string", description: "The mark (single-mark form). Required unless marks[] is provided." }, marks: { type: "array", items: { type: "object", properties: { name: { type: "string" }, classes: { type: "array", items: { type: "number" } }, ref: { type: "string" } }, required: ["name"] }, description: "Batch form: EVERY name of the batch in ONE job. Only a knockout-search reads more than one name at a time; a clearance reads one, and more is refused rather than truncated." }, classes: { type: "array", items: { type: "number" }, description: "Nice classes — whole numbers 1–45 (1–34 goods, 35–45 services). classes OR goods; either suffices." }, goods: { type: "string" }, jurisdictions: { type: "array", items: { type: "string" }, description: JURISDICTIONS_DESC }, platforms: { type: "array", items: { type: "string" }, description: "OPTIONAL per-run SCOPE: extra marketplaces to sweep, as bare store domains e.g. [\"gnc.com\"]. ADDED to the account's own marketplaces — additive only, never a replacement (a client's platform list is a mandate). Max 10; \"web\" is implicit and must not be listed." }, customer: { type: "string" }, profileKey: { type: "string", description: "The customer ACCOUNT key (see list_profiles) whose profile rates this run; omit for the neutral generic profile — that is how a clearance for a NEW client runs, and a client with no account yet is never a reason to refuse one. Offer it alongside the portal route (their own company, with its own framework, territories and marketplaces) so the requester chooses. On a session whose access names accounts, omitting it needs the generic profile to be one of them; when it is not, the refusal says so and names what the session does hold (see describe_options)." }, forwarder: { type: "string", description: "Requester/reply-routing key — rides the delivery packet so the integrator knows who gets the report (docs/DELIVERY.md). Account sessions may omit it — it is stamped from your verified identity." }, forwarderEmail: { type: "string" }, ref: { type: "string" }, provider: { type: "string" }, brief: { type: "string" }, upfrontInstructions: { type: "string" }, projectKey: { type: "string", description: "OPTIONAL (spec 62): the PROJECT/engagement key UNDER profileKey (see that customer's projects[] in list_profiles) whose overlay rates this run; omit to run on the customer profile. An unknown key clarifies at intake." }, product: { type: "string", enum: ORDERABLE_PRODUCTS, description: PRODUCT_DESC }, nativeLanguage: { type: "boolean", description: "OPTIONAL, and only on a multi-country-focus-search: the native-language investigation. Send TRUE or omit the field — FALSE IS REFUSED, not honoured: the toggle only ever added, so there is nothing for false to switch off, and accepting it would let you believe you had removed a reading that runs anyway. It runs AUTOMATICALLY on a full-country-search and is not part of the other two, so asking for it there is refused rather than accepted and ignored. It routes on territory — the scope must name one it covers." }, worldwide: { type: "boolean", description: "Search EVERYWHERE, and refuse to be narrowed by the account's own default territories. This is not the same as omitting jurisdictions, which means \"whatever the account says\" — the two used to be indistinguishable on this wire, which is how a request that bought everywhere ran an account's seven countries. Never send \"Worldwide\" as a jurisdictions entry." }, recipeKey: { type: "string", description: "OPTIONAL alternative selector: a saved search (recipe) slug for this customer. Mutually exclusive with product — a saved search already carries one." }, deliveryRoute: { type: "string", enum: ["email", "portal"], description: "OPTIONAL: how the delivered packet leaves — email (default). \"portal\" is reserved for the portal delivery lane and CLARIFIES at admission until it ships (never a silent no-op)." }, parentRunId: { type: "string", description: "OPTIONAL escalation lineage: the runId this run escalates from (e.g. a knockout HIGH mark → this clearotron)." }, deliverableSpec: { type: "string" }, commercialFlexibility: { type: "string" }, priorUse: { type: "string" }, campaignShape: { type: "string", description: "Campaign-shape FACTS from the request/client — how the mark will be deployed: standalone brand vs flavour/sub-brand under a NAMED house mark; seasonal/limited vs permanent; launch scale. Verbatim facts only — the engine records them on the matter frame instead of inferring a launch shape." }, deadline: { type: "string", description: "ISO-8601 — drives the deadline envelope." }, customerUnknown: { type: "boolean" }, dupOverride: { type: "boolean", description: "Requester-confirmed force-run past matter dedup." }, clientPrincipal: { type: "boolean", description: "Set by the client portal only: this run was started by a CLIENT and consumes that account's runCaps.dailyRuns allowance. Omit for staff, agent and email-door runs — absence means uncapped, and setting it can only restrict the run that carries it." }, rawRequest: { type: "string" }, forwarderDomain: { type: "string" }, msgId: { type: "string" }, conversationId: { type: "string" }, id: { type: "string" } }, required: ["forwarder"] } },
|
|
744
|
+
{ name: "start_run", description: "OPS-ONLY. Enqueue a NEW clearance/search run the driver will pick up. Provide markName (or marks[] for a batch) + forwarder (and ideally classes/goods/customer/profileKey/ref). Returns the queue id + slug; the runId/codename is assigned when the runner claims it — poll list_runs (by markName) or run_changes for progress. Spends real money once it runs.", inputSchema: { type: "object", properties: { agent: { type: "string", description: "Which agent workspace's queue. An assistant passes its own agent id: the run's events name the queue's agent, and a courier takes only its own. Omitted, the job goes to the deployment default (CLEAROTRON_QUEUE_DIR or the default agent's queue — docs/INTAKE.md), which on a box with more than one assistant may be another one's." }, markName: { type: "string", description: "The mark (single-mark form). Required unless marks[] is provided." }, marks: { type: "array", items: { type: "object", properties: { name: { type: "string" }, classes: { type: "array", items: { type: "number" } }, ref: { type: "string" } }, required: ["name"] }, description: "Batch form: EVERY name of the batch in ONE job. Only a knockout-search reads more than one name at a time; a clearance reads one, and more is refused rather than truncated." }, classes: { type: "array", items: { type: "number" }, description: "Nice classes — whole numbers 1–45 (1–34 goods, 35–45 services). classes OR goods; either suffices." }, goods: { type: "string" }, jurisdictions: { type: "array", items: { type: "string" }, description: JURISDICTIONS_DESC }, platforms: { type: "array", items: { type: "string" }, description: "OPTIONAL per-run SCOPE: extra marketplaces to sweep, as bare store domains e.g. [\"gnc.com\"]. ADDED to the account's own marketplaces — additive only, never a replacement (a client's platform list is a mandate). Max 10; \"web\" is implicit and must not be listed." }, customer: { type: "string" }, profileKey: { type: "string", description: "The customer ACCOUNT key (see list_profiles) whose profile rates this run; omit for the neutral generic profile — that is how a clearance for a NEW client runs, and a client with no account yet is never a reason to refuse one. Offer it alongside the portal route (their own company, with its own framework, territories and marketplaces) so the requester chooses. On a session whose access names accounts, omitting it needs the generic profile to be one of them; when it is not, the refusal says so and names what the session does hold (see describe_options)." }, forwarder: { type: "string", description: "Requester/reply-routing key — rides the delivery packet so the integrator knows who gets the report (docs/DELIVERY.md). Account sessions may omit it — it is stamped from your verified identity." }, forwarderEmail: { type: "string" }, ref: { type: "string" }, provider: { type: "string" }, brief: { type: "string" }, upfrontInstructions: { type: "string" }, projectKey: { type: "string", description: "OPTIONAL (spec 62): the PROJECT/engagement key UNDER profileKey (see that customer's projects[] in list_profiles) whose overlay rates this run; omit to run on the customer profile. An unknown key clarifies at intake." }, product: { type: "string", enum: ORDERABLE_PRODUCTS, description: PRODUCT_DESC }, urgent: { type: "boolean" }, nativeLanguage: { type: "boolean", description: "OPTIONAL, and only on a multi-country-focus-search: the native-language investigation. Send TRUE or omit the field — FALSE IS REFUSED, not honoured: the toggle only ever added, so there is nothing for false to switch off, and accepting it would let you believe you had removed a reading that runs anyway. It runs AUTOMATICALLY on a full-country-search and is not part of the other two, so asking for it there is refused rather than accepted and ignored. It routes on territory — the scope must name one it covers." }, worldwide: { type: "boolean", description: "Search EVERYWHERE, and refuse to be narrowed by the account's own default territories. This is not the same as omitting jurisdictions, which means \"whatever the account says\" — the two used to be indistinguishable on this wire, which is how a request that bought everywhere ran an account's seven countries. Never send \"Worldwide\" as a jurisdictions entry." }, recipeKey: { type: "string", description: "OPTIONAL alternative selector: a saved search (recipe) slug for this customer. Mutually exclusive with product — a saved search already carries one." }, deliveryRoute: { type: "string", enum: ["email", "portal"], description: "OPTIONAL: how the delivered packet leaves — email (default). \"portal\" is reserved for the portal delivery lane and CLARIFIES at admission until it ships (never a silent no-op)." }, parentRunId: { type: "string", description: "OPTIONAL escalation lineage: the runId this run escalates from (e.g. a knockout HIGH mark → this clearotron)." }, deliverableSpec: { type: "string" }, commercialFlexibility: { type: "string" }, priorUse: { type: "string" }, campaignShape: { type: "string", description: "Campaign-shape FACTS from the request/client — how the mark will be deployed: standalone brand vs flavour/sub-brand under a NAMED house mark; seasonal/limited vs permanent; launch scale. Verbatim facts only — the engine records them on the matter frame instead of inferring a launch shape." }, deadline: { type: "string", description: "ISO-8601 — drives the deadline envelope." }, customerUnknown: { type: "boolean" }, dupOverride: { type: "boolean", description: "Requester-confirmed force-run past matter dedup." }, clientPrincipal: { type: "boolean", description: "Set by the client portal only: this run was started by a CLIENT and consumes that account's runCaps.dailyRuns allowance. Omit for staff, agent and email-door runs — absence means uncapped, and setting it can only restrict the run that carries it." }, rawRequest: { type: "string" }, forwarderDomain: { type: "string" }, msgId: { type: "string" }, conversationId: { type: "string" }, id: { type: "string" } }, required: ["forwarder"] } },
|
|
713
745
|
{ name: "stop_run", description: "OPS-ONLY. Cancel a run. Pass id to remove a not-yet-claimed queued job (a real cancel, no spend). Pass runId to file a cancel request on a started run. By default the cancel is COOPERATIVE — the sentinel is written and a turn already in flight is allowed to finish, which has no deadline: a reasoning turn can run for tens of minutes. Add immediate:true to also end that turn: it is sent a stop, anything of it still running a few seconds later is killed, and the answer says the turn ended only once it has seen it end. If it could not be ended, the run ends at its next step boundary, and the answer says that instead.", inputSchema: { type: "object", properties: { agent: { type: "string" }, id: { type: "string", description: "A queued job id (from start_run) — dequeues before the runner claims it." }, runId: { type: "string", description: "A started run's runId — files a cancel sentinel." }, immediate: { type: "boolean", description: "Stop NOW instead of at the next step boundary. The cancel sentinel is written FIRST and then the run's own recorded engine turn is stopped, in that order — the sentinel is what makes the record clean, so the terminal names the stage, the actor and the request time instead of leaving a run that reads as still running. The turn is sent SIGTERM (to its whole process group when it leads one, as both engines spawn it, so the tools it started are reached too), watched, and sent SIGKILL if anything of it is still running when the grace runs out; the answer waits for that, which takes seconds. A turn that is stopped loses its step's work; everything already recorded is kept. Sending the stop is not the same as the turn ending, and the answer claims the second only when it has seen it (immediate.ended). Falls back to the boundary stop, and SAYS SO in the answer, when there is no live turn to signal — a run between steps, or one whose turn has already exited — or when the turn was still there after the SIGKILL. The answer states which of the two actually happened."}, onBehalfOf: { type: "string", description: "The identifier of a human this caller has itself verified. RECORDED BESIDE the token's own principal, never instead of it — a stop by the portal for alice@x is written `portal:alice@x`, so an asserted name is never mistaken for a proved one. Bare identifiers only; anything else is dropped." } } } },
|
|
714
746
|
{ name: "server_info", description: "The AGPL §13 source offer: this server's name, version, licence, source repository and the COMMIT IT IS RUNNING. Callable by every session kind — the offer is owed to whoever interacts with the service. Reads no run and no account data.", inputSchema: { type: "object", properties: {} } },
|
|
715
747
|
{ name: "list_outbox_events", description: "Integrator discovery read (docs/DELIVERY.md): every pending outbox event — delivered markers plus the self-contained run-failed / intake-rejected / duplicate-skipped / late-bind-ack packets. Route each, then settle delivered and run-failed events with mark_sent, and every other kind with ack_event.", inputSchema: { type: "object", properties: {} } },
|
|
@@ -906,10 +938,25 @@ export function withAnnotations(def) {
|
|
|
906
938
|
return { ...def, annotations: { readOnlyHint: readOnlyFor(def.name) } };
|
|
907
939
|
}
|
|
908
940
|
|
|
941
|
+
/** The tool's declared result for this session's audience (lib/result-shapes.mjs); a tool that declares none is listed as before. */
|
|
942
|
+
export function withOutputSchema(def, kind) {
|
|
943
|
+
const outputSchema = outputSchemaFor(def.name, { client: CLIENT_KINDS.has(kind) });
|
|
944
|
+
return outputSchema ? { ...def, outputSchema } : def;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* A refused call: the same text as ever, and for a write verb the refusal's own sentence in a named field as well, so a
|
|
949
|
+
* caller can tell a refusal from a verb that ran without parsing the sentence.
|
|
950
|
+
*/
|
|
951
|
+
function refusal(name, text, reason) {
|
|
952
|
+
const structured = structuredRefusal(name, reason);
|
|
953
|
+
return { isError: true, content: [{ type: "text", text }], ...(structured ? { structuredContent: structured } : {}) };
|
|
954
|
+
}
|
|
955
|
+
|
|
909
956
|
export function attachHandlers(server, { scope = { kind: "ops", runId: null }, local = true } = {}) {
|
|
910
957
|
const demo = demoServing();
|
|
911
958
|
const allow = visibleTools({ kind: scope.kind, local, demo });
|
|
912
|
-
const toolDefs = TOOL_DEFS.filter((d) => allow(d.name)).map((d) => withAnnotations(demo ? inDemo(describeForAudience(d, scope.kind), scope.kind) : describeForAudience(d, scope.kind)));
|
|
959
|
+
const toolDefs = TOOL_DEFS.filter((d) => allow(d.name)).map((d) => withOutputSchema(withAnnotations(demo ? inDemo(describeForAudience(d, scope.kind), scope.kind) : describeForAudience(d, scope.kind)), scope.kind));
|
|
913
960
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: toolDefs }));
|
|
914
961
|
|
|
915
962
|
// Prompts are guidance, like the pack: offered to the two client audiences, empty for everyone else.
|
|
@@ -931,7 +978,7 @@ export function attachHandlers(server, { scope = { kind: "ops", runId: null }, l
|
|
|
931
978
|
// (run-pinned) args to dispatch. The single chokepoint every tool call flows through.
|
|
932
979
|
let authedArgs;
|
|
933
980
|
try { authedArgs = authorize(scope, name, args); }
|
|
934
|
-
catch (e) { log(`authz deny ${name} [${scope.kind}]: ${e.message}`); return
|
|
981
|
+
catch (e) { log(`authz deny ${name} [${scope.kind}]: ${e.message}`); return refusal(name, `FORBIDDEN (${name}): ${e.message}`, e.message); }
|
|
935
982
|
// THE LISTING IS THE WALL. A tool this session's audience is not shown is one it cannot call: this
|
|
936
983
|
// used to filter only the listing, and a hidden tool called by name ran anyway once authorize()
|
|
937
984
|
// passed it. That is how an ops token reached what_if_run over HTTP, where the listing hides it and
|
|
@@ -951,20 +998,24 @@ export function attachHandlers(server, { scope = { kind: "ops", runId: null }, l
|
|
|
951
998
|
if (run) assertAccountAccess(scope, runAccountKey(run), `run "${authedArgs.runId}"`, runOrganisation(run));
|
|
952
999
|
} catch (e) {
|
|
953
1000
|
log(`account deny ${name} [${scope.sub ?? scope.kind}]: ${e.message}`);
|
|
954
|
-
return
|
|
1001
|
+
return refusal(name, `FORBIDDEN (${name}): ${e.message}`, e.message);
|
|
955
1002
|
}
|
|
956
1003
|
}
|
|
957
1004
|
try {
|
|
958
|
-
|
|
1005
|
+
// Run inside the call's own record of which report document it read (lib/document-reads.mjs).
|
|
1006
|
+
const { value, documents } = await withDocumentReads(() => fn(authedArgs, { scope }));
|
|
1007
|
+
let result = value;
|
|
959
1008
|
// ACCOUNT FILTER: enumeration results narrow to the grant. Events with no resolvable run
|
|
960
1009
|
// (intake rejections before a run exists) stay visible only to full-grant sessions.
|
|
961
1010
|
if (Array.isArray(scope?.accounts)) result = filterByAccounts(scope, name, result);
|
|
962
1011
|
// CLIENT VIEW: a client principal gets the client cut of artifact text ( R1).
|
|
963
1012
|
result = presentForPrincipal(scope, name, result);
|
|
964
|
-
|
|
1013
|
+
// THE TEXT IS TODAY'S, BYTE FOR BYTE; the structured result rides beside it for a tool that declares one.
|
|
1014
|
+
const structured = structuredResult(name, result, { documents });
|
|
1015
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], ...(structured ? { structuredContent: structured } : {}) };
|
|
965
1016
|
} catch (e) {
|
|
966
1017
|
log(`tool ${name} error: ${e.message}`);
|
|
967
|
-
return
|
|
1018
|
+
return refusal(name, `ERROR (${name}): ${e.message}`, e.message);
|
|
968
1019
|
}
|
|
969
1020
|
});
|
|
970
1021
|
|
|
@@ -1149,6 +1200,8 @@ export function filterByAccounts(scope, name, result) {
|
|
|
1149
1200
|
return { ...result, clients: result.clients.filter((c) => scope.accounts.includes(c.key)) };
|
|
1150
1201
|
if ((name === "list_runs" || name === "search_runs") && Array.isArray(result)) {
|
|
1151
1202
|
const map = accountOf();
|
|
1203
|
+
// An order is not a run yet, so its owner comes from the order itself, read by the same walk.
|
|
1204
|
+
if (name === "list_runs") for (const o of queuedOrders()) if (!map.has(o.runId)) map.set(o.runId, { account: o.account, organisation: o.organisation });
|
|
1152
1205
|
return result.filter((r) => seen(map, r.runId ?? r.id ?? null));
|
|
1153
1206
|
}
|
|
1154
1207
|
// search_runs answers an OBJECT ({query, mode, scope, runsScanned, hits, truncated}) — the array
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "clearotron",
|
|
3
3
|
"mcpName": "io.github.CordilleraSarl/clearotron",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.8.0-beta.0",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -78,6 +78,9 @@
|
|
|
78
78
|
"buffers": "file:vendor/buffers",
|
|
79
79
|
"exceljs": "^4.4.0",
|
|
80
80
|
"jose": "^6.2.3",
|
|
81
|
+
"jpeg-js": "^0.4.4",
|
|
82
|
+
"omggif": "^1.0.10",
|
|
83
|
+
"pngjs": "^7.0.0",
|
|
81
84
|
"undici": "^7.29.1"
|
|
82
85
|
},
|
|
83
86
|
"bin": {
|