@xano/developer-mcp 2.3.0-beta.0 → 2.3.0-beta.2
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/README.md +16 -5
- package/dist/cli_docs/index.js +4 -0
- package/dist/cli_docs/topics/function.js +2 -0
- package/dist/cli_docs/topics/knowledge.js +2 -1
- package/dist/cli_docs/topics/policy.d.ts +2 -0
- package/dist/cli_docs/topics/policy.js +91 -0
- package/dist/cli_docs/topics/skills.d.ts +2 -0
- package/dist/cli_docs/topics/skills.js +57 -0
- package/dist/cli_docs/topics/workspace.js +11 -4
- package/dist/meta_api_docs/index.js +2 -0
- package/dist/meta_api_docs/topics/policy.d.ts +3 -0
- package/dist/meta_api_docs/topics/policy.js +135 -0
- package/dist/tools/validate_xanoscript.js +14 -2
- package/dist/xanoscript.d.ts +5 -0
- package/dist/xanoscript.js +4 -0
- package/dist/xanoscript_docs/README.md +1 -0
- package/dist/xanoscript_docs/database.md +30 -0
- package/dist/xanoscript_docs/docs_index.json +8 -0
- package/dist/xanoscript_docs/policies.md +308 -0
- package/dist/xanoscript_docs/survival.md +5 -1
- package/dist/xanoscript_docs/working.md +5 -0
- package/package.json +3 -2
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const workspace = {
|
|
2
|
+
name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID",
|
|
3
|
+
};
|
|
4
|
+
const branch = {
|
|
5
|
+
name: "branch", type: "string", in: "query", default: "", description: "Branch label; empty selects the live branch. Use the same label for every operation in a workflow.",
|
|
6
|
+
};
|
|
7
|
+
const policyId = {
|
|
8
|
+
name: "policy_id", type: "integer", required: true, in: "path", description: "Stored policy ID on the selected branch",
|
|
9
|
+
};
|
|
10
|
+
const prefix = "/workspace/{workspace_id}/policy";
|
|
11
|
+
const runId = { name: "run_id", type: "integer", required: true, in: "path", description: "Run ID" };
|
|
12
|
+
// Canonical source exactly as POST /policy/parse returns it: quoted key, the platform's
|
|
13
|
+
// field order (title, statement, severity, active, enforcement), a blank line before the
|
|
14
|
+
// first rule, and a one-key params map inline with no padding inside the braces.
|
|
15
|
+
export const policyExample = `policy "AUTH-EXAMPLE" {
|
|
16
|
+
title = "Require authentication"
|
|
17
|
+
statement = "Endpoints require authentication unless the endpoint or its API group is tagged public."
|
|
18
|
+
severity = "high"
|
|
19
|
+
active = true
|
|
20
|
+
enforcement = "advisory"
|
|
21
|
+
|
|
22
|
+
rule {
|
|
23
|
+
check = "object.auth_required"
|
|
24
|
+
params = {except_tags: ["public", "xano:quick-start"]}
|
|
25
|
+
}
|
|
26
|
+
}`;
|
|
27
|
+
const aiModified = {
|
|
28
|
+
name: "ai_modified", type: "boolean", in: "query", default: false, description: "true marks a change an AI agent made (the authenticated MCP sends it): the audit entry gains the agent label and stays attributed to the authenticated user",
|
|
29
|
+
};
|
|
30
|
+
export const policyDoc = {
|
|
31
|
+
topic: "policy",
|
|
32
|
+
title: "Workspace Policies",
|
|
33
|
+
description: `Policies are branch-scoped workspace XanoScript objects combining a human description and deterministic check rules. These endpoints require a platform build with policy support. Discover supported checks and their exact parameter schemas from the instance; do not invent checks or parameters. The policy language - syntax, fields, rules, refusal messages and versioning - is documented once, in xano_xanoscript_docs({topic: "policies"}) (mode: "quick_reference" for the short form; the full topic carries every check's description); this topic covers the routes.
|
|
34
|
+
|
|
35
|
+
Every route needs the workspace:policy permission: read for the reads, parse, the object lookup and evaluate; create, update or delete for the writes. An OAuth token is also capped by its workspace:read or workspace:write ceiling. A refusal is a 403 whose payload.code names the gate: policy_feature_disabled, policy_permission_required or policy_scope_required (both with permission and level). The OAuth ceiling answers insufficient_scope without a code, and a write from a read-only session (a read-only Studio session or a read-only impersonation) is refused without a code too: This is a read-only session. Enable editing to modify this resource. The policies topic's Permissions section says what each one needs.
|
|
36
|
+
|
|
37
|
+
The native platform parses and formats policy source. Send source alone inside data, or structured fields without source; never both. Canonical source is server-owned. A write answers the policy as GET serves it, plus unchanged: an unchanged save writes nothing and answers unchanged: true. PUT and DELETE take an optional last_updated_at, the updated_at you last read: a write or delete over a newer change is refused with HTTP 400 and payload.code policy_stale, and nothing changes. A source error is a 400 whose payload.line and payload.col count from 1, like the message. A rule naming a check id the instance does not have is refused on parse, save and push with HTTP 400 and payload {code: "policy_unknown_check", check} (the id as written); the message names the nearest ids and the catalogue route, and a client keys its own pointer to the catalogue on the code.
|
|
38
|
+
|
|
39
|
+
Every policy the list, a GET and a write serve carries latest_run {run_id, included, version, enforcement, stale}: its place in the branch's newest run. stale: true means the policy changed after that run, so its findings no longer describe it; included: false means that run did not evaluate it. The platform decides this once; do not compare versions or timestamps yourself.
|
|
40
|
+
|
|
41
|
+
A rule with zero objects checked and no findings has status no_objects and message no objects checked. Older stored runs keep pass with checked: 0; readers accept both. The run and policy_check stay pass when nothing failed, and policy_check.message names the unchecked rules. Merge, publish and deploy gates read findings and are unaffected.
|
|
42
|
+
|
|
43
|
+
A policy_check block reports an evaluation. status is one of: pass ("No policy findings."), fail ("Policies reported findings."), error ("A policy check could not run; its result is marked error."), not_applicable ("No active policies on this branch; nothing was evaluated."), disabled ("Policies are not enabled on this instance; nothing was evaluated."), forbidden ("This credential cannot read this workspace's policies (workspace:policy read); nothing was evaluated.") or unavailable ("Policy evaluation is unavailable; the import itself completed."), and message carries that sentence. blocking is true when an active mandatory policy has findings, and status is then fail even if a check errored. not_applicable, disabled and forbidden load, store and audit nothing. Evaluate answers pass, fail, error or not_applicable; the feature gate and the permission refuse it with a 403 instead. A not_applicable evaluate is no run: id 0, stored: false, the run's own status not_applicable too, and empty policies, results and findings. The workspace multidoc import answers all seven. Its findings and blocking_findings list the first 100 each, in the platform's order, beside counts {findings, blocking, errors}, total (every finding) and truncated (whether either list was cut); the stored run (run_id) has them all, and its results are whole; a draft import answers no policy_check. A tier1 tenant, ephemeral or sandbox push and its dry run, and a release built from a multidoc (release push), carry policy files while the feature is on; a tenant or sandbox push carries them without evaluating them and answers no policy_check, and a release built from a multidoc carries its files only for a caller holding workspace:policy create and update (for anyone else it carries the workspace's live-branch policies instead, and names the files in policies_skipped when they differ from the live ones). A remote tenant push, a push to a tenant without a policy table (one created before policies, until its next platform update), or any push while the feature is off leaves them out and names them once in policies_skipped {message, keys}, whose message says why ("N policy files were left out (KEY, KEY): <reason>."). With the policies feature off a workspace push and its dry run leave them out too (policy_check disabled), exports omit policies, and an archive import leaves its policies out and keeps the workspace's own, except that a replace deletes the policies of the branches it removes.
|
|
44
|
+
|
|
45
|
+
Gates: a merge, a set-live, an archive import with mode=merge, and a save or a non-draft push to the workspace's live branch are refused with HTTP 403 and payload.code policy_gate when they introduce a blocking finding or leave one on an object they change; existing findings elsewhere never block. The payload is {gate, status, total, introduced, changed, existing, run_id, can_override, findings (first 100, policy readers only), truncated}. A tenant release deploy is refused the same way when the release's own policy check has any blocking finding, existing debt included: it judges the release alone, never against the tenant's current release, so a release gets the same verdict on every tenant (ephemeral and sandbox tenants get it with gated false and are never refused). Its payload is {gate, status, total, run_id, can_override, gated, release {id, name, run_id, status, counts, carried}, message, findings, truncated}. A caller with workspace:policy update may proceed by resending with override_reason (the create and save routes of the gated objects, the multidoc, upload, import and branch live routes, a release deploy with set_live and import-schema with setlive; override_policy with the reason on tenant deploys), which is audited. A release deploy with set_live and an import-schema with setlive land the new branch first and then run the set-live gate, so a refusal keeps that branch and names it in payload.branch {id, label}. Gates are decided by the policies the branch will have after the change (a merge's carried policies, a push's policy files, the set-live candidate's own policies), so a merge, a push to the live branch or a set-live that weakens a policy active and mandatory on the branch (demotes, deactivates or deletes it, or loosens a rule) needs workspace:policy update: otherwise it is refused before anything is written with 403 policy_weakening_permission_required and {gate, permission, level, policies}, which override_reason does not lift, and the push dry run is refused the same way. A set-live of a branch that landed no policy (an import-schema with setlive always leaves the archive's policies out; a release may carry none) is judged by the live branch's policies, with no weakening check. A set-live check that cannot read the policies fails closed (only update proceeds; the refusal carries unavailable: true). Deleting an active mandatory policy needs workspace:policy update as well as delete (the same 403, gate delete), and so does an archive import with mode=replace or delete=true that would remove one from the branch it writes (gate archive_import). The publish gate covers the draftable kinds (function, query, task, middleware, addon, tool, workflow test, trigger and realtime message), agents, MCP servers and realtime channels: tables, API groups, environment variables, workspace and branch settings, realtime servers, and MCP prompts and resources are saved without it, even on the live branch, and the next run reports what they break while a set-live or tenant deploy that carries it is gated. Adding a prompt or resource to an MCP server, or removing one, changes the server, so that save is gated. A push to the live branch needs its transaction (400 policy_gate_transaction_required). Pushes to other branches are not gated: they answer policy_check after the import. A create past the plan's per-branch policy cap (lower plans cap the policies on each branch; Pro and above are unlimited) is refused with 403 policy_plan_limit; a create whose rules exactly match a live policy on the branch with 400 policy_duplicate (with existing_key, existing_id and policies); a draft import carrying a changed policy with 400 policy_draft_import (Policies are saved directly, not drafted.).
|
|
46
|
+
|
|
47
|
+
Releases carry their branch's policies and store a policy check when cut. An uploaded release archive (release/import) that says it carries policies needs workspace:policy create and update, or is refused with 403 policy_permission_required and nothing is stored. Routes: GET /workspace/{workspace_id}/release/{release_id}/policy_run (POST re-checks it), .../policy_run/findings, and GET /workspace/{workspace_id}/release/policy_check?release_id[]= for several (at most 200 ids). GET /workspace/{workspace_id}/tenant/{tenant_name}/policy_gate?release_name= previews a tenant deploy's gate, and GET /workspace/{workspace_id}/tenant/{tenant_name}/policy lists a tenant's policies; both need tenant_center read besides workspace:policy read.
|
|
48
|
+
|
|
49
|
+
Policies expose active as a boolean (default true). Source always writes active = true or active = false before enforcement. Authored lifecycle is refused: policy: "lifecycle" was replaced by "active"; write active = true or active = false. Source refusals include line and column. An inactive policy may have no rules. Policies are saved directly, not drafted.
|
|
50
|
+
|
|
51
|
+
An evaluation stores a run and its findings; it does not modify the policy. Findings arrive in one order: blocking first, then by severity, policy key, rule position (R2 before R10) and object. A run can hold tens of thousands of findings (85,855 findings is a 44 MB run), so read a large one in parts: GET run/{run_id}/summary serves it without its findings, with its counts, each policy's verdict and the facets, and GET run/{run_id}/findings serves its findings a page at a time, filtered on the instance. Evaluate with answer: "summary" answers the same way, with the first 50 findings. Checks are static: they inspect stored definitions and nothing runs at request time. A check passing is not proof of runtime behavior or compliance.`,
|
|
52
|
+
ai_hints: `Use the authenticated Xano MCP policy tools when available. Their workspace and instance come from the authenticated request, not tool arguments. The standalone developer MCP offers documentation and local language-server validation; it does not carry a workspace credential. Validate policy source with the native policy/parse endpoint before saving; the developer MCP's local validation is a preview against its bundled catalogue. Key refusals on payload.code, never on the message wording. Read latest_run.stale to know whether a run still describes a policy. Evaluate with answer: "summary" and page a run's findings with GET run/{run_id}/findings rather than reading a large run whole. Re-sending an identical definition is safe: the platform answers unchanged: true and writes nothing, so do not add a cosmetic edit to force a new version.`,
|
|
53
|
+
related_topics: ["workspace", "branch", "authentication"],
|
|
54
|
+
endpoints: [
|
|
55
|
+
{ method: "GET", path: prefix + "/check", description: "The check catalogue: items (each check's id, label, description, keywords, supported object kinds and full parameter schema) and goals (the outcomes a new policy can start from, each with the title, statement, key, severity and rules it seeds, the needs the author fills and a limits note on what its rules cannot see; see the policies topic).", parameters: [workspace] },
|
|
56
|
+
{ method: "GET", path: prefix, description: "List policies on a branch, 1000 a page (nextPage says whether there are more). Each item is served as GET serves one policy, with latest_run.", parameters: [workspace, branch, { name: "page", type: "integer", in: "query", default: 1, description: "Page number" }] },
|
|
57
|
+
{ method: "GET", path: prefix + "/{policy_id}", description: "Read one policy on the selected branch, with latest_run. source is canonical, so it can be sent back to PUT unchanged (a no-op) or edited. A policy that is not live on the branch answers 404 Policy not found on this branch of the workspace., as PUT and DELETE do.", parameters: [workspace, policyId, branch] },
|
|
58
|
+
{
|
|
59
|
+
method: "GET", path: prefix + "/object", description: "The active policies whose rules reach one object, why each rule applies, and that object's findings in the branch's newest run. An unknown type is a 400 naming the known types; an object the branch does not have is a 404.",
|
|
60
|
+
parameters: [workspace, branch, { name: "type", type: "string", required: true, in: "query", description: "Object kind as findings name it: query, function, table, task, trigger, message and the other kinds the catalogue lists" }, { name: "id", type: "integer", required: true, in: "query", description: "Object ID on the selected branch" }],
|
|
61
|
+
response: { type: "object", description: "{object, policies: [{id, key, title, statement, severity, active, enforcement, tag, rules: [{id, title, check, label, reason, warnings}], latest_run}], run: {id, started_at, status, policies: [{key, blocking}]} | null, findings}. policies come from the policies as they are now; findings come from the newest stored run, and run.policies names each policy whose findings are listed, with blocking from the run's snapshot." },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
method: "POST", path: prefix + "/parse", description: "Parse and format one policy with the native platform parser, without saving it. Send exactly one of source or data.", parameters: [workspace],
|
|
65
|
+
request_body: { type: "object", properties: { source: { type: "string", description: "One complete policy XanoScript document" }, data: { type: "object", description: "Structured policy fields instead of source" }, branch: { type: "string", description: "Optional branch label to check rule warnings against" } }, example: { source: policyExample } },
|
|
66
|
+
response: { type: "object", description: "Parsed policy definition, canonical source and rule warnings: {policy, source, rule_warnings: [{rule, rule_id, warnings}]} (only rules with warnings). A source error is a 400 whose payload.line and payload.col count from 1." },
|
|
67
|
+
},
|
|
68
|
+
...["POST", "PUT"].map(method => ({
|
|
69
|
+
method, path: prefix + (method === "PUT" ? "/{policy_id}" : ""),
|
|
70
|
+
description: method === "POST"
|
|
71
|
+
? "Create a policy on the selected branch. A key the branch already has is refused, naming the policy id that holds it. A policy whose rules exactly match a live policy on the branch (the same checks and normalized params, as a set; key, title, severity, enforcement, active and tags ignored) is refused with 400 payload.code policy_duplicate: A policy with exactly these rules already exists: KEY. Change a parameter or scope to add another., with existing_key, existing_id and policies."
|
|
72
|
+
: "Update the selected branch's existing policy. A definition identical to the stored one is a no-op and answers unchanged: true with the same version.",
|
|
73
|
+
parameters: method === "POST" ? [workspace] : [workspace, policyId],
|
|
74
|
+
request_body: { type: "object", properties: {
|
|
75
|
+
branch: { type: "string", description: "Branch label; empty selects live" },
|
|
76
|
+
data: { type: "object", required: true, description: "{source: canonical XanoScript}; omit all structured fields when supplying source" },
|
|
77
|
+
message: { type: "string", description: "Optional short label for the Version History entry this save creates; ignored when the save changes nothing" },
|
|
78
|
+
description: { type: "string", description: "Optional longer note stored beside message on that same entry" },
|
|
79
|
+
ai_modified: { type: "boolean", description: "Optional, default false. " + aiModified.description },
|
|
80
|
+
...(method === "PUT" ? { last_updated_at: { type: "string", description: "Optional: the updated_at you last read. A write over a newer change is refused with HTTP 400, payload.code policy_stale; omit, null or empty means no check" } } : {}),
|
|
81
|
+
}, example: { branch: "dev", data: { source: policyExample }, message: "Tightened the scope" } },
|
|
82
|
+
response: { type: "object", description: "The policy as GET serves it, with latest_run, plus unchanged" },
|
|
83
|
+
})),
|
|
84
|
+
{ method: "DELETE", path: prefix + "/{policy_id}", description: "Soft-delete a policy on the selected branch; its Version History is kept. Answers {}. With last_updated_at, a policy changed since that read is refused with HTTP 400, payload.code policy_stale, and nothing is deleted.", parameters: [workspace, policyId, branch, aiModified, { name: "last_updated_at", type: "string", in: "query", description: "Optional: the updated_at you last read. Omit, null or empty means no check" }] },
|
|
85
|
+
{
|
|
86
|
+
method: "POST", path: prefix + "/evaluate", description: "Evaluate the active policies on the selected branch and store the run. Every run it stores is a manual run.", parameters: [workspace],
|
|
87
|
+
request_body: { type: "object", properties: {
|
|
88
|
+
branch: { type: "string", description: "Branch label; empty selects live" },
|
|
89
|
+
ai_modified: { type: "boolean", description: "Optional, default false. true records the run as made by an AI agent acting for the authenticated user" },
|
|
90
|
+
policy: { type: "string", description: "Optional policy key (case-insensitive): a single-policy trial of that policy alone, even if inactive. Never stored or audited (stored: false, id 0), never the latest run, gates nothing; answers clear [{policy_key, rule_id, total, items}], each rule's first 100 objects examined without a finding. An unknown key is 404, a blank one is refused." },
|
|
91
|
+
answer: { type: "string", description: "Optional: run (the default) or summary. summary answers the run as GET run/{run_id}/summary serves it instead, plus findings (its first 50, in the platform's order), total, truncated and stored, and a policy_check whose blocking_finding_ids name the blocking findings listed and whose blocking_total counts them all; the rest are on GET run/{run_id}/findings" },
|
|
92
|
+
}, example: { branch: "dev", answer: "summary" } },
|
|
93
|
+
response: { type: "object", description: "The run exactly as GET run/{run_id} serves it, plus stored and policy_check {status, message, blocking, run_id, blocking_finding_ids}; with answer: \"summary\", the run summary and its first 50 findings instead (see answer). stored: false with id 0 means no run was kept: nothing was active, or the caller is a read-only session or an OAuth token without workspace:write. With nothing active the answer is status not_applicable in policy_check and in the run itself, with no policies, results or findings; nothing is read, stored or audited." },
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
method: "GET", path: prefix + "/run", description: "List the retained runs newest first, as summaries: the findings, per-rule results and policy snapshots are on the single run. Only a branch's newest twenty runs are retained.",
|
|
97
|
+
parameters: [workspace, branch, { name: "limit", type: "integer", in: "query", default: 20, description: "How many runs to return, 1-20" }],
|
|
98
|
+
response: { type: "object", description: "{items, curPage, nextPage, prevPage}; each item is {id, created_at, trigger, actor, started_at, finished_at, status, objects_checked, counts: {findings, blocking, errors}, policies: [{id, key, version, enforcement, status, findings, blocking, objects_checked}], branch}: each policy with its verdict in that run" },
|
|
99
|
+
},
|
|
100
|
+
{ method: "GET", path: prefix + "/run/{run_id}", description: "Read one retained run in full: findings, per-rule results and the policies[] snapshot of what it checked (each policy's statement and, per rule, its label and resolved params). A run is served whole, all its findings included, so read a large one through its summary and findings pages below. An evicted run or another branch's answers 404 Policy run not found on this branch of the workspace, as its summary and findings do. Only a branch's newest runs are retained.", parameters: [workspace, branch, runId] },
|
|
101
|
+
{
|
|
102
|
+
method: "GET", path: prefix + "/run/{run_id}/summary", description: "Read one retained run without its findings: what it adds up to, stored with the run when it was kept (a run kept before summaries is summarised on read).",
|
|
103
|
+
parameters: [workspace, branch, runId, { name: "object_limit", type: "integer", in: "query", default: 100, description: "The most objects the object facet names, 1-1000; facets.object.total counts them all" }],
|
|
104
|
+
response: { type: "object", description: "{id, created_at, updated_at, trigger, actor, started_at, finished_at, status, objects_checked, branch, counts: {findings, blocking, advisory, errors}, policy_check, policies, results, zero_object_rules, facets}. policies is the snapshot, each policy with its verdict {status, findings, blocking, objects_checked}; each result carries its finding count (findings); zero_object_rules lists {policy_key, rule_id} for the rules with no_objects (or older pass with checked: 0); facets {policy, severity, kind, object: {items, total}, tag, object_tags_from} count the findings by each, split into blocking and advisory. policy_check is the verdict a Run checks run kept, with blocking_total in place of blocking_finding_ids, and null for other runs." },
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
method: "GET", path: prefix + "/run/{run_id}/findings", description: "Read one page of a retained run's findings, in the platform's order, filtered and searched on the instance. A list filter matches a finding when any of its values does, and a page holds the findings that match every filter given. Send a list with indexed keys: policy[0]=A&policy[1]=B.",
|
|
108
|
+
parameters: [
|
|
109
|
+
workspace, branch, runId,
|
|
110
|
+
{ name: "offset", type: "integer", in: "query", default: 0, description: "How many matching findings to skip" },
|
|
111
|
+
{ name: "limit", type: "integer", in: "query", default: 100, description: "How many findings to return, 1-500" },
|
|
112
|
+
{ name: "blocking", type: "boolean", in: "query", description: "Optional: true keeps the blocking findings, false the advisory ones" },
|
|
113
|
+
{ name: "policy", type: "string[]", in: "query", description: "Policy keys" },
|
|
114
|
+
{ name: "rule", type: "string[]", in: "query", description: "Rule ids, such as AUTH-001.R1" },
|
|
115
|
+
{ name: "severity", type: "string[]", in: "query", description: "Severities: critical, high, medium, low" },
|
|
116
|
+
{ name: "kind", type: "string[]", in: "query", description: "Object kinds: query, function, table and the other kinds findings name" },
|
|
117
|
+
{ name: "object", type: "string[]", in: "query", description: "Objects, each written type:id, such as query:18" },
|
|
118
|
+
{ name: "tag", type: "string[]", in: "query", description: "Tags of the finding's policy (from the run's snapshot) or of its object (as the run read it)" },
|
|
119
|
+
{ name: "q", type: "string", in: "query", description: "Case-insensitive text in the policy key or title, rule title, object name or message" },
|
|
120
|
+
],
|
|
121
|
+
response: { type: "object", description: "{items, total, objects, offset, limit}: items are the findings as the run stored them; total counts every finding that matches, and objects counts the distinct objects the matching findings name." },
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
method: "GET", path: prefix + "/run/{run_id}/clear", description: "Page one rule's clear objects in a retained run: the objects it examined without a finding of its own. policy and rule are required (400 without them).",
|
|
125
|
+
parameters: [workspace, branch, runId, { name: "policy", type: "string", required: true, in: "query", description: "Policy key" }, { name: "rule", type: "string", required: true, in: "query", description: "Rule id, such as AUTH-001.R1" }, { name: "offset", type: "integer", in: "query", default: 0, description: "How many to skip" }, { name: "limit", type: "integer", in: "query", default: 100, description: "How many to return, 1-500" }, { name: "q", type: "string", in: "query", description: "Case-insensitive text in the object name" }],
|
|
126
|
+
response: { type: "object", description: "{items, total, offset, limit, recorded}; recorded is false for a run stored before clear objects were kept." },
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
method: "GET", path: "/workspace/{workspace_id}/agent-skills",
|
|
130
|
+
description: "Serve the generated xano-policies agent skill. One generator, three surfaces: studio (the default, the variant the Studio agent loads), cli (the variant xano skills pull writes) and mcp (the variant the authenticated MCP's xano_get_policy_skill serves). With digest=true and surface studio or mcp it also answers xano-active-policies, a budgeted digest of the branch's active policies (mandatory first, one line per rule) when the branch has one. Each surface has its own description. The check catalogue inside it is generated from the live registry at request time, so it can never document a check this instance does not have. A workspace knowledge record named xano-policies replaces the platform skill and is served instead. Needs the workspace:policy permission at read level, like the other policy routes.",
|
|
131
|
+
parameters: [workspace, branch, { name: "surface", type: "string", in: "query", default: "studio", enum: ["studio", "cli", "mcp"], description: "Which variant of the generated skill to return" }, { name: "digest", type: "boolean", in: "query", default: false, description: "Also answer the xano-active-policies digest item" }],
|
|
132
|
+
response: { type: "object", description: "{knowledge: [...]}: the same envelope as workspace knowledge, with one item named xano-policies whose knowledge_type is skill and whose content is the skill markdown. The platform's own item has id -101." },
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { xanoscriptParser } from "@xano/xanoscript-language-server/parser/parser.js";
|
|
14
14
|
import { getSchemeFromContent } from "@xano/xanoscript-language-server/utils.js";
|
|
15
|
+
import { setPolicyCatalogue } from "@xano/xanoscript-language-server/parser/policy/catalogue.js";
|
|
16
|
+
import policyCatalogueSnapshot from "@xano/xanoscript-language-server/parser/policy/catalogueSnapshot.js";
|
|
15
17
|
import { readFileSync, existsSync, readdirSync } from "fs";
|
|
16
18
|
import { join, resolve, basename } from "path";
|
|
17
19
|
import { minimatch } from "minimatch";
|
|
@@ -21,6 +23,13 @@ export const SEVERITY = {
|
|
|
21
23
|
ERROR: 1,
|
|
22
24
|
WARNING: 2,
|
|
23
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Check policy rules against the check catalogue the language server ships with, as its
|
|
28
|
+
* own server does. Without a catalogue it checks a policy's block shape only. A problem
|
|
29
|
+
* the catalogue decides (an unknown check, field or param, a value outside its set) is
|
|
30
|
+
* a warning, since the instance a file is pushed to may have a newer catalogue.
|
|
31
|
+
*/
|
|
32
|
+
setPolicyCatalogue(policyCatalogueSnapshot, { source: "snapshot" });
|
|
24
33
|
// =============================================================================
|
|
25
34
|
// Error Message Improvements
|
|
26
35
|
// =============================================================================
|
|
@@ -379,7 +388,6 @@ export function validateXanoscript(args) {
|
|
|
379
388
|
invalidCount++;
|
|
380
389
|
}
|
|
381
390
|
}
|
|
382
|
-
// Build summary message
|
|
383
391
|
const allValid = invalidCount === 0;
|
|
384
392
|
const summaryLines = [
|
|
385
393
|
`Validated ${filesToValidate.length} file(s): ${validCount} valid, ${invalidCount} invalid`,
|
|
@@ -443,7 +451,11 @@ export const validateXanoscriptToolSpec = defineTool({
|
|
|
443
451
|
"- file_paths: Array of file paths for batch validation\n" +
|
|
444
452
|
"- directory: Validate all .xs files in a directory\n\n" +
|
|
445
453
|
"Returns errors with line/column positions and helpful suggestions for common mistakes. " +
|
|
446
|
-
"The language server auto-detects the object type from the code syntax."
|
|
454
|
+
"The language server auto-detects the object type from the code syntax. " +
|
|
455
|
+
"Policy documents (policies/*.xs) are validated too: their syntax and block shape are errors, " +
|
|
456
|
+
"and what the check catalogue decides (an unknown check, field or param, a value outside its set) " +
|
|
457
|
+
"is a warning against the catalogue the language server ships with. The instance decides on save; " +
|
|
458
|
+
"format and check a policy against its branch with xano_parse_policy or `xano policy parse --file <path>`.",
|
|
447
459
|
annotations: {
|
|
448
460
|
readOnlyHint: true,
|
|
449
461
|
destructiveHint: false,
|
package/dist/xanoscript.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ export interface DocConfig {
|
|
|
14
14
|
* docs_index.json declaration order. Omitted (undefined) sorts last (99).
|
|
15
15
|
*/
|
|
16
16
|
priority?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The topic alone documents the files its `applyTo` matches: file_path mode
|
|
19
|
+
* returns it without `syntax` or any other matching topic.
|
|
20
|
+
*/
|
|
21
|
+
exclusive?: boolean;
|
|
17
22
|
}
|
|
18
23
|
export interface XanoscriptDocsArgs {
|
|
19
24
|
topic?: string;
|
package/dist/xanoscript.js
CHANGED
|
@@ -19,6 +19,7 @@ function buildDocsConfig() {
|
|
|
19
19
|
applyTo: topic.applyTo,
|
|
20
20
|
description: topic.description,
|
|
21
21
|
priority: topic.priority,
|
|
22
|
+
exclusive: topic.exclusive === true,
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
return config;
|
|
@@ -122,6 +123,8 @@ export function getDocsForFilePath(filePath) {
|
|
|
122
123
|
continue; // Don't auto-include readme
|
|
123
124
|
for (const pattern of config.applyTo) {
|
|
124
125
|
if (minimatch(filePath, pattern)) {
|
|
126
|
+
if (config.exclusive)
|
|
127
|
+
return [topic];
|
|
125
128
|
matches.push(topic);
|
|
126
129
|
break;
|
|
127
130
|
}
|
|
@@ -338,6 +341,7 @@ export function readXanoscriptDocsV2(docsPath, args) {
|
|
|
338
341
|
`- file_path='api/users/create.xs' — auto-select the docs for the file you're editing`,
|
|
339
342
|
`- filter='round' — one expression filter's signature and example (comma-separate for several, e.g. filter='to_upper,split')`,
|
|
340
343
|
`- tier='survival' (~${tiers.survival.tokens}) or tier='working' (~${tiers.working.tokens}) for context-limited models`,
|
|
344
|
+
`- topic='policies' — when the workspace has a policies/ folder: keep to its active mandatory policies while changing code, and evaluate after`,
|
|
341
345
|
`- mode='quick_reference' — compact output when you only need a reminder`,
|
|
342
346
|
`- max_tokens=4000 with file_path= — stop loading once the budget is reached`,
|
|
343
347
|
`- exclude_topics=['syntax'] with file_path= — skip topics you've already loaded`,
|
|
@@ -269,6 +269,7 @@ Use `xano_xanoscript_docs({ tier: "survival" })` or `xano_xanoscript_docs({ tier
|
|
|
269
269
|
| `workspace` | Workspace-level settings: environment variables, preferences, realtime | Env Variables, Preferences |
|
|
270
270
|
| `branch` | Branch-level settings: middleware, history retention, visual styling | Middleware Config, History |
|
|
271
271
|
| `middleware` | Request/response interceptors for functions, queries, tasks, and tools | Pre/Post Hooks |
|
|
272
|
+
| `policies` | Workspace policy documents: syntax, check catalogue, goals, authoring rules | Quick Reference, Permissions |
|
|
272
273
|
|
|
273
274
|
### Development
|
|
274
275
|
|
|
@@ -127,6 +127,36 @@ db.query "product" {
|
|
|
127
127
|
} as $exists
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
### Output (Explicit Field List)
|
|
131
|
+
|
|
132
|
+
`output` names exactly which fields a read returns. Without it a read returns the whole
|
|
133
|
+
row, so an endpoint widens silently whenever someone adds a column — including a column
|
|
134
|
+
holding something the caller should never see.
|
|
135
|
+
|
|
136
|
+
```xs
|
|
137
|
+
// Only these four fields come back
|
|
138
|
+
db.query "product" {
|
|
139
|
+
where = $db.product.retired == false
|
|
140
|
+
output = ["id", "name", "price", "sku"]
|
|
141
|
+
return = { type: "list" }
|
|
142
|
+
} as $products
|
|
143
|
+
|
|
144
|
+
// The same parameter on a single-record read
|
|
145
|
+
db.get "product" {
|
|
146
|
+
field_name = "id"
|
|
147
|
+
field_value = $input.product_id
|
|
148
|
+
output = ["id", "name", "price"]
|
|
149
|
+
} as $product
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
A dotted path selects a nested field (`"price.amount"`). `output` is valid on `db.query`,
|
|
153
|
+
`db.get`, `db.add`, `db.edit`, `db.patch` and `db.add_or_edit`; `db.has`, `db.del` and the
|
|
154
|
+
bulk statements do not take it. The bundled language server behind `xano_validate_xanoscript`
|
|
155
|
+
rejects it on `db.patch` and `db.add_or_edit`, which the platform accepts. The policy check
|
|
156
|
+
`statement.param_required` with `param_names: ["output"]` (and `statements: ["db.query",
|
|
157
|
+
"db.get"]`) is how a workspace requires it, so a finding reading `output must be explicit` is
|
|
158
|
+
asking for exactly this line.
|
|
159
|
+
|
|
130
160
|
### Sorting
|
|
131
161
|
|
|
132
162
|
```xs
|
|
@@ -302,6 +302,14 @@
|
|
|
302
302
|
"applyTo": ["workspace/**/*.xs"],
|
|
303
303
|
"priority": 3,
|
|
304
304
|
"aliases": ["env", "environment", "preferences"]
|
|
305
|
+
},
|
|
306
|
+
"policies": {
|
|
307
|
+
"file": "policies.md",
|
|
308
|
+
"description": "Workspace policies: human descriptions and deterministic check rules, validated by the platform",
|
|
309
|
+
"applyTo": ["policies/*.xs"],
|
|
310
|
+
"exclusive": true,
|
|
311
|
+
"priority": 3,
|
|
312
|
+
"aliases": ["policy", "governance"]
|
|
305
313
|
}
|
|
306
314
|
},
|
|
307
315
|
|