@codai/axiom-mcp 2.0.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/axm-lazy.js CHANGED
@@ -5809,13 +5809,30 @@ const ERROR_CODES = [
5809
5809
  "ERR_PROVIDER_FAILED",
5810
5810
  "ERR_GUARD_TIMEOUT",
5811
5811
  "ERR_GUARD_OUTPUT",
5812
+ "ERR_FACT_DISABLED",
5813
+ "ERR_SIGNATURE_MISSING",
5814
+ "ERR_SIGNATURE_INVALID",
5815
+ "ERR_TRUST_STATE_CORRUPT",
5816
+ "ERR_ROLLBACK",
5817
+ "ERR_EMITTER_UNKNOWN",
5818
+ "ERR_TEMPLATE_UNKNOWN",
5819
+ "ERR_TEMPLATE_PARAMS",
5820
+ "ERR_PATCH_FORMAT",
5821
+ "ERR_PATCH_PREIMAGE",
5822
+ "ERR_PATCH_NO_MATCH",
5812
5823
  "ERR_GIT_NOT_FOUND",
5813
5824
  "ERR_GIT_NOT_REPO",
5814
5825
  "ERR_GIT_DIRTY",
5815
5826
  "ERR_GIT_BRANCH_EXISTS",
5816
5827
  "ERR_GIT_BRANCH_INVALID",
5817
5828
  "ERR_GIT_FAILED",
5829
+ "ERR_TASK_NOT_FOUND",
5830
+ "ERR_TASK_CANCELLED",
5831
+ "ERR_PLAN_SESSION_STATE",
5818
5832
  "ERR_REF_OFFLINE",
5833
+ "ERR_NET_DISABLED",
5834
+ "ERR_NET_DENIED",
5835
+ "ERR_NET_FAILED",
5819
5836
  "ERR_NOT_CANONICAL",
5820
5837
  "ERR_UNSUPPORTED_OP",
5821
5838
  "ERR_INTERNAL"
@@ -5910,7 +5927,18 @@ object({
5910
5927
  /** sha256(JCS(all facts)) → replayable. */
5911
5928
  factsDigest: DigestRefSchema,
5912
5929
  durationMs: int().nonnegative(),
5913
- providers: array(ProviderStatusSchema)
5930
+ providers: array(ProviderStatusSchema),
5931
+ /**
5932
+ * S-402: how the manifest's `preImage` related to the tree at check time.
5933
+ * `verified` = every entry matched; `drifted` = at least one differed (an `error`
5934
+ * finding `ERR_PREIMAGE_CHANGED` is also emitted); `unverified` = no root, or the
5935
+ * manifest carries no `preImage`.
5936
+ */
5937
+ preImage: _enum([
5938
+ "verified",
5939
+ "drifted",
5940
+ "unverified"
5941
+ ]).optional()
5914
5942
  }).strict();
5915
5943
  const ApiVersionSchema = literal("axiom.dev/v2");
5916
5944
  /** Per-blob inline limit: 256 KiB of string content (≈192 KiB decoded when base64). */
@@ -5950,7 +5978,18 @@ const PlanArtifactSourceSchema = discriminatedUnion("type", [
5950
5978
  emitter: string().min(1),
5951
5979
  template: string().min(1),
5952
5980
  params: record(string(), json()).default({})
5953
- }).strict().describe("v2.1")
5981
+ }).strict().describe("template source rendered by a registered emitter at compile time"),
5982
+ object({
5983
+ type: literal("patch"),
5984
+ format: _enum([
5985
+ "unified",
5986
+ "v4a",
5987
+ "search-replace"
5988
+ ]),
5989
+ /** sha256 of the file the patch was authored against, or `absent` for a new file. */
5990
+ preImage: union([DigestRefSchema, literal("absent")]),
5991
+ body: string().max(INLINE_CONTENT_MAX)
5992
+ }).strict().describe("patch applied at compile time to the pre-image named by its digest")
5954
5993
  ]);
5955
5994
  const PlanArtifactSchema = object({
5956
5995
  path: RelPathSchema,
@@ -5981,6 +6020,8 @@ const PlanSchema = object({
5981
6020
  capabilities: array(CapabilitySchema).default([]),
5982
6021
  artifacts: array(PlanArtifactSchema).min(1).max(2e3),
5983
6022
  checks: array(CheckRefSchema).default([]),
6023
+ /** Anti-rollback counter (D-16); copied verbatim into `ManifestBody.counter`. */
6024
+ counter: int().nonnegative().optional(),
5984
6025
  metadata: record(string(), json()).default({})
5985
6026
  }).strict();
5986
6027
  const ErrorCodeSchema = _enum(ERROR_CODES);
@@ -6028,6 +6069,11 @@ object({
6028
6069
  /** Path of `.axiom/journal/<digest>.json`. */
6029
6070
  journal: string().optional(),
6030
6071
  git: GitResultSchema.optional(),
6072
+ /**
6073
+ * Re-apply of an already-applied digest whose files no longer matched on disk:
6074
+ * the artifacts listed here were re-written over foreign changes (design §apply).
6075
+ */
6076
+ drifted: array(RelPathSchema).optional(),
6031
6077
  error: ApplyErrorSchema.optional()
6032
6078
  }).strict().superRefine((r, ctx) => {
6033
6079
  if (r.status === "failed" && r.error === void 0) ctx.addIssue({
@@ -6094,7 +6140,8 @@ const ManifestArtifactSchema = object({
6094
6140
  "inline",
6095
6141
  "template",
6096
6142
  "cas",
6097
- "ref"
6143
+ "ref",
6144
+ "patch"
6098
6145
  ]).optional()
6099
6146
  }).strict().superRefine((a, ctx) => {
6100
6147
  if (a.op !== "delete" && a.digest === void 0) ctx.addIssue({
@@ -6108,6 +6155,15 @@ const ToolchainSchema = object({
6108
6155
  axiom: string().min(1),
6109
6156
  emitters: record(string(), string())
6110
6157
  }).strict();
6158
+ /**
6159
+ * What compile saw on disk for one artifact path (S-402): the sha256 of the existing file
6160
+ * or `absent`. Binds a manifest — and every CheckReport/attestation over it — to the tree
6161
+ * it was produced against; `apply` refuses a different tree with `ERR_PREIMAGE_CHANGED`.
6162
+ */
6163
+ const PreImageEntrySchema = object({
6164
+ path: RelPathSchema,
6165
+ sha256: union([Sha256HexSchema, literal("absent")])
6166
+ }).strict();
6111
6167
  /** The exact object that is JCS-canonicalised and sha256-hashed into `manifestDigest`. */
6112
6168
  const ManifestBodySchema = object({
6113
6169
  apiVersion: ApiVersionSchema,
@@ -6120,8 +6176,25 @@ const ManifestBodySchema = object({
6120
6176
  artifacts: array(ManifestArtifactSchema).min(1).max(2e3),
6121
6177
  /** Sorted by id, unique (§2.4 determinism). */
6122
6178
  checks: array(CheckRefSchema),
6123
- toolchain: ToolchainSchema
6179
+ toolchain: ToolchainSchema,
6180
+ /**
6181
+ * Anti-rollback counter (D-16): monotonic per root, part of the canonical body so a
6182
+ * signature binds it. Verified by `manifest.requireSigned { antiRollback: true }`.
6183
+ */
6184
+ counter: int().nonnegative().optional(),
6185
+ /**
6186
+ * Pre-image of every artifact path at compile time (S-402), sorted by path, unique;
6187
+ * present when compile had a root (or a pre-image reader). Part of the canonical body:
6188
+ * the same Plan compiled against a different tree is a different manifest.
6189
+ */
6190
+ preImage: array(PreImageEntrySchema).optional()
6124
6191
  }).strict().superRefine((m, ctx) => {
6192
+ if (m.preImage !== void 0 && !isSortedUnique(m.preImage.map((p) => p.path))) ctx.addIssue({
6193
+ code: "custom",
6194
+ path: ["preImage"],
6195
+ message: "preImage must be sorted by path (UTF-8 byte order) and unique",
6196
+ params: { code: "ERR_NOT_CANONICAL" }
6197
+ });
6125
6198
  if (!isSortedUnique(m.artifacts.map((a) => a.path))) ctx.addIssue({
6126
6199
  code: "custom",
6127
6200
  path: ["artifacts"],
@@ -6155,7 +6228,7 @@ const InTotoStatementLooseSchema = object({
6155
6228
  predicateType: url(),
6156
6229
  predicate: record(string(), unknown())
6157
6230
  }).strict();
6158
- /** DSSE envelope (secure-systems-lab/dsse v1.0.2). */
6231
+ /** DSSE envelope (secure-systems-lab/dsse v1.0.2) around an in-toto attestation. */
6159
6232
  const DsseEnvelopeSchema = object({
6160
6233
  payloadType: literal("application/vnd.in-toto+json"),
6161
6234
  payload: base64(),
@@ -6164,11 +6237,71 @@ const DsseEnvelopeSchema = object({
6164
6237
  sig: base64()
6165
6238
  }).strict())
6166
6239
  }).strict();
6240
+ /** DSSE payloadType of a signed `ManifestBody` (D-16). */
6241
+ const AXIOM_MANIFEST_PAYLOAD_TYPE = "application/vnd.axiom.manifest+json";
6242
+ /**
6243
+ * DSSE payloadType of a **root-bound** signature (S-409): the payload is
6244
+ * `JCS({ manifest, rootId })`, so the same key's signature over the same manifest is not
6245
+ * valid for a root whose trust store declares a different `rootId`.
6246
+ */
6247
+ const AXIOM_MANIFEST_BOUND_PAYLOAD_TYPE = "application/vnd.axiom.manifest-bound+json";
6248
+ /** Operator-chosen root identity, e.g. `github:dragoscv/brivio` or a UUID. */
6249
+ const RootIdSchema = string().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/@-]*$/, "rootId: letters, digits, . _ : / @ - only");
6250
+ /**
6251
+ * DSSE envelope whose payload is `base64(JCS(manifest))`, signed with Ed25519 (D-16).
6252
+ * Lives outside the canonical body: `manifestDigest` is unchanged whether signed or not.
6253
+ * With `payloadType` = `AXIOM_MANIFEST_BOUND_PAYLOAD_TYPE` the payload is
6254
+ * `base64(JCS({ manifest, rootId }))` (S-409).
6255
+ */
6256
+ const ManifestSignatureSchema = object({
6257
+ payloadType: union([literal(AXIOM_MANIFEST_PAYLOAD_TYPE), literal(AXIOM_MANIFEST_BOUND_PAYLOAD_TYPE)]),
6258
+ payload: base64(),
6259
+ signatures: array(object({
6260
+ keyid: string().optional(),
6261
+ sig: base64()
6262
+ }).strict()).min(1)
6263
+ }).strict();
6264
+ /** `.axiom/trust/keys.json` — the per-root allowlist of signing keys (D-16). */
6265
+ const TrustedKeySchema = object({
6266
+ /** sha256(raw 32-byte public key), lowercase hex. */
6267
+ keyid: string().regex(/^[0-9a-f]{64}$/),
6268
+ alg: literal("ed25519"),
6269
+ /** base64 of the raw 32-byte Ed25519 public key. */
6270
+ publicKey: base64(),
6271
+ name: string().min(1).max(200).optional(),
6272
+ /** Lowest manifest `counter` this key may sign for. */
6273
+ notBefore: int().nonnegative().optional()
6274
+ }).strict();
6275
+ object({
6276
+ version: literal(1),
6277
+ keys: array(TrustedKeySchema),
6278
+ /** Floor for `counter` when no state has been recorded yet. */
6279
+ minCounter: int().nonnegative().optional(),
6280
+ /**
6281
+ * When set, only root-bound signatures carrying this exact id count (S-409): an
6282
+ * unbound or differently-bound envelope is `signature.unbound`. Absent → both accepted.
6283
+ */
6284
+ rootId: RootIdSchema.optional()
6285
+ }).strict();
6286
+ object({
6287
+ version: literal(1),
6288
+ lastCounter: int().nonnegative(),
6289
+ /** Digest of the manifest that advanced `lastCounter` (informational). */
6290
+ manifestDigest: DigestRefSchema.optional(),
6291
+ /**
6292
+ * HMAC-SHA256 (hex) over `JCS(state without mac)` keyed by `.axiom/trust/state.key`
6293
+ * (S-409). Written by every `advanceTrustState`; a state with a key on disk but a
6294
+ * missing/wrong mac is `ERR_TRUST_STATE_CORRUPT`.
6295
+ */
6296
+ mac: string().regex(/^[0-9a-f]{64}$/).optional()
6297
+ }).strict();
6167
6298
  object({
6168
6299
  manifest: ManifestBodySchema,
6169
6300
  manifestDigest: DigestRefSchema,
6170
6301
  attestation: InTotoStatementLooseSchema.optional(),
6171
6302
  envelope: DsseEnvelopeSchema.optional(),
6303
+ /** Detached DSSE signatures over `manifest` (D-16). Not part of `manifestDigest`. */
6304
+ signatures: array(ManifestSignatureSchema).optional(),
6172
6305
  /** Inline side-channel keyed by `sha256:<hex>`. */
6173
6306
  blobs: record(DigestRefSchema, BlobSchema).default({})
6174
6307
  }).strict().superRefine((b, ctx) => {
@@ -6204,6 +6337,32 @@ object({
6204
6337
  limits: ProfileLimitsSchema.default({}),
6205
6338
  facts: ProfileFactsSchema.prefault({})
6206
6339
  }).strict();
6340
+ const RepoSnapshotEntryKindSchema = _enum(["file", "symlink"]);
6341
+ /** The hashed part: `snapshotDigest = sha256(JCS(body))`. No timestamps, no absolute paths. */
6342
+ const RepoSnapshotBodySchema = object({
6343
+ /** Sorted by `compareUtf8(path)`. */
6344
+ files: array(object({
6345
+ path: RelPathSchema,
6346
+ bytes: int().nonnegative(),
6347
+ sha256: Sha256HexSchema.optional(),
6348
+ mode: ArtifactModeSchema,
6349
+ kind: RepoSnapshotEntryKindSchema
6350
+ }).strict()),
6351
+ /** True when `maxFiles` or `maxBytes` stopped the walk; `files` is then a prefix of the full order. */
6352
+ truncated: boolean(),
6353
+ counts: object({
6354
+ files: int().nonnegative(),
6355
+ bytes: int().nonnegative()
6356
+ }).strict()
6357
+ }).strict();
6358
+ object({
6359
+ apiVersion: ApiVersionSchema,
6360
+ kind: literal("RepoSnapshot"),
6361
+ /** Paths are relative to the walked root; the root itself is deliberately not recorded. */
6362
+ root: object({ kind: literal("relative") }).strict(),
6363
+ snapshotDigest: DigestRefSchema,
6364
+ body: RepoSnapshotBodySchema
6365
+ }).strict();
6207
6366
  //#endregion
6208
6367
  //#region ../../node_modules/.pnpm/@chevrotain+utils@13.2.0/node_modules/@chevrotain/utils/lib/src/print.js
6209
6368
  function PRINT_ERROR(msg) {
@@ -12067,6 +12226,7 @@ const ModeKw = keyword("ModeKw", "mode");
12067
12226
  const OpKw = keyword("OpKw", "op");
12068
12227
  const Inline = keyword("Inline", "inline");
12069
12228
  const Template = keyword("Template", "template");
12229
+ const Patch = keyword("Patch", "patch");
12070
12230
  const Cas = keyword("Cas", "cas");
12071
12231
  const Ref = keyword("Ref", "ref");
12072
12232
  const Check = keyword("Check", "check");
@@ -12243,6 +12403,7 @@ const allTokens = [
12243
12403
  OpKw,
12244
12404
  Inline,
12245
12405
  Template,
12406
+ Patch,
12246
12407
  Cas,
12247
12408
  Ref,
12248
12409
  Check,
@@ -12515,6 +12676,26 @@ var Compiler = class {
12515
12676
  params: params ?? {}
12516
12677
  };
12517
12678
  }
12679
+ const patch = first(nodes(ctx, "patchSource"));
12680
+ if (patch !== void 0) {
12681
+ const pc = patch.children;
12682
+ const f = first(tokens(pc, "format"));
12683
+ const d = first(tokens(pc, "preImage"));
12684
+ const ab = first(tokens(pc, "absent"));
12685
+ const h = first(tokens(pc, "body"));
12686
+ this.at(`${path}.format`, tokenRange(f));
12687
+ this.at(`${path}.preImage`, tokenRange(d ?? ab ?? f));
12688
+ this.at(`${path}.body`, tokenRange(h));
12689
+ if (ab !== void 0 && ab.image !== "absent") this.error("patch pre-image must be a \"sha256:…\" digest or the word absent", tokenRange(ab));
12690
+ const payload = h?.payload;
12691
+ const body = payload === void 0 ? "" : `${payload.content}\n`;
12692
+ return {
12693
+ type: "patch",
12694
+ format: f?.image ?? "",
12695
+ preImage: d !== void 0 ? decodeString(d.image) : "absent",
12696
+ body
12697
+ };
12698
+ }
12518
12699
  }
12519
12700
  check(n, path) {
12520
12701
  const ctx = n.children;
@@ -12588,7 +12769,8 @@ function compileCst(file) {
12588
12769
  * PlanItem = "intent" String | "profile" Ident | "capabilities" "[" [Cap {"," Cap}] "]"
12589
12770
  * | "artifact" String ArtifactBody | "check" Ident "using" QualIdent [Json] | "meta" Json ;
12590
12771
  * ArtifactBody= "{", { "mode" Mode | "op" Op | Source }, "}" ;
12591
- * Source = "inline" HereDoc | "template" QualIdent String [Json] | "cas" Digest | "ref" String Digest ;
12772
+ * Source = "inline" HereDoc | "template" QualIdent String [Json] | "cas" Digest | "ref" String Digest
12773
+ * | "patch" Format ( Digest | "absent" ) HereDoc ; Format = unified | v4a | search-replace
12592
12774
  * QualIdent = Ident, { ".", Ident } ;
12593
12775
  */
12594
12776
  var AxmParser = class extends CstParser {
@@ -12670,9 +12852,16 @@ var AxmParser = class extends CstParser {
12670
12852
  { ALT: () => this.SUBRULE(this.inlineSource) },
12671
12853
  { ALT: () => this.SUBRULE(this.templateSource) },
12672
12854
  { ALT: () => this.SUBRULE(this.casSource) },
12673
- { ALT: () => this.SUBRULE(this.refSource) }
12855
+ { ALT: () => this.SUBRULE(this.refSource) },
12856
+ { ALT: () => this.SUBRULE(this.patchSource) }
12674
12857
  ]);
12675
12858
  });
12859
+ patchSource = this.RULE("patchSource", () => {
12860
+ this.CONSUME(Patch);
12861
+ this.CONSUME(IdentLike, { LABEL: "format" });
12862
+ this.OR([{ ALT: () => this.CONSUME(Digest, { LABEL: "preImage" }) }, { ALT: () => this.CONSUME2(IdentLike, { LABEL: "absent" }) }]);
12863
+ this.CONSUME(HereDoc, { LABEL: "body" });
12864
+ });
12676
12865
  inlineSource = this.RULE("inlineSource", () => {
12677
12866
  this.CONSUME(Inline);
12678
12867
  this.CONSUME(HereDoc, { LABEL: "content" });