@nexart/ai-execution 0.10.0 → 0.12.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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreateSnapshotParams, A as AiExecutionSnapshotV1, V as VerificationResult, a as CerMeta, B as BundleDeclaration, b as CerAiExecutionBundle, c as CertifyDecisionParams, R as RunBuilderOptions, S as StepParams, d as RunSummary, e as AttestOptions, f as AttestationResult, g as SanitizeStorageOptions, h as AttestationReceipt, N as NodeKeysDocument, i as NodeReceiptVerifyResult, j as SignedAttestationReceipt, k as CerVerifyCode, l as AiefVerifyResult, T as ToolEvent, m as RunSummaryVerifyResult, n as AiefProfile } from './types-C5t12OK8.cjs';
2
- export { o as AiExecutionParameters, p as AttestationReceiptResult, q as ClientDefaults, r as NexArtClient, P as ProviderCallParams, s as ProviderCallResult, t as ProviderConfig, u as RedactionEnvelope, W as WrappedExecutionParams, v as WrappedExecutionResult } from './types-C5t12OK8.cjs';
1
+ import { C as CreateSnapshotParams, A as AiExecutionSnapshotV1, V as VerificationResult, a as CerMeta, B as BundleDeclaration, b as CerContextSignal, c as CerAiExecutionBundle, d as CertifyDecisionParams, R as RunBuilderOptions, S as StepParams, e as RunSummary, f as AttestOptions, g as AttestationResult, h as SanitizeStorageOptions, i as AttestationReceipt, N as NodeKeysDocument, j as NodeReceiptVerifyResult, k as SignedAttestationReceipt, l as CerVerifyCode, m as AiefVerifyResult, T as ToolEvent, n as RunSummaryVerifyResult, o as AiefProfile } from './types-C_M2xSWK.cjs';
2
+ export { p as AiExecutionParameters, q as AttestationReceiptResult, r as CerContext, s as ClientDefaults, t as NexArtClient, P as ProviderCallParams, u as ProviderCallResult, v as ProviderConfig, w as RedactionEnvelope, W as WrappedExecutionParams, x as WrappedExecutionResult } from './types-C_M2xSWK.cjs';
3
3
  export { wrapProvider } from './providers/wrap.cjs';
4
4
  export { AttestDecisionFn, LangChainAttestedResult, LangChainCerResult, LangChainCertificationInput, certifyLangChainRun, createLangChainCer } from './langchain.cjs';
5
5
 
@@ -29,6 +29,8 @@ declare function sealCer(snapshot: AiExecutionSnapshotV1, options?: {
29
29
  createdAt?: string;
30
30
  meta?: CerMeta;
31
31
  declaration?: BundleDeclaration;
32
+ /** v0.10.0 — upstream signals to bind as evidence. Included in certificateHash. */
33
+ signals?: CerContextSignal[];
32
34
  }): CerAiExecutionBundle;
33
35
  declare function verifyCer(bundle: CerAiExecutionBundle): VerificationResult;
34
36
 
@@ -566,4 +568,116 @@ interface CerVerificationResult {
566
568
  */
567
569
  declare function verifyAiCerBundleDetailed(bundle: unknown): CerVerificationResult;
568
570
 
569
- export { AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerMeta, CerVerificationError, type CerVerificationResult, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, type CheckStatus, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, ReasonCode, ReasonCode as ReasonCodeType, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, type VerificationStatus, type VerifyRunSummaryOptions, attest, attestIfNeeded, certifyAndAttestDecision, certifyAndAttestRun, certifyDecision, certifyDecisionFromProviderCall, computeInputHash, computeOutputHash, createClient, createSnapshot, exportCer, exportVerifiableRedacted, fetchNodeKeys, getAttestationReceipt, hasAttestation, hashCanonicalJson, hashToolOutput, hashUtf8, importCer, makeToolEvent, mapToAiefReason, redactBeforeSeal, sanitizeForAttestation, sanitizeForStamp, sanitizeForStorage, sealCer, selectNodeKey, sha256Hex, toCanonicalJson, validateProfile, verifyCer as verify, verifyAiCerBundleDetailed, verifyAief, verifyBundleAttestation, verifyCer, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
571
+ /**
572
+ * @nexart/ai-execution — CER package helpers (v0.12.0)
573
+ *
574
+ * A "CER package" is a transport/export envelope that wraps a sealed
575
+ * cer.ai.execution.v1 bundle with optional receipt, signature, and
576
+ * attestation metadata.
577
+ *
578
+ * These helpers sit around the existing core and do NOT change CER hashing,
579
+ * canonicalization, attestation, or verification semantics in any way.
580
+ *
581
+ * @example
582
+ * ```ts
583
+ * import { certifyDecision } from '@nexart/ai-execution';
584
+ * import { createCerPackage, exportCerPackage, importCerPackage } from '@nexart/ai-execution';
585
+ *
586
+ * const cer = certifyDecision({ ... });
587
+ * const pkg = createCerPackage({ cer });
588
+ * const json = exportCerPackage(pkg);
589
+ * const restored = importCerPackage(json); // verifies inner CER
590
+ * ```
591
+ */
592
+
593
+ /**
594
+ * A CER package — a transport/export envelope for a sealed CER bundle.
595
+ *
596
+ * The `cer` field is the only required field. All other fields are additive
597
+ * transport/export metadata and do not affect CER hashing or verification.
598
+ */
599
+ interface AiCerPackage {
600
+ /** The sealed cer.ai.execution.v1 bundle. Required. */
601
+ cer: CerAiExecutionBundle;
602
+ /** Optional attestation receipt from a NexArt attestation node. */
603
+ receipt?: AttestationReceipt;
604
+ /**
605
+ * Optional base64url-encoded signature covering the package.
606
+ * NexArt does not interpret or verify this field — it is opaque transport metadata.
607
+ */
608
+ signature?: string;
609
+ /**
610
+ * Optional attestation summary block.
611
+ * NexArt does not interpret or verify its contents.
612
+ */
613
+ attestation?: Record<string, unknown>;
614
+ /**
615
+ * Optional verification envelope metadata.
616
+ * NexArt does not interpret or verify its contents.
617
+ */
618
+ verificationEnvelope?: Record<string, unknown>;
619
+ /**
620
+ * Optional base64url-encoded signature covering verificationEnvelope.
621
+ * NexArt does not interpret or verify this field — it is opaque transport metadata.
622
+ */
623
+ verificationEnvelopeSignature?: string;
624
+ }
625
+ /** Input parameters for createCerPackage(). Structurally identical to AiCerPackage. */
626
+ type CreateCerPackageParams = AiCerPackage;
627
+ /**
628
+ * Type guard: returns true if `value` is shaped like a CER package.
629
+ *
630
+ * A value qualifies as a CER package if it is a plain object whose `cer`
631
+ * field is a plain object with `bundleType === 'cer.ai.execution.v1'`.
632
+ *
633
+ * Lightweight structural check only — does NOT verify the inner CER hash.
634
+ * Use `verifyCerPackage()` or `importCerPackage()` for integrity verification.
635
+ */
636
+ declare function isCerPackage(value: unknown): value is AiCerPackage;
637
+ /**
638
+ * Assemble a CER package from a sealed CER bundle and optional transport metadata.
639
+ *
640
+ * Simple assembly only. Does NOT sign, re-hash, or re-verify the CER.
641
+ * The `cer.certificateHash` is taken as-is and remains authoritative.
642
+ * Only fields explicitly provided in `params` are included in the returned package.
643
+ */
644
+ declare function createCerPackage(params: CreateCerPackageParams): AiCerPackage;
645
+ /**
646
+ * Extract the inner CER bundle from a CER package.
647
+ *
648
+ * Throws `CerVerificationError` if `pkg` is not a valid CER package shape.
649
+ * Does NOT re-verify the CER hash — use `verifyCerPackage()` if verification is needed.
650
+ */
651
+ declare function getCerFromPackage(pkg: unknown): CerAiExecutionBundle;
652
+ /**
653
+ * Serialize a CER package to a stable canonical JSON string for transport or storage.
654
+ *
655
+ * Uses the same canonicalJson serializer as the rest of the SDK for
656
+ * predictable, stable output across environments.
657
+ */
658
+ declare function exportCerPackage(pkg: AiCerPackage): string;
659
+ /**
660
+ * Parse a CER package JSON string, validate its shape, and verify the inner CER bundle.
661
+ *
662
+ * Throws `CerVerificationError` if:
663
+ * - the JSON string is malformed
664
+ * - the parsed value is not a CER package shape
665
+ * - the inner `cer` bundle fails `verifyCer()`
666
+ *
667
+ * Does NOT change or reinterpret the bundle — returns it exactly as parsed.
668
+ */
669
+ declare function importCerPackage(json: string): AiCerPackage;
670
+ /**
671
+ * Verify the inner CER bundle of a package using the existing `verifyCer()`.
672
+ *
673
+ * Conservative by design:
674
+ * - ONLY verifies the inner `cer` bundle (certificate hash, snapshot hashes, input/output hashes).
675
+ * - Does NOT verify `receipt`, `signature`, `verificationEnvelope`, or any other
676
+ * package-level fields — those require provider-specific trust semantics outside this SDK.
677
+ *
678
+ * Returns the same `VerificationResult` shape as `verifyCer()`.
679
+ * When `pkg` is not a valid package shape, returns `ok: false` with code `SCHEMA_ERROR`.
680
+ */
681
+ declare function verifyCerPackage(pkg: unknown): VerificationResult;
682
+
683
+ export { type AiCerPackage, AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerContextSignal, CerMeta, CerVerificationError, type CerVerificationResult, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, type CheckStatus, type CreateCerPackageParams, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, ReasonCode, ReasonCode as ReasonCodeType, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, type VerificationStatus, type VerifyRunSummaryOptions, attest, attestIfNeeded, certifyAndAttestDecision, certifyAndAttestRun, certifyDecision, certifyDecisionFromProviderCall, computeInputHash, computeOutputHash, createCerPackage, createClient, createSnapshot, exportCer, exportCerPackage, exportVerifiableRedacted, fetchNodeKeys, getAttestationReceipt, getCerFromPackage, hasAttestation, hashCanonicalJson, hashToolOutput, hashUtf8, importCer, importCerPackage, isCerPackage, makeToolEvent, mapToAiefReason, redactBeforeSeal, sanitizeForAttestation, sanitizeForStamp, sanitizeForStorage, sealCer, selectNodeKey, sha256Hex, toCanonicalJson, validateProfile, verifyCer as verify, verifyAiCerBundleDetailed, verifyAief, verifyBundleAttestation, verifyCer, verifyCerPackage, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreateSnapshotParams, A as AiExecutionSnapshotV1, V as VerificationResult, a as CerMeta, B as BundleDeclaration, b as CerAiExecutionBundle, c as CertifyDecisionParams, R as RunBuilderOptions, S as StepParams, d as RunSummary, e as AttestOptions, f as AttestationResult, g as SanitizeStorageOptions, h as AttestationReceipt, N as NodeKeysDocument, i as NodeReceiptVerifyResult, j as SignedAttestationReceipt, k as CerVerifyCode, l as AiefVerifyResult, T as ToolEvent, m as RunSummaryVerifyResult, n as AiefProfile } from './types-C5t12OK8.js';
2
- export { o as AiExecutionParameters, p as AttestationReceiptResult, q as ClientDefaults, r as NexArtClient, P as ProviderCallParams, s as ProviderCallResult, t as ProviderConfig, u as RedactionEnvelope, W as WrappedExecutionParams, v as WrappedExecutionResult } from './types-C5t12OK8.js';
1
+ import { C as CreateSnapshotParams, A as AiExecutionSnapshotV1, V as VerificationResult, a as CerMeta, B as BundleDeclaration, b as CerContextSignal, c as CerAiExecutionBundle, d as CertifyDecisionParams, R as RunBuilderOptions, S as StepParams, e as RunSummary, f as AttestOptions, g as AttestationResult, h as SanitizeStorageOptions, i as AttestationReceipt, N as NodeKeysDocument, j as NodeReceiptVerifyResult, k as SignedAttestationReceipt, l as CerVerifyCode, m as AiefVerifyResult, T as ToolEvent, n as RunSummaryVerifyResult, o as AiefProfile } from './types-C_M2xSWK.js';
2
+ export { p as AiExecutionParameters, q as AttestationReceiptResult, r as CerContext, s as ClientDefaults, t as NexArtClient, P as ProviderCallParams, u as ProviderCallResult, v as ProviderConfig, w as RedactionEnvelope, W as WrappedExecutionParams, x as WrappedExecutionResult } from './types-C_M2xSWK.js';
3
3
  export { wrapProvider } from './providers/wrap.js';
4
4
  export { AttestDecisionFn, LangChainAttestedResult, LangChainCerResult, LangChainCertificationInput, certifyLangChainRun, createLangChainCer } from './langchain.js';
5
5
 
@@ -29,6 +29,8 @@ declare function sealCer(snapshot: AiExecutionSnapshotV1, options?: {
29
29
  createdAt?: string;
30
30
  meta?: CerMeta;
31
31
  declaration?: BundleDeclaration;
32
+ /** v0.10.0 — upstream signals to bind as evidence. Included in certificateHash. */
33
+ signals?: CerContextSignal[];
32
34
  }): CerAiExecutionBundle;
33
35
  declare function verifyCer(bundle: CerAiExecutionBundle): VerificationResult;
34
36
 
@@ -566,4 +568,116 @@ interface CerVerificationResult {
566
568
  */
567
569
  declare function verifyAiCerBundleDetailed(bundle: unknown): CerVerificationResult;
568
570
 
569
- export { AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerMeta, CerVerificationError, type CerVerificationResult, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, type CheckStatus, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, ReasonCode, ReasonCode as ReasonCodeType, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, type VerificationStatus, type VerifyRunSummaryOptions, attest, attestIfNeeded, certifyAndAttestDecision, certifyAndAttestRun, certifyDecision, certifyDecisionFromProviderCall, computeInputHash, computeOutputHash, createClient, createSnapshot, exportCer, exportVerifiableRedacted, fetchNodeKeys, getAttestationReceipt, hasAttestation, hashCanonicalJson, hashToolOutput, hashUtf8, importCer, makeToolEvent, mapToAiefReason, redactBeforeSeal, sanitizeForAttestation, sanitizeForStamp, sanitizeForStorage, sealCer, selectNodeKey, sha256Hex, toCanonicalJson, validateProfile, verifyCer as verify, verifyAiCerBundleDetailed, verifyAief, verifyBundleAttestation, verifyCer, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
571
+ /**
572
+ * @nexart/ai-execution — CER package helpers (v0.12.0)
573
+ *
574
+ * A "CER package" is a transport/export envelope that wraps a sealed
575
+ * cer.ai.execution.v1 bundle with optional receipt, signature, and
576
+ * attestation metadata.
577
+ *
578
+ * These helpers sit around the existing core and do NOT change CER hashing,
579
+ * canonicalization, attestation, or verification semantics in any way.
580
+ *
581
+ * @example
582
+ * ```ts
583
+ * import { certifyDecision } from '@nexart/ai-execution';
584
+ * import { createCerPackage, exportCerPackage, importCerPackage } from '@nexart/ai-execution';
585
+ *
586
+ * const cer = certifyDecision({ ... });
587
+ * const pkg = createCerPackage({ cer });
588
+ * const json = exportCerPackage(pkg);
589
+ * const restored = importCerPackage(json); // verifies inner CER
590
+ * ```
591
+ */
592
+
593
+ /**
594
+ * A CER package — a transport/export envelope for a sealed CER bundle.
595
+ *
596
+ * The `cer` field is the only required field. All other fields are additive
597
+ * transport/export metadata and do not affect CER hashing or verification.
598
+ */
599
+ interface AiCerPackage {
600
+ /** The sealed cer.ai.execution.v1 bundle. Required. */
601
+ cer: CerAiExecutionBundle;
602
+ /** Optional attestation receipt from a NexArt attestation node. */
603
+ receipt?: AttestationReceipt;
604
+ /**
605
+ * Optional base64url-encoded signature covering the package.
606
+ * NexArt does not interpret or verify this field — it is opaque transport metadata.
607
+ */
608
+ signature?: string;
609
+ /**
610
+ * Optional attestation summary block.
611
+ * NexArt does not interpret or verify its contents.
612
+ */
613
+ attestation?: Record<string, unknown>;
614
+ /**
615
+ * Optional verification envelope metadata.
616
+ * NexArt does not interpret or verify its contents.
617
+ */
618
+ verificationEnvelope?: Record<string, unknown>;
619
+ /**
620
+ * Optional base64url-encoded signature covering verificationEnvelope.
621
+ * NexArt does not interpret or verify this field — it is opaque transport metadata.
622
+ */
623
+ verificationEnvelopeSignature?: string;
624
+ }
625
+ /** Input parameters for createCerPackage(). Structurally identical to AiCerPackage. */
626
+ type CreateCerPackageParams = AiCerPackage;
627
+ /**
628
+ * Type guard: returns true if `value` is shaped like a CER package.
629
+ *
630
+ * A value qualifies as a CER package if it is a plain object whose `cer`
631
+ * field is a plain object with `bundleType === 'cer.ai.execution.v1'`.
632
+ *
633
+ * Lightweight structural check only — does NOT verify the inner CER hash.
634
+ * Use `verifyCerPackage()` or `importCerPackage()` for integrity verification.
635
+ */
636
+ declare function isCerPackage(value: unknown): value is AiCerPackage;
637
+ /**
638
+ * Assemble a CER package from a sealed CER bundle and optional transport metadata.
639
+ *
640
+ * Simple assembly only. Does NOT sign, re-hash, or re-verify the CER.
641
+ * The `cer.certificateHash` is taken as-is and remains authoritative.
642
+ * Only fields explicitly provided in `params` are included in the returned package.
643
+ */
644
+ declare function createCerPackage(params: CreateCerPackageParams): AiCerPackage;
645
+ /**
646
+ * Extract the inner CER bundle from a CER package.
647
+ *
648
+ * Throws `CerVerificationError` if `pkg` is not a valid CER package shape.
649
+ * Does NOT re-verify the CER hash — use `verifyCerPackage()` if verification is needed.
650
+ */
651
+ declare function getCerFromPackage(pkg: unknown): CerAiExecutionBundle;
652
+ /**
653
+ * Serialize a CER package to a stable canonical JSON string for transport or storage.
654
+ *
655
+ * Uses the same canonicalJson serializer as the rest of the SDK for
656
+ * predictable, stable output across environments.
657
+ */
658
+ declare function exportCerPackage(pkg: AiCerPackage): string;
659
+ /**
660
+ * Parse a CER package JSON string, validate its shape, and verify the inner CER bundle.
661
+ *
662
+ * Throws `CerVerificationError` if:
663
+ * - the JSON string is malformed
664
+ * - the parsed value is not a CER package shape
665
+ * - the inner `cer` bundle fails `verifyCer()`
666
+ *
667
+ * Does NOT change or reinterpret the bundle — returns it exactly as parsed.
668
+ */
669
+ declare function importCerPackage(json: string): AiCerPackage;
670
+ /**
671
+ * Verify the inner CER bundle of a package using the existing `verifyCer()`.
672
+ *
673
+ * Conservative by design:
674
+ * - ONLY verifies the inner `cer` bundle (certificate hash, snapshot hashes, input/output hashes).
675
+ * - Does NOT verify `receipt`, `signature`, `verificationEnvelope`, or any other
676
+ * package-level fields — those require provider-specific trust semantics outside this SDK.
677
+ *
678
+ * Returns the same `VerificationResult` shape as `verifyCer()`.
679
+ * When `pkg` is not a valid package shape, returns `ok: false` with code `SCHEMA_ERROR`.
680
+ */
681
+ declare function verifyCerPackage(pkg: unknown): VerificationResult;
682
+
683
+ export { type AiCerPackage, AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerContextSignal, CerMeta, CerVerificationError, type CerVerificationResult, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, type CheckStatus, type CreateCerPackageParams, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, ReasonCode, ReasonCode as ReasonCodeType, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, type VerificationStatus, type VerifyRunSummaryOptions, attest, attestIfNeeded, certifyAndAttestDecision, certifyAndAttestRun, certifyDecision, certifyDecisionFromProviderCall, computeInputHash, computeOutputHash, createCerPackage, createClient, createSnapshot, exportCer, exportCerPackage, exportVerifiableRedacted, fetchNodeKeys, getAttestationReceipt, getCerFromPackage, hasAttestation, hashCanonicalJson, hashToolOutput, hashUtf8, importCer, importCerPackage, isCerPackage, makeToolEvent, mapToAiefReason, redactBeforeSeal, sanitizeForAttestation, sanitizeForStamp, sanitizeForStorage, sealCer, selectNodeKey, sha256Hex, toCanonicalJson, validateProfile, verifyCer as verify, verifyAiCerBundleDetailed, verifyAief, verifyBundleAttestation, verifyCer, verifyCerPackage, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
package/dist/index.mjs CHANGED
@@ -258,14 +258,22 @@ function computeCertificateHash(payload) {
258
258
  const canonical = toCanonicalJson(payload);
259
259
  return `sha256:${sha256Hex(canonical)}`;
260
260
  }
261
+ function buildContext(signals) {
262
+ if (!signals || signals.length === 0) return void 0;
263
+ return { signals };
264
+ }
261
265
  function sealCer(snapshot, options) {
262
266
  const createdAt = options?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
267
+ const context = buildContext(options?.signals);
263
268
  const payload = {
264
269
  bundleType: "cer.ai.execution.v1",
265
270
  createdAt,
266
271
  snapshot,
267
272
  version: "0.1"
268
273
  };
274
+ if (context) {
275
+ payload.context = context;
276
+ }
269
277
  const certificateHash = computeCertificateHash(payload);
270
278
  const bundle = {
271
279
  bundleType: "cer.ai.execution.v1",
@@ -274,6 +282,9 @@ function sealCer(snapshot, options) {
274
282
  version: "0.1",
275
283
  snapshot
276
284
  };
285
+ if (context) {
286
+ bundle.context = context;
287
+ }
277
288
  if (options?.meta) {
278
289
  bundle.meta = options.meta;
279
290
  }
@@ -322,6 +333,10 @@ function verifyCer(bundle) {
322
333
  snapshot: bundle.snapshot,
323
334
  version: "0.1"
324
335
  };
336
+ const verifyContext = buildContext(bundle.context?.signals);
337
+ if (verifyContext) {
338
+ payload.context = verifyContext;
339
+ }
325
340
  const expectedHash = computeCertificateHash(payload);
326
341
  if (bundle.certificateHash !== expectedHash) {
327
342
  certHashErrors.push(`certificateHash mismatch: expected ${expectedHash}, got ${bundle.certificateHash}`);
@@ -382,7 +397,11 @@ function certifyDecision(params) {
382
397
  conversationId: params.conversationId,
383
398
  prevStepHash: params.prevStepHash
384
399
  });
385
- return sealCer(snapshot, { createdAt: params.createdAt, meta: params.meta });
400
+ return sealCer(snapshot, {
401
+ createdAt: params.createdAt,
402
+ meta: params.meta,
403
+ signals: params.signals
404
+ });
386
405
  }
387
406
 
388
407
  // src/run.ts
@@ -2607,7 +2626,8 @@ function buildCertifyParams(input, executionId) {
2607
2626
  runId: typeof input.metadata?.runId === "string" ? input.metadata.runId : void 0,
2608
2627
  workflowId: typeof input.metadata?.workflowId === "string" ? input.metadata.workflowId : void 0,
2609
2628
  conversationId: typeof input.metadata?.conversationId === "string" ? input.metadata.conversationId : void 0,
2610
- meta: buildMeta(input.metadata)
2629
+ meta: buildMeta(input.metadata),
2630
+ signals: input.signals
2611
2631
  };
2612
2632
  }
2613
2633
  function createLangChainCer(input) {
@@ -2636,6 +2656,67 @@ function certifyLangChainRun(input, _options) {
2636
2656
  }
2637
2657
  return createLangChainCer(input);
2638
2658
  }
2659
+
2660
+ // src/package.ts
2661
+ function isCerPackage(value) {
2662
+ if (typeof value !== "object" || value === null) return false;
2663
+ const pkg = value;
2664
+ if (typeof pkg["cer"] !== "object" || pkg["cer"] === null) return false;
2665
+ const cer = pkg["cer"];
2666
+ return cer["bundleType"] === "cer.ai.execution.v1";
2667
+ }
2668
+ function createCerPackage(params) {
2669
+ const pkg = { cer: params.cer };
2670
+ if (params.receipt !== void 0) pkg.receipt = params.receipt;
2671
+ if (params.signature !== void 0) pkg.signature = params.signature;
2672
+ if (params.attestation !== void 0) pkg.attestation = params.attestation;
2673
+ if (params.verificationEnvelope !== void 0) pkg.verificationEnvelope = params.verificationEnvelope;
2674
+ if (params.verificationEnvelopeSignature !== void 0) pkg.verificationEnvelopeSignature = params.verificationEnvelopeSignature;
2675
+ return pkg;
2676
+ }
2677
+ function getCerFromPackage(pkg) {
2678
+ if (!isCerPackage(pkg)) {
2679
+ throw new CerVerificationError([
2680
+ "getCerFromPackage: value is not a valid CER package (missing or invalid cer field)"
2681
+ ]);
2682
+ }
2683
+ return pkg.cer;
2684
+ }
2685
+ function exportCerPackage(pkg) {
2686
+ return toCanonicalJson(pkg);
2687
+ }
2688
+ function importCerPackage(json) {
2689
+ let parsed;
2690
+ try {
2691
+ parsed = JSON.parse(json);
2692
+ } catch (err2) {
2693
+ throw new CerVerificationError([
2694
+ `importCerPackage: invalid JSON: ${err2.message}`
2695
+ ]);
2696
+ }
2697
+ if (!isCerPackage(parsed)) {
2698
+ throw new CerVerificationError([
2699
+ "importCerPackage: parsed value is not a CER package (missing or invalid cer field)"
2700
+ ]);
2701
+ }
2702
+ const result = verifyCer(parsed.cer);
2703
+ if (!result.ok) {
2704
+ throw new CerVerificationError([
2705
+ `importCerPackage: inner CER failed verification: ${result.errors.join("; ")}`
2706
+ ]);
2707
+ }
2708
+ return parsed;
2709
+ }
2710
+ function verifyCerPackage(pkg) {
2711
+ if (!isCerPackage(pkg)) {
2712
+ return {
2713
+ ok: false,
2714
+ errors: ["verifyCerPackage: value is not a CER package (missing or invalid cer field)"],
2715
+ code: CerVerifyCode.SCHEMA_ERROR
2716
+ };
2717
+ }
2718
+ return verifyCer(pkg.cer);
2719
+ }
2639
2720
  export {
2640
2721
  CerAttestationError,
2641
2722
  CerVerificationError,
@@ -2651,18 +2732,23 @@ export {
2651
2732
  certifyLangChainRun,
2652
2733
  computeInputHash,
2653
2734
  computeOutputHash,
2735
+ createCerPackage,
2654
2736
  createClient,
2655
2737
  createLangChainCer,
2656
2738
  createSnapshot,
2657
2739
  exportCer,
2740
+ exportCerPackage,
2658
2741
  exportVerifiableRedacted,
2659
2742
  fetchNodeKeys,
2660
2743
  getAttestationReceipt,
2744
+ getCerFromPackage,
2661
2745
  hasAttestation,
2662
2746
  hashCanonicalJson,
2663
2747
  hashToolOutput,
2664
2748
  hashUtf8,
2665
2749
  importCer,
2750
+ importCerPackage,
2751
+ isCerPackage,
2666
2752
  makeToolEvent,
2667
2753
  mapToAiefReason,
2668
2754
  redactBeforeSeal,
@@ -2679,6 +2765,7 @@ export {
2679
2765
  verifyAief,
2680
2766
  verifyBundleAttestation,
2681
2767
  verifyCer,
2768
+ verifyCerPackage,
2682
2769
  verifyNodeReceiptSignature,
2683
2770
  verifyRunSummary,
2684
2771
  verifySnapshot,