suppa-mcp-2 1.45.1 → 1.47.0

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 CHANGED
@@ -30,7 +30,7 @@ No API key needed to start — the server authenticates interactively via the `s
30
30
 
31
31
  ## The `suppa` command
32
32
 
33
- The same 108 operations the MCP server exposes are available as a command, for
33
+ The same 118 operations the MCP server exposes are available as a command, for
34
34
  shells, scripts and CI:
35
35
 
36
36
  ```bash
@@ -419,7 +419,7 @@ extension table is created outside that check and is not subject to it.
419
419
 
420
420
  ## Available tools
421
421
 
422
- 108 tools across the areas below.
422
+ 118 tools across the areas below.
423
423
 
424
424
  ### Session & identity
425
425
 
@@ -484,7 +484,7 @@ extension table is created outside that check and is not subject to it.
484
484
  | `suppa_list_entities` | List entities (tables) |
485
485
  | `suppa_describe_entity` | Field definitions + types for an entity (compact by default; `full=true` for the raw schema) |
486
486
  | `suppa_list_tabular_parts` | List tabular parts (ТЧ) of an entity |
487
- | `suppa_search_records` | Search / filter records in any entity — nested AND/OR groups, auto-diagnoses an empty result (`deleted_scope` finds soft-deleted rows) |
487
+ | `suppa_search_records` | Search / filter records in any entity — nested AND/OR groups, auto-diagnoses an empty result (`deleted_scope` finds soft-deleted rows); `order_by='custom_order(page, 12)'` reads the platform's manual order of a list |
488
488
  | `suppa_validate_select` | Check a select/filter payload against the entity without running it — names the field that does not resolve |
489
489
  | `suppa_query` | Run one read-only SuppaSQL statement (SELECT/WITH) with the caller's read permissions — check a SQL chart or table source before writing the form |
490
490
  | `suppa_sql_kb` | The SuppaSQL skill offline (`skills/writing-suppa-sql`): rules, cheat sheet, common mistakes, references by section, and `check` — what the platform refuses and the measured slow shapes a draft's text shows |
@@ -511,6 +511,8 @@ extension table is created outside that check and is not subject to it.
511
511
  | `suppa_delete_record` | Soft-delete a record — reversible (confirm-gated); permanent delete is blocked server-wide |
512
512
  | `suppa_restore_record` | Undo a soft delete: clear `deletedAt` on a record (confirm-gated) |
513
513
  | `suppa_copy_record` | Duplicate a record, optionally with its files / related records |
514
+ | `suppa_reorder_records` | Move records within any entity's manual order — a board column, a hierarchy's children; a hierarchy kept per owner orders its top level under the owner (`custom_order(page, 12)` for a page's blocks) and each parent's children under `custom_order(parent, <id>)`; rows checked with your rights first (confirm-gated) |
515
+ | `suppa_insert_record_at` | Create records at a place in any entity's manual order (before / after a record, first / last) |
514
516
  | `suppa_attach_file_to_record` | Attach a local file to any record |
515
517
  | `suppa_list_record_files` | List the files attached to a record |
516
518
  | `suppa_download_file` | Download one attachment (original, preview, or generated PDF) |
@@ -536,6 +538,25 @@ extension table is created outside that check and is not subject to it.
536
538
  Designing, laying out or optimizing an automation before writing it: the bundled
537
539
  `skills/building-suppa-automations` skill (see below).
538
540
 
541
+ ### Registers
542
+
543
+ 1C-style accumulation registers (stock: movements, balances, turnovers) and information registers
544
+ (prices by period) built into entity-builder — `REGISTERS_ENABLED` on the platform.
545
+
546
+ | Tool | Description |
547
+ |---|---|
548
+ | `suppa_registers_kb` | The bundled `skills/suppa-registers` skill, offline: the cycle, concepts, rules, reads, operations, errors |
549
+ | `suppa_create_register` | Create a register with its fields and roles; frozen options are checked before the request, `timezone` is required, and it asks first (`confirm`) — a register cannot be removed |
550
+ | `suppa_save_posting_rule` | Create or update a posting rule by names; the confirmation request previews it on a document (confirm-gated) |
551
+ | `suppa_read_register` | Balance, turnovers, balance and turnovers, movements, slices — under the caller's rights, paged |
552
+ | `suppa_register_document` | A document's posting state, movements, violations and preview; or the state of up to 1000 documents |
553
+ | `suppa_repost_documents` | Repost one document, or history as a job; the confirmation request carries the dry run (confirm-gated) |
554
+ | `suppa_register_status` | The operations panel, one register's state with held documents and open violations, a job |
555
+ | `suppa_operate_register` | Totals suspend / resume / rebuild / check, the closed date, release held, resolve a violation, jobs (confirm-gated) |
556
+
557
+ A document is an entity with the `document` option (`suppa_update_entity_options`); your own SQL over
558
+ register reads is `suppa_query` with `virtual_tables_json`.
559
+
539
560
  ### Forms
540
561
 
541
562
  | Tool | Description |
@@ -589,6 +610,7 @@ Guided workflows clients can expose as slash commands:
589
610
  | `build_entity` | `entity_purpose` | Guided design + creation of a new entity, fields, enums, and a form |
590
611
  | `migrate_from_v1` | `entity_names?` | Guided Suppa 1.0 → 2.0 schema migration (dry-run, review, execute) |
591
612
  | `write_entity_code` | `entity_purpose` | Guided: write v2 application schema code (entities, seeds, registration) instead of API calls |
613
+ | `build_register` | `register_purpose` | Guided: a stock register from zero — register, document, posting rule previewed on a real document, repost of history |
592
614
 
593
615
  ---
594
616
 
@@ -844,7 +866,7 @@ At run time a read is checked the same way before it is sent, so no tool learns
844
866
  suppa-mcp-node/
845
867
  ├── src/
846
868
  │ ├── bin.ts # Entry point — stdio transport
847
- │ ├── server.ts # McpServer + all 95 tool + 4 prompt registrations
869
+ │ ├── server.ts # McpServer + all 118 tool + 5 prompt registrations
848
870
  │ ├── config.ts # Env / .env config surface
849
871
  │ ├── store.ts # Credentials in the OS keychain (@napi-rs/keyring)
850
872
  │ ├── registry.ts # Non-secret tenant registry (~/.suppa-mcp/tenants.json)
@@ -856,10 +878,12 @@ suppa-mcp-node/
856
878
  │ └── tools/
857
879
  │ ├── tasks.ts docs.ts entity.ts forms.ts
858
880
  │ ├── automation.ts # read + write automation tools
881
+ │ ├── registers.ts # registers: create, rules, reads, documents, repost, operations
859
882
  │ ├── migrate.ts nameMap.ts v1Fields.ts
860
883
  │ └── workspace.ts
861
884
  ├── skills/suppa-entity-code/ # bundled agent skill: write v2 schema code + validator
862
885
  ├── skills/building-suppa-automations/ # bundled agent skill: design, lay out, lint and publish automations
886
+ ├── skills/suppa-registers/ # bundled agent skill: registers — served by suppa_registers_kb
863
887
  ├── test/ # vitest suite (ports the Python test suite)
864
888
  ├── scripts/ # live read-only / write verify scripts
865
889
  ├── package.json
package/dist/cli/run.js CHANGED
@@ -92,7 +92,7 @@ function parseArgsObject(text, source) {
92
92
  return { error: `${source} is not valid JSON: ${e instanceof Error ? e.message : String(e)}` };
93
93
  }
94
94
  if (json === null || typeof json !== "object" || Array.isArray(json)) {
95
- return { error: `${source} must hold a JSON object of arguments ({"entity_name": "Tasks", …})` };
95
+ return { error: `${source} must hold a JSON object of arguments ({"entity_name": "Orders", …} — a hypothetical entity; use the tenant's own)` };
96
96
  }
97
97
  return { args: json };
98
98
  }
package/dist/server.js CHANGED
@@ -12,6 +12,7 @@ import { config } from "./config.js";
12
12
  import * as tasks from "./tools/tasks.js";
13
13
  import * as docs from "./tools/docs.js";
14
14
  import * as entity from "./tools/entity.js";
15
+ import * as recordOrder from "./tools/recordOrder.js";
15
16
  import * as customFields from "./tools/customFields.js";
16
17
  import * as customFieldSets from "./tools/customFieldSets.js";
17
18
  import * as customFieldsAsCode from "./tools/customFieldsAsCode.js";
@@ -29,6 +30,7 @@ import * as automation from "./tools/automation.js";
29
30
  import * as query from "./tools/query.js";
30
31
  import * as sqlKb from "./tools/sqlKb.js";
31
32
  import * as queryAnalyze from "./tools/queryAnalyze.js";
33
+ import * as registers from "./tools/registers.js";
32
34
  import * as auth from "./auth.js";
33
35
  import * as tenants from "./tenants.js";
34
36
  import { confirmRequired, jsonResponse } from "./utils.js";
@@ -142,6 +144,32 @@ const RecordValuesOrBatchJson = z
142
144
  .describe('JSON object of field values — or a JSON ARRAY of such objects to create many ' +
143
145
  'in one request. Relations/enums as {"id": N}, e.g. {"title": "X", ' +
144
146
  '"customer": {"id": 7}}; batch: [{"title": "A"}, {"title": "B"}].');
147
+ // The manual-order tools (suppa_reorder_records, suppa_insert_record_at): which
148
+ // list, where in it, and how the list is read. See tools/customOrder.ts.
149
+ const OrderContextField = z
150
+ .string()
151
+ .nullable()
152
+ .default(null)
153
+ .describe("The list's scoping field (many-to-one or enum), e.g. 'page'; null = the entity's own list.");
154
+ const OrderContextValue = z
155
+ .number()
156
+ .int()
157
+ .positive()
158
+ .nullable()
159
+ .default(null)
160
+ .describe("Id that scopes the list, e.g. the page id; null with a field = its empty group.");
161
+ const OrderWhereArg = z.enum(["before", "after", "first", "last"]);
162
+ const OrderAnchorId = z
163
+ .number()
164
+ .int()
165
+ .positive()
166
+ .nullable()
167
+ .default(null)
168
+ .describe("For before / after: a record of the same list.");
169
+ const OrderDirectionArg = z
170
+ .enum(["asc", "desc"])
171
+ .default("desc")
172
+ .describe("The direction you read the list in (default desc).");
145
173
  const MergeNamesJson = z
146
174
  .string()
147
175
  .nullable()
@@ -176,7 +204,7 @@ const BlocksJson = z
176
204
  'checkList|quote|callout|divider|code|table|toggle", "title": "text or HTML"}].');
177
205
  const EntityName = z
178
206
  .string()
179
- .describe("Exact entity name, e.g. 'Tasks' — discover via suppa_list_entities.");
207
+ .describe("Exact entity name as suppa_list_entities reports it (e.g. a hypothetical 'Orders').");
180
208
  /**
181
209
  * A field label: a plain string, or the LOCALIZATION OBJECT the builder doc
182
210
  * prescribes (`title | object | Localization object`, builder.txt:56).
@@ -334,7 +362,7 @@ ENTITY BUILDER (create + edit fields; core-field removal is UI-only) — suppa_a
334
362
  - OWNED CHILD COLLECTIONS ARE TABULAR PARTS: repeating rows that belong to ONE parent record (a part's BOM items) go through suppa_create_tabular_part(parent_entity, name), which creates the child's 'owner' relation and the parent link. Never model it by hand — suppa_add_field REFUSES field_type='one-to-many'; 'many-to-many' is for a shared lookup referenced by many records.
335
363
  - An enum value on a RECORD is a reference, {"id": <Enums row id>} (an array of those for multi-enum), never a bare code like "red" — that is refused. Read the ids with suppa_search_records on 'Enums' filtered by name.
336
364
 
337
- CUSTOM FIELDS — ANY entity, not just Tasks: one whose options.customFields is on (an admin enables it; suppa_describe_entity shows it) carries extra columns that vary BY CONTEXT, so which are live differs from record to record — suppa_resolve_custom_fields answers for a given record. Their values ride on the OWNER record under the reserved key customFields, e.g. fields_json {"customFields": {"budget": 600}}.
365
+ CUSTOM FIELDS — ANY entity: one whose options.customFields is on (an admin enables it; suppa_describe_entity shows it) carries extra columns that vary BY CONTEXT, so which are live differs from record to record — suppa_resolve_custom_fields answers for a given record. Their values ride on the OWNER record under the reserved key customFields, e.g. fields_json {"customFields": {"budget": 600}}.
338
366
 
339
367
  ${formV2.FORM_V2_INSTRUCTION_LINE}
340
368
 
@@ -567,14 +595,12 @@ export function buildToolTable() {
567
595
  return text(await tasks.closeTask(a.task_id));
568
596
  });
569
597
  reg("suppa_add_comment", {
570
- description: "Add a comment to a task. Supports HTML — plain text is auto-wrapped in <p>…</p>, so\n" +
571
- " start the string with < to pass raw markup. mention_ids: comma-separated\n" +
572
- " 'userId:Name' pairs for @mentions.",
598
+ description: "Add a comment to a task. Plain text is wrapped in <p>; a string starting with < is HTML.\n" +
599
+ " mention_ids: comma-separated 'userId:Name' pairs — one @mention each, in the first\n" +
600
+ " paragraph; a user the content already mentions is not added again.",
573
601
  inputSchema: {
574
602
  task_id: z.number().int(),
575
- content: z
576
- .string()
577
- .describe("Comment text; plain text is wrapped in <p>, raw HTML passes through."),
603
+ content: z.string().describe("Comment text or HTML."),
578
604
  mention_ids: z
579
605
  .string()
580
606
  .nullable()
@@ -960,6 +986,14 @@ export function buildToolTable() {
960
986
  " An EMPTY result (or a 400) is auto-diagnosed with select/validate: if the query\n" +
961
987
  ' references a field that does not exist you get "validation" naming it, not silence.\n' +
962
988
  " Returns {records, returned, has_more, next_offset, deleted_scope} — page with offset until has_more is false.\n\n" +
989
+ " MANUAL ORDER: order_by='custom_order(page, 12)' returns the rows of that list (any entity:\n" +
990
+ " context field, scoping record's id) in the order the platform keeps by hand; 'custom_order'\n" +
991
+ " = a flat entity's own list; ':asc' reads it reversed (default desc). A hierarchy kept per\n" +
992
+ " owner orders its top level under the owner (custom_order(page, 12): a page's top-level\n" +
993
+ " blocks), each parent's children under custom_order(parent, <id>); another hierarchy's top\n" +
994
+ ' level: custom_order(parent). Nested rows in order: {"children": "#expand_tree(10)"} in\n' +
995
+ " fields_json. Move rows with suppa_reorder_records; create at a place with\n" +
996
+ " suppa_insert_record_at.\n\n" +
963
997
  " Enum fields read back as objects {value, title, id} — project them as\n" +
964
998
  ' {"myEnum": {"value": true}} and read .value, not as a bare string.\n\n' +
965
999
  " SOFT-DELETED ROWS: deleted_scope='deleted' returns ONLY records that\n" +
@@ -969,7 +1003,7 @@ export function buildToolTable() {
969
1003
  inputSchema: {
970
1004
  entity_name: z
971
1005
  .string()
972
- .describe("Exact entity name, e.g. 'Tasks', 'Users' — see suppa_list_entities."),
1006
+ .describe("Exact entity name as suppa_list_entities reports it (e.g. a hypothetical 'Orders')."),
973
1007
  filters_json: z
974
1008
  .string()
975
1009
  .default("[]")
@@ -985,7 +1019,7 @@ export function buildToolTable() {
985
1019
  order_by: z
986
1020
  .string()
987
1021
  .default("createdAt:desc")
988
- .describe("'field:asc' or 'field:desc', e.g. 'createdAt:desc'."),
1022
+ .describe("'field:asc' or 'field:desc', e.g. 'createdAt:desc' — or 'custom_order(<field>, <id>)' for the manual order (see MANUAL ORDER)."),
989
1023
  match_any: z
990
1024
  .boolean()
991
1025
  .default(false)
@@ -1040,7 +1074,7 @@ export function buildToolTable() {
1040
1074
  inputSchema: {
1041
1075
  query: z
1042
1076
  .string()
1043
- .describe('The SuppaSQL statement, e.g. SELECT "stage.name", COUNT("id") AS "n" FROM Tasks GROUP BY "stage.name" LIMIT 100 — as a chart: sqlCategoryColumn "name", sqlValueColumns [{"key": "n"}].'),
1077
+ .describe('The SuppaSQL statement, e.g. SELECT "status.title", COUNT("id") AS "n" FROM Orders GROUP BY "status.title" LIMIT 100 (Orders is a hypothetical entity; use the one you found) — as a chart: sqlCategoryColumn "title", sqlValueColumns [{"key": "n"}].'),
1044
1078
  bind_params_json: z
1045
1079
  .string()
1046
1080
  .optional()
@@ -1052,9 +1086,13 @@ export function buildToolTable() {
1052
1086
  .max(query.QUERY_MAX_LIMIT)
1053
1087
  .default(query.QUERY_DEFAULT_LIMIT)
1054
1088
  .describe("Rows to show (1-500)."),
1089
+ virtual_tables_json: z
1090
+ .string()
1091
+ .optional()
1092
+ .describe('Register reads to select FROM: {"b": {"register": "Stock", "kind": "balance"}}.'),
1055
1093
  },
1056
1094
  annotations: _READ,
1057
- }, async (a) => text(await query.runQuery(a.query, a.bind_params_json ?? null, a.limit)));
1095
+ }, async (a) => text(await query.runQuery(a.query, a.bind_params_json ?? null, a.limit, a.virtual_tables_json ?? null)));
1058
1096
  reg("suppa_sql_kb", {
1059
1097
  description: "The SuppaSQL skill (skills/writing-suppa-sql): write, check and tune a query for\n" +
1060
1098
  " suppa_query, a chart / table SQL source or an application. Offline; touches no tenant.\n\n" +
@@ -1173,7 +1211,8 @@ export function buildToolTable() {
1173
1211
  "globalSearch, timeTracking, favorites, pinned, approvals, checklists, " +
1174
1212
  "recurrence, reminders, notificationMutes, customFields, stateHistory (booleans), " +
1175
1213
  "hierarchyDepthLimit (integer 1-20), commentsPrivacy (object), externalSource " +
1176
- '({"sourceEntity": <id>}). Unknown keys are refused (the platform would ' +
1214
+ '({"sourceEntity": <id>}), document (true, or {"dateField", "postedField"}: a registers ' +
1215
+ "recorder; frozen once set). Unknown keys are refused (the platform would " +
1177
1216
  "drop them silently). Enabling an option creates the side table that backs it, " +
1178
1217
  "and recurrence/reminders/notificationMutes/timeTracking/pinned also refresh the " +
1179
1218
  "corresponding system entity's cache — so this is not a free toggle."),
@@ -1313,7 +1352,7 @@ export function buildToolTable() {
1313
1352
  "platform's own docs say the backend never defaults them and every consumer " +
1314
1353
  "reads an absent key as FALSE — which is how agent-created fields ended up " +
1315
1354
  "non-groupable, unsortable and hidden from tables. The stored shape does look " +
1316
- "sparse: of 70 Tasks fields, 15 carry no options object at all. So if the new " +
1355
+ "sparse: of 70 fields on one live entity, 15 carry no options object at all. So if the new " +
1317
1356
  "field MUST be visible and sortable, pass the five explicitly rather than " +
1318
1357
  "trusting a default — it costs nothing — and read the field back afterwards. " +
1319
1358
  "Unknown keys are refused here (the platform would silently drop them)."),
@@ -1954,6 +1993,62 @@ export function buildToolTable() {
1954
1993
  },
1955
1994
  annotations: _ADD,
1956
1995
  }, async (a) => text(await entity.copyRecord(a.entity_name, a.record_id, a.fields_json, a.copy_files, a.copy_related_entities)));
1996
+ reg("suppa_reorder_records", {
1997
+ description: "Move records within an entity's MANUAL (hand-kept) order — page blocks, a hierarchy's children,\n" +
1998
+ " a board column. Changes no field, deletes nothing.\n\n" +
1999
+ " The order is per LIST: both null = the entity's own list; a hierarchy kept per owner keeps\n" +
2000
+ " its top level under the owner (PageBlocks of page 12 = context_field='page', context_value=12),\n" +
2001
+ " each parent's children under 'parent', <id>; another hierarchy's top level = 'parent', null.\n" +
2002
+ " Read it with suppa_search_records(order_by='custom_order(page, 12)'). record_ids land as one\n" +
2003
+ " block in the order given, before / after anchor_id or first / last. Refused before sending:\n" +
2004
+ " a record missing, not visible to you or in another list.\n\n" +
2005
+ " APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
2006
+ inputSchema: {
2007
+ entity_name: EntityName,
2008
+ record_ids: z.array(z.number().int().positive()).describe("Ids to move, in the order they should stand (at most 200)."),
2009
+ context_field: OrderContextField,
2010
+ context_value: OrderContextValue,
2011
+ where: OrderWhereArg,
2012
+ anchor_id: OrderAnchorId,
2013
+ direction: OrderDirectionArg,
2014
+ confirm: Confirm,
2015
+ },
2016
+ annotations: _MUT,
2017
+ }, async (a) => {
2018
+ // A move rearranges what other people see in a list, like suppa_reorder_blocks:
2019
+ // gated, and the preview reads nothing.
2020
+ if (!a.confirm) {
2021
+ return text(confirmRequired("reorder records", {
2022
+ entity_name: a.entity_name,
2023
+ record_ids: a.record_ids,
2024
+ context_field: a.context_field,
2025
+ context_value: a.context_value,
2026
+ where: a.where,
2027
+ anchor_id: a.anchor_id,
2028
+ direction: a.direction,
2029
+ }));
2030
+ }
2031
+ return text(await recordOrder.reorderRecords(a.entity_name, a.record_ids, a.context_field, a.context_value, a.where, a.anchor_id, a.direction));
2032
+ });
2033
+ reg("suppa_insert_record_at", {
2034
+ description: "Create records AT A PLACE in an entity's manual order — e.g. a page block after block 40:\n" +
2035
+ " entity_name='PageBlocks', context_field='page', context_value=12, where='after', anchor_id=40,\n" +
2036
+ ' fields_json=[{"type": "text", "properties": {"title": "<p>Hi</p>"}, "format": {"block_color": ""}}].\n\n' +
2037
+ " fields_json as in suppa_create_record (an array is placed as one block, in order); the context\n" +
2038
+ " field is filled in. The list and place work as in suppa_reorder_records; a bad anchor is\n" +
2039
+ " refused BEFORE anything is created. If only the placing fails, the answer has inserted_ids:\n" +
2040
+ " move them with suppa_reorder_records, never insert again.",
2041
+ inputSchema: {
2042
+ entity_name: EntityName,
2043
+ fields_json: RecordValuesOrBatchJson,
2044
+ context_field: OrderContextField,
2045
+ context_value: OrderContextValue,
2046
+ where: OrderWhereArg,
2047
+ anchor_id: OrderAnchorId,
2048
+ direction: OrderDirectionArg,
2049
+ },
2050
+ annotations: _ADD,
2051
+ }, async (a) => text(await recordOrder.insertRecordAt(a.entity_name, a.fields_json, a.context_field, a.context_value, a.where, a.anchor_id, a.direction)));
1957
2052
  reg("suppa_list_record_files", {
1958
2053
  description: "List the files attached to one record of any entity.\n" +
1959
2054
  "\n" +
@@ -2954,6 +3049,150 @@ export function buildToolTable() {
2954
3049
  },
2955
3050
  annotations: _READ,
2956
3051
  }, async (a) => text(await healthCheck(a.deep)));
3052
+ // =========================================================================
3053
+ // Registers — 1C-style accumulation / information registers (tools/registers.ts;
3054
+ // knowledge: skills/suppa-registers, served by suppa_registers_kb).
3055
+ // =========================================================================
3056
+ const RegisterName = z.string();
3057
+ const DocEntity = z.string().describe("The document entity.");
3058
+ reg("suppa_registers_kb", {
3059
+ description: "Registers (1C-style stock / price registers), offline: no topic — the cycle; concepts | rules | reads |\n" +
3060
+ "operations | errors. Read it before creating a register or a rule: kinds and roles freeze.",
3061
+ inputSchema: {
3062
+ topic: z.enum(registers.KB_TOPICS).optional(),
3063
+ },
3064
+ annotations: _READ,
3065
+ }, async (a) => text(await registers.registersKb(a.topic ?? null)));
3066
+ reg("suppa_create_register", {
3067
+ description: "Create a register with its fields and roles, checked first: kind, type, periodicity, write mode and timezone\n" +
3068
+ "FREEZE, and a register cannot be removed. dimension: many-to-one, text, integer, boolean, timestamp+sub_type\n" +
3069
+ "date (≤ 8); resource: numeric, integer (≤ 6 decimals); attribute. No platform fields (period, recorder…).\n" +
3070
+ "suppa_registers_kb concepts. APPROVAL GATE: confirm=true creates.",
3071
+ inputSchema: {
3072
+ name: z.string().describe("PascalCase, ≤ 24 chars: GoodsInWarehouses."),
3073
+ title: z.string(),
3074
+ kind: z.enum(registers.REGISTER_KINDS).describe("accumulation: stock, balances. information: prices by period."),
3075
+ accumulation_type: z.enum(registers.ACCUMULATION_TYPES).nullable().default(null).describe("accumulation; default balance."),
3076
+ periodicity: z.enum(registers.PERIODICITIES).nullable().default(null).describe("information: required."),
3077
+ write_mode: z.enum(registers.WRITE_MODES).nullable().default(null).describe("information; default independent."),
3078
+ timezone: z.string().describe("IANA zone (Europe/Kyiv). Ask, never assume."),
3079
+ fields_json: z
3080
+ .string()
3081
+ .describe('[{"name":"warehouse","type":"many-to-one","relation_entity":"Warehouses","role":"dimension"},{"name":"qty","type":"numeric","decimal_places":3,"role":"resource"}]; optional title, sub_type.'),
3082
+ confirm: Confirm,
3083
+ },
3084
+ annotations: _ADD,
3085
+ }, async (a) => text(await registers.createRegister(a.name, a.title, a.kind, a.accumulation_type, a.periodicity, a.write_mode, a.timezone, a.fields_json, a.confirm)));
3086
+ reg("suppa_save_posting_rule", {
3087
+ description: "Create or update a posting rule by names: how a document's rows become movements. Without confirm and with\n" +
3088
+ "preview_document_id the platform checks it and shows that document's movements (rolled back). Saving does\n" +
3089
+ "NOT repost existing documents. suppa_registers_kb rules. APPROVAL GATE: confirm=true writes.",
3090
+ inputSchema: {
3091
+ register: RegisterName,
3092
+ recorder: DocEntity,
3093
+ source: z.string().nullable().default(null).describe("The tabular part it reads; null = the document."),
3094
+ key: z.string().describe("sale, receipt…"),
3095
+ definition_json: z
3096
+ .string()
3097
+ .describe('{"link":"owner","movements":[{"recordKind":"expense","set":{"sku":"\\"sku\\"","qty":"\\"qty\\""}}]} (SuppaSQL values), or {"sql":…,"link":…}.'),
3098
+ preview_document_id: z.number().int().positive().nullable().default(null),
3099
+ confirm: Confirm,
3100
+ },
3101
+ annotations: _MUT,
3102
+ }, async (a) => text(await registers.savePostingRule(a.register, a.recorder, a.source, a.key, a.definition_json, a.preview_document_id, a.confirm)));
3103
+ reg("suppa_read_register", {
3104
+ description: "Read a register: balance (at), turnovers / balance_and_turnovers (from, to, grain), movements, slice_last /\n" +
3105
+ "slice_first. Moments: 'now', YYYY-MM-DD (as at/to: its end) or an instant WITH offset. Sums are text;\n" +
3106
+ "meta.pending > 0: still queued. Page until nextCursor is null. SQL over reads: suppa_query virtual_tables_json.",
3107
+ inputSchema: {
3108
+ register: RegisterName,
3109
+ kind: z.enum(registers.READ_KINDS),
3110
+ at: z.string().nullable().default(null).describe("Absent = now; a slice: 'latest'."),
3111
+ from: z.string().nullable().default(null),
3112
+ to: z.string().nullable().default(null),
3113
+ group_by: z.array(z.string()).nullable().default(null).describe("Dimensions; null = all; [] = a total."),
3114
+ filter_json: z.string().nullable().default(null).describe('Dimensions: {"warehouse": [3, 4]}.'),
3115
+ conditions_json: z.string().nullable().default(null).describe("Or a conditions tree on dimensions."),
3116
+ grain: z.enum(registers.GRAINS).nullable().default(null),
3117
+ limit: z.number().int().min(1).max(registers.READ_MAX_LIMIT).default(100),
3118
+ cursor: z.string().nullable().default(null),
3119
+ },
3120
+ annotations: _READ,
3121
+ }, async (a) => text(await registers.readRegister({
3122
+ register: a.register,
3123
+ kind: a.kind,
3124
+ at: a.at,
3125
+ from: a.from,
3126
+ to: a.to,
3127
+ groupBy: a.group_by,
3128
+ filterJson: a.filter_json,
3129
+ conditionsJson: a.conditions_json,
3130
+ grain: a.grain,
3131
+ limit: a.limit,
3132
+ cursor: a.cursor,
3133
+ })));
3134
+ reg("suppa_register_document", {
3135
+ description: "A document's posting: record_id — state (posted, queued, held + reason, unposted), movements, violations, and\n" +
3136
+ "with preview=true what its rules give now; record_ids — the state of up to 1000 documents.",
3137
+ inputSchema: {
3138
+ entity: DocEntity,
3139
+ record_id: z.number().int().positive().nullable().default(null),
3140
+ record_ids: z.array(z.number().int().positive()).nullable().default(null),
3141
+ preview: z.boolean().default(false),
3142
+ },
3143
+ annotations: _READ,
3144
+ }, async (a) => text(await registers.registerDocument(a.entity, a.record_id, a.record_ids, a.preview)));
3145
+ reg("suppa_repost_documents", {
3146
+ description: "Repost: record_id — one document now (control applies to you); from_date ('all', a day) — history as a job,\n" +
3147
+ "after a rule change. The confirmation request carries the dry run. Never repost by flipping posted.\n" +
3148
+ "APPROVAL GATE: confirm=true reposts.",
3149
+ inputSchema: {
3150
+ entity: DocEntity,
3151
+ record_id: z.number().int().positive().nullable().default(null),
3152
+ from_date: z.string().nullable().default(null),
3153
+ rate: z.number().int().min(1).max(500).default(50).describe("Documents a second."),
3154
+ confirm: Confirm,
3155
+ },
3156
+ annotations: _MUT,
3157
+ }, async (a) => text(await registers.repostDocuments(a.entity, a.record_id, a.from_date, a.rate, a.confirm)));
3158
+ reg("suppa_register_status", {
3159
+ description: "Registers' status: no args — every register (pending, held, violations); register — its state, held\n" +
3160
+ "documents, open violations; job_id — a job (part: a sheet part / check examples).",
3161
+ inputSchema: {
3162
+ register: z.string().nullable().default(null),
3163
+ job_id: z.number().int().positive().nullable().default(null),
3164
+ part: z.number().int().min(0).nullable().default(null),
3165
+ },
3166
+ annotations: _READ,
3167
+ }, async (a) => text(await registers.registerStatus(a.register, a.job_id, a.part)));
3168
+ reg("suppa_operate_register", {
3169
+ description: "Operate a register: totals (suspend, resume, rebuild from_month, check), close_period (closed_until\n" +
3170
+ "YYYY-MM-DD, or 'none' to open all), release_held, resolve_violation, pause / resume / cancel a job.\n" +
3171
+ "suppa_registers_kb operations. APPROVAL GATE: confirm=true acts.",
3172
+ inputSchema: {
3173
+ action: z.enum(registers.OPERATE_ACTIONS),
3174
+ register: z.string().nullable().default(null),
3175
+ closed_until: z.string().nullable().default(null),
3176
+ from_month: z.string().nullable().default(null),
3177
+ repair: z.boolean().default(false),
3178
+ derivation: z.boolean().default(false),
3179
+ from_date: z.string().nullable().default(null),
3180
+ violation_id: z.number().int().positive().nullable().default(null),
3181
+ job_id: z.number().int().positive().nullable().default(null),
3182
+ confirm: Confirm,
3183
+ },
3184
+ annotations: _MUT,
3185
+ }, async (a) => text(await registers.operateRegister({
3186
+ action: a.action,
3187
+ register: a.register,
3188
+ closedUntil: a.closed_until,
3189
+ fromMonth: a.from_month,
3190
+ repair: a.repair,
3191
+ derivation: a.derivation,
3192
+ fromDate: a.from_date,
3193
+ violationId: a.violation_id,
3194
+ jobId: a.job_id,
3195
+ }, a.confirm)));
2957
3196
  return table;
2958
3197
  }
2959
3198
  /**
@@ -3117,6 +3356,40 @@ export function buildServer() {
3117
3356
  "the gate fails with E301 if anything is unregistered — run it, do not assume.\n" +
3118
3357
  "Porting from Suppa 1.0? Read the schema with suppa_read_v1_entity_props / suppa_read_v1_enum and map per references/v1-mapping.md — " +
3119
3358
  "never invent a mapping; record data stays with suppa_migrate_entities_from_v1.");
3359
+ regPrompt("build_register", {
3360
+ description: "Guided: a stock (accumulation) register from zero — register, document, posting rule, preview on a real document, repost of history",
3361
+ argsSchema: {
3362
+ register_purpose: z
3363
+ .string()
3364
+ .describe("What the register keeps, e.g. 'goods in warehouses by warehouse and SKU, quantity', and which documents move it."),
3365
+ },
3366
+ }, (a) => `Build a Suppa accumulation register from zero for: ${a.register_purpose}\n\n` +
3367
+ "Follow the bundled 'suppa-registers' skill (suppa_registers_kb; topic concepts and rules). Kinds, roles, the timezone " +
3368
+ "and the document option FREEZE once created — design first, write second.\n" +
3369
+ "1. Check: suppa_register_status() — registers exist on the tenant (a 400 register.disabled means the platform has " +
3370
+ "them off: stop and say so) and none already keeps this; suppa_list_entities for the document entities and their " +
3371
+ "tabular parts.\n" +
3372
+ "2. Design and show me, then WAIT for my approval: the register name (≤ 24 characters), kind accumulation with " +
3373
+ "accumulation_type balance (stock) or turnover (sales sums), the timezone (an IANA zone — ask me, never assume " +
3374
+ "it), the dimensions (what a balance is kept " +
3375
+ "by — a warehouse many-to-one, a SKU; ≤ 8), the resources (quantity numeric ≤ 6 decimals, amount), the attributes; " +
3376
+ "the documents that move it and, for each, receipt or expense per line (a transfer: one expense and one receipt).\n" +
3377
+ "3. Register: suppa_create_register(...) without confirm — show me what it will store (the option with its " +
3378
+ "defaults written out, the fields and their roles); confirm=true only after my approval: a register cannot be " +
3379
+ "removed.\n" +
3380
+ "4. Documents: for each document entity, suppa_update_entity_options(entity_name, options_json='{\"document\": true}') " +
3381
+ "— or {\"document\": {\"dateField\": …, \"postedField\": …}} to bind fields it has (show me the call first; it freezes). " +
3382
+ "Its lines are a tabular part (suppa_create_tabular_part) if they are not one already.\n" +
3383
+ "5. Rules: for each document, suppa_save_posting_rule WITHOUT confirm and WITH preview_document_id = a real document " +
3384
+ "of that entity (find one with suppa_search_records). Show me the movements the preview gives; fix the definition " +
3385
+ "until every dimension is filled and the kinds are right; only then confirm=true.\n" +
3386
+ "6. History: existing documents are NOT posted by a new rule. suppa_repost_documents(entity, from_date='all') " +
3387
+ "without confirm — show me the dry run (documents, changed, refused); start the job only after my approval, and " +
3388
+ "follow it with suppa_register_status(job_id).\n" +
3389
+ "7. Verify: suppa_read_register(register, kind='balance', group_by=[…]) — meta.pending 0 means the queue is done; " +
3390
+ "suppa_register_status(register) for held documents and violations.\n" +
3391
+ "8. Tell me: balance control is OFF until an operator puts resources into RegisterSettings.controlResources " +
3392
+ "(suppa_update_record on RegisterSettings, a list that is REPLACED); offer to do it, do not do it unasked.");
3120
3393
  // Every tools/list goes out without the schema boilerplate no model reads —
3121
3394
  // see toolsListEconomy.ts. Installed last so it wraps the SDK's own handler.
3122
3395
  installToolsListEconomy(server);
package/dist/toolTable.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export const PROFILES = {
2
2
  core: ["login", "logout", "use_tenant", "list_tenants", "get_me", "health_check", "diagnostics", "version"],
3
- data: ["search_records", "get_record", "create_record", "update_record", "delete_record", "restore_record", "copy_record", "validate_select", "query", "sql_kb", "query_analyze", "search_entities", "list_entities", "describe_entity", "search_users"],
3
+ data: ["search_records", "get_record", "create_record", "update_record", "delete_record", "restore_record", "copy_record", "reorder_records", "insert_record_at", "validate_select", "query", "sql_kb", "query_analyze", "search_entities", "list_entities", "describe_entity", "search_users"],
4
4
  tasks: ["search_tasks", "get_task", "create_task", "update_task", "close_task", "delete_task", "move_task", "count_tasks", "list_stages", "list_task_types", "list_workflows", "add_comment", "get_comments", "create_workspace", "add_menu_item"],
5
5
  files: ["attach_file", "attach_file_to_record", "download_file", "download_files_zip", "list_record_files"],
6
6
  schema: ["create_entity", "add_field", "update_field", "change_field_type", "update_entity_options", "set_title_field", "create_tabular_part", "list_tabular_parts", "list_field_types", "add_enum_values", "add_custom_field", "add_custom_fields_batch", "remove_custom_field", "restore_custom_field", "resolve_custom_fields", "link_custom_field", "apply_custom_fields", "validate_entity_code", "migrate_entities_from_v1", "read_v1_entities", "read_v1_entity_props", "read_v1_enum"],
@@ -13,6 +13,8 @@ export const PROFILES = {
13
13
  forms: ["create_form", "get_form", "list_forms", "update_form", "add_field_to_form", "generate_form_schema", "list_form_field_types", "form_kb", "validate_form_schema",
14
14
  "write_form_draft", "create_form_v2", "form_versions", "form_lifecycle", "form_code", "push_form_code"],
15
15
  automation: ["create_automation", "get_automation", "update_automation", "delete_automation", "list_automations", "publish_automation", "unpublish_automation", "list_automation_runs", "get_automation_run", "get_automation_node_schema", "list_automation_node_types"],
16
+ // 1C-style accumulation / information registers: the knowledge, the register and its rules, reads, operations.
17
+ registers: ["registers_kb", "create_register", "save_posting_rule", "read_register", "register_document", "repost_documents", "register_status", "operate_register"],
16
18
  };
17
19
  const BY_NAME = new Map();
18
20
  for (const [profile, tools] of Object.entries(PROFILES)) {