@talonic/mcp 0.1.107 → 0.1.108

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.
@@ -13581,8 +13581,8 @@ async function handleToMarkdown(talonic, args, opts = {}) {
13581
13581
  retryable: false
13582
13582
  });
13583
13583
  }
13584
- let documentId3 = args.document_id;
13585
- if (!documentId3) {
13584
+ let documentId4 = args.document_id;
13585
+ if (!documentId4) {
13586
13586
  const ingest = await talonic.extract({
13587
13587
  ...args.file_data !== void 0 ? {
13588
13588
  file: Buffer.from(args.file_data, "base64"),
@@ -13592,9 +13592,9 @@ async function handleToMarkdown(talonic, args, opts = {}) {
13592
13592
  ...args.file_url !== void 0 ? { file_url: args.file_url } : {},
13593
13593
  schema: INGEST_ONLY_SCHEMA
13594
13594
  });
13595
- documentId3 = ingest.document.id;
13595
+ documentId4 = ingest.document.id;
13596
13596
  }
13597
- const result = await talonic.documents.getMarkdown(documentId3);
13597
+ const result = await talonic.documents.getMarkdown(documentId4);
13598
13598
  return jsonOk(result);
13599
13599
  } catch (err) {
13600
13600
  return toolError(err);
@@ -15170,6 +15170,219 @@ var aggregateGroup = {
15170
15170
  aggregateTool
15171
15171
  ]
15172
15172
  };
15173
+ var documentId = zUuid().describe("The document id.");
15174
+ var labelList = z.array(z.string().min(1).max(200)).max(50).optional();
15175
+ var APPLY_BODY = ["document", "yaml"];
15176
+ var applyConfig = {
15177
+ name: "talonic_collections_apply_config",
15178
+ title: "Apply the collections configuration",
15179
+ description: describe({
15180
+ what: "Apply a collections configuration document: collections by `key` with `name`, `match` (labels a document must all carry) or `any` (several label sets), `children` (one level), `only` (who may read the documents it holds), plus `relationships`, `own_domains`, `directory.entries`, `default_views` and `inference`. A top-level key left out leaves that part of the workspace as it is. Collections are matched by their path of keys, so applying the same document twice changes nothing. DRY RUN BY DEFAULT: nothing is saved unless `dry_run` is false.",
15181
+ use: "the user wants collections created, renamed, re-sorted or limited from one document. First call with the default dry run, show the user what would change and, for each limit, how many documents it hides from how many people; apply with `dry_run: false` only after they agree.",
15182
+ not: "one document's labels or place (talonic_collections_set_labels, talonic_collections_move_document); one directory correction (talonic_collections_save_directory).",
15183
+ args: "`document` (the configuration object, `version: 1`) OR `yaml` (the same as YAML or JSON text); `dry_run` (default true); `prune` (true: remove keyed collections the document does not name; confirm each with the user).",
15184
+ returns: "{ dry_run, created[], changed[], removed[] (items like `collection <path>`, `limit <path>`, `relationship <slug>`), limits[] { path, documents_hidden, people_losing_access }, counts[] { path, documents } }.",
15185
+ errors: "400 with details.problems listing every problem, nothing changed; 403 not an Admin, or a key with no person changing `only`; 409 prune would remove a collection that still has a limit or documents placed by hand."
15186
+ }),
15187
+ route: "PUT /v1/collections/config",
15188
+ inputSchema: {
15189
+ document: z.record(z.string(), z.unknown()).optional().describe("The configuration document as an object (`version: 1`, `collections`, \u2026)."),
15190
+ yaml: z.string().min(1).max(1e6).optional().describe("The configuration document as YAML or JSON text (instead of `document`)."),
15191
+ dry_run: z.boolean().optional().describe("Default true: check and preview only. false saves the change."),
15192
+ prune: z.boolean().optional().describe("true: remove keyed collections the document does not name.")
15193
+ },
15194
+ annotations: write21(true, true),
15195
+ query: ["dry_run", "prune"],
15196
+ body: [...APPLY_BODY],
15197
+ handler: (ctx, args) => {
15198
+ const given = APPLY_BODY.filter((k) => args[k] !== void 0);
15199
+ if (given.length !== 1) {
15200
+ return Promise.resolve(
15201
+ validationError(
15202
+ "pass the configuration as `document` (an object) or as `yaml` (text), exactly one."
15203
+ )
15204
+ );
15205
+ }
15206
+ return runGroupTool({ ...applyConfig, handler: void 0 }, ctx, {
15207
+ ...args,
15208
+ dry_run: args["dry_run"] === false ? false : true
15209
+ });
15210
+ }
15211
+ };
15212
+ var setLabels = {
15213
+ name: "talonic_collections_set_labels",
15214
+ title: "Change a document's labels",
15215
+ description: describe({
15216
+ what: "Add and remove labels on one document by hand (such as `relationship:client` or `status:closed`). Labels set by a person are kept whenever the document's labels are derived again. The collections that sort by labels follow at once.",
15217
+ use: "a document sits in the wrong collection because a label is wrong or missing, and the user says what it should be.",
15218
+ not: "fixing who a party is for every document (talonic_collections_save_directory); taking a document out of one collection only (talonic_collections_move_document).",
15219
+ args: "`document_id`; `add` and / or `remove` (each at most 50 labels, `<kind>:<value>`).",
15220
+ returns: "{ effective[] } the document's labels after the change.",
15221
+ errors: "400 a label is not well-formed; 403 the change would move the document into or out of a limited collection the person may not manage; 404 the person may not read the document."
15222
+ }),
15223
+ route: "PATCH /v1/documents/{documentId}/traits",
15224
+ inputSchema: {
15225
+ document_id: documentId,
15226
+ add: labelList.describe("Labels to add, e.g. `relationship:client`."),
15227
+ remove: labelList.describe("Labels to remove.")
15228
+ },
15229
+ annotations: write21(true),
15230
+ body: ["add", "remove"],
15231
+ handler: (ctx, args) => {
15232
+ const n = (args["add"] ?? []).length + (args["remove"] ?? []).length;
15233
+ if (n === 0) return Promise.resolve(validationError("name labels to `add` or `remove`."));
15234
+ return runGroupTool({ ...setLabels, handler: void 0 }, ctx, args);
15235
+ }
15236
+ };
15237
+ var moveDocument = {
15238
+ name: "talonic_collections_move_document",
15239
+ title: "Move a document between collections",
15240
+ description: describe({
15241
+ what: "Take one document out of a collection (`from`), put it into one (`to`), or both. A collection that sorts by labels keeps the document out once it is moved out.",
15242
+ use: "the user says a document belongs in a different collection, or not in this one.",
15243
+ not: "changing why it was sorted there (talonic_collections_set_labels); adding many documents by hand (talonic_collections_add_documents).",
15244
+ args: "`document_id`; `from` and / or `to` (collection ids, from talonic_collections_list or talonic_collections_explain_document).",
15245
+ returns: "{ moved: true, from, to, still_matched_by_rule? } (still_matched_by_rule: another rule of `from` still holds the document).",
15246
+ errors: "403 a limited collection needs a person its limit admits or an owner, an enforced collection or an account needs an owner; 404 the person may not read the document, or it is not in `from`; 409 `from` holds it by another rule."
15247
+ }),
15248
+ route: "POST /v1/documents/{documentId}/move",
15249
+ inputSchema: {
15250
+ document_id: documentId,
15251
+ from: zUuid().optional().describe("The collection to take the document out of."),
15252
+ to: zUuid().optional().describe("The collection to put the document into.")
15253
+ },
15254
+ annotations: write21(false),
15255
+ body: ["from", "to"],
15256
+ handler: (ctx, args) => {
15257
+ if (!args["from"] && !args["to"]) {
15258
+ return Promise.resolve(validationError("name the collection to move `from`, `to`, or both."));
15259
+ }
15260
+ return runGroupTool({ ...moveDocument, handler: void 0 }, ctx, args);
15261
+ }
15262
+ };
15263
+ var saveDirectory = {
15264
+ name: "talonic_collections_save_directory",
15265
+ title: "Correct the relationship directory",
15266
+ description: describe({
15267
+ what: "Set directory entries as a person's correction (they outrank configuration, records and conversations for their identifier) and remove entries by id. The documents of every identifier touched are labelled again, which can move them into or out of limited collections.",
15268
+ use: "the user says what a party really is ('acme.com is a client, not a supplier'), or an entry is wrong and should go.",
15269
+ not: "one document only (talonic_collections_set_labels); the whole configuration (talonic_collections_apply_config).",
15270
+ args: "`entries[]` { match_value (`domain:acme.com`, `email:\u2026`, `phone:\u2026`, `handle:\u2026`, `entity:\u2026`), relationship (a kind's slug, or `own` / `other`) } (at most 200); `remove[]` (entry ids from talonic_collections_list_directory, at most 200); `wait` (true: wait up to 60 seconds for the documents to be labelled again).",
15271
+ returns: "{ saved, removed, pending } (pending: documents still to be labelled again).",
15272
+ errors: "403 the person is not an Admin of the workspace; 404 an entry id to remove does not exist."
15273
+ }),
15274
+ route: "PUT /v1/collections/directory",
15275
+ inputSchema: {
15276
+ entries: z.array(
15277
+ z.object({
15278
+ match_value: z.string().min(1).max(320).describe("A typed identifier, e.g. `domain:acme.com`."),
15279
+ relationship: z.string().min(1).max(64).describe("A relationship kind's slug, or `own` / `other`.")
15280
+ })
15281
+ ).max(200).optional().describe("Entries to set."),
15282
+ remove: z.array(zUuid()).max(200).optional().describe("Entry ids to remove."),
15283
+ wait: z.boolean().optional().describe("Wait up to 60 seconds for relabelling.")
15284
+ },
15285
+ annotations: write21(true, true),
15286
+ body: ["entries", "remove", "wait"],
15287
+ handler: (ctx, args) => {
15288
+ const n = (args["entries"] ?? []).length + (args["remove"] ?? []).length;
15289
+ if (n === 0) {
15290
+ return Promise.resolve(validationError("name `entries` to set or entry ids to `remove`."));
15291
+ }
15292
+ return runGroupTool({ ...saveDirectory, handler: void 0 }, ctx, args);
15293
+ }
15294
+ };
15295
+ var collectionsConfigGroup = {
15296
+ key: "collections_config",
15297
+ label: "Collections configuration and sorting",
15298
+ docsSlug: "collections-config-tools",
15299
+ probe: { path: "/v1/collections/config" },
15300
+ tools: [
15301
+ {
15302
+ name: "talonic_collections_get_config",
15303
+ title: "Collections configuration",
15304
+ description: describe({
15305
+ what: "The workspace's collections as one configuration document: each collection that has a `key` with its name, the labels it sorts by (`match`, or `any` for several label sets) and its children, plus the relationship kinds, own domains and whether relationships may be inferred. Who may read a limited collection (`only`), the directory's configured entries and the default views appear for a workspace owner only.",
15306
+ use: "the user asks how documents are sorted into collections, or wants to change it: read this first, edit it, then talonic_collections_apply_config.",
15307
+ not: "the plain list of collections with counts (talonic_collections_list); a first draft for a workspace that has none (talonic_collections_propose).",
15308
+ returns: "{ version, inference?, own_domains[]?, relationships[] { slug, name, meaning?, scope?, source_values[]? }, directory? { entries[] { id, relationship } }, collections[] { key, name, description?, match[]? | any[][]?, only?, children[]? }, default_views[]? }."
15309
+ }),
15310
+ route: "GET /v1/collections/config",
15311
+ inputSchema: {},
15312
+ annotations: READ
15313
+ },
15314
+ applyConfig,
15315
+ {
15316
+ name: "talonic_collections_propose",
15317
+ title: "Propose a collections configuration",
15318
+ description: describe({
15319
+ what: "A configuration document built from the workspace's own documents, as far as the person may read them: one top-level collection per channel with documents, children for the labels common enough to be worth one, and suggested relationship kinds from the most frequent outside organisations when the workspace has conversations and fewer than two kinds. Saves nothing and never proposes a limit.",
15320
+ use: "setting up collections for the first time, or the user asks what a sensible structure would be. Show it, let the user edit it, then talonic_collections_apply_config.",
15321
+ not: "the configuration in force now (talonic_collections_get_config).",
15322
+ returns: "The proposed document in the shape talonic_collections_get_config returns ({ version: 1, relationships[]?, collections[] }).",
15323
+ errors: "403 the person is not an Admin of the workspace."
15324
+ }),
15325
+ route: "POST /v1/collections/proposal",
15326
+ inputSchema: {},
15327
+ annotations: READ
15328
+ },
15329
+ {
15330
+ name: "talonic_collections_explain_document",
15331
+ title: "Why a document sits in its collections",
15332
+ description: describe({
15333
+ what: "Why one document sits where it does: each of its labels, whether it was derived or set by a person, with the evidence the person may see behind it, the labels a person removed, and each collection it is in with why (`rule`, `hand`, or `held` by a limit while its labels settle).",
15334
+ use: "'why is this document in Clients', 'why can't Anna see this', or before correcting a label or moving the document.",
15335
+ not: "the documents of a collection (talonic_collections_preview).",
15336
+ args: "`document_id`.",
15337
+ returns: "{ document_id, pending, unresolved, labels[] { label, origin: derived|person, evidence[]? { party, source, relationship?, quote? } }, removed[], collections[] { id, name, path, why } }.",
15338
+ errors: "404 the person may not read the document."
15339
+ }),
15340
+ route: "GET /v1/documents/{documentId}/collections",
15341
+ inputSchema: { document_id: documentId },
15342
+ annotations: READ
15343
+ },
15344
+ setLabels,
15345
+ moveDocument,
15346
+ {
15347
+ name: "talonic_collections_set_parties",
15348
+ title: "Set a document's parties",
15349
+ description: describe({
15350
+ what: "Hand over one document's parties as your system has them, the way a connected mailbox does at import: typed identifiers with an optional role, and whether the list is complete. The document's labels are derived again at once. Only a complete list whose every party is the workspace's own makes a document internal. A party nobody in the directory knows yet may leave the document pending for a short while, and it stays under every limit meanwhile.",
15351
+ use: "documents uploaded through the API whose sender and recipients are known to the caller, so they sort like mail.",
15352
+ not: "saying what a party is to the workspace (talonic_collections_save_directory); changing labels directly (talonic_collections_set_labels).",
15353
+ args: "`document_id`; `parties[]` { id (`email:jane@acme.com`, `domain:acme.com`, `phone:+4930123456`, `handle:<scope>:<id>` or `entity:<id>`; a bare address reads as email), role? from|to|cc|attendee|author } (at most 500); `complete` (true: these are all the parties).",
15354
+ returns: "{ document_id, parties[], pending }.",
15355
+ errors: "400 a malformed party; 404 the person may not read the document."
15356
+ }),
15357
+ route: "PUT /v1/documents/{documentId}/parties",
15358
+ inputSchema: {
15359
+ document_id: documentId,
15360
+ parties: z.array(
15361
+ z.object({
15362
+ id: z.string().min(1).max(320).describe("A typed identifier, e.g. `email:jane@acme.com`."),
15363
+ role: z.enum(["from", "to", "cc", "attendee", "author"]).optional()
15364
+ })
15365
+ ).max(500).describe("The document's parties."),
15366
+ complete: z.boolean().optional().describe("true: the list names every party.")
15367
+ },
15368
+ annotations: write21(true),
15369
+ body: ["parties", "complete"]
15370
+ },
15371
+ {
15372
+ name: "talonic_collections_list_directory",
15373
+ title: "Relationship directory",
15374
+ description: describe({
15375
+ what: "Who is who: each identifier (an address, a domain, a phone number, a handle) with what that party is to the workspace (a relationship kind such as `client`, or `own` / `other`) and where that came from (`person`, `config`, `record` or `read`). Each entry is shown only where the person may see its evidence.",
15376
+ use: "'why is acme.com treated as a supplier', or before correcting an entry.",
15377
+ returns: "{ entries[] { id, match_value, relationship, source, origin, labels[]?, evidence, created_at, updated_at } }."
15378
+ }),
15379
+ route: "GET /v1/collections/directory",
15380
+ inputSchema: {},
15381
+ annotations: READ
15382
+ },
15383
+ saveDirectory
15384
+ ]
15385
+ };
15173
15386
  var COMPLIANCE_EXPORT_MAX_BYTES = 8 * 1024 * 1024;
15174
15387
  var docIds = (min, max, what) => z.array(zUuid()).min(min).max(max).describe(what);
15175
15388
  var pageArgs3 = {
@@ -16232,7 +16445,7 @@ var DELETE_SCHEMA = describe({
16232
16445
  returns: "{ deleted: true, id }.",
16233
16446
  errors: "404 unknown schema; 409 the schema is managed by a Spec."
16234
16447
  });
16235
- var documentId = { document_id: zUuid().describe("The document id.") };
16448
+ var documentId2 = { document_id: zUuid().describe("The document id.") };
16236
16449
  var extractionId = {
16237
16450
  extraction_id: zUuid().describe("The extraction id (the same as its document's id).")
16238
16451
  };
@@ -16348,7 +16561,7 @@ var dataManagementGroup = {
16348
16561
  title: "Re-extract a document",
16349
16562
  description: REEXTRACT,
16350
16563
  route: "POST /v1/documents/{documentId}/re-extract",
16351
- inputSchema: documentId,
16564
+ inputSchema: documentId2,
16352
16565
  annotations: write21(false)
16353
16566
  },
16354
16567
  {
@@ -16356,7 +16569,7 @@ var dataManagementGroup = {
16356
16569
  title: "Delete a document",
16357
16570
  description: DELETE_DOCUMENT,
16358
16571
  route: "DELETE /v1/documents/{documentId}",
16359
- inputSchema: documentId,
16572
+ inputSchema: documentId2,
16360
16573
  annotations: write21(true, true)
16361
16574
  },
16362
16575
  {
@@ -16606,7 +16819,7 @@ var moneyFoundGroup = {
16606
16819
  ]
16607
16820
  };
16608
16821
  var folderId = zUuid().describe("The folder id (talonic_transport_folders_list or _worklist).");
16609
- var documentId2 = zUuid().describe("The document id, from the folder's documents.");
16822
+ var documentId3 = zUuid().describe("The document id, from the folder's documents.");
16610
16823
  var loadKey = z.string().min(1).max(200).describe("The load key, from the folder's loads.");
16611
16824
  var DETAIL_RETURNS = "the folder as talonic_transport_folders_get returns it, after the change: { id, folder_key, status, loads[] { key, verdict complete|check|missing, flags[], comparison[], handover[], confirmed }, documents[] { id, type, status auto|manual|folder|internal|review|pending, load_key, suggested_load_key, candidates[] }, \u2026 }.";
16612
16825
  var HANDOVER_MAX_BYTES = 8 * 1024 * 1024;
@@ -16721,7 +16934,7 @@ var transportFoldersGroup = {
16721
16934
  returns: "{ document_id, pages[], boxes[] { field, value, page, x, y, w, h } }."
16722
16935
  }),
16723
16936
  route: "GET /v1/transport-folders/{folderId}/documents/{documentId}/boxes",
16724
- inputSchema: { folder_id: folderId, document_id: documentId2 },
16937
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16725
16938
  annotations: READ
16726
16939
  },
16727
16940
  {
@@ -16735,7 +16948,7 @@ var transportFoldersGroup = {
16735
16948
  returns: "the document's boxes, as talonic_transport_folders_boxes returns them."
16736
16949
  }),
16737
16950
  route: "POST /v1/transport-folders/{folderId}/documents/{documentId}/locate",
16738
- inputSchema: { folder_id: folderId, document_id: documentId2 },
16951
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16739
16952
  annotations: write21(true)
16740
16953
  },
16741
16954
  {
@@ -16766,7 +16979,7 @@ var transportFoldersGroup = {
16766
16979
  route: "POST /v1/transport-folders/{folderId}/documents/{documentId}/assign",
16767
16980
  inputSchema: {
16768
16981
  folder_id: folderId,
16769
- document_id: documentId2,
16982
+ document_id: documentId3,
16770
16983
  load_key: z.string().max(200).nullable().describe("The load the document belongs to; null = it belongs to no load.")
16771
16984
  },
16772
16985
  annotations: write21(true),
@@ -16782,7 +16995,7 @@ var transportFoldersGroup = {
16782
16995
  returns: DETAIL_RETURNS
16783
16996
  }),
16784
16997
  route: "DELETE /v1/transport-folders/{folderId}/documents/{documentId}/assign",
16785
- inputSchema: { folder_id: folderId, document_id: documentId2 },
16998
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16786
16999
  annotations: write21(true)
16787
17000
  },
16788
17001
  {
@@ -16858,7 +17071,8 @@ var TOOL_GROUPS = [
16858
17071
  transportFoldersGroup,
16859
17072
  complianceGroup,
16860
17073
  moneyFoundGroup,
16861
- customsDeclarationGroup
17074
+ customsDeclarationGroup,
17075
+ collectionsConfigGroup
16862
17076
  ];
16863
17077
  TOOL_GROUPS.map((g) => g.key);
16864
17078
  function registerToolGroups(server, keys, getToken, baseUrl) {
@@ -17914,7 +18128,7 @@ function registerOperationsTools(server, getToken, baseUrl, families) {
17914
18128
 
17915
18129
  // package.json
17916
18130
  var package_default = {
17917
- version: "0.1.107"};
18131
+ version: "0.1.108"};
17918
18132
 
17919
18133
  // src/version.ts
17920
18134
  var VERSION = package_default.version;