@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.
package/dist/server.js CHANGED
@@ -13736,8 +13736,8 @@ async function handleToMarkdown(talonic, args, opts = {}) {
13736
13736
  retryable: false
13737
13737
  });
13738
13738
  }
13739
- let documentId3 = args.document_id;
13740
- if (!documentId3) {
13739
+ let documentId4 = args.document_id;
13740
+ if (!documentId4) {
13741
13741
  const ingest = await talonic.extract({
13742
13742
  ...args.file_data !== void 0 ? {
13743
13743
  file: Buffer.from(args.file_data, "base64"),
@@ -13747,9 +13747,9 @@ async function handleToMarkdown(talonic, args, opts = {}) {
13747
13747
  ...args.file_url !== void 0 ? { file_url: args.file_url } : {},
13748
13748
  schema: INGEST_ONLY_SCHEMA
13749
13749
  });
13750
- documentId3 = ingest.document.id;
13750
+ documentId4 = ingest.document.id;
13751
13751
  }
13752
- const result = await talonic.documents.getMarkdown(documentId3);
13752
+ const result = await talonic.documents.getMarkdown(documentId4);
13753
13753
  return jsonOk(result);
13754
13754
  } catch (err) {
13755
13755
  return toolError(err);
@@ -15336,6 +15336,219 @@ var aggregateGroup = {
15336
15336
  aggregateTool
15337
15337
  ]
15338
15338
  };
15339
+ var documentId = zUuid().describe("The document id.");
15340
+ var labelList = z.array(z.string().min(1).max(200)).max(50).optional();
15341
+ var APPLY_BODY = ["document", "yaml"];
15342
+ var applyConfig = {
15343
+ name: "talonic_collections_apply_config",
15344
+ title: "Apply the collections configuration",
15345
+ description: describe({
15346
+ 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.",
15347
+ 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.",
15348
+ not: "one document's labels or place (talonic_collections_set_labels, talonic_collections_move_document); one directory correction (talonic_collections_save_directory).",
15349
+ 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).",
15350
+ returns: "{ dry_run, created[], changed[], removed[] (items like `collection <path>`, `limit <path>`, `relationship <slug>`), limits[] { path, documents_hidden, people_losing_access }, counts[] { path, documents } }.",
15351
+ 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."
15352
+ }),
15353
+ route: "PUT /v1/collections/config",
15354
+ inputSchema: {
15355
+ document: z.record(z.string(), z.unknown()).optional().describe("The configuration document as an object (`version: 1`, `collections`, \u2026)."),
15356
+ yaml: z.string().min(1).max(1e6).optional().describe("The configuration document as YAML or JSON text (instead of `document`)."),
15357
+ dry_run: z.boolean().optional().describe("Default true: check and preview only. false saves the change."),
15358
+ prune: z.boolean().optional().describe("true: remove keyed collections the document does not name.")
15359
+ },
15360
+ annotations: write21(true, true),
15361
+ query: ["dry_run", "prune"],
15362
+ body: [...APPLY_BODY],
15363
+ handler: (ctx, args) => {
15364
+ const given = APPLY_BODY.filter((k) => args[k] !== void 0);
15365
+ if (given.length !== 1) {
15366
+ return Promise.resolve(
15367
+ validationError(
15368
+ "pass the configuration as `document` (an object) or as `yaml` (text), exactly one."
15369
+ )
15370
+ );
15371
+ }
15372
+ return runGroupTool({ ...applyConfig, handler: void 0 }, ctx, {
15373
+ ...args,
15374
+ dry_run: args["dry_run"] === false ? false : true
15375
+ });
15376
+ }
15377
+ };
15378
+ var setLabels = {
15379
+ name: "talonic_collections_set_labels",
15380
+ title: "Change a document's labels",
15381
+ description: describe({
15382
+ 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.",
15383
+ use: "a document sits in the wrong collection because a label is wrong or missing, and the user says what it should be.",
15384
+ 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).",
15385
+ args: "`document_id`; `add` and / or `remove` (each at most 50 labels, `<kind>:<value>`).",
15386
+ returns: "{ effective[] } the document's labels after the change.",
15387
+ 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."
15388
+ }),
15389
+ route: "PATCH /v1/documents/{documentId}/traits",
15390
+ inputSchema: {
15391
+ document_id: documentId,
15392
+ add: labelList.describe("Labels to add, e.g. `relationship:client`."),
15393
+ remove: labelList.describe("Labels to remove.")
15394
+ },
15395
+ annotations: write21(true),
15396
+ body: ["add", "remove"],
15397
+ handler: (ctx, args) => {
15398
+ const n = (args["add"] ?? []).length + (args["remove"] ?? []).length;
15399
+ if (n === 0) return Promise.resolve(validationError("name labels to `add` or `remove`."));
15400
+ return runGroupTool({ ...setLabels, handler: void 0 }, ctx, args);
15401
+ }
15402
+ };
15403
+ var moveDocument = {
15404
+ name: "talonic_collections_move_document",
15405
+ title: "Move a document between collections",
15406
+ description: describe({
15407
+ 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.",
15408
+ use: "the user says a document belongs in a different collection, or not in this one.",
15409
+ not: "changing why it was sorted there (talonic_collections_set_labels); adding many documents by hand (talonic_collections_add_documents).",
15410
+ args: "`document_id`; `from` and / or `to` (collection ids, from talonic_collections_list or talonic_collections_explain_document).",
15411
+ returns: "{ moved: true, from, to, still_matched_by_rule? } (still_matched_by_rule: another rule of `from` still holds the document).",
15412
+ 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."
15413
+ }),
15414
+ route: "POST /v1/documents/{documentId}/move",
15415
+ inputSchema: {
15416
+ document_id: documentId,
15417
+ from: zUuid().optional().describe("The collection to take the document out of."),
15418
+ to: zUuid().optional().describe("The collection to put the document into.")
15419
+ },
15420
+ annotations: write21(false),
15421
+ body: ["from", "to"],
15422
+ handler: (ctx, args) => {
15423
+ if (!args["from"] && !args["to"]) {
15424
+ return Promise.resolve(validationError("name the collection to move `from`, `to`, or both."));
15425
+ }
15426
+ return runGroupTool({ ...moveDocument, handler: void 0 }, ctx, args);
15427
+ }
15428
+ };
15429
+ var saveDirectory = {
15430
+ name: "talonic_collections_save_directory",
15431
+ title: "Correct the relationship directory",
15432
+ description: describe({
15433
+ 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.",
15434
+ 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.",
15435
+ not: "one document only (talonic_collections_set_labels); the whole configuration (talonic_collections_apply_config).",
15436
+ 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).",
15437
+ returns: "{ saved, removed, pending } (pending: documents still to be labelled again).",
15438
+ errors: "403 the person is not an Admin of the workspace; 404 an entry id to remove does not exist."
15439
+ }),
15440
+ route: "PUT /v1/collections/directory",
15441
+ inputSchema: {
15442
+ entries: z.array(
15443
+ z.object({
15444
+ match_value: z.string().min(1).max(320).describe("A typed identifier, e.g. `domain:acme.com`."),
15445
+ relationship: z.string().min(1).max(64).describe("A relationship kind's slug, or `own` / `other`.")
15446
+ })
15447
+ ).max(200).optional().describe("Entries to set."),
15448
+ remove: z.array(zUuid()).max(200).optional().describe("Entry ids to remove."),
15449
+ wait: z.boolean().optional().describe("Wait up to 60 seconds for relabelling.")
15450
+ },
15451
+ annotations: write21(true, true),
15452
+ body: ["entries", "remove", "wait"],
15453
+ handler: (ctx, args) => {
15454
+ const n = (args["entries"] ?? []).length + (args["remove"] ?? []).length;
15455
+ if (n === 0) {
15456
+ return Promise.resolve(validationError("name `entries` to set or entry ids to `remove`."));
15457
+ }
15458
+ return runGroupTool({ ...saveDirectory, handler: void 0 }, ctx, args);
15459
+ }
15460
+ };
15461
+ var collectionsConfigGroup = {
15462
+ key: "collections_config",
15463
+ label: "Collections configuration and sorting",
15464
+ docsSlug: "collections-config-tools",
15465
+ probe: { path: "/v1/collections/config" },
15466
+ tools: [
15467
+ {
15468
+ name: "talonic_collections_get_config",
15469
+ title: "Collections configuration",
15470
+ description: describe({
15471
+ 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.",
15472
+ 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.",
15473
+ not: "the plain list of collections with counts (talonic_collections_list); a first draft for a workspace that has none (talonic_collections_propose).",
15474
+ 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[]? }."
15475
+ }),
15476
+ route: "GET /v1/collections/config",
15477
+ inputSchema: {},
15478
+ annotations: READ
15479
+ },
15480
+ applyConfig,
15481
+ {
15482
+ name: "talonic_collections_propose",
15483
+ title: "Propose a collections configuration",
15484
+ description: describe({
15485
+ 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.",
15486
+ 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.",
15487
+ not: "the configuration in force now (talonic_collections_get_config).",
15488
+ returns: "The proposed document in the shape talonic_collections_get_config returns ({ version: 1, relationships[]?, collections[] }).",
15489
+ errors: "403 the person is not an Admin of the workspace."
15490
+ }),
15491
+ route: "POST /v1/collections/proposal",
15492
+ inputSchema: {},
15493
+ annotations: READ
15494
+ },
15495
+ {
15496
+ name: "talonic_collections_explain_document",
15497
+ title: "Why a document sits in its collections",
15498
+ description: describe({
15499
+ 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).",
15500
+ use: "'why is this document in Clients', 'why can't Anna see this', or before correcting a label or moving the document.",
15501
+ not: "the documents of a collection (talonic_collections_preview).",
15502
+ args: "`document_id`.",
15503
+ returns: "{ document_id, pending, unresolved, labels[] { label, origin: derived|person, evidence[]? { party, source, relationship?, quote? } }, removed[], collections[] { id, name, path, why } }.",
15504
+ errors: "404 the person may not read the document."
15505
+ }),
15506
+ route: "GET /v1/documents/{documentId}/collections",
15507
+ inputSchema: { document_id: documentId },
15508
+ annotations: READ
15509
+ },
15510
+ setLabels,
15511
+ moveDocument,
15512
+ {
15513
+ name: "talonic_collections_set_parties",
15514
+ title: "Set a document's parties",
15515
+ description: describe({
15516
+ 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.",
15517
+ use: "documents uploaded through the API whose sender and recipients are known to the caller, so they sort like mail.",
15518
+ not: "saying what a party is to the workspace (talonic_collections_save_directory); changing labels directly (talonic_collections_set_labels).",
15519
+ 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).",
15520
+ returns: "{ document_id, parties[], pending }.",
15521
+ errors: "400 a malformed party; 404 the person may not read the document."
15522
+ }),
15523
+ route: "PUT /v1/documents/{documentId}/parties",
15524
+ inputSchema: {
15525
+ document_id: documentId,
15526
+ parties: z.array(
15527
+ z.object({
15528
+ id: z.string().min(1).max(320).describe("A typed identifier, e.g. `email:jane@acme.com`."),
15529
+ role: z.enum(["from", "to", "cc", "attendee", "author"]).optional()
15530
+ })
15531
+ ).max(500).describe("The document's parties."),
15532
+ complete: z.boolean().optional().describe("true: the list names every party.")
15533
+ },
15534
+ annotations: write21(true),
15535
+ body: ["parties", "complete"]
15536
+ },
15537
+ {
15538
+ name: "talonic_collections_list_directory",
15539
+ title: "Relationship directory",
15540
+ description: describe({
15541
+ 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.",
15542
+ use: "'why is acme.com treated as a supplier', or before correcting an entry.",
15543
+ returns: "{ entries[] { id, match_value, relationship, source, origin, labels[]?, evidence, created_at, updated_at } }."
15544
+ }),
15545
+ route: "GET /v1/collections/directory",
15546
+ inputSchema: {},
15547
+ annotations: READ
15548
+ },
15549
+ saveDirectory
15550
+ ]
15551
+ };
15339
15552
  var COMPLIANCE_EXPORT_MAX_BYTES = 8 * 1024 * 1024;
15340
15553
  var docIds = (min, max, what) => z.array(zUuid()).min(min).max(max).describe(what);
15341
15554
  var pageArgs3 = {
@@ -16398,7 +16611,7 @@ var DELETE_SCHEMA = describe({
16398
16611
  returns: "{ deleted: true, id }.",
16399
16612
  errors: "404 unknown schema; 409 the schema is managed by a Spec."
16400
16613
  });
16401
- var documentId = { document_id: zUuid().describe("The document id.") };
16614
+ var documentId2 = { document_id: zUuid().describe("The document id.") };
16402
16615
  var extractionId = {
16403
16616
  extraction_id: zUuid().describe("The extraction id (the same as its document's id).")
16404
16617
  };
@@ -16514,7 +16727,7 @@ var dataManagementGroup = {
16514
16727
  title: "Re-extract a document",
16515
16728
  description: REEXTRACT,
16516
16729
  route: "POST /v1/documents/{documentId}/re-extract",
16517
- inputSchema: documentId,
16730
+ inputSchema: documentId2,
16518
16731
  annotations: write21(false)
16519
16732
  },
16520
16733
  {
@@ -16522,7 +16735,7 @@ var dataManagementGroup = {
16522
16735
  title: "Delete a document",
16523
16736
  description: DELETE_DOCUMENT,
16524
16737
  route: "DELETE /v1/documents/{documentId}",
16525
- inputSchema: documentId,
16738
+ inputSchema: documentId2,
16526
16739
  annotations: write21(true, true)
16527
16740
  },
16528
16741
  {
@@ -16772,7 +16985,7 @@ var moneyFoundGroup = {
16772
16985
  ]
16773
16986
  };
16774
16987
  var folderId = zUuid().describe("The folder id (talonic_transport_folders_list or _worklist).");
16775
- var documentId2 = zUuid().describe("The document id, from the folder's documents.");
16988
+ var documentId3 = zUuid().describe("The document id, from the folder's documents.");
16776
16989
  var loadKey = z.string().min(1).max(200).describe("The load key, from the folder's loads.");
16777
16990
  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 }.";
16778
16991
  var HANDOVER_MAX_BYTES = 8 * 1024 * 1024;
@@ -16887,7 +17100,7 @@ var transportFoldersGroup = {
16887
17100
  returns: "{ document_id, pages[], boxes[] { field, value, page, x, y, w, h } }."
16888
17101
  }),
16889
17102
  route: "GET /v1/transport-folders/{folderId}/documents/{documentId}/boxes",
16890
- inputSchema: { folder_id: folderId, document_id: documentId2 },
17103
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16891
17104
  annotations: READ
16892
17105
  },
16893
17106
  {
@@ -16901,7 +17114,7 @@ var transportFoldersGroup = {
16901
17114
  returns: "the document's boxes, as talonic_transport_folders_boxes returns them."
16902
17115
  }),
16903
17116
  route: "POST /v1/transport-folders/{folderId}/documents/{documentId}/locate",
16904
- inputSchema: { folder_id: folderId, document_id: documentId2 },
17117
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16905
17118
  annotations: write21(true)
16906
17119
  },
16907
17120
  {
@@ -16932,7 +17145,7 @@ var transportFoldersGroup = {
16932
17145
  route: "POST /v1/transport-folders/{folderId}/documents/{documentId}/assign",
16933
17146
  inputSchema: {
16934
17147
  folder_id: folderId,
16935
- document_id: documentId2,
17148
+ document_id: documentId3,
16936
17149
  load_key: z.string().max(200).nullable().describe("The load the document belongs to; null = it belongs to no load.")
16937
17150
  },
16938
17151
  annotations: write21(true),
@@ -16948,7 +17161,7 @@ var transportFoldersGroup = {
16948
17161
  returns: DETAIL_RETURNS
16949
17162
  }),
16950
17163
  route: "DELETE /v1/transport-folders/{folderId}/documents/{documentId}/assign",
16951
- inputSchema: { folder_id: folderId, document_id: documentId2 },
17164
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16952
17165
  annotations: write21(true)
16953
17166
  },
16954
17167
  {
@@ -17024,7 +17237,8 @@ var TOOL_GROUPS = [
17024
17237
  transportFoldersGroup,
17025
17238
  complianceGroup,
17026
17239
  moneyFoundGroup,
17027
- customsDeclarationGroup
17240
+ customsDeclarationGroup,
17241
+ collectionsConfigGroup
17028
17242
  ];
17029
17243
  TOOL_GROUPS.map((g) => g.key);
17030
17244
  async function probeToolGroups(token, baseUrl) {
@@ -18092,7 +18306,7 @@ function registerOperationsTools(server, getToken, baseUrl, families) {
18092
18306
 
18093
18307
  // package.json
18094
18308
  var package_default = {
18095
- version: "0.1.107"};
18309
+ version: "0.1.108"};
18096
18310
 
18097
18311
  // src/version.ts
18098
18312
  var VERSION = package_default.version;