boondmanager-mcp-server 2.15.2 → 2.17.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/LICENSE +1 -1
- package/NOTICE +16 -2
- package/README.md +60 -15
- package/dist/config/access-policy.d.ts.map +1 -1
- package/dist/config/access-policy.js +6 -18
- package/dist/config/access-policy.js.map +1 -1
- package/dist/config/dictionary-overrides.d.ts.map +1 -1
- package/dist/config/dictionary-overrides.js +2 -12
- package/dist/config/dictionary-overrides.js.map +1 -1
- package/dist/config/env.d.ts +63 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +116 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/profiles.d.ts +22 -8
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +48 -4
- package/dist/config/profiles.js.map +1 -1
- package/dist/constants.d.ts +13 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +25 -1
- package/dist/constants.js.map +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +6 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.js +33 -15
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/instructions.d.ts.map +1 -1
- package/dist/instructions.js +6 -6
- package/dist/instructions.js.map +1 -1
- package/dist/prompts/index.d.ts +19 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +495 -25
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/periods.d.ts +45 -0
- package/dist/prompts/periods.d.ts.map +1 -0
- package/dist/prompts/periods.js +154 -0
- package/dist/prompts/periods.js.map +1 -0
- package/dist/resources/index.d.ts +14 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +285 -0
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/templates.d.ts +1 -1
- package/dist/resources/templates.d.ts.map +1 -1
- package/dist/resources/templates.js +2 -0
- package/dist/resources/templates.js.map +1 -1
- package/dist/schema-dialect.js.map +1 -1
- package/dist/schemas/filter-aliases.d.ts +1 -1
- package/dist/schemas/filter-aliases.d.ts.map +1 -1
- package/dist/schemas/filter-aliases.js +101 -2
- package/dist/schemas/filter-aliases.js.map +1 -1
- package/dist/schemas/index.d.ts +987 -161
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +853 -323
- package/dist/schemas/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +10 -3
- package/dist/server.js.map +1 -1
- package/dist/services/boond-client.d.ts +29 -213
- package/dist/services/boond-client.d.ts.map +1 -1
- package/dist/services/boond-client.js +29 -1168
- package/dist/services/boond-client.js.map +1 -1
- package/dist/services/dictionary.d.ts +27 -3
- package/dist/services/dictionary.d.ts.map +1 -1
- package/dist/services/dictionary.js +60 -23
- package/dist/services/dictionary.js.map +1 -1
- package/dist/services/document-text.d.ts +32 -0
- package/dist/services/document-text.d.ts.map +1 -0
- package/dist/services/document-text.js +120 -0
- package/dist/services/document-text.js.map +1 -0
- package/dist/services/format/detail.d.ts +16 -0
- package/dist/services/format/detail.d.ts.map +1 -0
- package/dist/services/format/detail.js +36 -0
- package/dist/services/format/detail.js.map +1 -0
- package/dist/services/format/html.d.ts +19 -0
- package/dist/services/format/html.d.ts.map +1 -0
- package/dist/services/format/html.js +87 -0
- package/dist/services/format/html.js.map +1 -0
- package/dist/services/format/list.d.ts +3 -0
- package/dist/services/format/list.d.ts.map +1 -0
- package/dist/services/format/list.js +44 -0
- package/dist/services/format/list.js.map +1 -0
- package/dist/services/format/summary.d.ts +16 -0
- package/dist/services/format/summary.d.ts.map +1 -0
- package/dist/services/format/summary.js +172 -0
- package/dist/services/format/summary.js.map +1 -0
- package/dist/services/format/tab.d.ts +9 -0
- package/dist/services/format/tab.d.ts.map +1 -0
- package/dist/services/format/tab.js +32 -0
- package/dist/services/format/tab.js.map +1 -0
- package/dist/services/http/auth.d.ts +44 -0
- package/dist/services/http/auth.d.ts.map +1 -0
- package/dist/services/http/auth.js +146 -0
- package/dist/services/http/auth.js.map +1 -0
- package/dist/services/http/download.d.ts +60 -0
- package/dist/services/http/download.d.ts.map +1 -0
- package/dist/services/http/download.js +160 -0
- package/dist/services/http/download.js.map +1 -0
- package/dist/services/http/errors.d.ts +45 -0
- package/dist/services/http/errors.d.ts.map +1 -0
- package/dist/services/http/errors.js +188 -0
- package/dist/services/http/errors.js.map +1 -0
- package/dist/services/http/rate-limit.d.ts +40 -0
- package/dist/services/http/rate-limit.d.ts.map +1 -0
- package/dist/services/http/rate-limit.js +92 -0
- package/dist/services/http/rate-limit.js.map +1 -0
- package/dist/services/http/retry.d.ts +46 -0
- package/dist/services/http/retry.d.ts.map +1 -0
- package/dist/services/http/retry.js +101 -0
- package/dist/services/http/retry.js.map +1 -0
- package/dist/services/http/transport.d.ts +73 -0
- package/dist/services/http/transport.d.ts.map +1 -0
- package/dist/services/http/transport.js +272 -0
- package/dist/services/http/transport.js.map +1 -0
- package/dist/services/logger.d.ts +53 -2
- package/dist/services/logger.d.ts.map +1 -1
- package/dist/services/logger.js +82 -21
- package/dist/services/logger.js.map +1 -1
- package/dist/services/oauth.d.ts +12 -0
- package/dist/services/oauth.d.ts.map +1 -1
- package/dist/services/oauth.js +21 -8
- package/dist/services/oauth.js.map +1 -1
- package/dist/services/rate-limiter.d.ts +9 -2
- package/dist/services/rate-limiter.d.ts.map +1 -1
- package/dist/services/rate-limiter.js +18 -6
- package/dist/services/rate-limiter.js.map +1 -1
- package/dist/services/request-context.d.ts +47 -0
- package/dist/services/request-context.d.ts.map +1 -0
- package/dist/services/request-context.js +112 -0
- package/dist/services/request-context.js.map +1 -0
- package/dist/services/search.d.ts +26 -0
- package/dist/services/search.d.ts.map +1 -0
- package/dist/services/search.js +98 -0
- package/dist/services/search.js.map +1 -0
- package/dist/services/update-checker.d.ts.map +1 -1
- package/dist/services/update-checker.js +15 -8
- package/dist/services/update-checker.js.map +1 -1
- package/dist/tools/absences.d.ts +9 -0
- package/dist/tools/absences.d.ts.map +1 -1
- package/dist/tools/absences.js +65 -20
- package/dist/tools/absences.js.map +1 -1
- package/dist/tools/actions.d.ts.map +1 -1
- package/dist/tools/actions.js +11 -27
- package/dist/tools/actions.js.map +1 -1
- package/dist/tools/advantages.d.ts +2 -0
- package/dist/tools/advantages.d.ts.map +1 -1
- package/dist/tools/advantages.js +66 -13
- package/dist/tools/advantages.js.map +1 -1
- package/dist/tools/alerts.d.ts +18 -0
- package/dist/tools/alerts.d.ts.map +1 -0
- package/dist/tools/alerts.js +82 -0
- package/dist/tools/alerts.js.map +1 -0
- package/dist/tools/application.d.ts +2 -1
- package/dist/tools/application.d.ts.map +1 -1
- package/dist/tools/application.js +9 -3
- package/dist/tools/application.js.map +1 -1
- package/dist/tools/contacts.d.ts.map +1 -1
- package/dist/tools/contacts.js +3 -7
- package/dist/tools/contacts.js.map +1 -1
- package/dist/tools/contracts.d.ts +22 -0
- package/dist/tools/contracts.d.ts.map +1 -1
- package/dist/tools/contracts.js +185 -52
- package/dist/tools/contracts.js.map +1 -1
- package/dist/tools/crud-factory.d.ts +33 -2
- package/dist/tools/crud-factory.d.ts.map +1 -1
- package/dist/tools/crud-factory.js +42 -15
- package/dist/tools/crud-factory.js.map +1 -1
- package/dist/tools/deliveries.d.ts +3 -0
- package/dist/tools/deliveries.d.ts.map +1 -1
- package/dist/tools/deliveries.js +50 -94
- package/dist/tools/deliveries.js.map +1 -1
- package/dist/tools/description-builders.d.ts +0 -1
- package/dist/tools/description-builders.d.ts.map +1 -1
- package/dist/tools/description-builders.js +46 -3
- package/dist/tools/description-builders.js.map +1 -1
- package/dist/tools/documents.d.ts.map +1 -1
- package/dist/tools/documents.js +73 -21
- package/dist/tools/documents.js.map +1 -1
- package/dist/tools/expenses.d.ts.map +1 -1
- package/dist/tools/expenses.js +2 -11
- package/dist/tools/expenses.js.map +1 -1
- package/dist/tools/find.d.ts +61 -0
- package/dist/tools/find.d.ts.map +1 -0
- package/dist/tools/find.js +221 -0
- package/dist/tools/find.js.map +1 -0
- package/dist/tools/flags.d.ts +5 -0
- package/dist/tools/flags.d.ts.map +1 -1
- package/dist/tools/flags.js +116 -1
- package/dist/tools/flags.js.map +1 -1
- package/dist/tools/forms.d.ts +5 -0
- package/dist/tools/forms.d.ts.map +1 -0
- package/dist/tools/forms.js +64 -0
- package/dist/tools/forms.js.map +1 -0
- package/dist/tools/groupments.d.ts +5 -0
- package/dist/tools/groupments.d.ts.map +1 -0
- package/dist/tools/groupments.js +68 -0
- package/dist/tools/groupments.js.map +1 -0
- package/dist/tools/inactivities.d.ts +5 -0
- package/dist/tools/inactivities.d.ts.map +1 -0
- package/dist/tools/inactivities.js +59 -0
- package/dist/tools/inactivities.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/invoices.d.ts.map +1 -1
- package/dist/tools/invoices.js +27 -2
- package/dist/tools/invoices.js.map +1 -1
- package/dist/tools/linked-entity-filters.d.ts +48 -0
- package/dist/tools/linked-entity-filters.d.ts.map +1 -0
- package/dist/tools/linked-entity-filters.js +64 -0
- package/dist/tools/linked-entity-filters.js.map +1 -0
- package/dist/tools/notifications.d.ts.map +1 -1
- package/dist/tools/notifications.js +0 -5
- package/dist/tools/notifications.js.map +1 -1
- package/dist/tools/orders.d.ts.map +1 -1
- package/dist/tools/orders.js +33 -4
- package/dist/tools/orders.js.map +1 -1
- package/dist/tools/parameter-disclosure.js.map +1 -1
- package/dist/tools/payments.d.ts +3 -0
- package/dist/tools/payments.d.ts.map +1 -1
- package/dist/tools/payments.js +43 -109
- package/dist/tools/payments.js.map +1 -1
- package/dist/tools/positionings.d.ts.map +1 -1
- package/dist/tools/positionings.js +9 -39
- package/dist/tools/positionings.js.map +1 -1
- package/dist/tools/projects.d.ts.map +1 -1
- package/dist/tools/projects.js +5 -12
- package/dist/tools/projects.js.map +1 -1
- package/dist/tools/provider-invoices.d.ts +2 -0
- package/dist/tools/provider-invoices.d.ts.map +1 -1
- package/dist/tools/provider-invoices.js +30 -111
- package/dist/tools/provider-invoices.js.map +1 -1
- package/dist/tools/purchases.d.ts +2 -0
- package/dist/tools/purchases.d.ts.map +1 -1
- package/dist/tools/purchases.js +50 -104
- package/dist/tools/purchases.js.map +1 -1
- package/dist/tools/registration-decorators.d.ts +28 -0
- package/dist/tools/registration-decorators.d.ts.map +1 -1
- package/dist/tools/registration-decorators.js +107 -0
- package/dist/tools/registration-decorators.js.map +1 -1
- package/dist/tools/resources.d.ts.map +1 -1
- package/dist/tools/resources.js +27 -5
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/rights.d.ts +101 -0
- package/dist/tools/rights.d.ts.map +1 -0
- package/dist/tools/rights.js +75 -0
- package/dist/tools/rights.js.map +1 -0
- package/dist/tools/tab-tools.js +3 -3
- package/dist/tools/tab-tools.js.map +1 -1
- package/dist/tools/timesheets.d.ts +29 -0
- package/dist/tools/timesheets.d.ts.map +1 -1
- package/dist/tools/timesheets.js +196 -126
- package/dist/tools/timesheets.js.map +1 -1
- package/dist/tools/todolists.d.ts +2 -0
- package/dist/tools/todolists.d.ts.map +1 -1
- package/dist/tools/todolists.js +64 -1
- package/dist/tools/todolists.js.map +1 -1
- package/dist/tools/validations.d.ts +9 -0
- package/dist/tools/validations.d.ts.map +1 -1
- package/dist/tools/validations.js +86 -9
- package/dist/tools/validations.js.map +1 -1
- package/dist/tools/workflows.js +1 -1
- package/dist/tools/workflows.js.map +1 -1
- package/dist/transports/http.d.ts +116 -0
- package/dist/transports/http.d.ts.map +1 -1
- package/dist/transports/http.js +422 -92
- package/dist/transports/http.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/manifest.json +7 -7
- package/package.json +14 -10
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
reference: z.string().min(1).describe("Reference de la facture fournisseur"),
|
|
20
|
-
resourceId: z.string().min(1).describe("ID de la ressource portee par la facture fournisseur"),
|
|
21
|
-
companyId: z.string().optional().describe("ID de la societe fournisseur, mappe vers providerCompany"),
|
|
22
|
-
contactId: z.string().optional().describe("ID du contact fournisseur, mappe vers providerContact"),
|
|
23
|
-
invoiceDate: z.string().optional().describe("Date de facture (YYYY-MM-DD)"),
|
|
24
|
-
startDate: z.string().min(1).describe("Date de debut de periode (YYYY-MM-DD)"),
|
|
25
|
-
endDate: z.string().min(1).describe("Date de fin de periode (YYYY-MM-DD)"),
|
|
26
|
-
amountExcludingTax: z.number().optional().describe("Montant HT"),
|
|
27
|
-
amountIncludingTax: z.number().optional().describe("Montant TTC"),
|
|
28
|
-
currency: z.number().optional().describe("Devise Boond"),
|
|
29
|
-
exchangeRate: z.number().optional().describe("Taux de change"),
|
|
30
|
-
currencyAgency: z.number().optional().describe("Devise agence"),
|
|
31
|
-
exchangeRateAgency: z.number().optional().describe("Taux de change agence"),
|
|
32
|
-
state: z.number().int().optional().describe("Etat de la facture fournisseur"),
|
|
33
|
-
})
|
|
34
|
-
.strict();
|
|
1
|
+
import { ProviderInvoiceCreateSchema, ProviderInvoiceSearchSchema, ProviderInvoiceUpdateSchema, } from "../schemas/index.js";
|
|
2
|
+
import { buildJsonApiBody, registerCreateTool, registerDeleteTool, registerGetTool, registerSearchTool, registerUpdateTool, } from "./crud-factory.js";
|
|
3
|
+
import { composeDescription } from "./description-builders.js";
|
|
4
|
+
const OPTS = {
|
|
5
|
+
entityName: "facture fournisseur",
|
|
6
|
+
entityNamePlural: "factures fournisseur",
|
|
7
|
+
apiPath: "/provider-invoices",
|
|
8
|
+
prefix: "boond_provider_invoices",
|
|
9
|
+
};
|
|
10
|
+
/** `/provider-invoices` payload: `resource` is mandatory, `providerCompany` / `providerContact` optional. */
|
|
11
|
+
export function buildProviderInvoiceBody(params) {
|
|
12
|
+
const { companyId, contactId, resourceId, ...attrs } = params;
|
|
13
|
+
return buildJsonApiBody("providerinvoice", attrs, undefined, {
|
|
14
|
+
resource: { id: String(resourceId), type: "resource" },
|
|
15
|
+
providerCompany: companyId ? { id: String(companyId), type: "company" } : undefined,
|
|
16
|
+
providerContact: contactId ? { id: String(contactId), type: "contact" } : undefined,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
35
19
|
export function registerProviderInvoiceTools(server) {
|
|
36
|
-
server
|
|
37
|
-
title: "
|
|
20
|
+
registerCreateTool(server, OPTS, ProviderInvoiceCreateSchema, buildProviderInvoiceBody, {
|
|
21
|
+
title: "Créer une facture fournisseur",
|
|
38
22
|
description: composeDescription({
|
|
39
23
|
purpose: "Crée une facture fournisseur (facture reçue d'un prestataire).",
|
|
40
24
|
when: "pour enregistrer la facture émise par un sous-traitant.",
|
|
@@ -43,89 +27,24 @@ export function registerProviderInvoiceTools(server) {
|
|
|
43
27
|
"`resource`, `providerCompany` et `providerContact` sont attendus sous forme d'ID numériques.",
|
|
44
28
|
"Écriture non idempotente.",
|
|
45
29
|
],
|
|
46
|
-
returns: "confirmation et fiche de la facture fournisseur créée.",
|
|
30
|
+
returns: "confirmation et fiche de la facture fournisseur créée, avec son ID dans `structuredContent.id`.",
|
|
47
31
|
}),
|
|
48
|
-
inputSchema: ProviderInvoiceCreateSchema,
|
|
49
|
-
annotations: {
|
|
50
|
-
readOnlyHint: false,
|
|
51
|
-
destructiveHint: false,
|
|
52
|
-
idempotentHint: false,
|
|
53
|
-
openWorldHint: false,
|
|
54
|
-
},
|
|
55
|
-
}, async (params) => {
|
|
56
|
-
const { companyId, contactId, resourceId, ...attrs } = params;
|
|
57
|
-
const body = buildJsonApiBody("providerinvoice", attrs);
|
|
58
|
-
const relationships = {
|
|
59
|
-
resource: { data: { id: resourceId, type: "resource" } },
|
|
60
|
-
};
|
|
61
|
-
if (companyId)
|
|
62
|
-
relationships.providerCompany = { data: { id: companyId, type: "company" } };
|
|
63
|
-
if (contactId)
|
|
64
|
-
relationships.providerContact = { data: { id: contactId, type: "contact" } };
|
|
65
|
-
body.data.relationships = relationships;
|
|
66
|
-
const response = await apiRequest("/provider-invoices", "POST", body);
|
|
67
|
-
const entity = Array.isArray(response.data) ? response.data[0] : response.data;
|
|
68
|
-
return {
|
|
69
|
-
content: [
|
|
70
|
-
{
|
|
71
|
-
type: "text",
|
|
72
|
-
text: `Facture fournisseur creee avec succes.\nID: ${entity?.id}\n\n${formatDetailResponse(response)}`,
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
};
|
|
76
32
|
});
|
|
77
|
-
server
|
|
78
|
-
|
|
33
|
+
registerSearchTool(server, OPTS, {
|
|
34
|
+
schema: ProviderInvoiceSearchSchema,
|
|
79
35
|
description: composeDescription({
|
|
80
36
|
purpose: "Liste et recherche les factures fournisseur (factures reçues des prestataires).",
|
|
81
37
|
when: "pour suivre les factures d'achat, par fournisseur, état ou période.",
|
|
82
38
|
instead: "`boond_invoices_search` pour les factures de vente adressées aux clients — sens opposé, endpoint distinct.",
|
|
83
39
|
returns: "page de résumés de factures fournisseur (référence, date, montants). Lecture seule.",
|
|
84
40
|
}),
|
|
85
|
-
inputSchema: ProviderInvoiceSearchSchema,
|
|
86
|
-
annotations: {
|
|
87
|
-
readOnlyHint: true,
|
|
88
|
-
destructiveHint: false,
|
|
89
|
-
idempotentHint: true,
|
|
90
|
-
openWorldHint: true,
|
|
91
|
-
},
|
|
92
|
-
}, async (params) => {
|
|
93
|
-
const { resourceId, companyId, keywords, ...rest } = params;
|
|
94
|
-
const tokens = [];
|
|
95
|
-
if (keywords)
|
|
96
|
-
tokens.push(keywords);
|
|
97
|
-
if (resourceId)
|
|
98
|
-
tokens.push(`COMP${resourceId}`);
|
|
99
|
-
if (companyId)
|
|
100
|
-
tokens.push(`CSOC${companyId}`);
|
|
101
|
-
const query = buildSearchQuery(tokens.length > 0 ? { ...rest, keywords: tokens.join(" ") } : rest);
|
|
102
|
-
const response = await apiRequest("/provider-invoices", "GET", undefined, query);
|
|
103
|
-
return {
|
|
104
|
-
content: [{ type: "text", text: formatListResponse(response, "facture fournisseur", params.fields) }],
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
server.registerTool("boond_provider_invoices_get", {
|
|
108
|
-
title: "Details d'une facture fournisseur",
|
|
109
|
-
description: defaultGetDescription({
|
|
110
|
-
...{
|
|
111
|
-
entityName: "facture fournisseur",
|
|
112
|
-
entityNamePlural: "factures fournisseur",
|
|
113
|
-
prefix: "boond_provider_invoices",
|
|
114
|
-
},
|
|
115
|
-
withTab: false,
|
|
116
|
-
}),
|
|
117
|
-
inputSchema: IdSchema,
|
|
118
|
-
annotations: {
|
|
119
|
-
readOnlyHint: true,
|
|
120
|
-
destructiveHint: false,
|
|
121
|
-
idempotentHint: true,
|
|
122
|
-
openWorldHint: false,
|
|
123
|
-
},
|
|
124
|
-
}, async (params) => {
|
|
125
|
-
const response = await apiRequest(`/provider-invoices/${params.id}`);
|
|
126
|
-
return {
|
|
127
|
-
content: [{ type: "text", text: formatDetailResponse(response) }],
|
|
128
|
-
};
|
|
129
41
|
});
|
|
42
|
+
registerGetTool(server, OPTS, { withTab: false, title: "Détails d'une facture fournisseur" });
|
|
43
|
+
// Issue #252: mark a provider invoice paid (paidDate / state), fix a period or an amount.
|
|
44
|
+
registerUpdateTool(server, OPTS, ProviderInvoiceUpdateSchema, (params) => {
|
|
45
|
+
const { id, ...attrs } = params;
|
|
46
|
+
return buildJsonApiBody("providerinvoice", attrs, String(id));
|
|
47
|
+
}, { method: "PUT", title: "Modifier une facture fournisseur" });
|
|
48
|
+
registerDeleteTool(server, OPTS, { title: "Supprimer une facture fournisseur" });
|
|
130
49
|
}
|
|
131
50
|
//# sourceMappingURL=provider-invoices.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-invoices.js","sourceRoot":"","sources":["../../src/tools/provider-invoices.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider-invoices.js","sourceRoot":"","sources":["../../src/tools/provider-invoices.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,IAAI,GAAG;IACX,UAAU,EAAE,qBAAqB;IACjC,gBAAgB,EAAE,sBAAsB;IACxC,OAAO,EAAE,oBAAoB;IAC7B,MAAM,EAAE,yBAAyB;CAClC,CAAC;AAEF,6GAA6G;AAC7G,MAAM,UAAU,wBAAwB,CAAC,MAA+B;IACtE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;IAC9D,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE;QAC3D,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE;QACtD,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS;QACnF,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS;KACpF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,4BAA4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** `/purchases` payload: the three optional ids become relationships; `id` (update) lands on `data.id`. */
|
|
3
|
+
export declare function buildPurchaseBody(params: Record<string, unknown>): unknown;
|
|
2
4
|
export declare function registerPurchaseTools(server: McpServer): void;
|
|
3
5
|
//# sourceMappingURL=purchases.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"purchases.d.ts","sourceRoot":"","sources":["../../src/tools/purchases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"purchases.d.ts","sourceRoot":"","sources":["../../src/tools/purchases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8BzE,2GAA2G;AAC3G,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAY1E;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmD7D"}
|
package/dist/tools/purchases.js
CHANGED
|
@@ -1,76 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
note: z.string().optional().describe("Notes / commentaires"),
|
|
28
|
-
})
|
|
29
|
-
.strict();
|
|
1
|
+
import { PurchaseCreateSchema, PurchaseSearchSchema, PurchaseUpdateSchema } from "../schemas/index.js";
|
|
2
|
+
import { buildJsonApiBody, registerCreateTool, registerDeleteTool, registerGetTool, registerSearchTool, registerUpdateTool, } from "./crud-factory.js";
|
|
3
|
+
import { composeDescription } from "./description-builders.js";
|
|
4
|
+
import { registerTabTools } from "./tab-tools.js";
|
|
5
|
+
const OPTS = { entityName: "achat", entityNamePlural: "achats", apiPath: "/purchases", prefix: "boond_purchases" };
|
|
6
|
+
// `ENTITY_TABS.purchases` — `/purchases/{id}/information` verified live on
|
|
7
|
+
// 2026-09-26 (issue #258); `/actions` answers 404 on this entity.
|
|
8
|
+
const PURCHASE_TABS = [
|
|
9
|
+
{
|
|
10
|
+
name: "information",
|
|
11
|
+
tab: "information",
|
|
12
|
+
title: "Informations complètes d'un achat/sous-traitance",
|
|
13
|
+
subject: "les informations complètes",
|
|
14
|
+
content: "période, quantité, montants, taux de TVA, conditions de paiement, ressource, projet et prestation liés",
|
|
15
|
+
returns: "Fiche complète de l'achat (relations ressource, agence, projet, prestation incluses).",
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
/** `/purchases` payload: the three optional ids become relationships; `id` (update) lands on `data.id`. */
|
|
19
|
+
export function buildPurchaseBody(params) {
|
|
20
|
+
const { id, companyId, contactId, projectId, note, ...attrs } = params;
|
|
21
|
+
return buildJsonApiBody("purchase", { ...attrs, ...(note !== undefined ? { informationComments: note } : {}) }, typeof id === "string" ? id : undefined, {
|
|
22
|
+
company: companyId ? { id: String(companyId), type: "company" } : undefined,
|
|
23
|
+
contact: contactId ? { id: String(contactId), type: "contact" } : undefined,
|
|
24
|
+
project: projectId ? { id: String(projectId), type: "project" } : undefined,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
30
27
|
export function registerPurchaseTools(server) {
|
|
31
|
-
server
|
|
28
|
+
registerSearchTool(server, OPTS, {
|
|
29
|
+
schema: PurchaseSearchSchema,
|
|
32
30
|
title: "Rechercher des achats/sous-traitance",
|
|
33
|
-
description: `Recherche des achats et sous-traitances dans BoondManager.
|
|
31
|
+
description: `Recherche des achats et sous-traitances dans BoondManager, avec filtres par société et projet.
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
- keywords, companyId, projectId: Filtres
|
|
37
|
-
- page, pageSize: Pagination
|
|
33
|
+
\`companyId\` / \`projectId\` sont convertis en références \`keywords\` (CSOC<id> / PRJ<id>) : l'API n'a pas de paramètre dédié.
|
|
38
34
|
|
|
39
35
|
Returns: Liste des achats correspondants.`,
|
|
40
|
-
inputSchema: PurchaseSearchSchema,
|
|
41
|
-
annotations: {
|
|
42
|
-
readOnlyHint: true,
|
|
43
|
-
destructiveHint: false,
|
|
44
|
-
idempotentHint: true,
|
|
45
|
-
openWorldHint: true,
|
|
46
|
-
},
|
|
47
|
-
}, async (params, extra) => {
|
|
48
|
-
const query = buildSearchQuery(params);
|
|
49
|
-
const response = await apiSearch("/purchases", query, progressReporterFrom(extra));
|
|
50
|
-
return {
|
|
51
|
-
content: [{ type: "text", text: formatListResponse(response, "achat", params.fields) }],
|
|
52
|
-
};
|
|
53
36
|
});
|
|
54
|
-
server
|
|
55
|
-
|
|
56
|
-
description: defaultGetDescription({
|
|
57
|
-
...{ entityName: "achat", entityNamePlural: "achats", prefix: "boond_purchases" },
|
|
58
|
-
withTab: false,
|
|
59
|
-
}),
|
|
60
|
-
inputSchema: IdSchema,
|
|
61
|
-
annotations: {
|
|
62
|
-
readOnlyHint: true,
|
|
63
|
-
destructiveHint: false,
|
|
64
|
-
idempotentHint: true,
|
|
65
|
-
openWorldHint: false,
|
|
66
|
-
},
|
|
67
|
-
}, async (params) => {
|
|
68
|
-
const response = await apiRequest(`/purchases/${params.id}`);
|
|
69
|
-
return {
|
|
70
|
-
content: [{ type: "text", text: formatDetailResponse(response) }],
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
server.registerTool("boond_purchases_create", {
|
|
37
|
+
registerGetTool(server, OPTS, { withTab: false, title: "Détails d'un achat/sous-traitance" });
|
|
38
|
+
registerCreateTool(server, OPTS, PurchaseCreateSchema, buildPurchaseBody, {
|
|
74
39
|
title: "Créer un achat/sous-traitance",
|
|
75
40
|
description: composeDescription({
|
|
76
41
|
purpose: "Crée un achat ou une ligne de sous-traitance.",
|
|
@@ -80,47 +45,28 @@ Returns: Liste des achats correspondants.`,
|
|
|
80
45
|
"Écriture non idempotente.",
|
|
81
46
|
"Les ID de société, contact et projet sont des ID numériques BoondManager, à résoudre au préalable via les recherches correspondantes.",
|
|
82
47
|
],
|
|
83
|
-
returns: "confirmation et fiche de l'achat cr
|
|
48
|
+
returns: "confirmation et fiche de l'achat créé, avec son ID dans `structuredContent.id`.",
|
|
84
49
|
}),
|
|
85
|
-
inputSchema: PurchaseCreateSchema,
|
|
86
|
-
annotations: {
|
|
87
|
-
readOnlyHint: false,
|
|
88
|
-
destructiveHint: false,
|
|
89
|
-
idempotentHint: false,
|
|
90
|
-
openWorldHint: false,
|
|
91
|
-
},
|
|
92
|
-
}, async (params) => {
|
|
93
|
-
const { companyId, contactId, projectId, ...attrs } = params;
|
|
94
|
-
const body = buildJsonApiBody("purchase", attrs);
|
|
95
|
-
const relationships = {};
|
|
96
|
-
if (companyId)
|
|
97
|
-
relationships.company = { data: { id: companyId, type: "company" } };
|
|
98
|
-
if (contactId)
|
|
99
|
-
relationships.contact = { data: { id: contactId, type: "contact" } };
|
|
100
|
-
if (projectId)
|
|
101
|
-
relationships.project = { data: { id: projectId, type: "project" } };
|
|
102
|
-
if (Object.keys(relationships).length > 0) {
|
|
103
|
-
body.data.relationships = relationships;
|
|
104
|
-
}
|
|
105
|
-
const response = await apiRequest("/purchases", "POST", body);
|
|
106
|
-
const entity = Array.isArray(response.data) ? response.data[0] : response.data;
|
|
107
|
-
return {
|
|
108
|
-
content: [
|
|
109
|
-
{
|
|
110
|
-
type: "text",
|
|
111
|
-
text: `✅ Achat créé avec succès.\nID: ${entity?.id}\n\n${formatDetailResponse(response)}`,
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
};
|
|
115
50
|
});
|
|
116
|
-
//
|
|
117
|
-
|
|
51
|
+
// PUT /purchases/{id}/information (RAML `purchases/information.raml`, issue #252).
|
|
52
|
+
registerUpdateTool(server, OPTS, PurchaseUpdateSchema, buildPurchaseBody, {
|
|
53
|
+
method: "PUT",
|
|
54
|
+
pathSuffix: "information",
|
|
55
|
+
title: "Modifier un achat/sous-traitance",
|
|
56
|
+
});
|
|
57
|
+
registerDeleteTool(server, OPTS, {
|
|
118
58
|
title: "Supprimer un achat/sous-traitance",
|
|
119
|
-
description:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
59
|
+
description: composeDescription({
|
|
60
|
+
purpose: "Supprime définitivement un achat / sous-traitance de BoondManager.",
|
|
61
|
+
when: "uniquement sur demande explicite de l'utilisateur, et après avoir vérifié l'ID avec `boond_purchases_get`.",
|
|
62
|
+
instead: "`boond_purchases_update` pour corriger un montant, une période ou un état — vérifier avec `boond_payments_search` (`purchaseId`) qu'aucun règlement n'y est adossé avant de détruire.",
|
|
63
|
+
behaviour: [
|
|
64
|
+
"⚠️ Irréversible, sans corbeille côté API.",
|
|
65
|
+
"Si le client MCP annonce la capacité `elicitation`, une confirmation est demandée à l'utilisateur final et un refus annule l'appel (`structuredContent.deleted: false` + `reason`) ; sinon la suppression part directement.",
|
|
66
|
+
],
|
|
67
|
+
returns: "`{ id, deleted, reason? }` — vérifier `deleted`, qui vaut `false` en cas de refus utilisateur.",
|
|
123
68
|
}),
|
|
124
69
|
});
|
|
70
|
+
registerTabTools(server, OPTS, PURCHASE_TABS);
|
|
125
71
|
}
|
|
126
72
|
//# sourceMappingURL=purchases.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"purchases.js","sourceRoot":"","sources":["../../src/tools/purchases.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"purchases.js","sourceRoot":"","sources":["../../src/tools/purchases.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACvG,OAAO,EACL,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AAS,EAAE;gBACT,2CAA2C;gBAC3C,6NAA6N;aAC9N;YACD,OAAO,EAAE,gGAAgG;SAC1G,CAAC;KACH,CAAC,CAAC;IAEH,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -30,6 +30,34 @@ export interface RegistrationIndex {
|
|
|
30
30
|
toolDomains: Map<string, DomainName>;
|
|
31
31
|
}
|
|
32
32
|
export declare function createRegistrationIndex(): RegistrationIndex;
|
|
33
|
+
/**
|
|
34
|
+
* Wrap a server so every handler registered through it — tool, prompt or
|
|
35
|
+
* resource — runs inside a request context (issues #231, #236) and every tool
|
|
36
|
+
* call leaves one log line.
|
|
37
|
+
*
|
|
38
|
+
* The handler is always the last argument of the registration call and
|
|
39
|
+
* `extra` the last argument of the handler (`(args, extra)` for a tool with an
|
|
40
|
+
* input schema, `(extra)` without, `(uri, variables, extra)` for a template).
|
|
41
|
+
* From `extra` the wrapper takes:
|
|
42
|
+
*
|
|
43
|
+
* - `signal` — so `send()` can abort the BoondManager call on
|
|
44
|
+
* `notifications/cancelled`;
|
|
45
|
+
* - `_meta.traceparent` (SEP-414) — forwarded to BoondManager verbatim, and
|
|
46
|
+
* its `trace-id` becomes the `corrId`; otherwise the id the HTTP transport
|
|
47
|
+
* generated for the connection is kept, and on stdio a fresh one is made.
|
|
48
|
+
* `_meta.baggage` is never read.
|
|
49
|
+
*
|
|
50
|
+
* `send()` reads the context back from the AsyncLocalStorage, so the ~180
|
|
51
|
+
* handlers and the client helpers keep their signatures. The tool log line —
|
|
52
|
+
* `{ corrId, tool, durationMs, ok, chars }` — is the single place ~185 tools
|
|
53
|
+
* are instrumented; a thrown handler is logged at `warn` and rethrown so the
|
|
54
|
+
* SDK still turns it into an `isError` result.
|
|
55
|
+
*
|
|
56
|
+
* Applied once, on the innermost server, in `server.ts::registerAll` — before
|
|
57
|
+
* the per-domain decorations and the access policy — so that nothing
|
|
58
|
+
* registered anywhere escapes it.
|
|
59
|
+
*/
|
|
60
|
+
export declare function instrumentHandlers(server: McpServer): McpServer;
|
|
33
61
|
/**
|
|
34
62
|
* Wrap a server (or an already-wrapped Proxy) so every `registerTool` call made
|
|
35
63
|
* by `domain`'s registrar is decorated. Methods other than `registerTool` pass
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration-decorators.d.ts","sourceRoot":"","sources":["../../src/tools/registration-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"registration-decorators.d.ts","sourceRoot":"","sources":["../../src/tools/registration-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAalD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACtC;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CA6D/D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAyBjH"}
|
|
@@ -1,9 +1,116 @@
|
|
|
1
1
|
import { withValidationFeedback } from "./validation-wrapper.js";
|
|
2
2
|
import { withParameterDisclosure } from "./parameter-disclosure.js";
|
|
3
3
|
import { withUsageGuidance } from "./usage-guidance.js";
|
|
4
|
+
import { currentCorrId, requestSignalFrom, runWithRequestContext, traceparentFrom, } from "../services/request-context.js";
|
|
5
|
+
import { generateCorrelationId, logger } from "../services/logger.js";
|
|
4
6
|
export function createRegistrationIndex() {
|
|
5
7
|
return { toolDomains: new Map() };
|
|
6
8
|
}
|
|
9
|
+
/** The SDK registration methods whose last argument is a request handler. */
|
|
10
|
+
const HANDLER_REGISTRATIONS = new Set(["registerTool", "registerPrompt", "registerResource"]);
|
|
11
|
+
/** Size of a tool result as the model receives it: text content plus the structured payload. */
|
|
12
|
+
function resultChars(result) {
|
|
13
|
+
if (typeof result !== "object" || result === null)
|
|
14
|
+
return 0;
|
|
15
|
+
const { content, structuredContent } = result;
|
|
16
|
+
let chars = 0;
|
|
17
|
+
if (Array.isArray(content)) {
|
|
18
|
+
for (const item of content) {
|
|
19
|
+
const text = item?.text;
|
|
20
|
+
if (typeof text === "string")
|
|
21
|
+
chars += text.length;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (structuredContent !== undefined)
|
|
25
|
+
chars += JSON.stringify(structuredContent).length;
|
|
26
|
+
return chars;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wrap a server so every handler registered through it — tool, prompt or
|
|
30
|
+
* resource — runs inside a request context (issues #231, #236) and every tool
|
|
31
|
+
* call leaves one log line.
|
|
32
|
+
*
|
|
33
|
+
* The handler is always the last argument of the registration call and
|
|
34
|
+
* `extra` the last argument of the handler (`(args, extra)` for a tool with an
|
|
35
|
+
* input schema, `(extra)` without, `(uri, variables, extra)` for a template).
|
|
36
|
+
* From `extra` the wrapper takes:
|
|
37
|
+
*
|
|
38
|
+
* - `signal` — so `send()` can abort the BoondManager call on
|
|
39
|
+
* `notifications/cancelled`;
|
|
40
|
+
* - `_meta.traceparent` (SEP-414) — forwarded to BoondManager verbatim, and
|
|
41
|
+
* its `trace-id` becomes the `corrId`; otherwise the id the HTTP transport
|
|
42
|
+
* generated for the connection is kept, and on stdio a fresh one is made.
|
|
43
|
+
* `_meta.baggage` is never read.
|
|
44
|
+
*
|
|
45
|
+
* `send()` reads the context back from the AsyncLocalStorage, so the ~180
|
|
46
|
+
* handlers and the client helpers keep their signatures. The tool log line —
|
|
47
|
+
* `{ corrId, tool, durationMs, ok, chars }` — is the single place ~185 tools
|
|
48
|
+
* are instrumented; a thrown handler is logged at `warn` and rethrown so the
|
|
49
|
+
* SDK still turns it into an `isError` result.
|
|
50
|
+
*
|
|
51
|
+
* Applied once, on the innermost server, in `server.ts::registerAll` — before
|
|
52
|
+
* the per-domain decorations and the access policy — so that nothing
|
|
53
|
+
* registered anywhere escapes it.
|
|
54
|
+
*/
|
|
55
|
+
export function instrumentHandlers(server) {
|
|
56
|
+
return new Proxy(server, {
|
|
57
|
+
get(target, prop) {
|
|
58
|
+
const value = Reflect.get(target, prop, target);
|
|
59
|
+
if (typeof value !== "function")
|
|
60
|
+
return value;
|
|
61
|
+
if (typeof prop !== "string" || !HANDLER_REGISTRATIONS.has(prop)) {
|
|
62
|
+
return value.bind(target);
|
|
63
|
+
}
|
|
64
|
+
return (...args) => {
|
|
65
|
+
const handler = args[args.length - 1];
|
|
66
|
+
if (typeof handler !== "function") {
|
|
67
|
+
return value.apply(target, args);
|
|
68
|
+
}
|
|
69
|
+
const name = String(args[0]);
|
|
70
|
+
const isTool = prop === "registerTool";
|
|
71
|
+
const wrapped = (...handlerArgs) => {
|
|
72
|
+
const extra = handlerArgs[handlerArgs.length - 1];
|
|
73
|
+
const trace = traceparentFrom(extra);
|
|
74
|
+
const signal = requestSignalFrom(extra);
|
|
75
|
+
const context = {
|
|
76
|
+
...(signal !== undefined ? { signal } : {}),
|
|
77
|
+
corrId: trace?.traceId ?? currentCorrId() ?? generateCorrelationId(),
|
|
78
|
+
...(trace !== undefined ? { traceparent: trace.header } : {}),
|
|
79
|
+
};
|
|
80
|
+
return runWithRequestContext(context, () => {
|
|
81
|
+
const call = () => handler(...handlerArgs);
|
|
82
|
+
if (!isTool)
|
|
83
|
+
return call();
|
|
84
|
+
const startedAt = Date.now();
|
|
85
|
+
const done = (result) => {
|
|
86
|
+
const ok = typeof result === "object" && result !== null && !result.isError;
|
|
87
|
+
logger.info({
|
|
88
|
+
corrId: context.corrId,
|
|
89
|
+
tool: name,
|
|
90
|
+
durationMs: Date.now() - startedAt,
|
|
91
|
+
ok,
|
|
92
|
+
chars: resultChars(result),
|
|
93
|
+
}, "tool call");
|
|
94
|
+
return result;
|
|
95
|
+
};
|
|
96
|
+
const failed = (err) => {
|
|
97
|
+
logger.warn({ corrId: context.corrId, tool: name, durationMs: Date.now() - startedAt, err }, "tool call threw");
|
|
98
|
+
throw err;
|
|
99
|
+
};
|
|
100
|
+
try {
|
|
101
|
+
const result = call();
|
|
102
|
+
return result instanceof Promise ? result.then(done, failed) : done(result);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
return failed(err);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return value.apply(target, [...args.slice(0, -1), wrapped]);
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
7
114
|
/**
|
|
8
115
|
* Wrap a server (or an already-wrapped Proxy) so every `registerTool` call made
|
|
9
116
|
* by `domain`'s registrar is decorated. Methods other than `registerTool` pass
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration-decorators.js","sourceRoot":"","sources":["../../src/tools/registration-decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"registration-decorators.js","sourceRoot":"","sources":["../../src/tools/registration-decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;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M,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpG,CAAC,CAAC;YACJ,CAAC;YAED,OAAQ,KAAsC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/tools/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/tools/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8IzE,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuEzB;AAuCD,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAe5E,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,iBAAiB,GAAG,iBAAiB,CAQlF;AAWD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuP7D"}
|