@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/index.d.ts CHANGED
@@ -196,7 +196,8 @@ interface CreateServerOptions {
196
196
  /**
197
197
  * Keys of the probe-gated tool groups to register (`src/tools/tool-groups.ts`:
198
198
  * `data_management`, `events`, `aggregate`, `admin`, `contract_desk`,
199
- * `transport_folders`, `compliance`, `money_found`, `customs_declaration`).
199
+ * `transport_folders`, `compliance`, `money_found`, `customs_declaration`,
200
+ * `collections_config`).
200
201
  * Callers pass only the keys whose probe passed for the session's
201
202
  * credential (`probeToolGroups` at stdio boot, `toolGroupsAccessCached`
202
203
  * hosted). Listing visibility only; the platform authorizes every call.
package/dist/index.js CHANGED
@@ -13502,8 +13502,8 @@ async function handleToMarkdown(talonic, args, opts = {}) {
13502
13502
  retryable: false
13503
13503
  });
13504
13504
  }
13505
- let documentId3 = args.document_id;
13506
- if (!documentId3) {
13505
+ let documentId4 = args.document_id;
13506
+ if (!documentId4) {
13507
13507
  const ingest = await talonic.extract({
13508
13508
  ...args.file_data !== void 0 ? {
13509
13509
  file: Buffer.from(args.file_data, "base64"),
@@ -13513,9 +13513,9 @@ async function handleToMarkdown(talonic, args, opts = {}) {
13513
13513
  ...args.file_url !== void 0 ? { file_url: args.file_url } : {},
13514
13514
  schema: INGEST_ONLY_SCHEMA
13515
13515
  });
13516
- documentId3 = ingest.document.id;
13516
+ documentId4 = ingest.document.id;
13517
13517
  }
13518
- const result = await talonic.documents.getMarkdown(documentId3);
13518
+ const result = await talonic.documents.getMarkdown(documentId4);
13519
13519
  return jsonOk(result);
13520
13520
  } catch (err) {
13521
13521
  return toolError(err);
@@ -15088,6 +15088,219 @@ var aggregateGroup = {
15088
15088
  aggregateTool
15089
15089
  ]
15090
15090
  };
15091
+ var documentId = zUuid().describe("The document id.");
15092
+ var labelList = z.array(z.string().min(1).max(200)).max(50).optional();
15093
+ var APPLY_BODY = ["document", "yaml"];
15094
+ var applyConfig = {
15095
+ name: "talonic_collections_apply_config",
15096
+ title: "Apply the collections configuration",
15097
+ description: describe({
15098
+ 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.",
15099
+ 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.",
15100
+ not: "one document's labels or place (talonic_collections_set_labels, talonic_collections_move_document); one directory correction (talonic_collections_save_directory).",
15101
+ 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).",
15102
+ returns: "{ dry_run, created[], changed[], removed[] (items like `collection <path>`, `limit <path>`, `relationship <slug>`), limits[] { path, documents_hidden, people_losing_access }, counts[] { path, documents } }.",
15103
+ 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."
15104
+ }),
15105
+ route: "PUT /v1/collections/config",
15106
+ inputSchema: {
15107
+ document: z.record(z.string(), z.unknown()).optional().describe("The configuration document as an object (`version: 1`, `collections`, \u2026)."),
15108
+ yaml: z.string().min(1).max(1e6).optional().describe("The configuration document as YAML or JSON text (instead of `document`)."),
15109
+ dry_run: z.boolean().optional().describe("Default true: check and preview only. false saves the change."),
15110
+ prune: z.boolean().optional().describe("true: remove keyed collections the document does not name.")
15111
+ },
15112
+ annotations: write21(true, true),
15113
+ query: ["dry_run", "prune"],
15114
+ body: [...APPLY_BODY],
15115
+ handler: (ctx, args) => {
15116
+ const given = APPLY_BODY.filter((k) => args[k] !== void 0);
15117
+ if (given.length !== 1) {
15118
+ return Promise.resolve(
15119
+ validationError(
15120
+ "pass the configuration as `document` (an object) or as `yaml` (text), exactly one."
15121
+ )
15122
+ );
15123
+ }
15124
+ return runGroupTool({ ...applyConfig, handler: void 0 }, ctx, {
15125
+ ...args,
15126
+ dry_run: args["dry_run"] === false ? false : true
15127
+ });
15128
+ }
15129
+ };
15130
+ var setLabels = {
15131
+ name: "talonic_collections_set_labels",
15132
+ title: "Change a document's labels",
15133
+ description: describe({
15134
+ 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.",
15135
+ use: "a document sits in the wrong collection because a label is wrong or missing, and the user says what it should be.",
15136
+ 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).",
15137
+ args: "`document_id`; `add` and / or `remove` (each at most 50 labels, `<kind>:<value>`).",
15138
+ returns: "{ effective[] } the document's labels after the change.",
15139
+ 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."
15140
+ }),
15141
+ route: "PATCH /v1/documents/{documentId}/traits",
15142
+ inputSchema: {
15143
+ document_id: documentId,
15144
+ add: labelList.describe("Labels to add, e.g. `relationship:client`."),
15145
+ remove: labelList.describe("Labels to remove.")
15146
+ },
15147
+ annotations: write21(true),
15148
+ body: ["add", "remove"],
15149
+ handler: (ctx, args) => {
15150
+ const n = (args["add"] ?? []).length + (args["remove"] ?? []).length;
15151
+ if (n === 0) return Promise.resolve(validationError("name labels to `add` or `remove`."));
15152
+ return runGroupTool({ ...setLabels, handler: void 0 }, ctx, args);
15153
+ }
15154
+ };
15155
+ var moveDocument = {
15156
+ name: "talonic_collections_move_document",
15157
+ title: "Move a document between collections",
15158
+ description: describe({
15159
+ 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.",
15160
+ use: "the user says a document belongs in a different collection, or not in this one.",
15161
+ not: "changing why it was sorted there (talonic_collections_set_labels); adding many documents by hand (talonic_collections_add_documents).",
15162
+ args: "`document_id`; `from` and / or `to` (collection ids, from talonic_collections_list or talonic_collections_explain_document).",
15163
+ returns: "{ moved: true, from, to, still_matched_by_rule? } (still_matched_by_rule: another rule of `from` still holds the document).",
15164
+ 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."
15165
+ }),
15166
+ route: "POST /v1/documents/{documentId}/move",
15167
+ inputSchema: {
15168
+ document_id: documentId,
15169
+ from: zUuid().optional().describe("The collection to take the document out of."),
15170
+ to: zUuid().optional().describe("The collection to put the document into.")
15171
+ },
15172
+ annotations: write21(false),
15173
+ body: ["from", "to"],
15174
+ handler: (ctx, args) => {
15175
+ if (!args["from"] && !args["to"]) {
15176
+ return Promise.resolve(validationError("name the collection to move `from`, `to`, or both."));
15177
+ }
15178
+ return runGroupTool({ ...moveDocument, handler: void 0 }, ctx, args);
15179
+ }
15180
+ };
15181
+ var saveDirectory = {
15182
+ name: "talonic_collections_save_directory",
15183
+ title: "Correct the relationship directory",
15184
+ description: describe({
15185
+ 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.",
15186
+ 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.",
15187
+ not: "one document only (talonic_collections_set_labels); the whole configuration (talonic_collections_apply_config).",
15188
+ 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).",
15189
+ returns: "{ saved, removed, pending } (pending: documents still to be labelled again).",
15190
+ errors: "403 the person is not an Admin of the workspace; 404 an entry id to remove does not exist."
15191
+ }),
15192
+ route: "PUT /v1/collections/directory",
15193
+ inputSchema: {
15194
+ entries: z.array(
15195
+ z.object({
15196
+ match_value: z.string().min(1).max(320).describe("A typed identifier, e.g. `domain:acme.com`."),
15197
+ relationship: z.string().min(1).max(64).describe("A relationship kind's slug, or `own` / `other`.")
15198
+ })
15199
+ ).max(200).optional().describe("Entries to set."),
15200
+ remove: z.array(zUuid()).max(200).optional().describe("Entry ids to remove."),
15201
+ wait: z.boolean().optional().describe("Wait up to 60 seconds for relabelling.")
15202
+ },
15203
+ annotations: write21(true, true),
15204
+ body: ["entries", "remove", "wait"],
15205
+ handler: (ctx, args) => {
15206
+ const n = (args["entries"] ?? []).length + (args["remove"] ?? []).length;
15207
+ if (n === 0) {
15208
+ return Promise.resolve(validationError("name `entries` to set or entry ids to `remove`."));
15209
+ }
15210
+ return runGroupTool({ ...saveDirectory, handler: void 0 }, ctx, args);
15211
+ }
15212
+ };
15213
+ var collectionsConfigGroup = {
15214
+ key: "collections_config",
15215
+ label: "Collections configuration and sorting",
15216
+ docsSlug: "collections-config-tools",
15217
+ probe: { path: "/v1/collections/config" },
15218
+ tools: [
15219
+ {
15220
+ name: "talonic_collections_get_config",
15221
+ title: "Collections configuration",
15222
+ description: describe({
15223
+ 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.",
15224
+ 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.",
15225
+ not: "the plain list of collections with counts (talonic_collections_list); a first draft for a workspace that has none (talonic_collections_propose).",
15226
+ 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[]? }."
15227
+ }),
15228
+ route: "GET /v1/collections/config",
15229
+ inputSchema: {},
15230
+ annotations: READ
15231
+ },
15232
+ applyConfig,
15233
+ {
15234
+ name: "talonic_collections_propose",
15235
+ title: "Propose a collections configuration",
15236
+ description: describe({
15237
+ 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.",
15238
+ 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.",
15239
+ not: "the configuration in force now (talonic_collections_get_config).",
15240
+ returns: "The proposed document in the shape talonic_collections_get_config returns ({ version: 1, relationships[]?, collections[] }).",
15241
+ errors: "403 the person is not an Admin of the workspace."
15242
+ }),
15243
+ route: "POST /v1/collections/proposal",
15244
+ inputSchema: {},
15245
+ annotations: READ
15246
+ },
15247
+ {
15248
+ name: "talonic_collections_explain_document",
15249
+ title: "Why a document sits in its collections",
15250
+ description: describe({
15251
+ 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).",
15252
+ use: "'why is this document in Clients', 'why can't Anna see this', or before correcting a label or moving the document.",
15253
+ not: "the documents of a collection (talonic_collections_preview).",
15254
+ args: "`document_id`.",
15255
+ returns: "{ document_id, pending, unresolved, labels[] { label, origin: derived|person, evidence[]? { party, source, relationship?, quote? } }, removed[], collections[] { id, name, path, why } }.",
15256
+ errors: "404 the person may not read the document."
15257
+ }),
15258
+ route: "GET /v1/documents/{documentId}/collections",
15259
+ inputSchema: { document_id: documentId },
15260
+ annotations: READ
15261
+ },
15262
+ setLabels,
15263
+ moveDocument,
15264
+ {
15265
+ name: "talonic_collections_set_parties",
15266
+ title: "Set a document's parties",
15267
+ description: describe({
15268
+ 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.",
15269
+ use: "documents uploaded through the API whose sender and recipients are known to the caller, so they sort like mail.",
15270
+ not: "saying what a party is to the workspace (talonic_collections_save_directory); changing labels directly (talonic_collections_set_labels).",
15271
+ 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).",
15272
+ returns: "{ document_id, parties[], pending }.",
15273
+ errors: "400 a malformed party; 404 the person may not read the document."
15274
+ }),
15275
+ route: "PUT /v1/documents/{documentId}/parties",
15276
+ inputSchema: {
15277
+ document_id: documentId,
15278
+ parties: z.array(
15279
+ z.object({
15280
+ id: z.string().min(1).max(320).describe("A typed identifier, e.g. `email:jane@acme.com`."),
15281
+ role: z.enum(["from", "to", "cc", "attendee", "author"]).optional()
15282
+ })
15283
+ ).max(500).describe("The document's parties."),
15284
+ complete: z.boolean().optional().describe("true: the list names every party.")
15285
+ },
15286
+ annotations: write21(true),
15287
+ body: ["parties", "complete"]
15288
+ },
15289
+ {
15290
+ name: "talonic_collections_list_directory",
15291
+ title: "Relationship directory",
15292
+ description: describe({
15293
+ 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.",
15294
+ use: "'why is acme.com treated as a supplier', or before correcting an entry.",
15295
+ returns: "{ entries[] { id, match_value, relationship, source, origin, labels[]?, evidence, created_at, updated_at } }."
15296
+ }),
15297
+ route: "GET /v1/collections/directory",
15298
+ inputSchema: {},
15299
+ annotations: READ
15300
+ },
15301
+ saveDirectory
15302
+ ]
15303
+ };
15091
15304
  var COMPLIANCE_EXPORT_MAX_BYTES = 8 * 1024 * 1024;
15092
15305
  var docIds = (min, max, what) => z.array(zUuid()).min(min).max(max).describe(what);
15093
15306
  var pageArgs3 = {
@@ -16150,7 +16363,7 @@ var DELETE_SCHEMA = describe({
16150
16363
  returns: "{ deleted: true, id }.",
16151
16364
  errors: "404 unknown schema; 409 the schema is managed by a Spec."
16152
16365
  });
16153
- var documentId = { document_id: zUuid().describe("The document id.") };
16366
+ var documentId2 = { document_id: zUuid().describe("The document id.") };
16154
16367
  var extractionId = {
16155
16368
  extraction_id: zUuid().describe("The extraction id (the same as its document's id).")
16156
16369
  };
@@ -16266,7 +16479,7 @@ var dataManagementGroup = {
16266
16479
  title: "Re-extract a document",
16267
16480
  description: REEXTRACT,
16268
16481
  route: "POST /v1/documents/{documentId}/re-extract",
16269
- inputSchema: documentId,
16482
+ inputSchema: documentId2,
16270
16483
  annotations: write21(false)
16271
16484
  },
16272
16485
  {
@@ -16274,7 +16487,7 @@ var dataManagementGroup = {
16274
16487
  title: "Delete a document",
16275
16488
  description: DELETE_DOCUMENT,
16276
16489
  route: "DELETE /v1/documents/{documentId}",
16277
- inputSchema: documentId,
16490
+ inputSchema: documentId2,
16278
16491
  annotations: write21(true, true)
16279
16492
  },
16280
16493
  {
@@ -16524,7 +16737,7 @@ var moneyFoundGroup = {
16524
16737
  ]
16525
16738
  };
16526
16739
  var folderId = zUuid().describe("The folder id (talonic_transport_folders_list or _worklist).");
16527
- var documentId2 = zUuid().describe("The document id, from the folder's documents.");
16740
+ var documentId3 = zUuid().describe("The document id, from the folder's documents.");
16528
16741
  var loadKey = z.string().min(1).max(200).describe("The load key, from the folder's loads.");
16529
16742
  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 }.";
16530
16743
  var HANDOVER_MAX_BYTES = 8 * 1024 * 1024;
@@ -16639,7 +16852,7 @@ var transportFoldersGroup = {
16639
16852
  returns: "{ document_id, pages[], boxes[] { field, value, page, x, y, w, h } }."
16640
16853
  }),
16641
16854
  route: "GET /v1/transport-folders/{folderId}/documents/{documentId}/boxes",
16642
- inputSchema: { folder_id: folderId, document_id: documentId2 },
16855
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16643
16856
  annotations: READ
16644
16857
  },
16645
16858
  {
@@ -16653,7 +16866,7 @@ var transportFoldersGroup = {
16653
16866
  returns: "the document's boxes, as talonic_transport_folders_boxes returns them."
16654
16867
  }),
16655
16868
  route: "POST /v1/transport-folders/{folderId}/documents/{documentId}/locate",
16656
- inputSchema: { folder_id: folderId, document_id: documentId2 },
16869
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16657
16870
  annotations: write21(true)
16658
16871
  },
16659
16872
  {
@@ -16684,7 +16897,7 @@ var transportFoldersGroup = {
16684
16897
  route: "POST /v1/transport-folders/{folderId}/documents/{documentId}/assign",
16685
16898
  inputSchema: {
16686
16899
  folder_id: folderId,
16687
- document_id: documentId2,
16900
+ document_id: documentId3,
16688
16901
  load_key: z.string().max(200).nullable().describe("The load the document belongs to; null = it belongs to no load.")
16689
16902
  },
16690
16903
  annotations: write21(true),
@@ -16700,7 +16913,7 @@ var transportFoldersGroup = {
16700
16913
  returns: DETAIL_RETURNS
16701
16914
  }),
16702
16915
  route: "DELETE /v1/transport-folders/{folderId}/documents/{documentId}/assign",
16703
- inputSchema: { folder_id: folderId, document_id: documentId2 },
16916
+ inputSchema: { folder_id: folderId, document_id: documentId3 },
16704
16917
  annotations: write21(true)
16705
16918
  },
16706
16919
  {
@@ -16776,7 +16989,8 @@ var TOOL_GROUPS = [
16776
16989
  transportFoldersGroup,
16777
16990
  complianceGroup,
16778
16991
  moneyFoundGroup,
16779
- customsDeclarationGroup
16992
+ customsDeclarationGroup,
16993
+ collectionsConfigGroup
16780
16994
  ];
16781
16995
  TOOL_GROUPS.map((g) => g.key);
16782
16996
  function registerToolGroups(server, keys, getToken, baseUrl) {
@@ -17829,7 +18043,7 @@ function registerOperationsTools(server, getToken, baseUrl, families) {
17829
18043
 
17830
18044
  // package.json
17831
18045
  var package_default = {
17832
- version: "0.1.107"};
18046
+ version: "0.1.108"};
17833
18047
 
17834
18048
  // src/version.ts
17835
18049
  var VERSION = package_default.version;