@carbonstopper/agent-mcp 0.1.37 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -13
- package/dist/apipath.d.ts +1 -0
- package/dist/apipath.js +1 -0
- package/dist/apipath.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/server.js +34 -1
- package/dist/server.js.map +1 -1
- package/dist/tool-validation.d.ts +21 -0
- package/dist/tool-validation.js +200 -0
- package/dist/tool-validation.js.map +1 -0
- package/dist/tools.d.ts +3 -3
- package/dist/tools.js +173 -36
- package/dist/tools.js.map +1 -1
- package/docs/schema-audit.md +153 -0
- package/package.json +4 -1
package/dist/tools.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import * as apipath from "./apipath.js";
|
|
4
|
+
import { enterpriseEmissionSaveFactorContract, enterpriseEmissionUpdateFactorContract, ToolInputValidationError, validateEnterpriseFactorContract, } from "./tool-validation.js";
|
|
4
5
|
const sessionId = z
|
|
5
6
|
.string()
|
|
6
7
|
.min(1)
|
|
@@ -96,7 +97,7 @@ const factorSchema = z.object({
|
|
|
96
97
|
.enum(["library", "custom"])
|
|
97
98
|
.optional()
|
|
98
99
|
.describe("Factor source type. Use library for a CCDB factor selected from factor_search; use custom only when the user or Agent provides a custom emission factor."),
|
|
99
|
-
factorId: optionalProductFactorId.describe("CCDB library factor id selected from factor_search results. Accepts a number or numeric string. null, blank, and common missing-value placeholders are treated as omitted so they do not fail MCP validation. Required when sourceType=library. For normal library factors in update tools, also provide the full snapshot fields name, factor, unit, institution, and year. For Ecoinvent library factors, pass sourceType=library and factorId only; do not pass encrypted or placeholder factor values."),
|
|
100
|
+
factorId: optionalProductFactorId.describe("CCDB library factor id selected from factor_search results. Accepts a number or numeric string. null, blank, and common missing-value placeholders are treated as omitted so they do not fail MCP validation. Required when sourceType=library. When sourceType=custom, omit factorId; if it is sent accidentally, the backend ignores it. For normal library factors in update tools, also provide the full snapshot fields name, factor, unit, institution, and year. For Ecoinvent library factors, pass sourceType=library and factorId only; do not pass encrypted or placeholder factor values."),
|
|
100
101
|
name: z.string().optional().describe("Factor name. Required when sourceType=custom. For normal library factors in update tools, provide the returned snapshot name. For Ecoinvent library factors, omit when unavailable and use factorId only."),
|
|
101
102
|
factor: z.string().optional().describe("Emission factor value. Required when sourceType=custom. For normal library factors in update tools, provide the returned snapshot value. Do not provide this for Ecoinvent library factors because values may be encrypted or unavailable to Agent."),
|
|
102
103
|
unit: z.string().optional().describe("Factor unit, for example kgCO2e/kg. Required when sourceType=custom. For normal library factors in update tools, provide the returned snapshot unit. For Ecoinvent library factors, omit when unavailable and use factorId only."),
|
|
@@ -218,12 +219,12 @@ const memoryId = z
|
|
|
218
219
|
.string()
|
|
219
220
|
.trim()
|
|
220
221
|
.min(1)
|
|
221
|
-
.describe("Stable external memory id returned by
|
|
222
|
+
.describe("Stable external memory id returned by the recall, get, or upsert tool for the current memory scope.");
|
|
222
223
|
const memoryVersion = z
|
|
223
224
|
.number()
|
|
224
225
|
.int()
|
|
225
226
|
.positive()
|
|
226
|
-
.describe("Latest memory version returned by
|
|
227
|
+
.describe("Latest memory version returned by the corresponding get or upsert tool. Used for optimistic concurrency control.");
|
|
227
228
|
const memoryUpsertVersion = z
|
|
228
229
|
.union([
|
|
229
230
|
z.number().int().nonnegative(),
|
|
@@ -240,7 +241,7 @@ const memoryKey = z
|
|
|
240
241
|
.min(1)
|
|
241
242
|
.max(128)
|
|
242
243
|
.regex(/^[a-z0-9][a-z0-9._-]{0,127}$/, "Expected a lowercase stable topic key")
|
|
243
|
-
.describe("Stable lowercase
|
|
244
|
+
.describe("Stable lowercase key for one independently updatable memory slot. Never include mutable attitude or state such as like/dislike or enabled/disabled. For a single-valued attribute, keep a fixed key without its changing value, for example preference.favorite_color or format.response.language. For a multi-valued collection, include the canonical lowercase English object so entries can coexist, for example preference.color.white and preference.color.red; liking and disliking white both reuse preference.color.white. Prefer a semantically matching key returned by agent_user_memory_recall.");
|
|
244
245
|
const memoryScope = z
|
|
245
246
|
.enum(["USER", "USER_PROJECT"])
|
|
246
247
|
.describe("Memory scope: USER applies across the user's sessions; USER_PROJECT applies only to the current session project. Never pass projectId because the backend derives it from sessionId.");
|
|
@@ -282,9 +283,20 @@ const userMemoryUpsertSchema = z
|
|
|
282
283
|
.optional()
|
|
283
284
|
.describe("Optional future ISO-8601 expiration timestamp. Pass null or omit for long-term validity."),
|
|
284
285
|
});
|
|
286
|
+
const projectMemoryUpsertSchema = userMemoryUpsertSchema
|
|
287
|
+
.omit({ scope: true })
|
|
288
|
+
.extend({
|
|
289
|
+
memoryKey: memoryKey.describe("Stable lowercase key for one independently updatable project rule or decision. Reuse the exact key returned by agent_project_memory_recall for the same project topic. Recommended prefixes include project.accounting, project.factor, project.data, and project.delivery."),
|
|
290
|
+
content: z
|
|
291
|
+
.string()
|
|
292
|
+
.trim()
|
|
293
|
+
.min(1)
|
|
294
|
+
.max(120)
|
|
295
|
+
.describe("Normalized shared project memory, at most 120 characters. Store only a confirmed reusable project decision, accounting boundary, data-source rule, quality requirement, or delivery convention; never store a member's personal preference or private information."),
|
|
296
|
+
});
|
|
285
297
|
const enterpriseYear = z.number().int().positive().describe("Enterprise carbon accounting year, for example 2025. The Agent should always pass an explicit target year.");
|
|
286
298
|
const enterpriseCode = z.union([z.number(), z.string().regex(/^\d+$/, "Expected a numeric code string")]);
|
|
287
|
-
const enterpriseComputationPeriodDescription = "Accounting
|
|
299
|
+
const enterpriseComputationPeriodDescription = "Accounting-period value for this emission source. First read timeType from enterprise_computation_detail. For annual accounting (timeType=0), omit this field or use 1. For quarterly or monthly accounting (timeType=1 or 2), first call enterprise_computation_period_list for the same year, match the user-requested displayed period against a returned item.name, and pass that item's value here. Never infer value from the calendar quarter or month: in a fiscal year, a displayed April can have value=1 and a displayed January can have value=10. If the list is empty, no item.name matches, or the user has not identified a period, do not guess or call enterprise_emission_batch_save; obtain a valid period first. Accepts a number or numeric string from 1 to 12.";
|
|
288
300
|
const enterpriseComputationPeriod = z
|
|
289
301
|
.union([
|
|
290
302
|
z.number().int().min(1).max(12),
|
|
@@ -380,18 +392,25 @@ const enterpriseEmissionSourceBaseSchema = z.object({
|
|
|
380
392
|
const enterpriseEmissionSourceSaveSchema = enterpriseEmissionSourceBaseSchema.extend({
|
|
381
393
|
clientSourceKey: z.string().trim().min(1).describe("Required Agent-side row key for a new source. Generate a non-empty value that is unique across the whole enterprise_emission_batch_save request, and use the echoed value to match each response item to its request item."),
|
|
382
394
|
computationPeriod: enterpriseComputationPeriod.optional().describe(enterpriseComputationPeriodDescription),
|
|
383
|
-
})
|
|
395
|
+
})
|
|
396
|
+
.catchall(z.unknown())
|
|
397
|
+
.describe("Pure-new enterprise emission source. Do not pass sourceId to enterprise_emission_batch_save; the backend creates it and returns sourceId.")
|
|
398
|
+
.meta(enterpriseEmissionSaveFactorContract);
|
|
384
399
|
const enterpriseEmissionSourceUpdateSchema = enterpriseEmissionSourceBaseSchema.omit({ factorGasList: true }).extend({
|
|
385
400
|
sourceId: longId.describe("Existing enterprise emission source id returned in enterprise_computation_detail.sourceRows after mapping with sourceColumns. Do not guess it by name or hard-code a column position."),
|
|
386
401
|
activityType: enterpriseCode.optional().describe("Activity type code: 0=factor method, 1=methodology. Omit only when the existing/default value should be used."),
|
|
387
402
|
grouping: z.string().optional().describe("Optional custom grouping name. Omit to preserve the existing group; pass an empty string to explicitly clear the group."),
|
|
388
403
|
fdType: optionalWithoutBlank(enterpriseFactorMode).describe("Optional factor handling mode for update. fdType=1 requires factorId. Without factorId, a non-empty gasList selects a custom factor and fdType=2 is optional. Blank values are treated as omitted. Omit all factor action and snapshot fields to preserve the existing factor."),
|
|
389
|
-
autoMatchFactor: z.boolean().optional().describe("Set true only when the factor must be re-matched from the updated source name, unit, and classification. Cannot be combined with factorId, fdType, or
|
|
404
|
+
autoMatchFactor: z.boolean().optional().describe("Set true only when the factor must be re-matched from the updated source name, unit, and classification. Cannot be combined with factorId, fdType, gasList, factorName, factorType, factorSource, or factorPublic."),
|
|
390
405
|
gasList: optionalNonEmptyArray(enterpriseFactorGasSchema).describe("Complete custom factor gas list. Without factorId, providing it switches to a custom factor and replaces all existing gas details; fdType=2 is optional. With factorId, the library factor is authoritative and MCP removes this ignored list before calling Java. Omit this field instead of sending an empty list. Cannot be combined with autoMatchFactor."),
|
|
391
|
-
})
|
|
406
|
+
})
|
|
407
|
+
.catchall(z.unknown())
|
|
408
|
+
.meta(enterpriseEmissionUpdateFactorContract);
|
|
409
|
+
const enterpriseEmissionSourceSaveFields = new Set(Object.keys(enterpriseEmissionSourceSaveSchema.shape));
|
|
410
|
+
const enterpriseEmissionSourceUpdateFields = new Set(Object.keys(enterpriseEmissionSourceUpdateSchema.shape));
|
|
392
411
|
const enterpriseEmissionOrgSaveSchema = z.object({
|
|
393
412
|
computationId: longId.describe("Required enterprise subject-year computation id returned in enterprise_computation_detail.computationRows after mapping with computationColumns. The backend derives and validates the organization identity from this id."),
|
|
394
|
-
sourceList: z.array(enterpriseEmissionSourceSaveSchema).min(1).describe("Pure-new enterprise emission sources. Do not include sourceId in any item. Set computationPeriod on each source, not on this organization group
|
|
413
|
+
sourceList: z.array(enterpriseEmissionSourceSaveSchema).min(1).describe("Pure-new enterprise emission sources. Do not include sourceId in any item. Set computationPeriod on each source, not on this organization group. For annual accounting, omit it or use 1. For quarterly/monthly accounting, call enterprise_computation_period_list, match the displayed item.name, and use its exact item.value; never derive the value from calendar order."),
|
|
395
414
|
});
|
|
396
415
|
const enterpriseEmissionComputationUpdateSchema = z.object({
|
|
397
416
|
computationId: longId.describe("Enterprise subject-year computation id returned in enterprise_computation_detail.computationRows after mapping with computationColumns."),
|
|
@@ -451,6 +470,45 @@ export const schemas = {
|
|
|
451
470
|
.describe("Must be true. Set it only after the user explicitly requests or confirms forgetting this exact memory."),
|
|
452
471
|
pendingActionId: confirmedActionFields.pendingActionId,
|
|
453
472
|
}),
|
|
473
|
+
agent_project_memory_recall: z.object({
|
|
474
|
+
sessionId,
|
|
475
|
+
messageId: memoryMessageId,
|
|
476
|
+
query: z
|
|
477
|
+
.string()
|
|
478
|
+
.trim()
|
|
479
|
+
.min(1)
|
|
480
|
+
.max(500)
|
|
481
|
+
.describe("Concise description of the confirmed project rule, accounting convention, data-source principle, or delivery constraint needed for the current project task."),
|
|
482
|
+
memoryTypes: z
|
|
483
|
+
.array(z.enum(["preference", "constraint", "domain_habit", "format_habit"]))
|
|
484
|
+
.min(1)
|
|
485
|
+
.max(4)
|
|
486
|
+
.optional()
|
|
487
|
+
.describe("Optional project-memory type filter. Omit it to search all supported project-memory types."),
|
|
488
|
+
limit: z
|
|
489
|
+
.number()
|
|
490
|
+
.int()
|
|
491
|
+
.min(1)
|
|
492
|
+
.max(10)
|
|
493
|
+
.optional()
|
|
494
|
+
.describe("Maximum number of project memories to return. Defaults to 5 and cannot exceed 10."),
|
|
495
|
+
}),
|
|
496
|
+
agent_project_memory_get: z.object({
|
|
497
|
+
sessionId,
|
|
498
|
+
messageId: memoryMessageId,
|
|
499
|
+
memoryId,
|
|
500
|
+
}),
|
|
501
|
+
agent_project_memory_upsert: projectMemoryUpsertSchema,
|
|
502
|
+
agent_project_memory_forget: z.object({
|
|
503
|
+
sessionId,
|
|
504
|
+
messageId: memoryMessageId,
|
|
505
|
+
memoryId,
|
|
506
|
+
expectedVersion: memoryVersion,
|
|
507
|
+
confirmed: z
|
|
508
|
+
.literal(true)
|
|
509
|
+
.describe("Must be true. Use only after the project owner explicitly requests or confirms forgetting this exact shared project memory."),
|
|
510
|
+
pendingActionId: confirmedActionFields.pendingActionId,
|
|
511
|
+
}),
|
|
454
512
|
modeling_execute: z.object({
|
|
455
513
|
sessionId,
|
|
456
514
|
...skillTraceFields,
|
|
@@ -639,6 +697,12 @@ export const schemas = {
|
|
|
639
697
|
orgId: longId.optional().describe("Optional organization subject id. Omit to return all subjects under the year."),
|
|
640
698
|
computationPeriod: z.string().optional().describe("Optional computation period filter. For annual accounting this is usually omitted or the year string."),
|
|
641
699
|
}),
|
|
700
|
+
enterprise_computation_period_list: z.object({
|
|
701
|
+
sessionId,
|
|
702
|
+
...skillTraceFields,
|
|
703
|
+
year: enterpriseYear.describe("Enterprise carbon accounting year whose available quarterly or monthly periods are needed, for example 2026."),
|
|
704
|
+
lang: z.string().trim().min(1).optional().describe("Optional display language. Use zh by default, or en for English period labels when supported by the backend."),
|
|
705
|
+
}),
|
|
642
706
|
enterprise_emission_category_list: z.object({
|
|
643
707
|
sessionId: sessionId.describe("Agent session id. Use this read-only tool before creating or updating enterprise emission sources to obtain valid GHG and ISO category/classification codes."),
|
|
644
708
|
...skillTraceFields,
|
|
@@ -723,6 +787,10 @@ export const exposedToolNames = [
|
|
|
723
787
|
"agent_user_memory_get",
|
|
724
788
|
"agent_user_memory_upsert",
|
|
725
789
|
"agent_user_memory_forget",
|
|
790
|
+
"agent_project_memory_recall",
|
|
791
|
+
"agent_project_memory_get",
|
|
792
|
+
"agent_project_memory_upsert",
|
|
793
|
+
"agent_project_memory_forget",
|
|
726
794
|
"modeling_re_modeling",
|
|
727
795
|
"modeling_detail",
|
|
728
796
|
"modeling_account_detail",
|
|
@@ -748,6 +816,7 @@ export const exposedToolNames = [
|
|
|
748
816
|
"enterprise_computation_batch_delete",
|
|
749
817
|
"enterprise_computation_update_base_info",
|
|
750
818
|
"enterprise_computation_detail",
|
|
819
|
+
"enterprise_computation_period_list",
|
|
751
820
|
"enterprise_emission_category_list",
|
|
752
821
|
"enterprise_report_org_tree",
|
|
753
822
|
"enterprise_report_generate",
|
|
@@ -759,10 +828,14 @@ export const exposedToolNames = [
|
|
|
759
828
|
];
|
|
760
829
|
export const descriptions = {
|
|
761
830
|
session_carbon_objects: "Recover the product-carbon and enterprise-carbon computations bound to the current Agent session. Call this before guessing or reusing a lost product accountId or enterprise computationId, and after ACCOUNT_CONTEXT_MISMATCH. Omit module to return everything; module=footprint3 returns productCarbonAccounts, and module=enterprise returns enterpriseCarbonComputations. Match product computations by accountName, productName, or functionalUnit, then use productCarbonAccounts[].accountId. Match enterprise computations by year and orgList[].orgName, then use orgList[].computationId. Never use an enterprise year as a product accountId. Reports are not returned. This tool is read-only and requires sessionId.",
|
|
762
|
-
agent_user_memory_recall: "Recall the current user's stored cross-session preferences, long-term constraints, carbon-domain habits, and response-style preferences. Call this
|
|
831
|
+
agent_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 agent_user_memory_upsert or agent_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.",
|
|
763
832
|
agent_user_memory_get: "Read exactly one current-user memory by the stable memoryId returned by agent_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.",
|
|
764
|
-
agent_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.
|
|
765
|
-
agent_user_memory_forget: "Forget exactly one stored user memory. Use only when the user explicitly requests or confirms forgetting that specific memory.
|
|
833
|
+
agent_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 agent_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 agent_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.",
|
|
834
|
+
agent_user_memory_forget: "Forget exactly one stored user memory. Use only when the user explicitly requests or confirms forgetting that specific memory. If the exact memoryId is not already known from a recall in this turn, first call agent_user_memory_recall for the target topic; if multiple memories could match, ask the user to identify the intended one. Then call agent_user_memory_get with the exact memoryId and pass its latest version as expectedVersion with confirmed=true. Do not guess ids, do not loop over recalled items, and do not simulate a bulk or 'forget everything' operation. The backend performs a version-checked soft delete; on a version conflict, read the item again and ask/verify intent before one new attempt. MCP maps confirmed=true to the backend confirm flag and never automatically retries this destructive action. Requires sessionId, messageId, memoryId, expectedVersion, and confirmed=true.",
|
|
835
|
+
agent_project_memory_recall: "Recall only the current collaboration project's shared long-term memory. Use this tool only in a project-scoped session; never call agent_user_memory_recall as a fallback in a project session. Search for confirmed reusable project decisions, accounting boundaries and methods, factor/data-source principles, data-quality requirements, stable terminology, and delivery conventions. The backend derives the project from sessionId and never mixes in the session initiator's personal memory. Current user input, live business data, and current project settings override recalled memory. Do not reveal memory ids, versions, scores, author metadata, or implementation details. Requires sessionId, a messageId belonging to that project session, and query.",
|
|
836
|
+
agent_project_memory_get: "Read exactly one shared project memory by a memoryId returned by agent_project_memory_recall or a previous project-memory write. Use only in a project-scoped session and immediately before updating or forgetting that item. The backend derives project membership and projectId from the trusted session; never enumerate or guess ids. Requires sessionId, messageId, and memoryId.",
|
|
837
|
+
agent_project_memory_upsert: "Create or update one shared project memory. Use only in a project-scoped session after a project member explicitly confirms a reusable project decision, accounting boundary/method, factor or data-source rule, quality requirement, terminology, or delivery convention. Never store a member's personal preference, identity, contact details, transient task status, emission values, factor ids, secrets, or an unconfirmed Agent suggestion. First call agent_project_memory_recall for the same topic and reuse a matching memoryKey; when updating an exact item, call agent_project_memory_get and reuse its memoryId and latest version. The backend forces scope=PROJECT from sessionId, so this schema intentionally has no scope or projectId field. All active project members may create or update shared memories; MCP never automatically retries this write.",
|
|
838
|
+
agent_project_memory_forget: "Forget exactly one shared project memory. Use only in a project-scoped session when the project owner explicitly requests or confirms deletion of that exact item. First call agent_project_memory_recall, then agent_project_memory_get, and pass the latest memoryId/version with confirmed=true. Ordinary project members are rejected by the backend. Never guess ids, bulk-delete, or retry a version conflict blindly. Requires sessionId, messageId, memoryId, expectedVersion, and confirmed=true.",
|
|
766
839
|
modeling_execute: "Create a new product carbon model from input.content. Use this only when the user wants a new model and no existing account should be reused. Calls /modeling/execute. Requires idempotencyKey and input.content.",
|
|
767
840
|
modeling_re_modeling: "Re-model an existing product carbon account from updated context. Use this when the user wants to redo or recalculate the whole model for an existing account. Calls /modeling/reModeling. Requires accountId and idempotencyKey.",
|
|
768
841
|
modeling_update: "Natural-language supplement or adjustment for an existing product carbon account. Prefer modeling_account_update_structured for account/master-data changes and modeling_emission_update_structured for precise single-emission-source changes. Use this only when the user gives a broad natural-language update that is not yet structured. Calls /modeling/update. Requires accountId, idempotencyKey, and input.content.",
|
|
@@ -790,12 +863,13 @@ export const descriptions = {
|
|
|
790
863
|
enterprise_computation_batch_delete: "Delete subject-year enterprise carbon computations. Use only after mapping enterprise_computation_detail.computationRows with computationColumns to obtain exact computationIds and the user confirms deletion. Never hard-code compact row positions. Calls /agent/computation/batchDelete. Requires computationIdList and idempotencyKey.",
|
|
791
864
|
enterprise_computation_update_base_info: "Update enterprise carbon computation base settings such as GWP version or accounting period type. Do not use this for emission source data. Calls /agent/computation/updateBaseInfo. Requires year and idempotencyKey.",
|
|
792
865
|
enterprise_computation_detail: "Get the full enterprise carbon yearly accounting detail in compact column-and-row tables. Call this before adding, updating, deleting sources, or generating reports. The response data has resultFormat=compact_enterprise_computation_table plus computationColumns/computationRows, sourceColumns/sourceRows, and gasColumns/gasRows. ALWAYS map each row by its accompanying columns array; never assume or hard-code array positions. Read computationId from computationRows, sourceId and its parent computationId from sourceRows, and join gasRows to a source by sourceId. orgSummary is aggregate display data only and must not replace detail ids. The compact response is full data, not pagination or truncation. Calls /agent/computation/detail. Requires year.",
|
|
866
|
+
enterprise_computation_period_list: "Resolve the authoritative enterprise accounting-period values before pure-insert emission-source creation. First call enterprise_computation_detail and read timeType. For annual accounting (timeType=0), do not call this tool; computationPeriod may be omitted or set to 1. For quarterly or monthly accounting (timeType=1 or 2), call this read-only tool for the same year before enterprise_emission_batch_save. Match the user's requested quarter or month against a returned item.name, then copy that exact item's value to every applicable sourceList[].computationPeriod. Never assume value=calendar month or derive the value yourself: fiscal years can return name=\"4\", value=1 for April and name=\"1\", value=10 for January. status describes the period state only and is never the computationPeriod. Status codes: 0=filling, 1=completed, 2=not started, 3=waiting for data, 4=waiting for submission, 5=not open. If data is empty, no name matches, or the user has not selected a period, do not guess and do not call enterprise_emission_batch_save; obtain a valid period first. Calls GET /agent/computation/periodList with cYear, sessionId, and optional lang. Requires year.",
|
|
793
867
|
enterprise_emission_category_list: "Required dictionary lookup before enterprise emission source creation or update. Call this once before enterprise_emission_batch_save or enterprise_emission_batch_update and reuse the result during that workflow. Select a ghgList child id as the source's ghgClassify and never invent a classification code. The backend derives ghgCategory, isoCategory, and isoClassify from ghgClassify, so the Agent must not submit those derived fields. This tool is read-only and requires only sessionId plus optional trace fields. Calls /agent/category/list.",
|
|
794
868
|
enterprise_report_org_tree: "Get the enterprise carbon organization tree nodes that can generate reports for a target year. Call this before enterprise_report_generate or enterprise_report_regenerate and use the selected node's exact orgId. The server resolves authoritative organization names for confirmation; the Agent must not submit display-only organization names. Calls /agent/report/orgTree. Requires year.",
|
|
795
869
|
enterprise_report_generate: "CRITICAL BACKEND-REPORT RULE: the backend, not the Agent, creates the complete report正文, emission inventory, calculations, ratios, charts, and conclusions from stored accounting data. Before calling, DO NOT draft or calculate a parallel report and DO NOT place report正文 or Markdown in reportName, confirmation content, or any tool argument. A confirmation summary MUST stay brief and contain only the selected organization, accounting year/period, report standard, language, and requested version types. After success, treat the backend fileList as the final report output: show generation status and returned report files, and DO NOT produce a second text report unless the user explicitly asks for a separate summary or interpretation. CRITICAL AGGREGATION RULE: one user message and one initial report-generation action MUST produce exactly one call to this tool. Before calling, collect every requested standard and output type into one versionTypeList. NEVER split GHG and ISO, Word and Excel, or individual version codes into separate tool calls. Use versionTypeList=[2,5] for GHG+ISO full reports, [2,3] for GHG full report+inventory, and [2,3,5,6] for both standards with full reports and inventories. Multiple fileList items in one response are the expected complete result and MUST NOT trigger another call. Call enterprise_report_org_tree first and pass only the selected valid orgId; the server resolves authoritative organization names and covered subjects for confirmation. If the user explicitly asks to regenerate the complete report, use enterprise_report_regenerate instead. Report code fields accept numbers or numeric strings and are normalized to numbers before calling Java. versionTypeList codes: 2=GHG full report Word, 3=GHG inventory Excel, 5=ISO full report Word, 6=ISO inventory Excel; summary versions 1 and 4 are rejected by the backend. languageType: 1=Chinese (default), 2=English. timeType: 0=annual (default), 1=quarterly, 2=monthly. The backend fileList and persistent fileList[].path values are returned unchanged. Timeout, network, 429, or 5xx failures are returned immediately and are not automatically retried. Calls /agent/report/generate. Requires versionTypeList, calculatePeriod, orgId, and idempotencyKey.",
|
|
796
870
|
enterprise_report_regenerate: "CRITICAL BACKEND-REPORT RULE: the backend, not the Agent, regenerates the complete report正文, emission inventory, calculations, ratios, charts, and conclusions. Before calling, DO NOT draft a replacement report or put report正文 or Markdown into reportName, confirmation content, or tool arguments. Keep confirmation to a brief summary of organization, accounting year/period, standard, language, and requested version types. After success, use fileList as the final report output and DO NOT generate another text report unless the user explicitly asks for a separate summary or interpretation. CRITICAL AGGREGATION RULE: one user message and one whole-report regeneration action MUST produce exactly one call to this tool. Before calling, merge every requested report version into one versionTypeList; NEVER regenerate GHG and ISO, Word and Excel, or individual version codes through separate calls. Use [2,5] for GHG+ISO full reports and [2,3,5,6] for both standards with full reports and inventories. Multiple fileList items are the expected complete result and MUST NOT trigger another call. Use this tool only after the user explicitly requests a whole-report re-generation, for example after accounting data, report scope, organization, period, language, or requested versions changed. It intentionally calls the same /agent/report/generate backend as enterprise_report_generate and creates one new report action. Call enterprise_report_org_tree first and pass the same business fields as enterprise_report_generate; organization display names are resolved by the server and must not be submitted by Agent. Generate one new idempotencyKey for this aggregated action; reuse it only when retrying the identical request outside MCP. MCP never automatically retries it. Do not use this tool to retry one failed file record; use enterprise_report_file_record_retry instead. Requires versionTypeList, calculatePeriod, orgId, and idempotencyKey.",
|
|
797
871
|
enterprise_report_file_record_retry: "Retry generation of exactly one failed enterprise report file record; this is not whole-report regeneration. Use only an exact reportFileRecordId whose file status=2, returned by the report card/runtime result or by enterprise_report_generate/enterprise_report_regenerate fileList[] when available. Report generation can fail before returning a complete fileList, so never invent or infer this id. If several file records failed, call this tool separately for each failed record, with a distinct idempotencyKey per file retry. Do not call it for status=1 success or status=0 generating records; do not pass reportId; do not use it to change report content. It returns the retried file record with versionType, fileName, persistent path, status, and message. The call is synchronous, uses a 120-second timeout, and is never automatically retried by MCP. Calls /agent/report/reGenerate. Requires reportFileRecordId and idempotencyKey.",
|
|
798
|
-
enterprise_emission_batch_save: "Pure-insert enterprise carbon emission source batch save. Call enterprise_computation_detail first and group every request item by its exact required computationId; read compact detail rows by their columns arrays and never hard-code positions. The server derives the organization identity and confirmation names. Set computationPeriod on each sourceList[] item, never on orgList[]
|
|
872
|
+
enterprise_emission_batch_save: "Pure-insert enterprise carbon emission source batch save. Call enterprise_computation_detail first and group every request item by its exact required computationId; read compact detail rows by their columns arrays and never hard-code positions. The server derives the organization identity and confirmation names. Set computationPeriod on each sourceList[] item, never on orgList[]. For annual timeType=0, omit it or use 1. For quarterly or monthly timeType=1 or 2, first call enterprise_computation_period_list for the same year, match the user's displayed quarter/month to item.name, and pass the returned item.value. Never infer a period value from calendar order, especially for fiscal years. If the period list is empty, no name matches, or the user has not selected a period, do not call this tool. Call enterprise_emission_category_list and use a returned GHG child id as each source's required ghgClassify. Never send sourceId, emissionQuantity, ghgCategory, isoCategory, or isoClassify. Every source needs a request-unique clientSourceKey. activityData and activityUnit are independently optional; pass only the values actually known and never invent or send blank placeholders. Prefer activityUnit and custom factorUnitM from unit_list; the backend also accepts common aliases and automatically infers deterministic same-dimension conversions when unitConver is omitted. Pass unitConver only when the user supplied or explicitly confirmed it. For a custom factor, factorUnit accepts either a standard unit label or the gas-specific code documented on factorGasList[].factorUnit. The backend calculates emissionQuantity only when calculation inputs are sufficient; otherwise it remains null, not zero. activityCategory accepts number, numeric string, or official Chinese label: 1=自行推估, 3=定期记录/凭证数据, 6=自动连续测量. factorId selects an authoritative library factor; omit factorGasList and factor snapshot fields when factorId is present. MCP removes redundant gas details and snapshots before calling Java so encrypted library-factor values are never validated as custom factors. Without factorId, a non-empty factorGasList creates a custom factor with fdType=2 optional; omitting all factor action and snapshot fields lets the backend auto-match. Automatic matching must not include factorName, factorType, factorSource, or factorPublic. Always inspect successCount, failCount, and orgList[].sourceList[] and align rows by clientSourceKey/index. Calls /agent/emission/batchSave. Requires year, orgList[].computationId, sourceList, and idempotencyKey.",
|
|
799
873
|
enterprise_emission_batch_update: "Batch update existing enterprise carbon emission sources. Call enterprise_computation_detail first, map compact sourceRows with sourceColumns, and use the exact computationId and sourceId; never hard-code row positions. Then call enterprise_emission_category_list and submit only the selected ghgClassify; the backend derives all parent and ISO classifications. Never send emissionQuantity, ghgCategory, isoCategory, or isoClassify. activityData and activityUnit are independently optional; pass only the values actually known and never send blank placeholders except grouping=\"\" when explicitly clearing the existing group. Prefer activityUnit and custom factorUnitM from unit_list; common aliases are accepted and deterministic same-dimension conversion is inferred when unitConver is omitted. Pass unitConver only when the user supplied or explicitly confirmed it. For a custom factor, factorUnit accepts either a standard unit label or the gas-specific code documented on gasList[].factorUnit. The backend recalculates emissionQuantity when calculation inputs are sufficient and clears it to null when they are not; null does not mean zero emissions. activityCategory accepts number, numeric string, or official Chinese label: 1=自行推估, 3=定期记录/凭证数据, 6=自动连续测量; omitting it preserves the old value. factorId switches to an authoritative library factor; omit gasList and factor snapshot fields when factorId is present. MCP removes redundant gas details and snapshots before calling Java so encrypted library-factor values are never validated as custom factors. Without factorId, a non-empty gasList switches to a custom factor with fdType=2 optional; autoMatchFactor=true deliberately re-matches; omitting all factor action and snapshot fields preserves the existing factor. Automatic matching and preservation must not include factorName, factorType, factorSource, or factorPublic. Always inspect successCount, failCount, and computationList[].sourceList[] and align rows by clientSourceKey/index/sourceId. Calls /agent/emission/batchUpdate. Requires year, computationList, and idempotencyKey.",
|
|
800
874
|
enterprise_emission_batch_delete: "Batch delete enterprise carbon emission sources. Call enterprise_computation_detail first, map sourceRows with sourceColumns, use exact sourceIds, and ask for confirmation when needed. Never hard-code compact row positions. Calls /agent/emission/batchDelete. Requires year, sourceIdList, and idempotencyKey.",
|
|
801
875
|
workspace_authorize_file: "Authorize a workspace file for the current Agent sandbox session. Use this before reading or using a user-uploaded workspace file.",
|
|
@@ -832,6 +906,30 @@ export const toolRoutes = {
|
|
|
832
906
|
bodyKind: "userMemoryForget",
|
|
833
907
|
maxRetries: 0,
|
|
834
908
|
},
|
|
909
|
+
agent_project_memory_recall: {
|
|
910
|
+
method: "POST",
|
|
911
|
+
path: apipath.UserMemoryRecall(),
|
|
912
|
+
bodyKind: "userMemoryRecall",
|
|
913
|
+
},
|
|
914
|
+
agent_project_memory_get: {
|
|
915
|
+
method: "POST",
|
|
916
|
+
path: apipath.UserMemoryGet(),
|
|
917
|
+
bodyKind: "userMemoryGet",
|
|
918
|
+
responseKind: "userMemoryItem",
|
|
919
|
+
},
|
|
920
|
+
agent_project_memory_upsert: {
|
|
921
|
+
method: "POST",
|
|
922
|
+
path: apipath.UserMemoryUpsert(),
|
|
923
|
+
bodyKind: "projectMemoryUpsert",
|
|
924
|
+
maxRetries: 0,
|
|
925
|
+
responseKind: "userMemoryItem",
|
|
926
|
+
},
|
|
927
|
+
agent_project_memory_forget: {
|
|
928
|
+
method: "POST",
|
|
929
|
+
path: apipath.UserMemoryForget(),
|
|
930
|
+
bodyKind: "userMemoryForget",
|
|
931
|
+
maxRetries: 0,
|
|
932
|
+
},
|
|
835
933
|
modeling_execute: {
|
|
836
934
|
method: "POST",
|
|
837
935
|
path: apipath.ModelingExecute(),
|
|
@@ -967,6 +1065,11 @@ export const toolRoutes = {
|
|
|
967
1065
|
path: apipath.EnterpriseComputationDetail(),
|
|
968
1066
|
bodyKind: "agentSkill",
|
|
969
1067
|
},
|
|
1068
|
+
enterprise_computation_period_list: {
|
|
1069
|
+
method: "GET",
|
|
1070
|
+
path: apipath.EnterpriseComputationPeriodList(),
|
|
1071
|
+
bodyKind: "enterprisePeriodList",
|
|
1072
|
+
},
|
|
970
1073
|
enterprise_emission_category_list: {
|
|
971
1074
|
method: "POST",
|
|
972
1075
|
path: apipath.EnterpriseEmissionCategoryList(),
|
|
@@ -1071,6 +1174,28 @@ export function buildBody(route, args) {
|
|
|
1071
1174
|
}
|
|
1072
1175
|
return body;
|
|
1073
1176
|
}
|
|
1177
|
+
if (route.bodyKind === "projectMemoryUpsert") {
|
|
1178
|
+
const hasMemoryId = typeof args.memoryId === "string" && args.memoryId.trim().length > 0;
|
|
1179
|
+
const body = pickDefined({
|
|
1180
|
+
sessionId: args.sessionId,
|
|
1181
|
+
messageId: args.messageId,
|
|
1182
|
+
memoryId: args.memoryId,
|
|
1183
|
+
expectedVersion: hasMemoryId ? normalizeNumericCode(args.expectedVersion) : undefined,
|
|
1184
|
+
scope: "PROJECT",
|
|
1185
|
+
type: args.type,
|
|
1186
|
+
memoryKey: args.memoryKey,
|
|
1187
|
+
content: args.content,
|
|
1188
|
+
source: args.source,
|
|
1189
|
+
recallMode: args.recallMode,
|
|
1190
|
+
confidence: normalizeDecimalValue(args.confidence),
|
|
1191
|
+
importance: normalizeDecimalValue(args.importance),
|
|
1192
|
+
expiresAt: args.expiresAt,
|
|
1193
|
+
});
|
|
1194
|
+
if (Object.prototype.hasOwnProperty.call(args, "expiresAt") && args.expiresAt === null) {
|
|
1195
|
+
body.expiresAt = null;
|
|
1196
|
+
}
|
|
1197
|
+
return body;
|
|
1198
|
+
}
|
|
1074
1199
|
if (route.bodyKind === "userMemoryForget") {
|
|
1075
1200
|
return pickDefined({
|
|
1076
1201
|
sessionId: args.sessionId,
|
|
@@ -1113,6 +1238,13 @@ export function buildBody(route, args) {
|
|
|
1113
1238
|
: [args.emissionSource],
|
|
1114
1239
|
}));
|
|
1115
1240
|
}
|
|
1241
|
+
if (route.bodyKind === "enterprisePeriodList") {
|
|
1242
|
+
return pickDefined({
|
|
1243
|
+
cYear: String(args.year),
|
|
1244
|
+
sessionId: args.sessionId,
|
|
1245
|
+
lang: args.lang,
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1116
1248
|
if (route.bodyKind === "enterpriseReport") {
|
|
1117
1249
|
const body = normalizeIds(args);
|
|
1118
1250
|
const versionTypeList = Array.isArray(body.versionTypeList)
|
|
@@ -1155,6 +1287,13 @@ function normalizeEnterpriseEmissionSource(source, gasListField) {
|
|
|
1155
1287
|
if (!source || typeof source !== "object" || Array.isArray(source))
|
|
1156
1288
|
return source;
|
|
1157
1289
|
const normalized = { ...source };
|
|
1290
|
+
const allowedFields = gasListField === "factorGasList"
|
|
1291
|
+
? enterpriseEmissionSourceSaveFields
|
|
1292
|
+
: enterpriseEmissionSourceUpdateFields;
|
|
1293
|
+
for (const key of Object.keys(normalized)) {
|
|
1294
|
+
if (!allowedFields.has(key))
|
|
1295
|
+
delete normalized[key];
|
|
1296
|
+
}
|
|
1158
1297
|
if (normalized.factorId === undefined || normalized.factorId === null)
|
|
1159
1298
|
return normalized;
|
|
1160
1299
|
delete normalized[gasListField];
|
|
@@ -1207,7 +1346,7 @@ function validateEnterpriseEmissionSaveArgs(orgList) {
|
|
|
1207
1346
|
const path = `${sourcePath}.clientSourceKey`;
|
|
1208
1347
|
const firstPath = seen.get(key);
|
|
1209
1348
|
if (firstPath) {
|
|
1210
|
-
throw new
|
|
1349
|
+
throw new ToolInputValidationError("DUPLICATE_CLIENT_SOURCE_KEY", path, `Duplicate clientSourceKey \"${key}\"; first used at ${firstPath}`);
|
|
1211
1350
|
}
|
|
1212
1351
|
seen.set(key, path);
|
|
1213
1352
|
}
|
|
@@ -1230,44 +1369,42 @@ function validateEnterpriseEmissionUpdateArgs(computationList) {
|
|
|
1230
1369
|
}
|
|
1231
1370
|
}
|
|
1232
1371
|
function validateEnterpriseFactorAction(source, path, gasListField, allowAutoMatch) {
|
|
1372
|
+
if (!allowAutoMatch
|
|
1373
|
+
&& Object.prototype.hasOwnProperty.call(source, "sourceId")) {
|
|
1374
|
+
throw new ToolInputValidationError("SERVER_GENERATED_FIELD_NOT_ALLOWED", `${path}.sourceId`, "sourceId must not be sent when creating an enterprise emission source; the backend creates and returns it");
|
|
1375
|
+
}
|
|
1233
1376
|
if (Object.prototype.hasOwnProperty.call(source, "emissionQuantity")) {
|
|
1234
|
-
throw new
|
|
1377
|
+
throw new ToolInputValidationError("SERVER_DERIVED_FIELD_NOT_ALLOWED", `${path}.emissionQuantity`, "emissionQuantity must not be sent; the backend calculates it when inputs are sufficient and otherwise stores null");
|
|
1235
1378
|
}
|
|
1379
|
+
validateEnterpriseFactorContract(source, path, gasListField, allowAutoMatch);
|
|
1236
1380
|
const factorIdProvided = source.factorId !== undefined && source.factorId !== null;
|
|
1237
|
-
const fdTypeProvided = source.fdType !== undefined && source.fdType !== null;
|
|
1238
1381
|
const fdType = normalizeNumericCode(source.fdType);
|
|
1239
1382
|
const gasList = source[gasListField];
|
|
1240
1383
|
const gasListProvided = Array.isArray(gasList) && gasList.length > 0;
|
|
1241
1384
|
const hasGas = gasListProvided;
|
|
1242
|
-
const autoMatch = allowAutoMatch && source.autoMatchFactor === true;
|
|
1243
|
-
const factorMetadataFields = ["factorName", "factorType", "factorSource", "factorPublic"]
|
|
1244
|
-
.filter((key) => Object.prototype.hasOwnProperty.call(source, key)
|
|
1245
|
-
&& source[key] !== undefined
|
|
1246
|
-
&& source[key] !== null);
|
|
1247
|
-
if (autoMatch && (factorIdProvided || fdTypeProvided || gasListProvided)) {
|
|
1248
|
-
throw new Error(`${path}.autoMatchFactor cannot be combined with factorId, fdType, or ${gasListField}`);
|
|
1249
|
-
}
|
|
1250
|
-
if (factorIdProvided && fdType === 2) {
|
|
1251
|
-
throw new Error(`${path}.factorId cannot be combined with fdType=2; omit fdType or use fdType=1 for a library factor`);
|
|
1252
|
-
}
|
|
1253
|
-
if (fdType === 1 && !factorIdProvided) {
|
|
1254
|
-
throw new Error(`${path}.factorId is required when fdType=1`);
|
|
1255
|
-
}
|
|
1256
1385
|
if ((fdType === 2 || gasListProvided) && !hasGas) {
|
|
1257
|
-
throw new
|
|
1386
|
+
throw new ToolInputValidationError("CUSTOM_FACTOR_GAS_REQUIRED", `${path}.${gasListField}`, `${gasListField} must contain at least one gas item for a custom factor`);
|
|
1258
1387
|
}
|
|
1259
1388
|
const usesCustomFactor = !factorIdProvided && (fdType === 2 || gasListProvided);
|
|
1260
1389
|
if (usesCustomFactor) {
|
|
1261
1390
|
const result = z.array(enterpriseCustomFactorGasSchema).min(1).safeParse(gasList);
|
|
1262
1391
|
if (!result.success) {
|
|
1263
|
-
|
|
1392
|
+
const firstIssue = result.error.issues[0];
|
|
1393
|
+
throw new ToolInputValidationError("CUSTOM_FACTOR_INVALID", appendIssuePath(`${path}.${gasListField}`, firstIssue?.path || []), `${gasListField} contains invalid custom factor details; factorValue must be a non-negative number and factor units are required`);
|
|
1264
1394
|
}
|
|
1265
1395
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1396
|
+
}
|
|
1397
|
+
function appendIssuePath(basePath, issuePath) {
|
|
1398
|
+
let result = basePath;
|
|
1399
|
+
for (const segment of issuePath) {
|
|
1400
|
+
if (typeof segment === "number") {
|
|
1401
|
+
result += `[${segment}]`;
|
|
1402
|
+
}
|
|
1403
|
+
else {
|
|
1404
|
+
result += `.${String(segment)}`;
|
|
1405
|
+
}
|
|
1270
1406
|
}
|
|
1407
|
+
return result;
|
|
1271
1408
|
}
|
|
1272
1409
|
export function resolveRoutePath(route, args) {
|
|
1273
1410
|
return typeof route.path === "function" ? route.path(args) : route.path;
|