@absolutejs/mcp 0.24.0 → 0.25.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/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.25.0 — 2026-09-13
10
+
11
+ ### Added
12
+
13
+ - **Add estimate-based background work admission while preserving exact-ID recovery and hard charge caps.** (`McpBackgroundWorkEstimate`, `createBackgroundWorkTools`)
14
+
9
15
  ## 0.24.0 — 2026-09-13
10
16
 
11
17
  ### Added
package/changelog.json CHANGED
@@ -2,6 +2,20 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/mcp",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "added",
9
+ "summary": "Add estimate-based background work admission while preserving exact-ID recovery and hard charge caps.",
10
+ "symbols": [
11
+ "McpBackgroundWorkEstimate",
12
+ "createBackgroundWorkTools"
13
+ ]
14
+ }
15
+ ],
16
+ "date": "2026-09-13",
17
+ "version": "0.25.0"
18
+ },
5
19
  {
6
20
  "changes": [
7
21
  {
package/dist/index.js CHANGED
@@ -2917,11 +2917,32 @@ var createBackgroundWorkTools = (options) => {
2917
2917
  }
2918
2918
  }
2919
2919
  };
2920
+ const estimate = options.estimate;
2921
+ if (estimate)
2922
+ tools.estimate_background_work = {
2923
+ description: "Estimate service credits for a background plan without reserving credits or starting work. The minimum admits one step; the total estimates the whole plan. Actual usage varies. Get the user's approval for the maximum before starting; never silently increase it.",
2924
+ annotations: { readOnlyHint: true },
2925
+ commerce: { action: "paid_access", categories: ["usage_credits"] },
2926
+ inputSchema: options.inputSchema,
2927
+ handler: async (input) => {
2928
+ const value = await estimate(input);
2929
+ if (![value.minimumCredits, value.estimatedCredits, value.totalSteps].every(Number.isSafeInteger) || value.minimumCredits < 1 || value.estimatedCredits < value.minimumCredits || value.totalSteps < 1 || typeof value.assumptions !== "string" || !value.assumptions)
2930
+ throw new Error("Invalid background work estimate");
2931
+ const summary = {
2932
+ minimumCredits: value.minimumCredits,
2933
+ estimatedCredits: value.estimatedCredits,
2934
+ totalSteps: value.totalSteps,
2935
+ assumptions: value.assumptions,
2936
+ message: "Estimate only, not a quote or guarantee. No credits reserved and no work started. Admission is checked again at start and before each step; work can stop with partial results. The approved maximum charge is never increased."
2937
+ };
2938
+ return { content: [{ type: "text", text: JSON.stringify(summary) }], structuredContent: summary };
2939
+ }
2940
+ };
2920
2941
  const start = options.start;
2921
2942
  if (start)
2922
2943
  tools.start_background_work = budgetedMcpTool({
2923
2944
  tool: {
2924
- description: `${options.description} Launch bounded background work only after the user agrees to the plan and maximum credits. Return the requestId promptly; poll get_background_work for progress.`,
2945
+ description: `${options.description} Use estimate_background_work when available before asking for a budget. Launch bounded background work only after the user agrees to the plan and maximum credits. Return the requestId promptly; poll get_background_work for progress.`,
2925
2946
  inputSchema: options.inputSchema,
2926
2947
  handler: async () => {
2927
2948
  throw new Error("Background work must use durable dispatch");
@@ -1,5 +1,11 @@
1
1
  import { type McpCreditWorkRequest } from "./budgetedTool";
2
2
  import type { McpTool, McpToolRegistry, McpToolResult } from "./types";
3
+ export type McpBackgroundWorkEstimate = {
4
+ minimumCredits: number;
5
+ estimatedCredits: number;
6
+ totalSteps: number;
7
+ assumptions: string;
8
+ };
3
9
  /** Public output only. Adapters must scope reads to the authenticated account. */
4
10
  export type McpBackgroundWorkSnapshot = {
5
11
  status: "queued" | "running" | "completed" | "stopped" | "failed" | "unknown";
@@ -16,6 +22,7 @@ export declare const createBackgroundWorkResult: (requestId: string, work: McpBa
16
22
  export declare const createBackgroundWorkTools: (options: {
17
23
  description: string;
18
24
  inputSchema: McpTool["inputSchema"];
25
+ estimate?: (input: unknown) => Promise<McpBackgroundWorkEstimate>;
19
26
  start?: (request: McpCreditWorkRequest) => Promise<McpBackgroundWorkSnapshot>;
20
27
  read: (requestId: string) => Promise<McpBackgroundWorkSnapshot | null>;
21
28
  }) => McpToolRegistry;
@@ -55,3 +55,4 @@ export { createSetupSelectionTools, projectSetupSelection, type SetupSelection,
55
55
  export { createActionWorkflowTools, projectActionReview, projectActionJob, type ActionReview, type ActionConfirmation, type ActionJob, } from "./actionWorkflow";
56
56
  export { createCreditWorkResult, type McpCreditWorkSnapshot, } from "./creditWorkResult";
57
57
  export { createBackgroundWorkTools, createBackgroundWorkResult, type McpBackgroundWorkSnapshot } from "./backgroundWork";
58
+ export type { McpBackgroundWorkEstimate } from "./backgroundWork";
@@ -368,3 +368,18 @@ bounded work until their reservation and recovery lifecycle is implemented.
368
368
  This documentation update changes no runtime API, profile, feature flag or
369
369
  published package version. It is available in the shared repository and will
370
370
  ship with the next package release through the existing documentation allowlist.
371
+
372
+ ### Background research estimates
373
+
374
+ `createBackgroundWorkTools({ estimate, start, read, ... })` optionally exposes
375
+ `estimate_background_work`. Its adapter returns minimum credits for one step,
376
+ estimated total credits, total steps and explicit assumptions. Public output is
377
+ identical in text and structured hosts, and omits adapter-private fields. No
378
+ provider work or reservation belongs in the estimate adapter.
379
+
380
+ Estimates use `paid_access` commerce policy, so a restricted host cannot use this
381
+ as a pricing/purchase workaround. Obtain user agreement to the exact plan and
382
+ maximum before start. Server-side start must reevaluate admission atomically;
383
+ never silently raise a maximum. Saved-work reads remain separate and credit-free.
384
+ An estimate is advisory, not an expiring quote or guaranteed cost. Bind input,
385
+ account and maximum durably; exact-ID recovery must not depend on current pricing.
package/package.json CHANGED
@@ -90,5 +90,5 @@
90
90
  "canary:checkout": "bun canary/checkout.ts"
91
91
  },
92
92
  "types": "./dist/src/index.d.ts",
93
- "version": "0.24.0"
93
+ "version": "0.25.0"
94
94
  }