@ekwo-ai/mcp 0.30.0 → 0.31.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/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export { amountIn, decimal, money, moneyFields, type Decimal } from '@ekwo-ai/co
12
12
  export { connect, sqlBackend, type SqlBackendOptions, type SqlClient } from './sql.js';
13
13
  export { AGENT_HEADER, AGENT_SESSION_HEADER, API_KEY_HEADER, postgrestBackend, type PostgrestBackendOptions } from './postgrest.js';
14
14
  export { checkConnection, handleHttpRequest, handleNodeRequest, openHttpBackend, type HttpConnection, type HttpHandlerOptions, } from './http.js';
15
- export { INSTRUCTIONS, SERVER_NAME, SERVER_VERSION, buildServer, instructionsFor, type RegisterTool, type ServerOptions, } from './server.js';
15
+ export { INSTRUCTIONS, SERVER_NAME, SERVER_VERSION, STATEMENT_IS, TAX_RETURN_IS, buildServer, instructionsFor, type RegisterTool, type ServerOptions, } from './server.js';
16
16
  export { TOOL_EFFECTS, annotationsFor, effectOf, type EffectAnnotations, type EffectDetails, type ToolEffect } from './tools/effect.js';
17
17
  export { CORE_TOOLS, LOADING_TOOLS, TOOL_LOADING, loadTools, searchTools, type FoundTool, type ToolLoading } from './tools/loading.js';
18
18
  export { SCHEMA_MIN, UPGRADE_COMMAND, assertSchemaSupported, installedSchemaVersion, readSchemaStatus, type SchemaStatus } from './schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,EACZ,OAAO,EACP,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,WAAW,EAAE,UA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Aa,EACb,WAAW,EACX,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxI,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACvI,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9I,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAChI,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ export { amountIn, decimal, money, moneyFields } from '@ekwo-ai/core';
12
12
  export { connect, sqlBackend } from './sql.js';
13
13
  export { AGENT_HEADER, AGENT_SESSION_HEADER, API_KEY_HEADER, postgrestBackend } from './postgrest.js';
14
14
  export { checkConnection, handleHttpRequest, handleNodeRequest, openHttpBackend, } from './http.js';
15
- export { INSTRUCTIONS, SERVER_NAME, SERVER_VERSION, buildServer, instructionsFor, } from './server.js';
15
+ export { INSTRUCTIONS, SERVER_NAME, SERVER_VERSION, STATEMENT_IS, TAX_RETURN_IS, buildServer, instructionsFor, } from './server.js';
16
16
  export { TOOL_EFFECTS, annotationsFor, effectOf } from './tools/effect.js';
17
17
  export { CORE_TOOLS, LOADING_TOOLS, TOOL_LOADING, loadTools, searchTools } from './tools/loading.js';
18
18
  export { SCHEMA_MIN, UPGRADE_COMMAND, assertSchemaSupported, installedSchemaVersion, readSchemaStatus } from './schema.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,EACZ,OAAO,EACP,SAAS,GAQV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAe,MAAM,aAAa,CAAC;AACnJ,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAgB,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,UAAU,EAA0C,MAAM,UAAU,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,gBAAgB,EAAgC,MAAM,gBAAgB,CAAC;AACpI,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAGhB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,cAAc,EACd,WAAW,EACX,eAAe,GAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAA+D,MAAM,mBAAmB,CAAC;AACxI,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAoC,MAAM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;AAC1E,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAkB3D;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqD9F"}
package/dist/postgrest.js CHANGED
@@ -16,41 +16,8 @@
16
16
  * more than code of ours that is merely untested.
17
17
  */
18
18
  import { createClient } from '@supabase/supabase-js';
19
- import { onSocle, socleMarkerAnswer, socleSchemaResolver, SOCLE_MARKER } from '@ekwo-ai/core';
20
- import { EkwoMcpError, explain, identifier, } from './backend.js';
21
- function applyFilters(builder, filters) {
22
- let out = builder;
23
- for (const filter of filters ?? []) {
24
- const column = identifier(filter.column);
25
- switch (filter.op) {
26
- case 'is':
27
- out = out.is(column, null);
28
- break;
29
- case 'in':
30
- out = out.in(column, filter.value);
31
- break;
32
- case 'ilike':
33
- out = out.ilike(column, filter.value);
34
- break;
35
- default:
36
- out = out[filter.op](column, filter.value);
37
- }
38
- }
39
- return out;
40
- }
41
- /** Unwraps a PostgREST answer, letting the schema's own message through. */
42
- function unwrap(answer, what) {
43
- if (answer.error !== null) {
44
- const { message, details, hint } = answer.error;
45
- // `details` is where Postgres puts the rest of a raise; keep it.
46
- const full = [message, details, hint].filter((part) => typeof part === 'string' && part.length > 0).join(' — ');
47
- throw explain(full.length > 0 ? full : `${what} failed`);
48
- }
49
- if (answer.data === null) {
50
- throw new EkwoMcpError(`${what}: nothing came back`);
51
- }
52
- return answer.data;
53
- }
19
+ import { supabaseBackend } from '@ekwo-ai/core';
20
+ import { EkwoMcpError, explain } from './backend.js';
54
21
  /** The header the core's pre-request hook reads a key out of. */
55
22
  export const API_KEY_HEADER = 'X-Ekwo-Api-Key';
56
23
  /** The header that says a request is an agent's (`agent_call()`), and its session's choice. */
@@ -126,91 +93,9 @@ export async function postgrestBackend(options) {
126
93
  const { data } = await client.auth.getUser(options.accessToken);
127
94
  actingAs = data.user?.id;
128
95
  }
129
- /**
130
- * The client, pointed at one schema.
131
- *
132
- * PostgREST serves a schema other than `public` through the `Accept-Profile`
133
- * and `Content-Profile` headers, which `supabase-js` sets for you through
134
- * `.schema()`. It answers 406 for a schema the project does not expose, and
135
- * no migration can expose one — `ekwo module enable` prints the line to add.
136
- * The socle's schema is always named too (`onSocle()`, below), so a call
137
- * never rests on whichever schema the project happens to list first.
138
- */
139
- const on = (schema) => schema === undefined ? client : client.schema(identifier(schema));
140
- const backend = {
141
- mode: 'postgrest',
142
- actingAs,
143
- agent: options.agent,
144
- async rpc(fn, args = {}, schema) {
145
- const answer = (await on(schema).rpc(identifier(fn), args));
146
- const data = unwrap(answer, fn);
147
- // A function returning one composite row comes back as an object, a
148
- // set-returning one as an array. Tools see an array either way.
149
- return (Array.isArray(data) ? data : [data]);
150
- },
151
- // PostgREST cuts every answer at the `max_rows` of its server and says
152
- // nothing in the body; a range with the exact count is how `readWhole()`
153
- // of the core reads a long ledger to its last line.
154
- async rpcPage(fn, args, schema, page) {
155
- const answer = (await on(schema)
156
- .rpc(identifier(fn), args, { count: 'exact' })
157
- .range(page.offset, page.offset + page.limit - 1));
158
- // A range past the end — rows removed since the last one — is refused
159
- // (`PGRST103`): no rows and no count, which reads again from the start.
160
- if (answer.error?.code === 'PGRST103')
161
- return { rows: [], total: null };
162
- const data = unwrap(answer, fn);
163
- return { rows: (Array.isArray(data) ? data : [data]), total: answer.count ?? null };
164
- },
165
- async rpcVoid(fn, args = {}, schema) {
166
- const answer = (await on(schema).rpc(identifier(fn), args));
167
- if (answer.error !== null) {
168
- throw explain(answer.error.message);
169
- }
170
- },
171
- async select(query) {
172
- let builder = on(query.schema).from(identifier(query.table)).select(query.columns.join(','));
173
- builder = applyFilters(builder, query.where);
174
- for (const order of query.order ?? []) {
175
- builder = builder.order(identifier(order.column), { ascending: order.ascending !== false });
176
- }
177
- if (query.limit !== undefined)
178
- builder = builder.limit(query.limit);
179
- return unwrap((await builder), `select from ${query.table}`);
180
- },
181
- async insert(table, rows, returning = ['*'], schema) {
182
- const answer = (await on(schema)
183
- .from(identifier(table))
184
- .insert(rows)
185
- .select(returning.join(',')));
186
- return unwrap(answer, `insert into ${table}`);
187
- },
188
- async update(table, patch, where, returning = ['*'], schema) {
189
- let builder = on(schema).from(identifier(table)).update(patch);
190
- builder = applyFilters(builder, where);
191
- const answer = (await builder.select(returning.join(',')));
192
- return unwrap(answer, `update ${table}`);
193
- },
194
- async remove(table, where, schema) {
195
- let builder = on(schema).from(identifier(table)).delete();
196
- builder = applyFilters(builder, where);
197
- const answer = (await builder);
198
- if (answer.error !== null)
199
- throw explain(answer.error.message);
200
- },
201
- async close() {
202
- // Stops the refresh timer; there is no socket to give back.
203
- await client.auth.stopAutoRefresh();
204
- },
205
- };
206
- return onSocle(backend, socleSchemaResolver((schema) => socleMarkerOver(on(schema))));
207
- }
208
- /** Whether the socle's marker answers in the schema this client is pointed at. */
209
- async function socleMarkerOver(client) {
210
- const answer = (await client.rpc(SOCLE_MARKER));
211
- const found = socleMarkerAnswer({ ok: answer.error === null, status: answer.status, code: answer.error?.code });
212
- if (found === undefined)
213
- throw explain(answer.error?.message ?? `${SOCLE_MARKER} failed`);
214
- return found;
96
+ // The five operations over this client, and the socle found by its marker,
97
+ // are the core's: `EkwoClient` builds the same backend over the client its
98
+ // caller signed in.
99
+ return supabaseBackend(client, { actingAs, agent: options.agent, explain });
215
100
  }
216
101
  //# sourceMappingURL=postgrest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgrest.js","sourceRoot":"","sources":["../src/postgrest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAuB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAqB,MAAM,eAAe,CAAC;AACjH,OAAO,EACL,YAAY,EACZ,OAAO,EACP,UAAU,GAMX,MAAM,cAAc,CAAC;AAetB,SAAS,YAAY,CAA0B,OAAU,EAAE,OA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A2E;IAC3E,oBAAoB;IACpB,OAAO,eAAe,CAAC,MAAuC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/G,CAAC"}
package/dist/server.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare const SERVER_NAME = "@ekwo-ai/mcp";
23
23
  * `tests/mcp/surface.test.ts` keeps the two equal, so a release that bumps one
24
24
  * and forgets the other fails the build.
25
25
  */
26
- export declare const SERVER_VERSION = "0.30.0";
26
+ export declare const SERVER_VERSION = "0.31.0";
27
27
  export interface ServerOptions {
28
28
  /**
29
29
  * The modules this installation carries, from `public.modules`. Their tools
@@ -85,12 +85,23 @@ export interface ServerOptions {
85
85
  */
86
86
  belowFloor?: string;
87
87
  }
88
+ /**
89
+ * The three things called a statement, said the same way on every tool that
90
+ * names one (`docs/glossary.md`).
91
+ */
92
+ export declare const STATEMENT_IS: {
93
+ readonly financial: "A statement here is a financial statement — a balance sheet or an income statement; the lines of one contact are contact_statement, the file a bank sends is import_bank_statement.";
94
+ readonly account: "A statement here is a statement of account — the lines of one contact; a balance sheet or an income statement is financial_statement, the file a bank sends is import_bank_statement.";
95
+ readonly bank: "A statement here is a bank statement — the file a bank sends and its lines; a balance sheet or an income statement is financial_statement, the lines of one contact are contact_statement.";
96
+ };
97
+ /** What a tax return is beside its form and its filing, said once (`docs/glossary.md`). */
98
+ export declare const TAX_RETURN_IS = "A tax return here is the periodic declaration of every country \u2014 VAT, GST or sales tax \u2014 computed from what was posted; its form is what the pack declares (tax_report_templates), and a filing is one return of one period once prepared or filed (tax_filings).";
88
99
  /**
89
100
  * The period a report of the ledger reads, said once for every tool that takes
90
101
  * `from` and `to`: the same figure asked two ways is the same answer, and the
91
102
  * screens of the books read a year in progress up to today.
92
103
  */
93
- export declare const PERIOD_READ = "A financial year in progress is read up to today unless the person asks otherwise; the answer states the period read.";
104
+ export declare const PERIOD_READ = "Left out, to is today and from the first day of the financial year that holds to \u2014 the period the command line reads too; the answer states the period read.";
94
105
  /**
95
106
  * What a client reads at the handshake, before it calls anything.
96
107
  *
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAoB,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAC9H,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAGnG,OAAO,EAAgB,KAAK,OAAO,EAAY,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAqD,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAI7I,OAAO,EAAgC,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAiE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAErH,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAC1C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,WAAW,CAAC;AA+BvC,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,0HACiG,CAAC;AAE1H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S,GAAG,SAAS,EAEvE,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE;IACN,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,WAAW,EAAE,iBAAiB,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,EACD,EAAE,EAAE,YAAY,CAAC,SAAS,CAAC,KACxB,cAAc,CAAC;AAsCpB;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CASvD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,aAAkB,GAAG,SAAS,CA41CpF"}
package/dist/server.js CHANGED
@@ -27,7 +27,7 @@ export const SERVER_NAME = '@ekwo-ai/mcp';
27
27
  * `tests/mcp/surface.test.ts` keeps the two equal, so a release that bumps one
28
28
  * and forgets the other fails the build.
29
29
  */
30
- export const SERVER_VERSION = '0.30.0';
30
+ export const SERVER_VERSION = '0.31.0';
31
31
  /** Everything a tool returns: JSON, pretty-printed, as one text block. */
32
32
  function ok(payload) {
33
33
  return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
@@ -55,12 +55,23 @@ async function guard(run) {
55
55
  return fail(error);
56
56
  }
57
57
  }
58
+ /**
59
+ * The three things called a statement, said the same way on every tool that
60
+ * names one (`docs/glossary.md`).
61
+ */
62
+ export const STATEMENT_IS = {
63
+ financial: 'A statement here is a financial statement — a balance sheet or an income statement; the lines of one contact are contact_statement, the file a bank sends is import_bank_statement.',
64
+ account: 'A statement here is a statement of account — the lines of one contact; a balance sheet or an income statement is financial_statement, the file a bank sends is import_bank_statement.',
65
+ bank: 'A statement here is a bank statement — the file a bank sends and its lines; a balance sheet or an income statement is financial_statement, the lines of one contact are contact_statement.',
66
+ };
67
+ /** What a tax return is beside its form and its filing, said once (`docs/glossary.md`). */
68
+ export const TAX_RETURN_IS = 'A tax return here is the periodic declaration of every country — VAT, GST or sales tax — computed from what was posted; its form is what the pack declares (tax_report_templates), and a filing is one return of one period once prepared or filed (tax_filings).';
58
69
  /**
59
70
  * The period a report of the ledger reads, said once for every tool that takes
60
71
  * `from` and `to`: the same figure asked two ways is the same answer, and the
61
72
  * screens of the books read a year in progress up to today.
62
73
  */
63
- export const PERIOD_READ = 'A financial year in progress is read up to today unless the person asks otherwise; the answer states the period read.';
74
+ export const PERIOD_READ = 'Left out, to is today and from the first day of the financial year that holds to — the period the command line reads too; the answer states the period read.';
64
75
  /**
65
76
  * What a client reads at the handshake, before it calls anything.
66
77
  *
@@ -73,7 +84,7 @@ export const PERIOD_READ = 'A financial year in progress is read up to today unl
73
84
  export const INSTRUCTIONS = [
74
85
  'Ekwo OS keeps double-entry books in the user\'s own Postgres. You act as that user: everything you can see and change is what row level security lets them see and change. Amounts are decimal strings ("1210.00"), dates are ISO (2026-06-15), identifiers are uuids.',
75
86
  'A first session, in order. (1) list_companies: every other tool takes a company_id from it; an empty list means this user has not been invited to a company yet, and status says who you are acting as. (2) get_company: the financial years and whether each is closed, the lock dates, the journals and the role accounts — a date you book on falls in an open year, after the lock date. (3) list_accounts and the resource ekwo://companies/{companyId}/taxes: a document line names its account and its tax by code, never by rate, because several taxes share a rate; describe_pack says which country pack those codes come from and how far it has been reviewed. (4) search_contacts, then create_contact only if nobody matches, then create_document: a draft with the totals the database computed. Show it to the user. (5) post_document once the user has said yes to that document; record_payment when the money moves. How you may post is the database\'s to hold you to, and status says it: the company\'s agent_posting (in get_company) and the choice the person made for this session. In review, the default, a document is posted only after a person approved that draft as it stands, and post_document is refused with approval_required until then; in autopilot — the company\'s setting, or a session the person started so — you post directly, and every posting is recorded on the audit trail with this session. A company that forbids autopilot refuses it (autopilot_forbidden).',
76
- 'Reading a tax return: vat_return gives the boxes of a period with their names and amounts, summed from what was posted, and the boxes computed from other boxes; a draft is in no box. Name a report_code only where the country files several declarations. It prepares figures and files nothing — the prompt prepare_vat_return walks through checking them against the ledger. The reports beside it are trial_balance, general_ledger, journal_book (the book of one journal or of all of them, with the totals of each), aged_balance, subledger (a receivable or payable account contact by contact, with its control against the trial balance), contact_statement (one contact), financial_statement (list_statements first), financial_analysis, the figures a ratio is computed from, and analytic_report, the result of each project, cost centre or site of an analytic axis. The period: a financial year that is over is read whole, from its first day to its last; a year in progress from its first day to today, unless the person asks for another period. Every answer states the period it read.',
87
+ 'Reading a tax return: vat_return gives the boxes of a period with their names and amounts, summed from what was posted, and the boxes computed from other boxes; a draft is in no box. Name a report_code only where the country files several declarations. It prepares figures and files nothing — the prompt prepare_vat_return walks through checking them against the ledger. The reports beside it are trial_balance, general_ledger, journal_book (the book of one journal or of all of them, with the totals of each), aged_balance, subledger (a receivable or payable account contact by contact, with its control against the trial balance), contact_statement (one contact), financial_statement (list_statements first), financial_analysis, the figures a ratio is computed from, and analytic_report, the result of each project, cost centre or site of an analytic axis. The period: a financial year that is over is read whole, from its first day to its last; a year in progress from its first day to today, unless the person asks for another period — which is what a report reads when from and to are left out. Every answer states the period it read.',
77
88
  'Correcting: a posted entry is never deleted or edited. A posted invoice is undone by cancel_document — back to draft where its country allows it and nothing has left, by the credit note that names it otherwise, and it says which — and an entry keyed by hand by reverse_entry. A paid document is unmatched first with unreconcile, and only when the user says so. Ask the user before every post, cancel, reversal, payment or lock.',
78
89
  'When the database refuses, the message starts with a name — period_locked, entry_unbalanced, document_total_mismatch, reversal_date_needed — followed by a sentence saying what to do next. Report it to the user and follow that sentence rather than working around it.',
79
90
  ].join('\n\n');
@@ -193,10 +204,11 @@ export function buildServer(backend, options = {}) {
193
204
  }, async (args) => guard(() => read.suggestDuplicateContacts(backend, args)));
194
205
  register('contact_statement', {
195
206
  title: 'Statement of a contact',
196
- description: 'The statement of account of one customer or supplier over a period: the balance carried forward from before it, then every posted line of their receivable and payable accounts — date, journal, entry, the document it books, debit, credit and running balance — and the balance the period ends on. Debit minus credit, in the company currency: positive is what the contact owes the company, negative what the company owes them. Each line says how far a matching has settled it today (matching_state open, partial or matched, and open_amount). Drafts are not in it. It is the ledger read for one contact, on the accounts aged_balance reads, with the opposite sign on a payable: aged_balance gives what is still open as a positive amount on either side, one side at a time.',
207
+ description: 'The statement of account of one customer or supplier over a period: the balance carried forward from before it, then every posted line of their receivable and payable accounts — date, journal, entry, the document it books, debit, credit and running balance — and the balance the period ends on. Debit minus credit, in the company currency: positive is what the contact owes the company, negative what the company owes them. Each line says how far a matching has settled it today (matching_state open, partial or matched, and open_amount). Drafts are not in it. It is the ledger read for one contact, on the accounts aged_balance reads, with the opposite sign on a payable: aged_balance gives what is still open as a positive amount on either side, one side at a time.' +
208
+ ` ${STATEMENT_IS.account}`,
197
209
  inputSchema: read.ContactStatementInput.shape,
198
210
  annotations: { readOnlyHint: true, openWorldHint: false },
199
- }, async (args) => guard(() => read.contactStatement(backend, args)));
211
+ }, async (args) => guard(async () => read.contactStatement(backend, await read.inPeriod(backend, args))));
200
212
  register('list_tax_certificates', {
201
213
  title: 'Certificates the buyers handed over',
202
214
  description: 'The certificates the buyers of a company handed over — resale certificates, exemption certificates, declarations of intent — with the contact, the reference, the territory under whose law each was given and the days it covers, the most recent first. A sale invoice under a tax that applies on such a certificate (its conditions in describe_pack include buyer_certificate) posts only if its buyer holds one that covers the document\'s date and place of supply; post_document is refused with no_buyer_certificate otherwise.',
@@ -280,21 +292,21 @@ export function buildServer(backend, options = {}) {
280
292
  ` ${PERIOD_READ}`,
281
293
  inputSchema: read.TrialBalanceInput.shape,
282
294
  annotations: { readOnlyHint: true, openWorldHint: false },
283
- }, async (args) => guard(() => read.trialBalance(backend, args)));
295
+ }, async (args) => guard(async () => read.trialBalance(backend, await read.inPeriod(backend, args))));
284
296
  register('general_ledger', {
285
297
  title: 'General ledger',
286
298
  description: 'Every posted line of an account over a period, with the balance carried forward from before it and a running balance. Give account_code for one account; leave it out for all of them, which on a real company is a lot of lines. contact_ids keeps the lines of those contacts only, each with its own balance carried forward and running balance — the detail of a row of subledger. Every line is returned; truncated is true only when a ledger too long to read was stopped before its end, and then narrow the period or name an account before reading the last balance as the closing one.' +
287
299
  ` ${PERIOD_READ}`,
288
300
  inputSchema: read.GeneralLedgerInput.shape,
289
301
  annotations: { readOnlyHint: true, openWorldHint: false },
290
- }, async (args) => guard(() => read.generalLedger(backend, args)));
302
+ }, async (args) => guard(async () => read.generalLedger(backend, await read.inPeriod(backend, args))));
291
303
  register('journal_book', {
292
304
  title: 'Journal book',
293
305
  description: 'The book of a journal: every line of every posted entry over a period, in the order a book is read — day, journal, entry number, line — each with its entry, the document behind it, its account and its contact, and the totals of each journal at the head. Give journal_code for one journal (the sales journal, the bank); leave it out for the book of every journal, which on a real company is a lot of lines. For one account with its running balance, use general_ledger. Every line is returned; truncated is true only when a book too long to read was stopped before its end, its lines then no longer add up to the totals, and the period or the journal has to be narrowed.' +
294
306
  ` ${PERIOD_READ}`,
295
307
  inputSchema: read.JournalBookInput.shape,
296
308
  annotations: { readOnlyHint: true, openWorldHint: false },
297
- }, async (args) => guard(() => read.journalBook(backend, args)));
309
+ }, async (args) => guard(async () => read.journalBook(backend, await read.inPeriod(backend, args))));
298
310
  register('suggest_line_contacts', {
299
311
  title: 'Suggest the contact of lines that name nobody',
300
312
  description: 'For each open line on a receivable or payable account that names no contact — typically the open items of books imported line by line — the contacts it could be, best first, each with a score, the method (a learned motif, the number of a document of the company quoted in the label, the description or the reference of the entry, the words of a contact\'s name), the evidence in a sentence, and alternatives: how many contacts the same evidence reached. More than 1 is a question for the user, not an answer. It writes nothing; set_line_contact names a line once the user has chosen.',
@@ -331,10 +343,11 @@ export function buildServer(backend, options = {}) {
331
343
  ` ${PERIOD_READ}`,
332
344
  inputSchema: read.SubledgerInput.shape,
333
345
  annotations: { readOnlyHint: true, openWorldHint: false },
334
- }, async (args) => guard(() => read.subledger(backend, args)));
346
+ }, async (args) => guard(async () => read.subledger(backend, await read.inPeriod(backend, args))));
335
347
  register('vat_return', {
336
348
  title: 'VAT return',
337
- description: 'The boxes of the VAT return for a period, with their names: the base and tax boxes are summed from what the postings wrote on the ledger lines, the totals are derived from them by the declaration form of the country pack. No country rule lives in this tool, nor in the function behind it. Name a report_code only where a country files several declarations. It prepares figures; it files nothing. The boxes are read live from the ledger at the moment of the call. Where a declaration of the period was already prepared or filed, filing carries it — its state, dates and reference, and per box what was filed, what the ledger says now and the difference — and when drifted is true, tell the person that the filed figures are the ones the administration holds, that something was booked in the period since, and that changing a declaration that has gone takes a corrective.',
349
+ description: 'The boxes of the VAT return for a period, with their names: the base and tax boxes are summed from what the postings wrote on the ledger lines, the totals are derived from them by the declaration form of the country pack. No country rule lives in this tool, nor in the function behind it. Name a report_code only where a country files several declarations. It prepares figures; it files nothing. The boxes are read live from the ledger at the moment of the call. Where a declaration of the period was already prepared or filed, filing carries it — its state, dates and reference, and per box what was filed, what the ledger says now and the difference — and when drifted is true, tell the person that the filed figures are the ones the administration holds, that something was booked in the period since, and that changing a declaration that has gone takes a corrective.' +
350
+ ` ${TAX_RETURN_IS}`,
338
351
  inputSchema: read.VatReturnInput.shape,
339
352
  annotations: { readOnlyHint: true, openWorldHint: false },
340
353
  }, async (args) => guard(() => read.vatReturn(backend, args)));
@@ -370,24 +383,26 @@ export function buildServer(backend, options = {}) {
370
383
  }, async (args) => guard(() => read.portfolioOverview(backend, args)));
371
384
  register('list_statements', {
372
385
  title: 'List financial statements',
373
- description: 'The schemes this company can be presented on: those of its country and of its chart of accounts, plus the generic framework by account type that fits any chart. Ask this before financial_statement rather than guessing a code.',
386
+ description: 'The schemes this company can be presented on: those of its country and of its chart of accounts, plus the generic framework by account type that fits any chart. Ask this before financial_statement rather than guessing a code.' +
387
+ ` ${STATEMENT_IS.financial}`,
374
388
  inputSchema: read.ListStatementsInput.shape,
375
389
  annotations: { readOnlyHint: true, openWorldHint: false },
376
390
  }, async (args) => guard(() => read.listStatements(backend, args)));
377
391
  register('financial_statement', {
378
392
  title: 'Financial statement',
379
393
  description: 'A balance sheet or an income statement for a period, on the scheme the country pack declares — the Belgian abbreviated model, the French liasse — or on the generic framework by account type. Each line is summed from the accounts its rules catch and the totals are derived from the lines; no country rule lives in this tool. It also returns the accounts no line catches: if that list is not empty, say so instead of presenting a statement that does not tie out. It prepares figures; it files nothing.' +
380
- ` ${PERIOD_READ}`,
394
+ ` ${PERIOD_READ}` +
395
+ ` ${STATEMENT_IS.financial}`,
381
396
  inputSchema: read.FinancialStatementInput.shape,
382
397
  annotations: { readOnlyHint: true, openWorldHint: false },
383
- }, async (args) => guard(() => read.financialStatement(backend, args)));
398
+ }, async (args) => guard(async () => read.financialStatement(backend, await read.inPeriod(backend, args))));
384
399
  register('financial_analysis', {
385
400
  title: 'Financial analysis',
386
401
  description: "The figures an analysis of a company is computed from — revenue, other operating income, purchases, staff costs, depreciation, the financial result, income tax, the net result, equity, total and current assets, cash, trade receivables, current liabilities, trade payables, long-term debt — each with the accounts that make it. The movements are read over the period and the balances at its end; equity includes the result of the years not closed yet. Which accounts make each figure is written in the company's country pack and in no tool. Each row carries source: pack when the country pack defines the analysis; framework when it defines none and the figures are read by account type through the generic framework, which leaves out staff costs, the financial result and income tax because no account type tells them apart — say those are not read rather than zero. The figures are never to be guessed from account codes. Ratios — a margin, a current ratio, days of sales outstanding — are worked out from these, not stored. It prepares figures; it files nothing." +
387
402
  ` ${PERIOD_READ}`,
388
403
  inputSchema: read.FinancialAnalysisInput.shape,
389
404
  annotations: { readOnlyHint: true, openWorldHint: false },
390
- }, async (args) => guard(() => read.financialAnalysis(backend, args)));
405
+ }, async (args) => guard(async () => read.financialAnalysis(backend, await read.inPeriod(backend, args))));
391
406
  register('list_analytic_axes', {
392
407
  title: 'Analytic axes',
393
408
  description: 'The analytic axes of a company — a cost centre, a project, a site, a business unit — each with its values, which may nest under a parent_id, and required_on: none, or expense, income or result — the lines that must carry the axis whole, or posting refuses them (analytic_axis_required). A value says what a cost, a revenue or a fixed asset is for; a product says what was sold or bought. A retired value takes no new share. Read it before analytic_report, which takes an axis by its code.',
@@ -400,7 +415,7 @@ export function buildServer(backend, options = {}) {
400
415
  ` ${PERIOD_READ}`,
401
416
  inputSchema: read.AnalyticReportInput.shape,
402
417
  annotations: { readOnlyHint: true, openWorldHint: false },
403
- }, async (args) => guard(() => read.analyticReport(backend, args)));
418
+ }, async (args) => guard(async () => read.analyticReport(backend, await read.inPeriod(backend, args))));
404
419
  register('generate_fec', {
405
420
  title: 'Generate the French FEC',
406
421
  description: 'The Fichier des Écritures Comptables for a period: the eighteen columns of the arrêté du 29 juillet 2013, as text, with the checks a tax inspector applies first (mandatory fields, one side per line, entries balancing) and the filename the format wants. The file comes back in the answer; writing it to disk is the caller\'s business.',
@@ -577,7 +592,8 @@ export function buildServer(backend, options = {}) {
577
592
  }, async (args) => guard(() => write.reconcileWithDifference(backend, args)));
578
593
  register('settle_from_statement', {
579
594
  title: 'Settle a bank statement line',
580
- description: 'Books a pending statement line as the payment it is and matches it against the documents or open items named, in one entry: the bank, the customer or supplier account, and the extra lines the money is net of — the fee a payment provider kept from a payout, the charges of a bank, each on the account and with the tax the user names. A payout of 97.00 for an invoice of 100.00 settles the invoice in full with an extra line of 3.00 on a fee account. amounts says how much settles each item; left out, oldest first. The line has to balance to the cent (settlement_unbalanced otherwise, with the difference). Extra lines alone settle a bank charge. One counterparty per line. The entry cannot be unposted. Ask the user before calling it, and for the fee account and its tax.',
595
+ description: 'Books a pending statement line as the payment it is and matches it against the documents or open items named, in one entry: the bank, the customer or supplier account, and the extra lines the money is net of — the fee a payment provider kept from a payout, the charges of a bank, each on the account and with the tax the user names. A payout of 97.00 for an invoice of 100.00 settles the invoice in full with an extra line of 3.00 on a fee account. amounts says how much settles each item; left out, oldest first. The line has to balance to the cent (settlement_unbalanced otherwise, with the difference). Extra lines alone settle a bank charge. One counterparty per line. The entry cannot be unposted. Ask the user before calling it, and for the fee account and its tax.' +
596
+ ` ${STATEMENT_IS.bank}`,
581
597
  inputSchema: write.SettleFromStatementInput.shape,
582
598
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
583
599
  }, async (args) => guard(() => write.settleFromStatement(backend, args)));
@@ -607,7 +623,8 @@ export function buildServer(backend, options = {}) {
607
623
  }, async (args) => guard(() => write.createBankTransaction(backend, args)));
608
624
  register('import_bank_statement', {
609
625
  title: 'Import a bank statement',
610
- description: 'Reads a bank statement file and writes its statements and lines. `format` says what the file is — `camt.053` (the ISO 20022 XML statement), `coda`, `cfonb120`, or `csv` with the account it is of (`bank_account_id`) and the profile of its columns (`csv_profile`, kept on the account once an import with it succeeds, and read from there when left out), which are the ones this server reads today — and `content` is the file as text. It is never guessed from the content. It books nothing: every line waits as pending, to be settled afterwards. Safe to repeat: the same file imported twice creates nothing the second time, and a statement overlapping an earlier one imports only the new lines. Refused by name, with nothing written: an account the company does not have (create it first with create_bank_account — an import never creates one), a statement whose opening balance plus lines is not its closing balance, a line in another currency. Signalled in `warnings`, not refused: an opening balance that is not the previous closing one, which means a statement is missing.',
626
+ description: 'Reads a bank statement file and writes its statements and lines. `format` says what the file is — `camt.053` (the ISO 20022 XML statement), `coda`, `cfonb120`, or `csv` with the account it is of (`bank_account_id`) and the profile of its columns (`csv_profile`, kept on the account once an import with it succeeds, and read from there when left out), which are the ones this server reads today — and `content` is the file as text. It is never guessed from the content. It books nothing: every line waits as pending, to be settled afterwards. Safe to repeat: the same file imported twice creates nothing the second time, and a statement overlapping an earlier one imports only the new lines. Refused by name, with nothing written: an account the company does not have (create it first with create_bank_account — an import never creates one), a statement whose opening balance plus lines is not its closing balance, a line in another currency. Signalled in `warnings`, not refused: an opening balance that is not the previous closing one, which means a statement is missing.' +
627
+ ` ${STATEMENT_IS.bank}`,
611
628
  inputSchema: write.ImportBankStatementInput.shape,
612
629
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
613
630
  }, async (args) => guard(() => write.importBankStatement(backend, args)));