@clavis.nexus/setup 3.0.2 → 3.0.3

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/dist/mcp.js CHANGED
@@ -7,8 +7,8 @@ import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprot
7
7
  import { createRequire } from 'module';
8
8
  import { execFile } from 'child_process';
9
9
  import { promisify } from 'util';
10
- import { readFile, chmod, unlink, mkdir, writeFile, lstat } from 'fs/promises';
11
- import path, { dirname, join, resolve, relative, isAbsolute } from 'path';
10
+ import { mkdir, mkdtemp, writeFile, rename, rm, readFile, chmod, unlink, lstat } from 'fs/promises';
11
+ import path, { join, dirname, resolve, relative, isAbsolute } from 'path';
12
12
  import { homedir } from 'os';
13
13
  import { generateKeyPair, exportJWK, jwtVerify, importJWK } from 'jose';
14
14
  import { createInterface } from 'readline/promises';
@@ -185,6 +185,71 @@ async function checkTrustRoot(apiOrigin, trustRootJson) {
185
185
  await createVerifier({ trustRoot: trustRootJson, apiOrigin }).trust();
186
186
  return JSON.stringify(JSON.parse(trustRootJson));
187
187
  }
188
+ async function postAppLexDocument(apiOrigin, bearer, orgId, appId, url) {
189
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/apps/${encodeURIComponent(appId)}/lex-documents`, {
190
+ method: "POST",
191
+ bearer,
192
+ body: { url }
193
+ });
194
+ }
195
+ async function postAppLexProfileStatement(apiOrigin, bearer, orgId, appId, profile) {
196
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/apps/${encodeURIComponent(appId)}/lex-profile/statement`, {
197
+ method: "POST",
198
+ bearer,
199
+ body: { profile }
200
+ });
201
+ }
202
+ async function putAppLexProfile(apiOrigin, bearer, orgId, appId, args) {
203
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/apps/${encodeURIComponent(appId)}/lex-profile`, {
204
+ method: "PUT",
205
+ bearer,
206
+ body: { profile: args.profile, receipt: args.receipt }
207
+ });
208
+ }
209
+ async function postLexDecisionCounts(apiOrigin, bearer, orgId, query) {
210
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/lex/decisions/counts`, { method: "POST", bearer, body: { query } });
211
+ }
212
+ async function postLexExportStatement(apiOrigin, bearer, orgId, request) {
213
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/lex/exports/statement`, { method: "POST", bearer, body: { request } });
214
+ }
215
+ async function postLexExport(apiOrigin, bearer, orgId, args) {
216
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/lex/exports`, {
217
+ method: "POST",
218
+ bearer,
219
+ body: { request: args.request, ...args.receipt !== void 0 ? { receipt: args.receipt } : {} }
220
+ });
221
+ }
222
+ async function getLexExports(apiOrigin, bearer, orgId) {
223
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/lex/exports`, { bearer });
224
+ }
225
+ async function getLexExport(apiOrigin, bearer, orgId, jobId) {
226
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/lex/exports/${encodeURIComponent(jobId)}`, { bearer });
227
+ }
228
+ async function getLexDecision(apiOrigin, bearer, orgId, decisionId) {
229
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/lex/decisions/${encodeURIComponent(decisionId)}`, { bearer });
230
+ }
231
+ async function getLexSubjectDecisions(apiOrigin, bearer, orgId, subject) {
232
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/lex/subjects/${encodeURIComponent(subject)}/decisions`, { bearer });
233
+ }
234
+ async function postLexSubjectErase(apiOrigin, bearer, orgId, subject, receipt) {
235
+ return apiJson(apiOrigin, `/orgs/${encodeURIComponent(orgId)}/lex/subjects/${encodeURIComponent(subject)}/erase`, {
236
+ method: "POST",
237
+ bearer,
238
+ body: { receipt }
239
+ });
240
+ }
241
+ async function getLexExportFile(apiOrigin, bearer, orgId, jobId, path2) {
242
+ const res = await fetch(
243
+ `${apiOrigin.replace(/\/+$/, "")}/orgs/${encodeURIComponent(orgId)}/lex/exports/${encodeURIComponent(jobId)}/files/${path2.split("/").map(encodeURIComponent).join("/")}`,
244
+ { redirect: "error", headers: { Authorization: `Bearer ${bearer}` } }
245
+ );
246
+ if (!res.ok) {
247
+ const body = await res.json().catch(() => null);
248
+ const code = typeof body?.error === "string" ? body.error : `HTTP_${res.status}`;
249
+ throw new SetupApiError(res.status, code, typeof body?.message === "string" ? body.message : code);
250
+ }
251
+ return new Uint8Array(await res.arrayBuffer());
252
+ }
188
253
 
189
254
  // src/app-regions.ts
190
255
  var APP_REGIONS = ["JP", "US", "GB", "EEA"];
@@ -550,6 +615,9 @@ function orgAppRegionsStatement(input2) {
550
615
  regions: input2.regions === null ? null : [...new Set(input2.regions)].sort()
551
616
  };
552
617
  }
618
+ function orgLexSubjectEraseStatement(input2) {
619
+ return { type: "org.lex.subject_erase@1", org: input2.org.trim(), subject: input2.subject.trim() };
620
+ }
553
621
  function orgCardIncorporationStatement(input2) {
554
622
  return {
555
623
  type: "org.card.incorporation_set@1",
@@ -1112,6 +1180,33 @@ async function buildSetupStatus(args) {
1112
1180
  }
1113
1181
 
1114
1182
  // src/setup-client.ts
1183
+ var LEX_SUBJECT = /^[A-Za-z0-9._:-]{1,128}$/;
1184
+ var LEX_DECISION_ID = /^[A-Za-z0-9._:-]{1,128}$/;
1185
+ var LEX_EXPORT_PATH = /^(manifest\.json|anchor\.json|items\/\d{5}\.jsonl|decisions\/[A-Za-z0-9._:-]{1,128}\.json)$/;
1186
+ async function bytesDigest(bytes) {
1187
+ return `sha256:${bytesToBase64Url(new Uint8Array(await crypto.subtle.digest("SHA-256", new Uint8Array(bytes))))}`;
1188
+ }
1189
+ function lexRefusal(e) {
1190
+ if (!(e instanceof SetupApiError)) return null;
1191
+ switch (e.code) {
1192
+ case "PROFILE_INVALID":
1193
+ return { ok: false, error: "profile_invalid \u2014 the agreement profile is incomplete (version, service_name, purposes, destinations and terminal_categories are required)." };
1194
+ case "DOCUMENT_NOT_SNAPSHOTTED":
1195
+ return { ok: false, error: "document_not_snapshotted \u2014 run app-lex-document for each document in the profile first, and use the sha256 it returns." };
1196
+ case "EXPORT_RUNNING":
1197
+ return { ok: false, error: "export_running \u2014 another export of this organisation is running. Wait for it, then start again." };
1198
+ case "EXPORT_TOO_LARGE":
1199
+ return { ok: false, error: "export_too_large \u2014 more decisions match than one export holds. Narrow the period (query.from, query.to) and start again." };
1200
+ case "FORBIDDEN":
1201
+ return { ok: false, error: "forbidden \u2014 only an owner or admin of the Org can do this." };
1202
+ case "NOT_FOUND":
1203
+ return { ok: false, error: "not_found \u2014 the Org, the App, the export or the decision was not found, or this is not open to the Org yet." };
1204
+ case "ORG_HOLD":
1205
+ return { ok: false, error: "org_hold \u2014 these records are preserved under a hold, so erasure waits until the hold ends. Nothing was erased." };
1206
+ default:
1207
+ return null;
1208
+ }
1209
+ }
1115
1210
  async function requireSession(sessionPath) {
1116
1211
  const stored = await loadSession(sessionPath);
1117
1212
  if (!stored?.session?.accessToken) {
@@ -1632,6 +1727,197 @@ function createSetupClient(options = {}) {
1632
1727
  throw e;
1633
1728
  }
1634
1729
  },
1730
+ async appLexDocument(args) {
1731
+ const auth = await requireSession(sessionPath);
1732
+ if (!auth.ok) return auth;
1733
+ try {
1734
+ return { ok: true, data: await postAppLexDocument(auth.data.origins.apiOrigin, auth.data.session.accessToken, args.orgId, args.appId, args.url) };
1735
+ } catch (e) {
1736
+ const refusal = lexRefusal(e);
1737
+ if (refusal) return refusal;
1738
+ throw e;
1739
+ }
1740
+ },
1741
+ async appLexProfileSet(args) {
1742
+ const auth = await requireSession(sessionPath);
1743
+ if (!auth.ok) return auth;
1744
+ const apiOrigin = auth.data.origins.apiOrigin;
1745
+ const bearer = auth.data.session.accessToken;
1746
+ try {
1747
+ const prepared = await postAppLexProfileStatement(apiOrigin, bearer, args.orgId, args.appId, args.profile);
1748
+ const cer = await runPasskeyCeremony({
1749
+ origins: auth.data.origins,
1750
+ bearer,
1751
+ statement: prepared.statement,
1752
+ displayHint: args.profile === null ? "Clear the App's agreement profile" : "Set the App's agreement profile",
1753
+ openBrowserFlag
1754
+ });
1755
+ const proof = await cer.wait();
1756
+ return { ok: true, data: await putAppLexProfile(apiOrigin, bearer, args.orgId, args.appId, { profile: args.profile, receipt: proof }) };
1757
+ } catch (e) {
1758
+ const refusal = lexRefusal(e);
1759
+ if (refusal) return refusal;
1760
+ throw e;
1761
+ }
1762
+ },
1763
+ async lexCounts(args) {
1764
+ const auth = await requireSession(sessionPath);
1765
+ if (!auth.ok) return auth;
1766
+ try {
1767
+ return { ok: true, data: await postLexDecisionCounts(auth.data.origins.apiOrigin, auth.data.session.accessToken, args.orgId, args.query ?? {}) };
1768
+ } catch (e) {
1769
+ const refusal = lexRefusal(e);
1770
+ if (refusal) return refusal;
1771
+ throw e;
1772
+ }
1773
+ },
1774
+ async lexExport(args) {
1775
+ const auth = await requireSession(sessionPath);
1776
+ if (!auth.ok) return auth;
1777
+ const apiOrigin = auth.data.origins.apiOrigin;
1778
+ const bearer = auth.data.session.accessToken;
1779
+ try {
1780
+ const prepared = await postLexExportStatement(apiOrigin, bearer, args.orgId, args.request);
1781
+ let receipt;
1782
+ if (prepared.statement) {
1783
+ const cer = await runPasskeyCeremony({
1784
+ origins: auth.data.origins,
1785
+ bearer,
1786
+ statement: prepared.statement,
1787
+ displayHint: "Export the organisation's agreement records",
1788
+ openBrowserFlag
1789
+ });
1790
+ receipt = await cer.wait();
1791
+ }
1792
+ return { ok: true, data: await postLexExport(apiOrigin, bearer, args.orgId, { request: args.request, ...receipt ? { receipt } : {} }) };
1793
+ } catch (e) {
1794
+ const refusal = lexRefusal(e);
1795
+ if (refusal) return refusal;
1796
+ throw e;
1797
+ }
1798
+ },
1799
+ async lexExports(args) {
1800
+ const auth = await requireSession(sessionPath);
1801
+ if (!auth.ok) return auth;
1802
+ try {
1803
+ return { ok: true, data: await getLexExports(auth.data.origins.apiOrigin, auth.data.session.accessToken, args.orgId) };
1804
+ } catch (e) {
1805
+ const refusal = lexRefusal(e);
1806
+ if (refusal) return refusal;
1807
+ throw e;
1808
+ }
1809
+ },
1810
+ async lexExportStatus(args) {
1811
+ const auth = await requireSession(sessionPath);
1812
+ if (!auth.ok) return auth;
1813
+ try {
1814
+ return { ok: true, data: await getLexExport(auth.data.origins.apiOrigin, auth.data.session.accessToken, args.orgId, args.jobId) };
1815
+ } catch (e) {
1816
+ const refusal = lexRefusal(e);
1817
+ if (refusal) return refusal;
1818
+ throw e;
1819
+ }
1820
+ },
1821
+ async lexExportDownload(args) {
1822
+ if (!/^[0-9a-f]{32}$/.test(args.jobId)) return { ok: false, error: "job_id_invalid" };
1823
+ const auth = await requireSession(sessionPath);
1824
+ if (!auth.ok) return auth;
1825
+ const apiOrigin = auth.data.origins.apiOrigin;
1826
+ const bearer = auth.data.session.accessToken;
1827
+ try {
1828
+ const { job } = await getLexExport(apiOrigin, bearer, args.orgId, args.jobId);
1829
+ if (job.state !== "done" || typeof job.manifest_digest !== "string") {
1830
+ return { ok: false, error: `export_not_done \u2014 the export is ${String(job.state)}. Check again with lex-export-status.` };
1831
+ }
1832
+ const manifestBytes = await getLexExportFile(apiOrigin, bearer, args.orgId, args.jobId, "manifest.json");
1833
+ if (await bytesDigest(manifestBytes) !== job.manifest_digest) {
1834
+ return { ok: false, error: "export_manifest_mismatch \u2014 the manifest does not hash to the digest Clavis anchored. Nothing was kept." };
1835
+ }
1836
+ const manifest = JSON.parse(new TextDecoder().decode(manifestBytes));
1837
+ if (manifest?.kind !== "lex.package@1" || manifest.job_id !== args.jobId || !Array.isArray(manifest.files)) {
1838
+ return { ok: false, error: "invalid_export_manifest" };
1839
+ }
1840
+ const files = [];
1841
+ const seen = /* @__PURE__ */ new Set(["manifest.json", "anchor.json"]);
1842
+ await mkdir(args.dir, { recursive: true, mode: 448 });
1843
+ const staging = await mkdtemp(join(args.dir, ".clavis-export-"));
1844
+ const store = async (path2, bytes) => {
1845
+ await mkdir(dirname(join(staging, path2)), { recursive: true, mode: 448 });
1846
+ await writeFile(join(staging, path2), bytes, { flag: "wx", mode: 384 });
1847
+ files.push({ path: path2, bytes: bytes.byteLength });
1848
+ };
1849
+ try {
1850
+ await store("manifest.json", manifestBytes);
1851
+ for (const entry of manifest.files) {
1852
+ if (typeof entry?.path !== "string" || !LEX_EXPORT_PATH.test(entry.path) || seen.has(entry.path)) {
1853
+ return { ok: false, error: "invalid_export_manifest" };
1854
+ }
1855
+ seen.add(entry.path);
1856
+ const bytes = await getLexExportFile(apiOrigin, bearer, args.orgId, args.jobId, entry.path);
1857
+ if (bytes.byteLength !== entry.bytes || await bytesDigest(bytes) !== entry.sha256) {
1858
+ return { ok: false, error: `export_file_mismatch \u2014 ${entry.path} differs from the manifest.` };
1859
+ }
1860
+ await store(entry.path, bytes);
1861
+ }
1862
+ await store("anchor.json", await getLexExportFile(apiOrigin, bearer, args.orgId, args.jobId, "anchor.json"));
1863
+ const root = join(args.dir, args.jobId);
1864
+ await rename(staging, root);
1865
+ return { ok: true, data: { dir: root, manifest_digest: job.manifest_digest, files } };
1866
+ } finally {
1867
+ await rm(staging, { recursive: true, force: true });
1868
+ }
1869
+ } catch (e) {
1870
+ const refusal = lexRefusal(e);
1871
+ if (refusal) return refusal;
1872
+ throw e;
1873
+ }
1874
+ },
1875
+ async lexDecision(args) {
1876
+ if (!LEX_DECISION_ID.test(args.decisionId)) return { ok: false, error: "decision_id_invalid \u2014 pass the decision_id Clavis returned for the agreement." };
1877
+ const auth = await requireSession(sessionPath);
1878
+ if (!auth.ok) return auth;
1879
+ try {
1880
+ return { ok: true, data: await getLexDecision(auth.data.origins.apiOrigin, auth.data.session.accessToken, args.orgId, args.decisionId) };
1881
+ } catch (e) {
1882
+ const refusal = lexRefusal(e);
1883
+ if (refusal) return refusal;
1884
+ throw e;
1885
+ }
1886
+ },
1887
+ async lexSubjectDecisions(args) {
1888
+ if (!LEX_SUBJECT.test(args.subject)) return { ok: false, error: "subject_invalid \u2014 pass the person's ID in your App (the sub you passed as allowedSub)." };
1889
+ const auth = await requireSession(sessionPath);
1890
+ if (!auth.ok) return auth;
1891
+ try {
1892
+ return { ok: true, data: await getLexSubjectDecisions(auth.data.origins.apiOrigin, auth.data.session.accessToken, args.orgId, args.subject) };
1893
+ } catch (e) {
1894
+ const refusal = lexRefusal(e);
1895
+ if (refusal) return refusal;
1896
+ throw e;
1897
+ }
1898
+ },
1899
+ async lexSubjectErase(args) {
1900
+ if (!LEX_SUBJECT.test(args.subject)) return { ok: false, error: "subject_invalid \u2014 pass the person's ID in your App (the sub you passed as allowedSub)." };
1901
+ const auth = await requireSession(sessionPath);
1902
+ if (!auth.ok) return auth;
1903
+ const apiOrigin = auth.data.origins.apiOrigin;
1904
+ const bearer = auth.data.session.accessToken;
1905
+ try {
1906
+ const cer = await runPasskeyCeremony({
1907
+ origins: auth.data.origins,
1908
+ bearer,
1909
+ statement: orgLexSubjectEraseStatement({ org: args.orgId, subject: args.subject }),
1910
+ displayHint: "Erase one person's agreement records",
1911
+ openBrowserFlag
1912
+ });
1913
+ const proof = await cer.wait();
1914
+ return { ok: true, data: await postLexSubjectErase(apiOrigin, bearer, args.orgId, args.subject, proof) };
1915
+ } catch (e) {
1916
+ const refusal = lexRefusal(e);
1917
+ if (refusal) return refusal;
1918
+ throw e;
1919
+ }
1920
+ },
1635
1921
  async emitEnv(args) {
1636
1922
  const jwk = args.operatePrivateJwkJson?.trim() || await readOperatePrivateJwk(args.appId) || "";
1637
1923
  if (!jwk) {
@@ -1821,7 +2107,8 @@ var TOOLS = [
1821
2107
  org_id: { type: "string" },
1822
2108
  host: { type: "string" },
1823
2109
  display_name: { type: "string" },
1824
- redirect_path: { type: "string" }
2110
+ redirect_path: { type: "string" },
2111
+ agreements: { type: "boolean", description: "Allow this App to request agreements." }
1825
2112
  },
1826
2113
  required: ["org_id", "host", "display_name"],
1827
2114
  additionalProperties: false
@@ -1895,6 +2182,101 @@ var TOOLS = [
1895
2182
  additionalProperties: false
1896
2183
  }
1897
2184
  },
2185
+ {
2186
+ name: "clavis_app_lex_document",
2187
+ description: "Have Clavis take a snapshot of the org's terms or privacy notice from the App's confirmed host or the org's domain. Put the sha256 it returns in the agreement profile's documents.",
2188
+ inputSchema: {
2189
+ type: "object",
2190
+ properties: { org_id: { type: "string" }, app_id: { type: "string" }, url: { type: "string" } },
2191
+ required: ["org_id", "app_id", "url"],
2192
+ additionalProperties: false
2193
+ }
2194
+ },
2195
+ {
2196
+ name: "clavis_app_lex_profile_set",
2197
+ description: "Set what Connect shows when the App asks a user for an agreement (version, service_name, documents, purposes, destinations, terminal_categories), or clear it with profile null. Needs the human's Passkey (returns needs_human: passkey while waiting).",
2198
+ inputSchema: {
2199
+ type: "object",
2200
+ properties: { org_id: { type: "string" }, app_id: { type: "string" }, profile: { type: ["object", "null"] } },
2201
+ required: ["org_id", "app_id", "profile"],
2202
+ additionalProperties: false
2203
+ }
2204
+ },
2205
+ {
2206
+ name: "clavis_lex_counts",
2207
+ description: "Count the org's agreement decisions a query matches (period from/to, app_id, use_case, outcome, pack_id, template, requirement, versions), by outcome, stop reason and pack.",
2208
+ inputSchema: {
2209
+ type: "object",
2210
+ properties: { org_id: { type: "string" }, query: { type: "object" } },
2211
+ required: ["org_id"],
2212
+ additionalProperties: false
2213
+ }
2214
+ },
2215
+ {
2216
+ name: "clavis_lex_export",
2217
+ description: "Start an export of the org's agreement records. request: { kind: decisions | subject, query, expiring_within_days?, records? }. Many people's records (decisions) need the human's Passkey; one person's (subject, with query.subject_ref) does not. One export runs at a time.",
2218
+ inputSchema: {
2219
+ type: "object",
2220
+ properties: { org_id: { type: "string" }, request: { type: "object" } },
2221
+ required: ["org_id", "request"],
2222
+ additionalProperties: false
2223
+ }
2224
+ },
2225
+ {
2226
+ name: "clavis_lex_exports",
2227
+ description: "List the org's exports of agreement records, newest first.",
2228
+ inputSchema: { type: "object", properties: { org_id: { type: "string" } }, required: ["org_id"], additionalProperties: false }
2229
+ },
2230
+ {
2231
+ name: "clavis_lex_export_status",
2232
+ description: "Read one export: its state, its files once done, and where its manifest stands on the org's ledger.",
2233
+ inputSchema: {
2234
+ type: "object",
2235
+ properties: { org_id: { type: "string" }, job_id: { type: "string" } },
2236
+ required: ["org_id", "job_id"],
2237
+ additionalProperties: false
2238
+ }
2239
+ },
2240
+ {
2241
+ name: "clavis_lex_export_download",
2242
+ description: "Fetch a finished export into dir/<job_id>/ (files at mode 0600: they hold people's records), checking each file against the manifest and the manifest against the digest anchored on the ledger.",
2243
+ inputSchema: {
2244
+ type: "object",
2245
+ properties: { org_id: { type: "string" }, job_id: { type: "string" }, dir: { type: "string" } },
2246
+ required: ["org_id", "job_id", "dir"],
2247
+ additionalProperties: false
2248
+ }
2249
+ },
2250
+ {
2251
+ name: "clavis_lex_decision",
2252
+ description: "Read one agreement decision by the decision_id the App received: its record, its ledger proof and where it stands now.",
2253
+ inputSchema: {
2254
+ type: "object",
2255
+ properties: { org_id: { type: "string" }, decision_id: { type: "string" } },
2256
+ required: ["org_id", "decision_id"],
2257
+ additionalProperties: false
2258
+ }
2259
+ },
2260
+ {
2261
+ name: "clavis_lex_subject_decisions",
2262
+ description: "List every agreement decision the Org holds for one person (subject is their ID in the Org's App), to answer that person's request.",
2263
+ inputSchema: {
2264
+ type: "object",
2265
+ properties: { org_id: { type: "string" }, subject: { type: "string" } },
2266
+ required: ["org_id", "subject"],
2267
+ additionalProperties: false
2268
+ }
2269
+ },
2270
+ {
2271
+ name: "clavis_lex_subject_erase",
2272
+ description: "Erase one person's agreement decisions now, as the Org's instruction for that person's erasure request. Needs the owner's or admin's Passkey, cannot be undone, and is refused while the records are under a hold. Run it only when the Org has decided to erase.",
2273
+ inputSchema: {
2274
+ type: "object",
2275
+ properties: { org_id: { type: "string" }, subject: { type: "string" } },
2276
+ required: ["org_id", "subject"],
2277
+ additionalProperties: false
2278
+ }
2279
+ },
1898
2280
  {
1899
2281
  name: "clavis_emit_app_env",
1900
2282
  description: "Emit environment variables for @clavis.nexus/app after setup. Needs CLAVIS_TRUST_ROOT (the Clavis Master public JWK) in the environment.",
@@ -1959,6 +2341,7 @@ async function dispatch(client, name, args) {
1959
2341
  orgId: String(args.org_id),
1960
2342
  host: String(args.host),
1961
2343
  displayName: String(args.display_name),
2344
+ intentTypes: args.agreements === true ? ["generic_sign", "agreement"] : void 0,
1962
2345
  redirectPaths: args.redirect_path ? [String(args.redirect_path)] : void 0
1963
2346
  });
1964
2347
  case "clavis_app_host_plan":
@@ -1980,6 +2363,26 @@ async function dispatch(client, name, args) {
1980
2363
  endUsers: String(args.end_users),
1981
2364
  uses: args.uses
1982
2365
  });
2366
+ case "clavis_app_lex_document":
2367
+ return client.appLexDocument({ orgId: String(args.org_id), appId: String(args.app_id), url: String(args.url) });
2368
+ case "clavis_app_lex_profile_set":
2369
+ return client.appLexProfileSet({ orgId: String(args.org_id), appId: String(args.app_id), profile: args.profile ?? null });
2370
+ case "clavis_lex_counts":
2371
+ return client.lexCounts({ orgId: String(args.org_id), query: args.query ?? {} });
2372
+ case "clavis_lex_export":
2373
+ return client.lexExport({ orgId: String(args.org_id), request: args.request });
2374
+ case "clavis_lex_exports":
2375
+ return client.lexExports({ orgId: String(args.org_id) });
2376
+ case "clavis_lex_export_status":
2377
+ return client.lexExportStatus({ orgId: String(args.org_id), jobId: String(args.job_id) });
2378
+ case "clavis_lex_export_download":
2379
+ return client.lexExportDownload({ orgId: String(args.org_id), jobId: String(args.job_id), dir: String(args.dir) });
2380
+ case "clavis_lex_decision":
2381
+ return client.lexDecision({ orgId: String(args.org_id), decisionId: String(args.decision_id) });
2382
+ case "clavis_lex_subject_decisions":
2383
+ return client.lexSubjectDecisions({ orgId: String(args.org_id), subject: String(args.subject) });
2384
+ case "clavis_lex_subject_erase":
2385
+ return client.lexSubjectErase({ orgId: String(args.org_id), subject: String(args.subject) });
1983
2386
  case "clavis_emit_app_env":
1984
2387
  return client.emitEnv({
1985
2388
  appId: String(args.app_id)