@nexart/ai-execution 0.6.0 → 0.8.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/README.md +294 -10
- package/dist/index.cjs +401 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +303 -3
- package/dist/index.d.ts +303 -3
- package/dist/index.mjs +392 -2
- package/dist/index.mjs.map +1 -1
- package/dist/providers/anthropic.cjs +7 -1
- package/dist/providers/anthropic.cjs.map +1 -1
- package/dist/providers/anthropic.d.cts +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.mjs +7 -1
- package/dist/providers/anthropic.mjs.map +1 -1
- package/dist/providers/openai.cjs +7 -1
- package/dist/providers/openai.cjs.map +1 -1
- package/dist/providers/openai.d.cts +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.mjs +7 -1
- package/dist/providers/openai.mjs.map +1 -1
- package/dist/providers/wrap.cjs +7 -1
- package/dist/providers/wrap.cjs.map +1 -1
- package/dist/providers/wrap.d.cts +1 -1
- package/dist/providers/wrap.d.ts +1 -1
- package/dist/providers/wrap.mjs +7 -1
- package/dist/providers/wrap.mjs.map +1 -1
- package/dist/{types-Cgb52dTx.d.cts → types-CcqCDPrD.d.cts} +68 -1
- package/dist/{types-Cgb52dTx.d.ts → types-CcqCDPrD.d.ts} +68 -1
- package/package.json +2 -2
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 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 } from './types-
|
|
2
|
-
export {
|
|
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-CcqCDPrD.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-CcqCDPrD.cjs';
|
|
3
3
|
export { wrapProvider } from './providers/wrap.cjs';
|
|
4
4
|
|
|
5
5
|
declare class CerVerificationError extends Error {
|
|
@@ -27,6 +27,7 @@ declare function verifySnapshot(snapshot: AiExecutionSnapshotV1): VerificationRe
|
|
|
27
27
|
declare function sealCer(snapshot: AiExecutionSnapshotV1, options?: {
|
|
28
28
|
createdAt?: string;
|
|
29
29
|
meta?: CerMeta;
|
|
30
|
+
declaration?: BundleDeclaration;
|
|
30
31
|
}): CerAiExecutionBundle;
|
|
31
32
|
declare function verifyCer(bundle: CerAiExecutionBundle): VerificationResult;
|
|
32
33
|
|
|
@@ -201,4 +202,303 @@ interface NexArtClient {
|
|
|
201
202
|
*/
|
|
202
203
|
declare function createClient(defaults?: ClientDefaults): NexArtClient;
|
|
203
204
|
|
|
204
|
-
|
|
205
|
+
/**
|
|
206
|
+
* @nexart/ai-execution — AIEF §9 verifier adapter (v0.7.0)
|
|
207
|
+
*
|
|
208
|
+
* Provides verifyAief() which wraps the existing verifyCer() and returns the
|
|
209
|
+
* exact AIEF §9.1 output schema required for cross-vendor verifier interoperability.
|
|
210
|
+
*
|
|
211
|
+
* Existing verify() / verifyCer() output is unchanged — this is additive only.
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Map a NexArt CerVerifyCode to an AIEF §9.2 reason string.
|
|
216
|
+
* Unknown codes fall back to "malformedArtifact".
|
|
217
|
+
*/
|
|
218
|
+
declare function mapToAiefReason(code: string): string;
|
|
219
|
+
/**
|
|
220
|
+
* Verify a CER bundle and return the exact AIEF §9.1 output shape.
|
|
221
|
+
*
|
|
222
|
+
* This wraps verifyCer() — hashing logic is not duplicated.
|
|
223
|
+
* The internal NexArt verify() output is unchanged; this is purely an adapter.
|
|
224
|
+
*
|
|
225
|
+
* Per AIEF §9.0 rule #7: if chain fields are absent, chainValid MUST be true.
|
|
226
|
+
*/
|
|
227
|
+
declare function verifyAief(bundle: CerAiExecutionBundle): AiefVerifyResult;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @nexart/ai-execution — Level 4 tool/dependency evidence helpers (v0.7.0)
|
|
231
|
+
*
|
|
232
|
+
* Provides hashToolOutput() and makeToolEvent() for building AIEF-06 compliant
|
|
233
|
+
* tool call evidence records to include in AiExecutionSnapshotV1.toolCalls.
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Hash a tool output value for use as `outputHash` in a ToolEvent.
|
|
238
|
+
*
|
|
239
|
+
* - string → SHA-256 of UTF-8 bytes
|
|
240
|
+
* - anything else → SHA-256 of stable canonical JSON bytes
|
|
241
|
+
*
|
|
242
|
+
* Returns "sha256:<64hex>" format.
|
|
243
|
+
*/
|
|
244
|
+
declare function hashToolOutput(value: unknown): string;
|
|
245
|
+
interface MakeToolEventParams {
|
|
246
|
+
toolId: string;
|
|
247
|
+
output: unknown;
|
|
248
|
+
at?: string;
|
|
249
|
+
input?: unknown;
|
|
250
|
+
evidenceRef?: string;
|
|
251
|
+
error?: string;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Build a ToolEvent record for inclusion in snapshot.toolCalls.
|
|
255
|
+
*
|
|
256
|
+
* The outputHash is computed by hashToolOutput(output) so it is always consistent.
|
|
257
|
+
* Optionally computes inputHash if `input` is provided.
|
|
258
|
+
* If `at` is omitted, the current time is used.
|
|
259
|
+
*/
|
|
260
|
+
declare function makeToolEvent(params: MakeToolEventParams): ToolEvent;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @nexart/ai-execution — Level 4 chain integrity verification (v0.7.0)
|
|
264
|
+
*
|
|
265
|
+
* Provides verifyRunSummary() for validating multi-step RunBuilder outputs against
|
|
266
|
+
* AIEF-07 requirements: detects insertion, deletion, and reordering of steps.
|
|
267
|
+
*/
|
|
268
|
+
|
|
269
|
+
interface VerifyRunSummaryOptions {
|
|
270
|
+
/** Skip per-bundle certificateHash verification (use only if already verified separately). */
|
|
271
|
+
skipBundleVerification?: boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Verify that a RunSummary and its corresponding step bundles form a valid,
|
|
275
|
+
* unbroken cryptographic chain.
|
|
276
|
+
*
|
|
277
|
+
* Detects:
|
|
278
|
+
* - Missing steps (INCOMPLETE_ARTIFACT)
|
|
279
|
+
* - Extra steps (INCOMPLETE_ARTIFACT)
|
|
280
|
+
* - Reordered steps (CHAIN_BREAK_DETECTED via stepIndex or prevStepHash mismatch)
|
|
281
|
+
* - Inserted steps (CHAIN_BREAK_DETECTED)
|
|
282
|
+
* - Deleted steps (CHAIN_BREAK_DETECTED)
|
|
283
|
+
* - Summary finalStepHash mismatch (CHAIN_BREAK_DETECTED)
|
|
284
|
+
*
|
|
285
|
+
* @param summary RunSummary from RunBuilder.finalize()
|
|
286
|
+
* @param bundles Step bundles in declared order (step 0 first)
|
|
287
|
+
* @param opts Options for verification behaviour
|
|
288
|
+
*/
|
|
289
|
+
declare function verifyRunSummary(summary: RunSummary, bundles: CerAiExecutionBundle[], opts?: VerifyRunSummaryOptions): RunSummaryVerifyResult;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @nexart/ai-execution — Pre-seal redaction helpers (v0.7.0)
|
|
293
|
+
*
|
|
294
|
+
* redactBeforeSeal() replaces sensitive snapshot fields with stable redaction
|
|
295
|
+
* envelopes { _redacted: true, hash: "sha256:..." } BEFORE the snapshot is
|
|
296
|
+
* sealed with sealCer(). The resulting bundle will verify correctly because
|
|
297
|
+
* the certificateHash was computed over the already-redacted snapshot.
|
|
298
|
+
*
|
|
299
|
+
* For `input` and `output` fields, the corresponding `inputHash`/`outputHash`
|
|
300
|
+
* are recomputed to reflect the envelope (the original value's hash is
|
|
301
|
+
* preserved inside the envelope itself).
|
|
302
|
+
*
|
|
303
|
+
* IMPORTANT: Post-hoc redaction via sanitizeForStorage() breaks certificateHash
|
|
304
|
+
* by design. Only pre-seal redaction produces verifiable bundles.
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
interface RedactBeforeSealPolicy {
|
|
308
|
+
/** Dot-separated field paths to redact, e.g. ["input", "prompt"]. */
|
|
309
|
+
paths: string[];
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Replace sensitive snapshot fields with stable redaction envelopes before sealing.
|
|
313
|
+
*
|
|
314
|
+
* - For `input`: replaces with envelope and recomputes inputHash from envelope
|
|
315
|
+
* - For `output`: replaces with envelope and recomputes outputHash from envelope
|
|
316
|
+
* - For other paths: replaces with envelope (nested paths supported via dot notation)
|
|
317
|
+
*
|
|
318
|
+
* The original value's hash is preserved inside the envelope at `envelope.hash`,
|
|
319
|
+
* providing a trail for authorized reviewers while keeping the raw value private.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* const redactedSnap = redactBeforeSeal(snapshot, { paths: ['input', 'prompt'] });
|
|
324
|
+
* const bundle = sealCer(redactedSnap);
|
|
325
|
+
* // verifyCer(bundle) → { ok: true }
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
declare function redactBeforeSeal(snapshot: AiExecutionSnapshotV1, policy: RedactBeforeSealPolicy): AiExecutionSnapshotV1;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @nexart/ai-execution — AIEF profile validation (v0.7.0)
|
|
332
|
+
*
|
|
333
|
+
* Profiles add opt-in strictness at creation time — they enforce field
|
|
334
|
+
* presence and structure only. They NEVER change certificateHash computation.
|
|
335
|
+
*
|
|
336
|
+
* Available profiles:
|
|
337
|
+
* "flexible" — No extra validation (default SDK behaviour)
|
|
338
|
+
* "AIEF_L2" — Validates AIEF-01 required fields are present
|
|
339
|
+
* "AIEF_L3" — Same as AIEF_L2 (portability is structural, not field-level)
|
|
340
|
+
* "AIEF_L4" — AIEF_L3 + validates toolCalls fields, prevStepHash for step > 0
|
|
341
|
+
*/
|
|
342
|
+
|
|
343
|
+
interface ProfileValidationResult {
|
|
344
|
+
ok: boolean;
|
|
345
|
+
errors: string[];
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Validate a snapshot or bundle against the given AIEF profile.
|
|
349
|
+
*
|
|
350
|
+
* Returns { ok: true, errors: [] } for "flexible".
|
|
351
|
+
* Does NOT throw — errors are returned in the result.
|
|
352
|
+
* Does NOT affect hashing or sealing.
|
|
353
|
+
*/
|
|
354
|
+
declare function validateProfile(target: AiExecutionSnapshotV1 | CerAiExecutionBundle, profile: AiefProfile): ProfileValidationResult;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @nexart/ai-execution — Verifiable redacted export helper
|
|
358
|
+
*
|
|
359
|
+
* exportVerifiableRedacted() produces a NEW sealed bundle whose snapshot has
|
|
360
|
+
* sensitive fields replaced with redaction envelopes via redactBeforeSeal().
|
|
361
|
+
*
|
|
362
|
+
* The result is a fully independently verifiable bundle with a NEW certificateHash.
|
|
363
|
+
* The original certificateHash is preserved in meta.provenance as an informational
|
|
364
|
+
* cross-reference ONLY — it does not establish any cryptographic relationship
|
|
365
|
+
* between the two bundles.
|
|
366
|
+
*
|
|
367
|
+
* verify(newBundle) → { ok: true } ✅ the new bundle verifies on its own
|
|
368
|
+
* verify(originalBundle) → { ok: true } ✅ the original is unaffected
|
|
369
|
+
*
|
|
370
|
+
* IMPORTANT CONSTRAINTS:
|
|
371
|
+
* - Only `input` and `output` paths are safe to redact (their content hashes are
|
|
372
|
+
* recomputed from the envelope). Schema-validated string fields like `prompt`
|
|
373
|
+
* cannot be replaced with an object envelope — verify() will return SCHEMA_ERROR.
|
|
374
|
+
* - `meta.provenance.originalCertificateHash` is reference metadata only.
|
|
375
|
+
* Anyone who receives only the new bundle cannot verify the original's integrity.
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
interface ExportVerifiableRedactedOptions {
|
|
379
|
+
createdAt?: string;
|
|
380
|
+
}
|
|
381
|
+
interface ExportVerifiableRedactedProvenance {
|
|
382
|
+
originalCertificateHash: string;
|
|
383
|
+
redactionPolicy: {
|
|
384
|
+
paths: string[];
|
|
385
|
+
};
|
|
386
|
+
redactedAt: string;
|
|
387
|
+
}
|
|
388
|
+
interface ExportVerifiableRedactedResult {
|
|
389
|
+
bundle: CerAiExecutionBundle;
|
|
390
|
+
/**
|
|
391
|
+
* The original bundle's certificateHash. Convenience alias for
|
|
392
|
+
* `bundle.meta.provenance.originalCertificateHash`.
|
|
393
|
+
* Reference only — no cryptographic link to the new bundle.
|
|
394
|
+
*/
|
|
395
|
+
originalCertificateHash: string;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Produce a new sealed bundle with redacted snapshot fields.
|
|
399
|
+
*
|
|
400
|
+
* @param bundle The original sealed bundle to redact from.
|
|
401
|
+
* @param policy Which snapshot paths to redact. Only 'input' and 'output'
|
|
402
|
+
* are safe for verifiable redaction (their content hashes are
|
|
403
|
+
* recomputed). Other schema-validated string fields will cause
|
|
404
|
+
* verify() to return SCHEMA_ERROR on the new bundle.
|
|
405
|
+
* @param options Optional overrides (createdAt).
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```typescript
|
|
409
|
+
* import { certifyDecision, verify, exportVerifiableRedacted } from '@nexart/ai-execution';
|
|
410
|
+
*
|
|
411
|
+
* const original = certifyDecision({ ... });
|
|
412
|
+
* const { bundle, originalCertificateHash } = exportVerifiableRedacted(
|
|
413
|
+
* original,
|
|
414
|
+
* { paths: ['input', 'output'] },
|
|
415
|
+
* );
|
|
416
|
+
*
|
|
417
|
+
* verify(bundle).ok; // true
|
|
418
|
+
* bundle.meta.provenance.originalCertificateHash; // 'sha256:...' — reference only
|
|
419
|
+
* bundle.snapshot.input; // { _redacted: true, hash: 'sha256:...' }
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
declare function exportVerifiableRedacted(bundle: CerAiExecutionBundle, policy: RedactBeforeSealPolicy, options?: ExportVerifiableRedactedOptions): ExportVerifiableRedactedResult;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* @nexart/ai-execution — Opinionated run helper
|
|
426
|
+
*
|
|
427
|
+
* certifyAndAttestRun(): certify every step in a multi-step run via RunBuilder,
|
|
428
|
+
* optionally attest each sealed bundle, and return a consolidated result.
|
|
429
|
+
*
|
|
430
|
+
* Design principles:
|
|
431
|
+
* - Does NOT mutate or wrap any externally-owned RunBuilder. Creates its own.
|
|
432
|
+
* - RunBuilder semantics are unchanged: prevStepHash chaining is automatic.
|
|
433
|
+
* - attestStep is optional and injectable so callers can mock in tests without
|
|
434
|
+
* hitting the network.
|
|
435
|
+
* - Network failures from attestStep bubble up — wrap in try/catch for partial
|
|
436
|
+
* failure tolerance.
|
|
437
|
+
*/
|
|
438
|
+
|
|
439
|
+
interface CertifyAndAttestRunOptions {
|
|
440
|
+
runId?: string;
|
|
441
|
+
workflowId?: string | null;
|
|
442
|
+
conversationId?: string | null;
|
|
443
|
+
appId?: string | null;
|
|
444
|
+
/**
|
|
445
|
+
* Optional per-step attestation function. Receives each sealed step bundle
|
|
446
|
+
* immediately after it is created. Return an AttestationReceipt on success.
|
|
447
|
+
*
|
|
448
|
+
* If omitted, all receipts will be null (bundles are sealed but not attested).
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* import { attest } from '@nexart/ai-execution';
|
|
453
|
+
* certifyAndAttestRun(steps, {
|
|
454
|
+
* attestStep: (bundle) => attest(bundle, { nodeUrl, apiKey }),
|
|
455
|
+
* });
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
attestStep?: (bundle: CerAiExecutionBundle) => Promise<AttestationReceipt>;
|
|
459
|
+
}
|
|
460
|
+
interface CertifyAndAttestRunResult {
|
|
461
|
+
runSummary: RunSummary;
|
|
462
|
+
stepBundles: CerAiExecutionBundle[];
|
|
463
|
+
/**
|
|
464
|
+
* Attestation receipts in step order. `null` at index i means the step
|
|
465
|
+
* was sealed but not attested (no `attestStep` option was provided).
|
|
466
|
+
*/
|
|
467
|
+
receipts: (AttestationReceipt | null)[];
|
|
468
|
+
/** Alias for runSummary.finalStepHash — the last step's certificateHash. */
|
|
469
|
+
finalStepHash: string | null;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Certify every step in a multi-step run and optionally attest each bundle.
|
|
473
|
+
*
|
|
474
|
+
* Each step is sealed via RunBuilder, which automatically:
|
|
475
|
+
* - assigns stepIndex (0-based)
|
|
476
|
+
* - sets prevStepHash to the previous step's certificateHash
|
|
477
|
+
* - assigns a unique executionId and stepId per step
|
|
478
|
+
*
|
|
479
|
+
* The resulting runSummary + stepBundles can be validated offline with
|
|
480
|
+
* verifyRunSummary(runSummary, stepBundles).
|
|
481
|
+
*
|
|
482
|
+
* @param steps Ordered list of step parameters (step 0 first).
|
|
483
|
+
* @param options Run-level options and optional attestation hook.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* import { certifyAndAttestRun, verifyRunSummary } from '@nexart/ai-execution';
|
|
488
|
+
*
|
|
489
|
+
* const { runSummary, stepBundles, receipts, finalStepHash } =
|
|
490
|
+
* await certifyAndAttestRun(
|
|
491
|
+
* [step0Params, step1Params, step2Params],
|
|
492
|
+
* {
|
|
493
|
+
* runId: 'analysis-run',
|
|
494
|
+
* workflowId: 'data-pipeline',
|
|
495
|
+
* attestStep: (bundle) => attest(bundle, { nodeUrl, apiKey }),
|
|
496
|
+
* },
|
|
497
|
+
* );
|
|
498
|
+
*
|
|
499
|
+
* verifyRunSummary(runSummary, stepBundles); // { ok: true }
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
declare function certifyAndAttestRun(steps: StepParams[], options?: CertifyAndAttestRunOptions): Promise<CertifyAndAttestRunResult>;
|
|
503
|
+
|
|
504
|
+
export { AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerMeta, CerVerificationError, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, 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, verifyAief, verifyBundleAttestation, verifyCer, 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 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 } from './types-
|
|
2
|
-
export {
|
|
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-CcqCDPrD.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-CcqCDPrD.js';
|
|
3
3
|
export { wrapProvider } from './providers/wrap.js';
|
|
4
4
|
|
|
5
5
|
declare class CerVerificationError extends Error {
|
|
@@ -27,6 +27,7 @@ declare function verifySnapshot(snapshot: AiExecutionSnapshotV1): VerificationRe
|
|
|
27
27
|
declare function sealCer(snapshot: AiExecutionSnapshotV1, options?: {
|
|
28
28
|
createdAt?: string;
|
|
29
29
|
meta?: CerMeta;
|
|
30
|
+
declaration?: BundleDeclaration;
|
|
30
31
|
}): CerAiExecutionBundle;
|
|
31
32
|
declare function verifyCer(bundle: CerAiExecutionBundle): VerificationResult;
|
|
32
33
|
|
|
@@ -201,4 +202,303 @@ interface NexArtClient {
|
|
|
201
202
|
*/
|
|
202
203
|
declare function createClient(defaults?: ClientDefaults): NexArtClient;
|
|
203
204
|
|
|
204
|
-
|
|
205
|
+
/**
|
|
206
|
+
* @nexart/ai-execution — AIEF §9 verifier adapter (v0.7.0)
|
|
207
|
+
*
|
|
208
|
+
* Provides verifyAief() which wraps the existing verifyCer() and returns the
|
|
209
|
+
* exact AIEF §9.1 output schema required for cross-vendor verifier interoperability.
|
|
210
|
+
*
|
|
211
|
+
* Existing verify() / verifyCer() output is unchanged — this is additive only.
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Map a NexArt CerVerifyCode to an AIEF §9.2 reason string.
|
|
216
|
+
* Unknown codes fall back to "malformedArtifact".
|
|
217
|
+
*/
|
|
218
|
+
declare function mapToAiefReason(code: string): string;
|
|
219
|
+
/**
|
|
220
|
+
* Verify a CER bundle and return the exact AIEF §9.1 output shape.
|
|
221
|
+
*
|
|
222
|
+
* This wraps verifyCer() — hashing logic is not duplicated.
|
|
223
|
+
* The internal NexArt verify() output is unchanged; this is purely an adapter.
|
|
224
|
+
*
|
|
225
|
+
* Per AIEF §9.0 rule #7: if chain fields are absent, chainValid MUST be true.
|
|
226
|
+
*/
|
|
227
|
+
declare function verifyAief(bundle: CerAiExecutionBundle): AiefVerifyResult;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @nexart/ai-execution — Level 4 tool/dependency evidence helpers (v0.7.0)
|
|
231
|
+
*
|
|
232
|
+
* Provides hashToolOutput() and makeToolEvent() for building AIEF-06 compliant
|
|
233
|
+
* tool call evidence records to include in AiExecutionSnapshotV1.toolCalls.
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Hash a tool output value for use as `outputHash` in a ToolEvent.
|
|
238
|
+
*
|
|
239
|
+
* - string → SHA-256 of UTF-8 bytes
|
|
240
|
+
* - anything else → SHA-256 of stable canonical JSON bytes
|
|
241
|
+
*
|
|
242
|
+
* Returns "sha256:<64hex>" format.
|
|
243
|
+
*/
|
|
244
|
+
declare function hashToolOutput(value: unknown): string;
|
|
245
|
+
interface MakeToolEventParams {
|
|
246
|
+
toolId: string;
|
|
247
|
+
output: unknown;
|
|
248
|
+
at?: string;
|
|
249
|
+
input?: unknown;
|
|
250
|
+
evidenceRef?: string;
|
|
251
|
+
error?: string;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Build a ToolEvent record for inclusion in snapshot.toolCalls.
|
|
255
|
+
*
|
|
256
|
+
* The outputHash is computed by hashToolOutput(output) so it is always consistent.
|
|
257
|
+
* Optionally computes inputHash if `input` is provided.
|
|
258
|
+
* If `at` is omitted, the current time is used.
|
|
259
|
+
*/
|
|
260
|
+
declare function makeToolEvent(params: MakeToolEventParams): ToolEvent;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @nexart/ai-execution — Level 4 chain integrity verification (v0.7.0)
|
|
264
|
+
*
|
|
265
|
+
* Provides verifyRunSummary() for validating multi-step RunBuilder outputs against
|
|
266
|
+
* AIEF-07 requirements: detects insertion, deletion, and reordering of steps.
|
|
267
|
+
*/
|
|
268
|
+
|
|
269
|
+
interface VerifyRunSummaryOptions {
|
|
270
|
+
/** Skip per-bundle certificateHash verification (use only if already verified separately). */
|
|
271
|
+
skipBundleVerification?: boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Verify that a RunSummary and its corresponding step bundles form a valid,
|
|
275
|
+
* unbroken cryptographic chain.
|
|
276
|
+
*
|
|
277
|
+
* Detects:
|
|
278
|
+
* - Missing steps (INCOMPLETE_ARTIFACT)
|
|
279
|
+
* - Extra steps (INCOMPLETE_ARTIFACT)
|
|
280
|
+
* - Reordered steps (CHAIN_BREAK_DETECTED via stepIndex or prevStepHash mismatch)
|
|
281
|
+
* - Inserted steps (CHAIN_BREAK_DETECTED)
|
|
282
|
+
* - Deleted steps (CHAIN_BREAK_DETECTED)
|
|
283
|
+
* - Summary finalStepHash mismatch (CHAIN_BREAK_DETECTED)
|
|
284
|
+
*
|
|
285
|
+
* @param summary RunSummary from RunBuilder.finalize()
|
|
286
|
+
* @param bundles Step bundles in declared order (step 0 first)
|
|
287
|
+
* @param opts Options for verification behaviour
|
|
288
|
+
*/
|
|
289
|
+
declare function verifyRunSummary(summary: RunSummary, bundles: CerAiExecutionBundle[], opts?: VerifyRunSummaryOptions): RunSummaryVerifyResult;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @nexart/ai-execution — Pre-seal redaction helpers (v0.7.0)
|
|
293
|
+
*
|
|
294
|
+
* redactBeforeSeal() replaces sensitive snapshot fields with stable redaction
|
|
295
|
+
* envelopes { _redacted: true, hash: "sha256:..." } BEFORE the snapshot is
|
|
296
|
+
* sealed with sealCer(). The resulting bundle will verify correctly because
|
|
297
|
+
* the certificateHash was computed over the already-redacted snapshot.
|
|
298
|
+
*
|
|
299
|
+
* For `input` and `output` fields, the corresponding `inputHash`/`outputHash`
|
|
300
|
+
* are recomputed to reflect the envelope (the original value's hash is
|
|
301
|
+
* preserved inside the envelope itself).
|
|
302
|
+
*
|
|
303
|
+
* IMPORTANT: Post-hoc redaction via sanitizeForStorage() breaks certificateHash
|
|
304
|
+
* by design. Only pre-seal redaction produces verifiable bundles.
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
interface RedactBeforeSealPolicy {
|
|
308
|
+
/** Dot-separated field paths to redact, e.g. ["input", "prompt"]. */
|
|
309
|
+
paths: string[];
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Replace sensitive snapshot fields with stable redaction envelopes before sealing.
|
|
313
|
+
*
|
|
314
|
+
* - For `input`: replaces with envelope and recomputes inputHash from envelope
|
|
315
|
+
* - For `output`: replaces with envelope and recomputes outputHash from envelope
|
|
316
|
+
* - For other paths: replaces with envelope (nested paths supported via dot notation)
|
|
317
|
+
*
|
|
318
|
+
* The original value's hash is preserved inside the envelope at `envelope.hash`,
|
|
319
|
+
* providing a trail for authorized reviewers while keeping the raw value private.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* const redactedSnap = redactBeforeSeal(snapshot, { paths: ['input', 'prompt'] });
|
|
324
|
+
* const bundle = sealCer(redactedSnap);
|
|
325
|
+
* // verifyCer(bundle) → { ok: true }
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
declare function redactBeforeSeal(snapshot: AiExecutionSnapshotV1, policy: RedactBeforeSealPolicy): AiExecutionSnapshotV1;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @nexart/ai-execution — AIEF profile validation (v0.7.0)
|
|
332
|
+
*
|
|
333
|
+
* Profiles add opt-in strictness at creation time — they enforce field
|
|
334
|
+
* presence and structure only. They NEVER change certificateHash computation.
|
|
335
|
+
*
|
|
336
|
+
* Available profiles:
|
|
337
|
+
* "flexible" — No extra validation (default SDK behaviour)
|
|
338
|
+
* "AIEF_L2" — Validates AIEF-01 required fields are present
|
|
339
|
+
* "AIEF_L3" — Same as AIEF_L2 (portability is structural, not field-level)
|
|
340
|
+
* "AIEF_L4" — AIEF_L3 + validates toolCalls fields, prevStepHash for step > 0
|
|
341
|
+
*/
|
|
342
|
+
|
|
343
|
+
interface ProfileValidationResult {
|
|
344
|
+
ok: boolean;
|
|
345
|
+
errors: string[];
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Validate a snapshot or bundle against the given AIEF profile.
|
|
349
|
+
*
|
|
350
|
+
* Returns { ok: true, errors: [] } for "flexible".
|
|
351
|
+
* Does NOT throw — errors are returned in the result.
|
|
352
|
+
* Does NOT affect hashing or sealing.
|
|
353
|
+
*/
|
|
354
|
+
declare function validateProfile(target: AiExecutionSnapshotV1 | CerAiExecutionBundle, profile: AiefProfile): ProfileValidationResult;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @nexart/ai-execution — Verifiable redacted export helper
|
|
358
|
+
*
|
|
359
|
+
* exportVerifiableRedacted() produces a NEW sealed bundle whose snapshot has
|
|
360
|
+
* sensitive fields replaced with redaction envelopes via redactBeforeSeal().
|
|
361
|
+
*
|
|
362
|
+
* The result is a fully independently verifiable bundle with a NEW certificateHash.
|
|
363
|
+
* The original certificateHash is preserved in meta.provenance as an informational
|
|
364
|
+
* cross-reference ONLY — it does not establish any cryptographic relationship
|
|
365
|
+
* between the two bundles.
|
|
366
|
+
*
|
|
367
|
+
* verify(newBundle) → { ok: true } ✅ the new bundle verifies on its own
|
|
368
|
+
* verify(originalBundle) → { ok: true } ✅ the original is unaffected
|
|
369
|
+
*
|
|
370
|
+
* IMPORTANT CONSTRAINTS:
|
|
371
|
+
* - Only `input` and `output` paths are safe to redact (their content hashes are
|
|
372
|
+
* recomputed from the envelope). Schema-validated string fields like `prompt`
|
|
373
|
+
* cannot be replaced with an object envelope — verify() will return SCHEMA_ERROR.
|
|
374
|
+
* - `meta.provenance.originalCertificateHash` is reference metadata only.
|
|
375
|
+
* Anyone who receives only the new bundle cannot verify the original's integrity.
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
interface ExportVerifiableRedactedOptions {
|
|
379
|
+
createdAt?: string;
|
|
380
|
+
}
|
|
381
|
+
interface ExportVerifiableRedactedProvenance {
|
|
382
|
+
originalCertificateHash: string;
|
|
383
|
+
redactionPolicy: {
|
|
384
|
+
paths: string[];
|
|
385
|
+
};
|
|
386
|
+
redactedAt: string;
|
|
387
|
+
}
|
|
388
|
+
interface ExportVerifiableRedactedResult {
|
|
389
|
+
bundle: CerAiExecutionBundle;
|
|
390
|
+
/**
|
|
391
|
+
* The original bundle's certificateHash. Convenience alias for
|
|
392
|
+
* `bundle.meta.provenance.originalCertificateHash`.
|
|
393
|
+
* Reference only — no cryptographic link to the new bundle.
|
|
394
|
+
*/
|
|
395
|
+
originalCertificateHash: string;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Produce a new sealed bundle with redacted snapshot fields.
|
|
399
|
+
*
|
|
400
|
+
* @param bundle The original sealed bundle to redact from.
|
|
401
|
+
* @param policy Which snapshot paths to redact. Only 'input' and 'output'
|
|
402
|
+
* are safe for verifiable redaction (their content hashes are
|
|
403
|
+
* recomputed). Other schema-validated string fields will cause
|
|
404
|
+
* verify() to return SCHEMA_ERROR on the new bundle.
|
|
405
|
+
* @param options Optional overrides (createdAt).
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```typescript
|
|
409
|
+
* import { certifyDecision, verify, exportVerifiableRedacted } from '@nexart/ai-execution';
|
|
410
|
+
*
|
|
411
|
+
* const original = certifyDecision({ ... });
|
|
412
|
+
* const { bundle, originalCertificateHash } = exportVerifiableRedacted(
|
|
413
|
+
* original,
|
|
414
|
+
* { paths: ['input', 'output'] },
|
|
415
|
+
* );
|
|
416
|
+
*
|
|
417
|
+
* verify(bundle).ok; // true
|
|
418
|
+
* bundle.meta.provenance.originalCertificateHash; // 'sha256:...' — reference only
|
|
419
|
+
* bundle.snapshot.input; // { _redacted: true, hash: 'sha256:...' }
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
declare function exportVerifiableRedacted(bundle: CerAiExecutionBundle, policy: RedactBeforeSealPolicy, options?: ExportVerifiableRedactedOptions): ExportVerifiableRedactedResult;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* @nexart/ai-execution — Opinionated run helper
|
|
426
|
+
*
|
|
427
|
+
* certifyAndAttestRun(): certify every step in a multi-step run via RunBuilder,
|
|
428
|
+
* optionally attest each sealed bundle, and return a consolidated result.
|
|
429
|
+
*
|
|
430
|
+
* Design principles:
|
|
431
|
+
* - Does NOT mutate or wrap any externally-owned RunBuilder. Creates its own.
|
|
432
|
+
* - RunBuilder semantics are unchanged: prevStepHash chaining is automatic.
|
|
433
|
+
* - attestStep is optional and injectable so callers can mock in tests without
|
|
434
|
+
* hitting the network.
|
|
435
|
+
* - Network failures from attestStep bubble up — wrap in try/catch for partial
|
|
436
|
+
* failure tolerance.
|
|
437
|
+
*/
|
|
438
|
+
|
|
439
|
+
interface CertifyAndAttestRunOptions {
|
|
440
|
+
runId?: string;
|
|
441
|
+
workflowId?: string | null;
|
|
442
|
+
conversationId?: string | null;
|
|
443
|
+
appId?: string | null;
|
|
444
|
+
/**
|
|
445
|
+
* Optional per-step attestation function. Receives each sealed step bundle
|
|
446
|
+
* immediately after it is created. Return an AttestationReceipt on success.
|
|
447
|
+
*
|
|
448
|
+
* If omitted, all receipts will be null (bundles are sealed but not attested).
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* import { attest } from '@nexart/ai-execution';
|
|
453
|
+
* certifyAndAttestRun(steps, {
|
|
454
|
+
* attestStep: (bundle) => attest(bundle, { nodeUrl, apiKey }),
|
|
455
|
+
* });
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
attestStep?: (bundle: CerAiExecutionBundle) => Promise<AttestationReceipt>;
|
|
459
|
+
}
|
|
460
|
+
interface CertifyAndAttestRunResult {
|
|
461
|
+
runSummary: RunSummary;
|
|
462
|
+
stepBundles: CerAiExecutionBundle[];
|
|
463
|
+
/**
|
|
464
|
+
* Attestation receipts in step order. `null` at index i means the step
|
|
465
|
+
* was sealed but not attested (no `attestStep` option was provided).
|
|
466
|
+
*/
|
|
467
|
+
receipts: (AttestationReceipt | null)[];
|
|
468
|
+
/** Alias for runSummary.finalStepHash — the last step's certificateHash. */
|
|
469
|
+
finalStepHash: string | null;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Certify every step in a multi-step run and optionally attest each bundle.
|
|
473
|
+
*
|
|
474
|
+
* Each step is sealed via RunBuilder, which automatically:
|
|
475
|
+
* - assigns stepIndex (0-based)
|
|
476
|
+
* - sets prevStepHash to the previous step's certificateHash
|
|
477
|
+
* - assigns a unique executionId and stepId per step
|
|
478
|
+
*
|
|
479
|
+
* The resulting runSummary + stepBundles can be validated offline with
|
|
480
|
+
* verifyRunSummary(runSummary, stepBundles).
|
|
481
|
+
*
|
|
482
|
+
* @param steps Ordered list of step parameters (step 0 first).
|
|
483
|
+
* @param options Run-level options and optional attestation hook.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* import { certifyAndAttestRun, verifyRunSummary } from '@nexart/ai-execution';
|
|
488
|
+
*
|
|
489
|
+
* const { runSummary, stepBundles, receipts, finalStepHash } =
|
|
490
|
+
* await certifyAndAttestRun(
|
|
491
|
+
* [step0Params, step1Params, step2Params],
|
|
492
|
+
* {
|
|
493
|
+
* runId: 'analysis-run',
|
|
494
|
+
* workflowId: 'data-pipeline',
|
|
495
|
+
* attestStep: (bundle) => attest(bundle, { nodeUrl, apiKey }),
|
|
496
|
+
* },
|
|
497
|
+
* );
|
|
498
|
+
*
|
|
499
|
+
* verifyRunSummary(runSummary, stepBundles); // { ok: true }
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
declare function certifyAndAttestRun(steps: StepParams[], options?: CertifyAndAttestRunOptions): Promise<CertifyAndAttestRunResult>;
|
|
503
|
+
|
|
504
|
+
export { AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerMeta, CerVerificationError, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, 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, verifyAief, verifyBundleAttestation, verifyCer, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
|