@frihet/mcp-server 1.16.6 → 2.0.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.
Files changed (108) hide show
  1. package/README.md +168 -82
  2. package/dist/agent-onboarding.d.ts +98 -0
  3. package/dist/agent-onboarding.js +275 -0
  4. package/dist/api-origin.d.ts +9 -0
  5. package/dist/api-origin.js +41 -0
  6. package/dist/canary/mcp-harness.d.ts +77 -0
  7. package/dist/canary/mcp-harness.js +552 -0
  8. package/dist/capability-truth.d.ts +29 -0
  9. package/dist/capability-truth.js +262 -0
  10. package/dist/claude-candidate-contract.d.ts +482 -0
  11. package/dist/claude-candidate-contract.js +87 -0
  12. package/dist/claude-output-privacy.d.ts +17 -0
  13. package/dist/claude-output-privacy.js +240 -0
  14. package/dist/claude-profile.d.ts +18 -0
  15. package/dist/claude-profile.js +260 -0
  16. package/dist/client-interface.d.ts +47 -33
  17. package/dist/client.d.ts +172 -40
  18. package/dist/client.js +708 -165
  19. package/dist/demo-client.d.ts +41 -32
  20. package/dist/demo-client.js +202 -31
  21. package/dist/demo-fixtures.d.ts +3 -3
  22. package/dist/demo-fixtures.js +7 -7
  23. package/dist/deposit-contract.d.ts +29 -0
  24. package/dist/deposit-contract.js +76 -0
  25. package/dist/fetch-no-redirect.d.ts +3 -0
  26. package/dist/fetch-no-redirect.js +16 -0
  27. package/dist/fiscal-aliases.d.ts +44 -0
  28. package/dist/fiscal-aliases.js +62 -0
  29. package/dist/fiscal-period.d.ts +26 -0
  30. package/dist/fiscal-period.js +31 -0
  31. package/dist/google-profile.d.ts +19 -0
  32. package/dist/google-profile.js +122 -0
  33. package/dist/index.js +68 -59
  34. package/dist/logger.d.ts +2 -2
  35. package/dist/logger.js +140 -8
  36. package/dist/muse-profile.d.ts +19 -0
  37. package/dist/muse-profile.js +122 -0
  38. package/dist/observability.d.ts +18 -29
  39. package/dist/observability.js +194 -106
  40. package/dist/openai-profile.d.ts +26 -22
  41. package/dist/openai-profile.js +1193 -157
  42. package/dist/openai-review-contract.d.ts +15 -6
  43. package/dist/openai-review-contract.js +714 -41
  44. package/dist/openai-review-oauth.d.ts +149 -2
  45. package/dist/openai-review-oauth.js +220 -6
  46. package/dist/prompts/register-all.d.ts +2 -0
  47. package/dist/prompts/register-all.js +34 -78
  48. package/dist/public-capability-contract.d.ts +39 -0
  49. package/dist/public-capability-contract.js +186 -0
  50. package/dist/redaction.d.ts +15 -0
  51. package/dist/redaction.js +83 -0
  52. package/dist/resources/register-all.js +154 -64
  53. package/dist/retry-after.d.ts +19 -0
  54. package/dist/retry-after.js +84 -0
  55. package/dist/server-composition.d.ts +19 -0
  56. package/dist/server-composition.js +74 -0
  57. package/dist/tool-exposure.d.ts +31 -27
  58. package/dist/tool-exposure.js +211 -87
  59. package/dist/tools/accountingClose.d.ts +14 -5
  60. package/dist/tools/accountingClose.js +41 -23
  61. package/dist/tools/audit_gl.js +8 -8
  62. package/dist/tools/backend-availability.d.ts +8 -29
  63. package/dist/tools/backend-availability.js +31 -30
  64. package/dist/tools/bank_rules.js +66 -15
  65. package/dist/tools/banking.js +5 -13
  66. package/dist/tools/clients.js +261 -15
  67. package/dist/tools/crm.js +22 -21
  68. package/dist/tools/deposits.js +114 -85
  69. package/dist/tools/einvoice.d.ts +16 -2
  70. package/dist/tools/einvoice.js +59 -12
  71. package/dist/tools/expenses.d.ts +16 -0
  72. package/dist/tools/expenses.js +47 -27
  73. package/dist/tools/fiscal.d.ts +3 -4
  74. package/dist/tools/fiscal.js +93 -60
  75. package/dist/tools/gestoria.js +15 -7
  76. package/dist/tools/hr.d.ts +2 -3
  77. package/dist/tools/hr.js +49 -20
  78. package/dist/tools/igic.d.ts +9 -8
  79. package/dist/tools/igic.js +34 -64
  80. package/dist/tools/impuesto_sociedades.d.ts +4 -5
  81. package/dist/tools/impuesto_sociedades.js +16 -37
  82. package/dist/tools/intelligence.js +166 -12
  83. package/dist/tools/invoices.js +224 -54
  84. package/dist/tools/kitchen.js +19 -9
  85. package/dist/tools/payroll.d.ts +5 -8
  86. package/dist/tools/payroll.js +19 -32
  87. package/dist/tools/permissions.d.ts +4 -7
  88. package/dist/tools/permissions.js +11 -14
  89. package/dist/tools/products.js +6 -6
  90. package/dist/tools/quotes.js +172 -26
  91. package/dist/tools/recurring.js +26 -25
  92. package/dist/tools/register-all.d.ts +2 -2
  93. package/dist/tools/register-all.js +9 -6
  94. package/dist/tools/search.d.ts +19 -0
  95. package/dist/tools/search.js +84 -0
  96. package/dist/tools/shared.d.ts +1445 -109
  97. package/dist/tools/shared.js +478 -102
  98. package/dist/tools/team.js +24 -28
  99. package/dist/tools/time.js +4 -12
  100. package/dist/tools/vendors.js +249 -15
  101. package/dist/tools/webhooks.js +35 -30
  102. package/dist/types.d.ts +31 -5
  103. package/dist/workflows/daily-operational-brief.d.ts +163 -0
  104. package/dist/workflows/daily-operational-brief.js +881 -0
  105. package/docs/agent-onboarding.json +391 -0
  106. package/package.json +49 -12
  107. package/dist/tools/onboarding.d.ts +0 -19
  108. package/dist/tools/onboarding.js +0 -64
@@ -5,7 +5,7 @@
5
5
  * classes satisfy this interface via structural typing. Tool registration
6
6
  * functions depend on this interface so they can work with either client.
7
7
  */
8
- import type { PaginatedResponse } from "./types.js";
8
+ import type { CreateWebhookInput, CreateWebhookResult, PaginatedResponse, UpdateWebhookInput, Webhook } from "./types.js";
9
9
  export interface IFrihetClient {
10
10
  listInvoices(params?: {
11
11
  limit?: number;
@@ -21,7 +21,12 @@ export interface IFrihetClient {
21
21
  getInvoice(id: string): Promise<Record<string, unknown>>;
22
22
  createInvoice(data: Record<string, unknown>): Promise<Record<string, unknown>>;
23
23
  updateInvoice(id: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
24
- deleteInvoice(id: string): Promise<void>;
24
+ /**
25
+ * Resolves to the soft-cancel payload when the backend answered 200 (non-draft
26
+ * invoice CANCELLED, not destroyed — VeriFactu hash chain), or void/undefined
27
+ * when it answered 204 (draft really removed). See `FrihetClient.deleteInvoice`.
28
+ */
29
+ deleteInvoice(id: string): Promise<Record<string, unknown> | void>;
25
30
  searchInvoices(query: string, params?: {
26
31
  limit?: number;
27
32
  offset?: number;
@@ -83,7 +88,8 @@ export interface IFrihetClient {
83
88
  getQuote(id: string): Promise<Record<string, unknown>>;
84
89
  createQuote(data: Record<string, unknown>): Promise<Record<string, unknown>>;
85
90
  updateQuote(id: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
86
- deleteQuote(id: string): Promise<void>;
91
+ /** Same 200-cancel / 204-destroy contract as {@link IFrihetClient.deleteInvoice}. */
92
+ deleteQuote(id: string): Promise<Record<string, unknown> | void>;
87
93
  listVendors(params?: {
88
94
  q?: string;
89
95
  limit?: number;
@@ -97,8 +103,8 @@ export interface IFrihetClient {
97
103
  deleteVendor(id: string): Promise<void>;
98
104
  sendInvoice(id: string, to?: string): Promise<Record<string, unknown>>;
99
105
  markInvoicePaid(id: string, paidDate?: string): Promise<Record<string, unknown>>;
100
- getInvoicePdf(id: string): Promise<Record<string, unknown>>;
101
- getInvoiceEInvoice(invoiceId: string): Promise<any>;
106
+ getInvoicePdf(id: string): Promise<import("./client.js").BinaryDocument>;
107
+ getInvoiceEInvoice(invoiceId: string): Promise<import("./client.js").EInvoiceDocument>;
102
108
  createCreditNote(invoiceId: string, data: {
103
109
  reason: string;
104
110
  reasonDescription?: string;
@@ -110,14 +116,31 @@ export interface IFrihetClient {
110
116
  daysOverdue?: number;
111
117
  }): Promise<any>;
112
118
  sendQuote(id: string, to?: string): Promise<Record<string, unknown>>;
113
- listWebhooks(params?: {
119
+ listWebhooks(): Promise<{
120
+ data: Webhook[];
121
+ total: number;
122
+ _demo?: true;
123
+ _demoNotice?: string;
124
+ }>;
125
+ getWebhook(id: string): Promise<Webhook>;
126
+ createWebhook(data: CreateWebhookInput): Promise<CreateWebhookResult>;
127
+ updateWebhook(id: string, data: UpdateWebhookInput): Promise<Webhook>;
128
+ deleteWebhook(id: string): Promise<void>;
129
+ globalSearch(params: {
130
+ q: string;
131
+ types?: ReadonlyArray<"invoices" | "expenses" | "vendors" | "clients" | "products">;
114
132
  limit?: number;
115
133
  offset?: number;
116
- }): Promise<PaginatedResponse<Record<string, unknown>>>;
117
- getWebhook(id: string): Promise<Record<string, unknown>>;
118
- createWebhook(data: Record<string, unknown>): Promise<Record<string, unknown>>;
119
- updateWebhook(id: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
120
- deleteWebhook(id: string): Promise<void>;
134
+ }): Promise<{
135
+ data: Record<string, unknown>[];
136
+ total: number;
137
+ limit: number;
138
+ offset: number;
139
+ hasMore: boolean;
140
+ query: string;
141
+ types: ReadonlyArray<"invoices" | "expenses" | "vendors" | "clients" | "products">;
142
+ truncated?: boolean;
143
+ }>;
121
144
  listClientContacts(clientId: string, params?: {
122
145
  limit?: number;
123
146
  offset?: number;
@@ -198,14 +221,9 @@ export interface IFrihetClient {
198
221
  }>;
199
222
  exportEInvoice(params: {
200
223
  invoiceId: string;
201
- format: string;
224
+ format: import("./client.js").McpEInvoiceExportFormat;
202
225
  signed?: boolean;
203
- }): Promise<{
204
- xmlUrl: string;
205
- filename: string;
206
- format: string;
207
- signed: boolean;
208
- }>;
226
+ }): Promise<import("./client.js").EInvoiceExportResult>;
209
227
  faceSubmit(params: {
210
228
  invoiceId: string;
211
229
  mode: "mock" | "sandbox" | "production";
@@ -379,7 +397,7 @@ export interface IFrihetClient {
379
397
  updateTeamMemberRole(memberId: string, role: string): Promise<Record<string, unknown>>;
380
398
  removeTeamMember(memberId: string): Promise<void>;
381
399
  approveGLEntry(entryId: string, notes?: string): Promise<Record<string, unknown>>;
382
- rejectGLEntry(entryId: string, reason: string): Promise<Record<string, unknown>>;
400
+ rejectGLEntry(entryId: string, note: string): Promise<Record<string, unknown>>;
383
401
  getGLEntryAuditLog(entryId: string): Promise<Record<string, unknown>>;
384
402
  addCustomPortalDomain(data: {
385
403
  domain: string;
@@ -421,15 +439,13 @@ export interface IFrihetClient {
421
439
  }): Promise<import("./types.js").PaginatedResponse<Record<string, unknown>>>;
422
440
  createBankRule(data: {
423
441
  name: string;
424
- conditions: Array<{
442
+ bankConditions: Array<{
425
443
  field: string;
426
444
  operator: string;
427
445
  value: string;
428
446
  }>;
429
- actions: Array<{
430
- type: string;
431
- value: string;
432
- }>;
447
+ action: string;
448
+ actionConfig: Record<string, unknown>;
433
449
  isActive?: boolean;
434
450
  }): Promise<Record<string, unknown>>;
435
451
  sendGestoriaMessage(data: {
@@ -472,7 +488,9 @@ export interface IFrihetClient {
472
488
  };
473
489
  }): Promise<Record<string, unknown>>;
474
490
  getGestoriaAgingConsolidated(params?: {
475
- ownerUid?: string;
491
+ workspaceIds?: string[];
492
+ asOf?: string;
493
+ bustCache?: boolean;
476
494
  }): Promise<Record<string, unknown>>;
477
495
  listLeaves(params?: {
478
496
  employeeId?: string;
@@ -501,8 +519,8 @@ export interface IFrihetClient {
501
519
  employeeId: string;
502
520
  mood?: string;
503
521
  location?: string;
504
- }): Promise<Record<string, unknown>>;
505
- attendanceClockOut(entryId: string): Promise<Record<string, unknown>>;
522
+ }, idempotencyKey?: string): Promise<Record<string, unknown>>;
523
+ attendanceClockOut(entryId: string, idempotencyKey?: string): Promise<Record<string, unknown>>;
506
524
  getOvertimeReport(params: {
507
525
  period: string;
508
526
  employeeId?: string;
@@ -519,20 +537,16 @@ export interface IFrihetClient {
519
537
  eventType?: string;
520
538
  }): Promise<Record<string, unknown>>;
521
539
  exportPayroll(params: {
522
- format: "a3" | "contasol" | "sage" | "holded" | "siltra";
540
+ format: "a3" | "contasol" | "sage" | "siltra";
523
541
  month: string;
524
542
  }): Promise<Record<string, unknown>>;
525
543
  getPayrollChecklist(params: {
526
544
  month: string;
527
545
  }): Promise<Record<string, unknown>>;
528
- getOnboardingStatus(): Promise<Record<string, unknown>>;
529
- setOnboardingPersona(data: {
530
- persona: "autonomo" | "empresa" | "agencia" | "gestoria";
531
- }): Promise<Record<string, unknown>>;
532
546
  getPermissionsMatrix(): Promise<Record<string, unknown>>;
533
547
  getMyPermissions(): Promise<Record<string, unknown>>;
534
548
  getCurrentPeriod(params?: {
535
- periodId?: string;
549
+ fiscalYear?: string;
536
550
  }): Promise<Record<string, unknown>>;
537
551
  closePeriod(data: {
538
552
  type: "monthly" | "quarterly";
package/dist/client.d.ts CHANGED
@@ -11,11 +11,82 @@
11
11
  * (`req.query.cursor`, functions/src/publicApi.ts in Frihet-ERP). `after`
12
12
  * is never sent on the wire. See src/__tests__/pagination-cursor-param.test.ts.
13
13
  */
14
- import type { PaginatedResponse } from "./types.js";
14
+ import type { CreateWebhookInput, CreateWebhookResult, PaginatedResponse, UpdateWebhookInput, Webhook } from "./types.js";
15
+ /**
16
+ * Hard size caps for document responses. Enforced TWICE: precheck on
17
+ * `Content-Length` (so an honest server doesn't waste bandwidth) and after
18
+ * streaming (so a missing/lying `Content-Length` still can't trigger an
19
+ * unbounded allocation).
20
+ *
21
+ * - PDF: 25 MiB — generous for any ERP-issued invoice PDF, including
22
+ * embedded logos, Facturae XML attachments, and stamp signatures.
23
+ * - XML: 5 MiB — UBL / Facturae / PEPPOL documents stay well under 1 MiB
24
+ * in practice; 5 MiB absorbs any historical / annex-laden outlier.
25
+ *
26
+ * Anything larger is rejected with `413 payload_too_large` BEFORE we allocate
27
+ * — the user sees a clean error, the worker doesn't OOM.
28
+ */
29
+ export declare const MAX_PDF_BYTES: number;
30
+ export declare const MAX_XML_BYTES: number;
31
+ /**
32
+ * Bounded binary document response. Always base64-encoded because MCP
33
+ * `structuredContent` is JSON-only — raw `Uint8Array` would coerce to a
34
+ * sparse object on the wire.
35
+ */
36
+ export interface BinaryDocument {
37
+ /** Echoed id from the request (invoice id), so callers can correlate. */
38
+ id: string;
39
+ /** Verbatim `Content-Type` from the response (e.g. `application/pdf`). */
40
+ contentType: string;
41
+ /** Byte length of the decoded body. Equal to the decoded base64 byte length. */
42
+ sizeBytes: number;
43
+ /** Base64-encoded bytes. */
44
+ base64: string;
45
+ /** Filename hint parsed from `Content-Disposition`, when present. */
46
+ filename?: string;
47
+ }
48
+ /**
49
+ * Bounded XML document response (UBL / CII / Facturae / PEPPOL / FatturaPA /
50
+ * XRechnung — anything declared `application/xml` or `text/xml`).
51
+ */
52
+ export interface XmlDocument {
53
+ /** Echoed id from the request (invoice id). */
54
+ id: string;
55
+ /** Strictly decoded UTF-8 XML text. */
56
+ xml: string;
57
+ /** Verbatim `Content-Type` from the response. */
58
+ contentType: string;
59
+ /** Byte length of the decoded UTF-8 body. */
60
+ sizeBytes: number;
61
+ /** Filename hint parsed from `Content-Disposition`, when present. */
62
+ filename?: string;
63
+ }
64
+ /** `/invoices/:id/xml` serves XML or a Factur-X PDF, depending on storage MIME. */
65
+ export type EInvoiceDocument = XmlDocument | BinaryDocument;
66
+ /** Ergonomic values accepted by the MCP `einvoice_export` tool. This is
67
+ * deliberately narrower than the asynchronous dispatch/validation format
68
+ * family: the public export API exposes only the EN16931 Factur-X profile. */
69
+ export type McpEInvoiceExportFormat = "facturae" | "xrechnung-cii" | "xrechnung-ubl" | "facturx-en16931" | "fatturapa" | "peppol-bis-3" | "fa-2-ksef" | "ubl" | "cii";
70
+ /** Exact, case-sensitive enum accepted by the ERP export endpoint. */
71
+ export type ApiEInvoiceExportFormat = "Facturae" | "XRechnung-CII" | "XRechnung-UBL" | "Factur-X" | "FatturaPA" | "PEPPOL-BIS-3" | "FA-2-KSeF" | "UBL" | "CII";
72
+ export interface EInvoiceExportResult {
73
+ xml: string;
74
+ contentType: string;
75
+ filename: string;
76
+ signed: boolean;
77
+ format: ApiEInvoiceExportFormat;
78
+ }
79
+ export declare function isLocalInputValidationError(error: unknown): boolean;
80
+ export declare function toApiEInvoiceExportFormat(format: string): ApiEInvoiceExportFormat;
15
81
  export declare class FrihetApiError extends Error {
16
82
  readonly statusCode: number;
17
83
  readonly errorCode: string;
18
- constructor(statusCode: number, errorCode: string, message?: string);
84
+ readonly detail?: string | undefined;
85
+ /** Backend correlation id (`meta.requestId` or `X-Request-Id`); carried for diagnostics, never echoed to agents. */
86
+ readonly requestId?: string | undefined;
87
+ constructor(statusCode: number, errorCode: string, message?: string, detail?: string | undefined,
88
+ /** Backend correlation id (`meta.requestId` or `X-Request-Id`); carried for diagnostics, never echoed to agents. */
89
+ requestId?: string | undefined);
19
90
  }
20
91
  export interface FrihetClientOptions {
21
92
  /**
@@ -23,14 +94,44 @@ export interface FrihetClientOptions {
23
94
  * Cloudflare Workers should pass ≤25000 to leave margin under the ~30s limit.
24
95
  */
25
96
  timeoutMs?: number;
97
+ /**
98
+ * Cumulative time one call may sleep across 429 retries. A server-requested
99
+ * wait that does not fit is never shortened: the call fails with a
100
+ * `rate_limit_deferred` error carrying the wait to honor. Defaults to 30000.
101
+ */
102
+ retryBudgetMs?: number;
103
+ /** Test seams: timer and wall clock used for 429 waits. */
104
+ sleep?: (ms: number) => Promise<void>;
105
+ now?: () => number;
26
106
  }
27
107
  export declare class FrihetClient {
28
108
  private readonly apiKey;
29
109
  private readonly baseUrl;
30
110
  private readonly timeoutMs;
111
+ private readonly retryBudgetMs;
112
+ private readonly sleepFn;
113
+ private readonly nowFn;
31
114
  constructor(apiKey: string, baseUrl?: string, options?: FrihetClientOptions);
32
115
  private request;
33
- private sleep;
116
+ /** Fetch a raw response. The caller owns timeout and body consumption. */
117
+ private fetchRaw;
118
+ /** Consume one response body without ever retaining more than `maxBytes`. */
119
+ private readBoundedBody;
120
+ /**
121
+ * Bounded document fetch — ONE call, ONE Response, dispatch on Content-Type.
122
+ *
123
+ * Success and error bodies use the same bounded reader. The abort timer stays
124
+ * active until the body is complete, and a normal success performs one GET.
125
+ * A 429 may retry, matching the generic JSON client path.
126
+ */
127
+ private requestDocument;
128
+ /**
129
+ * Wait before the next 429 retry: the server's `Retry-After` when it parses
130
+ * (RFC 9110 §10.2.3), otherwise exponential backoff. Either wait that does
131
+ * not fit the remaining cumulative budget is deferred to the caller; a server
132
+ * wait is never shortened into an early retry.
133
+ */
134
+ private rateLimitDelayMs;
34
135
  /**
35
136
  * Wrapper for endpoints whose backend wraps the payload in a `{ data, meta }`
36
137
  * envelope. This is the UNIFORM convention across the Frihet `/v1` REST API:
@@ -46,20 +147,25 @@ export declare class FrihetClient {
46
147
  * output schema (id/clientName/items/success all read as `undefined`). This
47
148
  * unwraps to `body.data`. Every create/update/action mutation routes through
48
149
  * here for exactly this reason; single-object reads (`getInvoice`/…) have since
49
- * #64. `deleteX` methods deliberately keep `request` (they return `void` — the
50
- * tool discards the body and synthesizes `{ success, id }`, so there is nothing
51
- * to unwrap). Only unwraps a non-array-object `data` (see guard below), so an
150
+ * #64. Most `deleteX` methods keep `request` (they return `void` — the tool
151
+ * discards the body and synthesizes `{ success, id }`, so there is nothing to
152
+ * unwrap). `deleteInvoice`/`deleteQuote` are the EXCEPTION and route through
153
+ * here: their backend answers 204 for a real delete but 200 + `{ data, meta }`
154
+ * when it soft-CANCELS a non-draft document instead (see those methods).
155
+ * Only unwraps a non-array-object `data` (see guard below), so an
52
156
  * array-`data` list envelope and any non-enveloped body pass through unchanged.
157
+ * A 204 yields `undefined` from `request`, which falls through untouched — that
158
+ * `undefined` is what tells the delete tools "destroyed, not cancelled".
53
159
  *
54
160
  * Only unwraps when the body is an object carrying a `data` property that is
55
161
  * itself a (non-array) object — i.e. a genuine single-object envelope. It is
56
162
  * deliberately distinct from {@link requestPaginated}, which keeps the
57
- * `{ data: [...] , meta }` shape intact for list endpoints. If the body is
163
+ * list rows and pagination fields while omitting transport metadata. If the body is
58
164
  * not an envelope (legacy endpoints that return the item directly), it is
59
165
  * returned unchanged so existing callers keep working.
60
166
  */
61
167
  private requestUnwrapped;
62
- /** Wrapper for paginated endpoints — validates response shape has `data` array. */
168
+ /** Validate list rows and emit only the declared MCP pagination envelope. */
63
169
  private requestPaginated;
64
170
  listInvoices(params?: {
65
171
  limit?: number;
@@ -75,7 +181,21 @@ export declare class FrihetClient {
75
181
  getInvoice(id: string): Promise<Record<string, unknown>>;
76
182
  createInvoice(data: Record<string, unknown>): Promise<Record<string, unknown>>;
77
183
  updateInvoice(id: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
78
- deleteInvoice(id: string): Promise<void>;
184
+ /**
185
+ * DELETE /invoices/{id} — NOT an unconditional destroy.
186
+ *
187
+ * The backend refuses to destroy a non-draft invoice (VeriFactu hash-chain
188
+ * integrity) and soft-CANCELS it instead, and it distinguishes the two
189
+ * outcomes on the wire (`publicApi.ts` DELETE branch):
190
+ * - 204 No Content → the draft row was really removed
191
+ * - 200 + `{ data: { id, status: 'cancelled', previousStatus,
192
+ * cancelledVia }, meta }` → the document still exists, now cancelled
193
+ *
194
+ * This used to be typed `Promise<void>` and the body was thrown away, so the
195
+ * tool reported "deleted successfully" for a document that was still there.
196
+ * Resolves to the unwrapped soft-cancel payload on 200, `undefined` on 204.
197
+ */
198
+ deleteInvoice(id: string): Promise<Record<string, unknown> | undefined>;
79
199
  searchInvoices(query: string, params?: {
80
200
  limit?: number;
81
201
  offset?: number;
@@ -137,7 +257,13 @@ export declare class FrihetClient {
137
257
  getQuote(id: string): Promise<Record<string, unknown>>;
138
258
  createQuote(data: Record<string, unknown>): Promise<Record<string, unknown>>;
139
259
  updateQuote(id: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
140
- deleteQuote(id: string): Promise<void>;
260
+ /**
261
+ * DELETE /quotes/{id} — same two-outcome contract as {@link deleteInvoice}:
262
+ * the backend soft-CANCELS a non-draft quote (200 + body), destroys only a
263
+ * clean draft with no delivery/response/attachment/conversion evidence (204),
264
+ * and refuses a protected draft with 409.
265
+ */
266
+ deleteQuote(id: string): Promise<Record<string, unknown> | undefined>;
141
267
  listVendors(params?: {
142
268
  q?: string;
143
269
  limit?: number;
@@ -151,8 +277,8 @@ export declare class FrihetClient {
151
277
  deleteVendor(id: string): Promise<void>;
152
278
  sendInvoice(id: string, to?: string): Promise<Record<string, unknown>>;
153
279
  markInvoicePaid(id: string, paidDate?: string): Promise<Record<string, unknown>>;
154
- getInvoicePdf(id: string): Promise<Record<string, unknown>>;
155
- getInvoiceEInvoice(invoiceId: string): Promise<any>;
280
+ getInvoicePdf(id: string): Promise<BinaryDocument>;
281
+ getInvoiceEInvoice(invoiceId: string): Promise<EInvoiceDocument>;
156
282
  /**
157
283
  * `POST /v1/invoices/:id/credit-note` — creates a rectificativa DRAFT.
158
284
  *
@@ -176,14 +302,29 @@ export declare class FrihetClient {
176
302
  daysOverdue?: number;
177
303
  }): Promise<any>;
178
304
  sendQuote(id: string, to?: string): Promise<Record<string, unknown>>;
179
- listWebhooks(params?: {
305
+ listWebhooks(): Promise<{
306
+ data: Webhook[];
307
+ total: number;
308
+ }>;
309
+ getWebhook(id: string): Promise<Webhook>;
310
+ createWebhook(data: CreateWebhookInput): Promise<CreateWebhookResult>;
311
+ updateWebhook(id: string, data: UpdateWebhookInput): Promise<Webhook>;
312
+ deleteWebhook(id: string): Promise<void>;
313
+ globalSearch(params: {
314
+ q: string;
315
+ types?: ReadonlyArray<"invoices" | "expenses" | "vendors" | "clients" | "products">;
180
316
  limit?: number;
181
317
  offset?: number;
182
- }): Promise<PaginatedResponse<Record<string, unknown>>>;
183
- getWebhook(id: string): Promise<Record<string, unknown>>;
184
- createWebhook(data: Record<string, unknown>): Promise<Record<string, unknown>>;
185
- updateWebhook(id: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
186
- deleteWebhook(id: string): Promise<void>;
318
+ }): Promise<{
319
+ data: Record<string, unknown>[];
320
+ total: number;
321
+ limit: number;
322
+ offset: number;
323
+ hasMore: boolean;
324
+ query: string;
325
+ types: ReadonlyArray<"invoices" | "expenses" | "vendors" | "clients" | "products">;
326
+ truncated?: boolean;
327
+ }>;
187
328
  listClientContacts(clientId: string, params?: {
188
329
  limit?: number;
189
330
  offset?: number;
@@ -261,14 +402,9 @@ export declare class FrihetClient {
261
402
  }>;
262
403
  exportEInvoice(params: {
263
404
  invoiceId: string;
264
- format: string;
405
+ format: McpEInvoiceExportFormat;
265
406
  signed?: boolean;
266
- }): Promise<{
267
- xmlUrl: string;
268
- filename: string;
269
- format: string;
270
- signed: boolean;
271
- }>;
407
+ }): Promise<EInvoiceExportResult>;
272
408
  faceSubmit(params: {
273
409
  invoiceId: string;
274
410
  mode: "mock" | "sandbox" | "production";
@@ -484,10 +620,12 @@ export declare class FrihetClient {
484
620
  };
485
621
  }): Promise<Record<string, unknown>>;
486
622
  getGestoriaAgingConsolidated(params?: {
487
- ownerUid?: string;
623
+ workspaceIds?: string[];
624
+ asOf?: string;
625
+ bustCache?: boolean;
488
626
  }): Promise<Record<string, unknown>>;
489
627
  approveGLEntry(entryId: string, notes?: string): Promise<Record<string, unknown>>;
490
- rejectGLEntry(entryId: string, reason: string): Promise<Record<string, unknown>>;
628
+ rejectGLEntry(entryId: string, note: string): Promise<Record<string, unknown>>;
491
629
  getGLEntryAuditLog(entryId: string): Promise<Record<string, unknown>>;
492
630
  addCustomPortalDomain(data: {
493
631
  domain: string;
@@ -529,15 +667,13 @@ export declare class FrihetClient {
529
667
  }): Promise<PaginatedResponse<Record<string, unknown>>>;
530
668
  createBankRule(data: {
531
669
  name: string;
532
- conditions: Array<{
670
+ bankConditions: Array<{
533
671
  field: string;
534
672
  operator: string;
535
673
  value: string;
536
674
  }>;
537
- actions: Array<{
538
- type: string;
539
- value: string;
540
- }>;
675
+ action: string;
676
+ actionConfig: Record<string, unknown>;
541
677
  isActive?: boolean;
542
678
  }): Promise<Record<string, unknown>>;
543
679
  listLeaves(params?: {
@@ -567,8 +703,8 @@ export declare class FrihetClient {
567
703
  employeeId: string;
568
704
  mood?: string;
569
705
  location?: string;
570
- }): Promise<Record<string, unknown>>;
571
- attendanceClockOut(entryId: string): Promise<Record<string, unknown>>;
706
+ }, idempotencyKey?: string): Promise<Record<string, unknown>>;
707
+ attendanceClockOut(entryId: string, idempotencyKey?: string): Promise<Record<string, unknown>>;
572
708
  getOvertimeReport(params: {
573
709
  period: string;
574
710
  employeeId?: string;
@@ -585,20 +721,16 @@ export declare class FrihetClient {
585
721
  eventType?: string;
586
722
  }): Promise<Record<string, unknown>>;
587
723
  exportPayroll(params: {
588
- format: "a3" | "contasol" | "sage" | "holded" | "siltra";
724
+ format: "a3" | "contasol" | "sage" | "siltra";
589
725
  month: string;
590
726
  }): Promise<Record<string, unknown>>;
591
727
  getPayrollChecklist(params: {
592
728
  month: string;
593
729
  }): Promise<Record<string, unknown>>;
594
- getOnboardingStatus(): Promise<Record<string, unknown>>;
595
- setOnboardingPersona(data: {
596
- persona: "autonomo" | "empresa" | "agencia" | "gestoria";
597
- }): Promise<Record<string, unknown>>;
598
730
  getPermissionsMatrix(): Promise<Record<string, unknown>>;
599
731
  getMyPermissions(): Promise<Record<string, unknown>>;
600
732
  getCurrentPeriod(params?: {
601
- periodId?: string;
733
+ fiscalYear?: string;
602
734
  }): Promise<Record<string, unknown>>;
603
735
  closePeriod(data: {
604
736
  type: "monthly" | "quarterly";