@codai/axiom-mcp 2.1.0 → 2.2.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/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { ErrorCode } from "@codai/axiom-schema";
1
+ import { ErrorCode, PlanArtifact, PlanInput } from "@codai/axiom-schema";
2
2
  import { z } from "zod";
3
3
  import { GuardOptions } from "@codai/axiom-checks";
4
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
- import "@modelcontextprotocol/sdk/types.js";
4
+ import { McpRequestContext, McpServer } from "@modelcontextprotocol/server";
5
+ import "@modelcontextprotocol/server/stdio";
6
6
  //#region src/jsonschema.d.ts
7
7
  export declare const SCHEMA_KINDS: readonly ["Plan", "Manifest", "ManifestBundle", "CheckReport", "ApplyResult", "Profile", "Journal", "RepoSnapshot"];
8
8
  type SchemaKind = (typeof SCHEMA_KINDS)[number];
@@ -55,6 +55,127 @@ export declare function createRootsPolicy(rootArgs: readonly string[]): Promise<
55
55
  */
56
56
  export declare function resolveRoot(policy: RootsPolicy, requested?: string): Promise<ResolvedRoot>;
57
57
  //#endregion
58
+ //#region src/adapter.d.ts
59
+ /** Wire era a connection/request is served on (`legacy` = 2024-10-07 … 2025-11-25). */
60
+ type WireEra = McpRequestContext["era"];
61
+ //#endregion
62
+ //#region src/tasks.d.ts
63
+ export declare const TASK_STATUSES: readonly ["working", "completed", "failed", "cancelled"];
64
+ type TaskStatus = (typeof TASK_STATUSES)[number];
65
+ /** How long a finished task stays pollable. */
66
+ export declare const TASK_TTL_MS: number;
67
+ /** Advisory poll interval returned to clients. */
68
+ export declare const TASK_POLL_INTERVAL_MS = 2000;
69
+ /** Concurrent `working` tasks per server process; the (n+1)th `axiom_check_start` is refused. */
70
+ export declare const TASK_MAX_WORKING = 8;
71
+ /** Idle sessions (no `add`/`seal`) are dropped after this. */
72
+ export declare const PLAN_SESSION_TTL_MS: number;
73
+ /** Artifacts a session may hold — same bound as `PlanSchema.artifacts.max`. */
74
+ export declare const PLAN_SESSION_MAX_ARTIFACTS = 2000;
75
+ /** Summed UTF-8 JSON bytes of every chunk a session accepts (64 MiB, the `default` profile's `maxTotalBytes`). */
76
+ export declare const PLAN_SESSION_MAX_BYTES: number;
77
+ declare const TaskErrorSchema: z.ZodObject<{
78
+ code: z.ZodString;
79
+ message: z.ZodString;
80
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
81
+ }, z.core.$strip>;
82
+ interface TaskRecord<T = unknown> {
83
+ taskId: string;
84
+ /** Tool that created the task (`axiom_check`). */
85
+ tool: string;
86
+ status: TaskStatus;
87
+ createdAt: number;
88
+ /** Set when the task reaches a terminal status. */
89
+ finishedAt?: number;
90
+ result?: T;
91
+ error?: z.output<typeof TaskErrorSchema>;
92
+ controller: AbortController;
93
+ /** Root the task was bound to (for logging / listing). */
94
+ root?: string;
95
+ }
96
+ interface TaskDescriptor {
97
+ taskId: string;
98
+ tool: string;
99
+ status: TaskStatus;
100
+ pollIntervalMs: number;
101
+ ttlMs: number;
102
+ /** Milliseconds since the task was created. */
103
+ elapsedMs: number;
104
+ }
105
+ interface TaskStoreOptions {
106
+ now?: () => number;
107
+ ttlMs?: number;
108
+ pollIntervalMs?: number;
109
+ maxWorking?: number;
110
+ }
111
+ export declare class TaskStore {
112
+ private readonly tasks;
113
+ private readonly now;
114
+ readonly ttlMs: number;
115
+ readonly pollIntervalMs: number;
116
+ readonly maxWorking: number;
117
+ constructor(opts?: TaskStoreOptions);
118
+ /**
119
+ * Start `work` in the background. The returned record is `working` until the promise settles;
120
+ * a rejection becomes `failed` (AxiomError → its closed code, anything else → `ERR_INTERNAL`),
121
+ * a rejection after `cancel()` stays `cancelled`.
122
+ */
123
+ start<T>(tool: string, work: (signal: AbortSignal) => Promise<T>, meta?: {
124
+ root?: string;
125
+ }): TaskRecord<T>;
126
+ get(taskId: string): TaskRecord;
127
+ /** Abort a `working` task; terminal tasks are left as they are (idempotent). */
128
+ cancel(taskId: string): TaskRecord;
129
+ describe(rec: TaskRecord): TaskDescriptor;
130
+ /** Drop terminal tasks older than `ttlMs`. */
131
+ sweep(): void;
132
+ /** Abort everything still running (server shutdown). */
133
+ abortAll(): void;
134
+ get size(): number;
135
+ }
136
+ /** Everything in a Plan except `artifacts` (and the fixed `apiVersion`/`kind`) — what `axiom_plan_begin` receives. */
137
+ type PlanHeader = Omit<PlanInput, "artifacts" | "apiVersion" | "kind">;
138
+ interface PlanSession {
139
+ sessionId: string;
140
+ header: PlanHeader;
141
+ artifacts: PlanArtifact[];
142
+ paths: Set<string>;
143
+ /** Summed UTF-8 JSON bytes of accepted chunks. */
144
+ bytes: number;
145
+ createdAt: number;
146
+ touchedAt: number;
147
+ sealed: boolean;
148
+ }
149
+ interface PlanSessionStoreOptions {
150
+ now?: () => number;
151
+ ttlMs?: number;
152
+ maxOpen?: number;
153
+ maxArtifacts?: number;
154
+ maxBytes?: number;
155
+ }
156
+ export declare class PlanSessionStore {
157
+ private readonly sessions;
158
+ private readonly now;
159
+ readonly ttlMs: number;
160
+ readonly maxOpen: number;
161
+ readonly maxArtifacts: number;
162
+ readonly maxBytes: number;
163
+ constructor(opts?: PlanSessionStoreOptions);
164
+ begin(header: PlanHeader): PlanSession;
165
+ get(sessionId: string): PlanSession;
166
+ /** Append already-validated artifacts; duplicates (within or across chunks) are `ERR_INVALID_PLAN`. */
167
+ add(sessionId: string, artifacts: readonly PlanArtifact[], chunkBytes: number): PlanSession;
168
+ /** Mark sealed and return the assembled Plan input; the session is dropped. */
169
+ seal(sessionId: string): {
170
+ session: PlanSession;
171
+ plan: PlanInput;
172
+ };
173
+ /** Drop an unsealed session without compiling. Unknown ids are a no-op. */
174
+ abandon(sessionId: string): boolean;
175
+ sweep(): void;
176
+ get size(): number;
177
+ }
178
+ //#endregion
58
179
  //#region src/tools.d.ts
59
180
  /** Hard cap on any single `bundle`/`plan` argument, measured as UTF-8 JSON bytes (§(f) payload size). */
60
181
  export declare const BUNDLE_BYTES_MAX: number;
@@ -74,6 +195,10 @@ interface ToolContext {
74
195
  seenRoots: Set<string>;
75
196
  /** `--allow-guards` / `--guard-allowlist` from startup (§3.2); absent = guards disabled. */
76
197
  guards?: GuardOptions;
198
+ /** Long-running checks (`axiom_check_start` / `axiom_task_*`), shared across a factory's instances (S-406). */
199
+ tasks: TaskStore;
200
+ /** Chunked plan sessions (`axiom_plan_begin` / `add` / `seal`), shared like `tasks`. */
201
+ planSessions: PlanSessionStore;
77
202
  }
78
203
  interface ToolDef<I extends z.ZodRawShape = z.ZodRawShape, O extends z.ZodType = z.ZodType> {
79
204
  name: string;
@@ -100,6 +225,17 @@ interface CreateServerOptions {
100
225
  tools?: readonly AnyToolDef[];
101
226
  /** `--allow-guards` / `--guard-allowlist` (§3.2). Omit to keep guards disabled. */
102
227
  guards?: ToolContext["guards"];
228
+ /** Wire era this instance will serve (set by the serving entry; `legacy` when hand-connected). */
229
+ era?: WireEra;
230
+ /**
231
+ * Roots discovered via tool calls (sub-roots of the allowlist). Shared across the instances a
232
+ * factory builds so a digest compiled on one 2026-era HTTP request is loadable on the next.
233
+ */
234
+ seenRoots?: Set<string>;
235
+ /** Background check tasks (S-406). Shared across a factory's instances; a fresh store per server otherwise. */
236
+ tasks?: TaskStore;
237
+ /** Chunked plan sessions (S-406). Shared like `tasks`. */
238
+ planSessions?: PlanSessionStore;
103
239
  }
104
240
  interface StructuredError {
105
241
  code: ErrorCode;
@@ -129,5 +265,5 @@ export declare function buildToolsSpec(): ToolSpecEntry[];
129
265
  /** Stable text form (2-space JSON + trailing newline) used both by the generator and the parity test. */
130
266
  export declare function renderToolsSpec(): string;
131
267
  //#endregion
132
- export type { AnyToolDef, CreateServerOptions, LogLevel, Logger, ResolvedRoot, RiskClass, RootsPolicy, SchemaKind, StructuredError, ToolAnnotations, ToolContext, ToolDef, ToolSpecEntry };
268
+ export type { AnyToolDef, CreateServerOptions, LogLevel, Logger, PlanSession, ResolvedRoot, RiskClass, RootsPolicy, SchemaKind, StructuredError, TaskDescriptor, TaskRecord, TaskStatus, ToolAnnotations, ToolContext, ToolDef, ToolSpecEntry };
133
269
  //# sourceMappingURL=index.d.ts.map