@carbonstopper/agent-mcp 0.1.48 → 0.1.49
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/AGENTS.md +1 -1
- package/README.md +10 -11
- package/dist/cbam-report-generation.d.ts +20 -0
- package/dist/cbam-report-generation.js +174 -0
- package/dist/cbam-report-generation.js.map +1 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +8 -3
- package/dist/client.js.map +1 -1
- package/dist/server.js +25 -0
- package/dist/server.js.map +1 -1
- package/dist/tools.d.ts +2 -1
- package/dist/tools.js +27 -21
- package/dist/tools.js.map +1 -1
- package/docs/cbam-agent-integration-guide.md +64 -73
- package/docs/schema-audit.md +5 -6
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -541,9 +541,13 @@ const cbamWriteFields = {
|
|
|
541
541
|
...cbamReadFields,
|
|
542
542
|
idempotencyKey: idempotencyKey.max(128),
|
|
543
543
|
};
|
|
544
|
+
const cbamApprovalFields = {
|
|
545
|
+
confirmed: z.boolean().optional()
|
|
546
|
+
.describe("Trusted Agent wrapper approval flag. For high-risk actions the wrapper must inject true only after the existing LangGraph approval interrupt is approved."),
|
|
547
|
+
};
|
|
544
548
|
const cbamConfirmedWriteFields = {
|
|
545
549
|
...cbamWriteFields,
|
|
546
|
-
...
|
|
550
|
+
...cbamApprovalFields,
|
|
547
551
|
};
|
|
548
552
|
const cbamReferenceType = z.enum([
|
|
549
553
|
"ORGANIZATION",
|
|
@@ -832,7 +836,7 @@ export const schemas = {
|
|
|
832
836
|
cbam_process_manage: z.object({
|
|
833
837
|
...cbamConfirmedWriteFields,
|
|
834
838
|
reportId: longId,
|
|
835
|
-
action: z.enum(["save", "delete", "reorder"]).describe("save requires items and forbids ids; delete requires
|
|
839
|
+
action: z.enum(["save", "delete", "reorder"]).describe("save requires items and forbids ids; delete requires prior Agent approval and confirmed=true; reorder requires the complete ordered ids list and forbids items."),
|
|
836
840
|
items: z.array(cbamProcessDefinition).min(1).max(10).optional()
|
|
837
841
|
.describe("Required only for action=save. The report can contain at most 10 processes."),
|
|
838
842
|
ids: z.array(longId).min(1).max(10).optional()
|
|
@@ -841,7 +845,7 @@ export const schemas = {
|
|
|
841
845
|
cbam_precursor_manage: z.object({
|
|
842
846
|
...cbamConfirmedWriteFields,
|
|
843
847
|
reportId: longId,
|
|
844
|
-
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids and
|
|
848
|
+
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids plus prior Agent approval and confirmed=true."),
|
|
845
849
|
items: z.array(cbamPrecursorDefinition).min(1).max(20).optional()
|
|
846
850
|
.describe("Required only for action=save. The report can contain at most 20 manually entered precursors."),
|
|
847
851
|
ids: z.array(longId).min(1).max(20).optional().describe("Required only for action=delete."),
|
|
@@ -849,7 +853,7 @@ export const schemas = {
|
|
|
849
853
|
cbam_source_flow_manage: z.object({
|
|
850
854
|
...cbamConfirmedWriteFields,
|
|
851
855
|
reportId: longId,
|
|
852
|
-
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids and
|
|
856
|
+
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids plus prior Agent approval and confirmed=true."),
|
|
853
857
|
items: z.array(cbamSourceFlow).min(1).max(200).optional().describe("Required only for action=save."),
|
|
854
858
|
ids: z.array(longId).min(1).max(100).optional().describe("Required only for action=delete."),
|
|
855
859
|
}),
|
|
@@ -868,14 +872,14 @@ export const schemas = {
|
|
|
868
872
|
cbam_sale_product_manage: z.object({
|
|
869
873
|
...cbamConfirmedWriteFields,
|
|
870
874
|
reportId: longId,
|
|
871
|
-
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids and
|
|
875
|
+
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids plus prior Agent approval and confirmed=true."),
|
|
872
876
|
items: z.array(cbamSaleProduct).min(1).max(100).optional().describe("Required only for action=save."),
|
|
873
877
|
ids: z.array(longId).min(1).max(100).optional().describe("Required only for action=delete."),
|
|
874
878
|
}),
|
|
875
879
|
cbam_carbon_tax_manage: z.object({
|
|
876
880
|
...cbamConfirmedWriteFields,
|
|
877
881
|
reportId: longId,
|
|
878
|
-
action: z.enum(["save", "delete", "calculate"]).describe("save requires items; delete requires ids
|
|
882
|
+
action: z.enum(["save", "delete", "calculate"]).describe("save requires items; delete requires ids; calculate forbids items/ids. delete/calculate require prior Agent approval and confirmed=true."),
|
|
879
883
|
items: z.array(cbamCarbonTax).min(1).max(100).optional().describe("Required only for action=save."),
|
|
880
884
|
ids: z.array(longId).min(1).max(100).optional().describe("Required only for action=delete."),
|
|
881
885
|
}),
|
|
@@ -1359,7 +1363,6 @@ export const exposedToolNames = [
|
|
|
1359
1363
|
"cbam_carbon_tax_manage",
|
|
1360
1364
|
"cbam_data_quality_update",
|
|
1361
1365
|
"cbam_report_generate",
|
|
1362
|
-
"cbam_report_generation_status",
|
|
1363
1366
|
"user_memory_recall",
|
|
1364
1367
|
"user_memory_get",
|
|
1365
1368
|
"user_memory_upsert",
|
|
@@ -1421,18 +1424,18 @@ export const descriptions = {
|
|
|
1421
1424
|
cbam_report_search: "Search CBAM reports accessible to the current user by optional name, organization, factory, year, and pagination. Use this or session_carbon_objects to resolve an exact reportId. A single Agent session can create and work with multiple CBAM reports; never silently select the first result when several reports match. Read-only.",
|
|
1422
1425
|
cbam_report_read: "Unified read-only CBAM report inspection. view=snapshot returns workflow overview/counts/readiness; section returns one complete editable section and requires section; item reads one child record and requires itemType+itemId; result returns result analysis; readiness returns generation blockers/warnings; carbon_tax_status returns asynchronous carbon-tax calculation state. itemId must belong to reportId. Call the corresponding read view before a full-form update so unchanged fields are preserved.",
|
|
1423
1426
|
cbam_factory_read: "Read the complete accessible CBAM factory form by exact factoryId. Call before updating a shared factory because factory updates are full-form writes and orgId is immutable. Read-only.",
|
|
1424
|
-
cbam_factory_save: "Create or fully update a shared CBAM factory. action=create omits factoryId; action=update requires factoryId and must follow cbam_factory_read, preserving unchanged fields and orgId. Country and orgId must come from cbam_reference_search. Both actions are shared-data mutations
|
|
1427
|
+
cbam_factory_save: "Create or fully update a shared CBAM factory. action=create omits factoryId; action=update requires factoryId and must follow cbam_factory_read, preserving unchanged fields and orgId. Country and orgId must come from cbam_reference_search. Both actions are shared-data mutations: reuse the existing Agent approval interrupt, then have the trusted wrapper inject confirmed=true and idempotencyKey before this single MCP call. MCP never automatically retries this write.",
|
|
1425
1428
|
cbam_report_save: "Create or fully update CBAM report general information. action=create omits reportId; every create call creates a NEW report and binds it to the same Agent session without replacing earlier CBAM reports. One session may therefore contain multiple reports. action=update requires an explicit reportId and should follow cbam_report_read view=section section=GENERAL_INFO. After more than one report exists, always pass the intended reportId to subsequent tools and ask the user when context is ambiguous. Basic general information is enough to create a report and later generate it; other sections are progressive supplements. Requires idempotencyKey.",
|
|
1426
|
-
cbam_process_manage: "Manage self-produced CBAM process definitions for one report. action=save batch-creates/updates complete definition rows; action=delete removes exact ids; action=reorder requires every current process id exactly once in target order. Read PROCESS before updates/deletes/reorder. A report supports at most 10 processes. Delete
|
|
1427
|
-
cbam_precursor_manage: "Manage manually entered purchased-precursor definitions. action=save batch-creates/updates complete rows; action=delete removes exact precursor ids. Read PRECURSOR first, and resolve category/country/route values through cbam_reference_search. A report supports at most 20 precursors. Delete
|
|
1428
|
-
cbam_source_flow_manage: "Manage direct-emission source-flow rows under report processes. action=save creates/updates rows and the backend recalculates direct emissions; action=delete removes exact ids. Read SOURCE_FLOW first, use process ids from the same report, and use CBAM_ENUM codes for processMethod/sourceType. Calculated results and support files are backend-owned and are not accepted by this tool. Delete
|
|
1429
|
+
cbam_process_manage: "Manage self-produced CBAM process definitions for one report. action=save batch-creates/updates complete definition rows; action=delete removes exact ids; action=reorder requires every current process id exactly once in target order. Read PROCESS before updates/deletes/reorder. A report supports at most 10 processes. Delete requires the existing Agent approval interrupt and wrapper-injected confirmed=true; save/reorder do not. Requires idempotencyKey; MCP never automatically retries.",
|
|
1430
|
+
cbam_precursor_manage: "Manage manually entered purchased-precursor definitions. action=save batch-creates/updates complete rows; action=delete removes exact precursor ids. Read PRECURSOR first, and resolve category/country/route values through cbam_reference_search. A report supports at most 20 precursors. Delete requires prior Agent approval and wrapper-injected confirmed=true. Requires idempotencyKey; MCP never automatically retries.",
|
|
1431
|
+
cbam_source_flow_manage: "Manage direct-emission source-flow rows under report processes. action=save creates/updates rows and the backend recalculates direct emissions; action=delete removes exact ids. Read SOURCE_FLOW first, use process ids from the same report, and use CBAM_ENUM codes for processMethod/sourceType. Calculated results and support files are backend-owned and are not accepted by this tool. Delete requires prior Agent approval and wrapper-injected confirmed=true. Requires idempotencyKey.",
|
|
1429
1432
|
cbam_heat_power_update: "Update complete heat-power cogeneration inputs for a report whose include flag enables this section. Read HEAT_POWER first. Submit only input fields; the backend calculates outPower/outFactor and invalidates dependent sale calculations. Requires idempotencyKey.",
|
|
1430
1433
|
cbam_product_data_update: "Update product activity/emission data for existing process or precursor rows. dataType=process requires process items with totalVolume and salesVolume; dataType=precursor requires precursor items. Read PROCESS_PRODUCT_DATA or PRECURSOR_PRODUCT_DATA first. The backend preserves definitions, validates report ownership and activity balances, replaces route rows transactionally, calculates dependent fields, and rejects server-owned result fields. Requires idempotencyKey.",
|
|
1431
|
-
cbam_sale_product_manage: "Manage sale products for one CBAM report. action=save batch-creates/updates complete form rows tied to exact report process ids; action=delete removes exact ids and dependent tax rows. Read SALE_PRODUCT first and use CN/category data from cbam_reference_search. Calculated emissions, versions, fill status, and payTax are backend-owned. Delete
|
|
1432
|
-
cbam_carbon_tax_manage: "Manage or calculate report carbon tax. action=save batch-creates/updates rows using exact saleProductId, currency, benchmark, and source candidates returned by CBAM reads/reference search; action=delete removes exact ids; action=calculate starts asynchronous calculation. Read CARBON_TAX and carbon-tax candidates first. delete and calculate
|
|
1434
|
+
cbam_sale_product_manage: "Manage sale products for one CBAM report. action=save batch-creates/updates complete form rows tied to exact report process ids; action=delete removes exact ids and dependent tax rows. Read SALE_PRODUCT first and use CN/category data from cbam_reference_search. Calculated emissions, versions, fill status, and payTax are backend-owned. Delete requires prior Agent approval and wrapper-injected confirmed=true. Requires idempotencyKey.",
|
|
1435
|
+
cbam_carbon_tax_manage: "Manage or calculate report carbon tax. action=save batch-creates/updates rows using exact saleProductId, currency, benchmark, and source candidates returned by CBAM reads/reference search; action=delete removes exact ids; action=calculate starts asynchronous calculation. Read CARBON_TAX and carbon-tax candidates first. delete and calculate require the existing Agent approval interrupt and wrapper-injected confirmed=true; after calculate succeeds, poll cbam_report_read with view=carbon_tax_status. Requires idempotencyKey and is never automatically retried.",
|
|
1433
1436
|
cbam_data_quality_update: "Update the complete CBAM data-quality form. First call cbam_report_read view=section section=DATA_QUALITY and preserve fields the user did not change. Use CBAM_ENUM codes for enum fields. Requires idempotencyKey.",
|
|
1434
|
-
cbam_report_generate: "
|
|
1435
|
-
cbam_report_generation_status: "
|
|
1437
|
+
cbam_report_generate: "Generate the selected CBAM report and wait for the backend file result. General information alone is sufficient to request generation; optional missing sections remain visible through cbam_report_read view=readiness and may produce warnings or incomplete content according to backend rules. The backend creates the file, uploads it, and records it in Carbon Cloud download management; the Agent must not create a parallel spreadsheet. Reuse the existing Agent approval interrupt, then have the trusted wrapper inject confirmed=true and idempotencyKey before this single MCP call. The MCP server polls the internal generation status itself and normally returns COMPLETED with the download file. If it returns RUNNING with timedOut=true, call this same tool again with the same idempotencyKey to continue waiting without creating a duplicate task. The generation write is never automatically retried after timeout/network/5xx failures.",
|
|
1438
|
+
cbam_report_generation_status: "Internal-only CBAM report-generation status route used by cbam_report_generate. It is intentionally not exposed to the Agent.",
|
|
1436
1439
|
user_memory_recall: "Recall the current user's stored cross-session preferences, long-term constraints, carbon-domain habits, and response-style preferences. Call this when stable prior preferences can materially improve the current task, when the user asks what was remembered, and before user_memory_upsert or user_memory_forget if this turn has not already recalled the same target topic. A direct write or forget needs this lookup even when the current request supplies the new value, so the Agent can reuse an existing memoryKey and memoryId instead of creating a semantic duplicate. Do not repeatedly recall the same topic in one turn. Write query as a concise question about the preference or constraint needed now; never copy the full user message or include unrelated sensitive business data. Optional memoryTypes: preference=general preference, constraint=persistent rule or boundary, domain_habit=carbon-accounting/modeling/reporting workflow habit, format_habit=response language/structure/length/file-format habit. The response contains rules and items with memoryId, scope, type, memoryKey, normalized content, recallMode, version, and relevance metadata. count=0 is a successful empty recall; continue the task using current context. The current user request always overrides recalled memory, and current business data is authoritative. Treat recalled items as guidance, not authoritative business facts. Never reveal memory ids, versions, scores, source metadata, or internal implementation details to the user. Requires sessionId, a messageId belonging to that session, and query.",
|
|
1437
1440
|
user_memory_get: "Read exactly one current-user memory by the stable memoryId returned by user_memory_recall or a previous write. Use this immediately before updating or forgetting a memory to obtain its latest version and avoid stale writes. Do not enumerate, guess, or probe memory ids, and do not use this tool to access another user or project: authorization is derived from sessionId and messageId. The response is reduced to Agent-safe fields and must not be displayed as internal metadata to the user. Requires sessionId, a messageId belonging to that session, and memoryId.",
|
|
1438
1441
|
user_memory_upsert: "Create or update one stable long-term user memory. Call only when the user explicitly asks the Agent to remember a lasting preference/constraint, or after the user clearly confirms it; ordinary observations, one-off task details, sensitive data, changing business facts, account ids, emission values, and unconfirmed model inferences must not be stored. Before writing, call user_memory_recall once for the target topic unless the same topic was already recalled in this turn. If recall finds the same independently updatable slot, reuse its exact memoryKey; for an exact update, also reuse its memoryId, call user_memory_get, and preferably pass the latest positive version as expectedVersion. If recall finds no matching slot, omit memoryId and create by a new stable memoryKey. memoryId determines the operation: omit it or pass a blank value to create/upsert by memoryKey; pass a valid memoryId to update that exact item. For compatibility, expectedVersion may be omitted or 0 and the backend will use the latest version read at update time; never blindly retry a version conflict. expectedVersion is ignored when memoryId is absent. memoryKey represents one independently updatable slot: never include mutable attitude/state such as like/dislike or enabled/disabled. A single-valued attribute uses one fixed key without the changing value, such as preference.favorite_color or format.response.language. A multi-valued collection includes a canonical lowercase English object so values can coexist, such as preference.color.white and preference.color.red; liking and disliking white both reuse preference.color.white. Different wording or languages for the same slot or object must reuse the recalled key. USER applies across sessions; USER_PROJECT applies only to the current session project, which the backend derives automatically. Prefer source=EXPLICIT_USER for a direct request or CONFIRMED_CONVERSATION after confirmation. Use ALWAYS for persistent constraints/response-style rules and SEMANTIC for context-dependent preferences, or omit recallMode for the backend default. Requires sessionId, messageId, scope, type, memoryKey, and normalized content no longer than 120 characters. MCP never automatically retries this write.",
|
|
@@ -1623,13 +1626,17 @@ export const toolRoutes = {
|
|
|
1623
1626
|
method: "POST",
|
|
1624
1627
|
path: apipath.CbamReportGenerate(),
|
|
1625
1628
|
bodyKind: "cbam",
|
|
1626
|
-
|
|
1629
|
+
// This endpoint only creates the asynchronous generation task. The MCP
|
|
1630
|
+
// composite call owns a separate 120-second total start-and-poll budget.
|
|
1631
|
+
timeoutSeconds: 20,
|
|
1632
|
+
exactTimeout: true,
|
|
1627
1633
|
maxRetries: 0,
|
|
1628
1634
|
},
|
|
1629
1635
|
cbam_report_generation_status: {
|
|
1630
1636
|
method: "POST",
|
|
1631
1637
|
path: apipath.CbamReportGenerationStatus(),
|
|
1632
1638
|
bodyKind: "cbam",
|
|
1639
|
+
maxRetries: 0,
|
|
1633
1640
|
},
|
|
1634
1641
|
user_memory_recall: {
|
|
1635
1642
|
method: "POST",
|
|
@@ -1978,7 +1985,6 @@ export function buildBody(route, args) {
|
|
|
1978
1985
|
|| action === "calculate";
|
|
1979
1986
|
if (!confirmationRequired) {
|
|
1980
1987
|
delete body.confirmed;
|
|
1981
|
-
delete body.pendingActionId;
|
|
1982
1988
|
}
|
|
1983
1989
|
return normalizeCbamCodes(normalizeIds(pickDefined(body)));
|
|
1984
1990
|
}
|
|
@@ -2407,11 +2413,11 @@ function validateCbamActionPayload(args, supported) {
|
|
|
2407
2413
|
}
|
|
2408
2414
|
}
|
|
2409
2415
|
function validateCbamConfirmation(args, required) {
|
|
2410
|
-
if (!required
|
|
2416
|
+
if (!required)
|
|
2411
2417
|
return;
|
|
2412
|
-
if (
|
|
2413
|
-
|
|
2414
|
-
|
|
2418
|
+
if (args.confirmed === true)
|
|
2419
|
+
return;
|
|
2420
|
+
cbamInputError("CONFIRMATION_REQUIRED", "confirmed", "confirmed=true must be injected by the trusted Agent wrapper after user approval");
|
|
2415
2421
|
}
|
|
2416
2422
|
function validateCbamSourceFlows(value) {
|
|
2417
2423
|
if (!Array.isArray(value))
|