@nexart/ai-execution 0.9.0 → 0.10.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 +167 -3
- package/dist/index.cjs +97 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +95 -0
- package/dist/index.mjs.map +1 -1
- package/dist/langchain.cjs +480 -0
- package/dist/langchain.cjs.map +1 -0
- package/dist/langchain.d.cts +185 -0
- package/dist/langchain.d.ts +185 -0
- package/dist/langchain.mjs +444 -0
- package/dist/langchain.mjs.map +1 -0
- package/package.json +7 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
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
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';
|
|
3
3
|
export { wrapProvider } from './providers/wrap.cjs';
|
|
4
|
+
export { AttestDecisionFn, LangChainAttestedResult, LangChainCerResult, LangChainCertificationInput, certifyLangChainRun, createLangChainCer } from './langchain.cjs';
|
|
4
5
|
|
|
5
6
|
declare class CerVerificationError extends Error {
|
|
6
7
|
readonly errors: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
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
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';
|
|
3
3
|
export { wrapProvider } from './providers/wrap.js';
|
|
4
|
+
export { AttestDecisionFn, LangChainAttestedResult, LangChainCerResult, LangChainCertificationInput, certifyLangChainRun, createLangChainCer } from './langchain.js';
|
|
4
5
|
|
|
5
6
|
declare class CerVerificationError extends Error {
|
|
6
7
|
readonly errors: string[];
|
package/dist/index.mjs
CHANGED
|
@@ -2543,6 +2543,99 @@ function verifyAiCerBundleDetailed(bundle) {
|
|
|
2543
2543
|
verifier
|
|
2544
2544
|
};
|
|
2545
2545
|
}
|
|
2546
|
+
|
|
2547
|
+
// src/langchain.ts
|
|
2548
|
+
import * as crypto6 from "crypto";
|
|
2549
|
+
function normalizeCerValue(value) {
|
|
2550
|
+
if (typeof value === "string") return value;
|
|
2551
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
2552
|
+
return value;
|
|
2553
|
+
}
|
|
2554
|
+
if (Array.isArray(value)) return { items: value };
|
|
2555
|
+
return String(value);
|
|
2556
|
+
}
|
|
2557
|
+
function extractPrompt(input, metadata) {
|
|
2558
|
+
if (typeof metadata?.prompt === "string" && metadata.prompt.length > 0) {
|
|
2559
|
+
return metadata.prompt;
|
|
2560
|
+
}
|
|
2561
|
+
if (input !== null && typeof input === "object" && !Array.isArray(input)) {
|
|
2562
|
+
const obj = input;
|
|
2563
|
+
if (Array.isArray(obj.messages) && obj.messages.length > 0) {
|
|
2564
|
+
const first = obj.messages[0];
|
|
2565
|
+
if (typeof first?.content === "string" && first.content.length > 0) {
|
|
2566
|
+
return first.content;
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
if (typeof obj.prompt === "string" && obj.prompt.length > 0) return obj.prompt;
|
|
2570
|
+
if (typeof obj.text === "string" && obj.text.length > 0) return obj.text;
|
|
2571
|
+
}
|
|
2572
|
+
if (typeof input === "string" && input.length > 0) return input;
|
|
2573
|
+
return "[LangChain run]";
|
|
2574
|
+
}
|
|
2575
|
+
function buildMeta(metadata) {
|
|
2576
|
+
if (!metadata || Object.keys(metadata).length === 0) return void 0;
|
|
2577
|
+
const reserved = /* @__PURE__ */ new Set(["prompt", "appId", "runId", "workflowId", "conversationId"]);
|
|
2578
|
+
const extraTags = [];
|
|
2579
|
+
for (const [k, v] of Object.entries(metadata)) {
|
|
2580
|
+
if (!reserved.has(k)) {
|
|
2581
|
+
extraTags.push(typeof v === "string" ? `${k}:${v}` : `${k}:${JSON.stringify(v)}`);
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
return extraTags.length > 0 ? { tags: extraTags } : void 0;
|
|
2585
|
+
}
|
|
2586
|
+
function resolveParameters(params) {
|
|
2587
|
+
return {
|
|
2588
|
+
temperature: params?.temperature ?? 0,
|
|
2589
|
+
maxTokens: params?.maxTokens ?? 0,
|
|
2590
|
+
topP: params?.topP ?? null,
|
|
2591
|
+
seed: params?.seed ?? null
|
|
2592
|
+
};
|
|
2593
|
+
}
|
|
2594
|
+
function buildCertifyParams(input, executionId) {
|
|
2595
|
+
return {
|
|
2596
|
+
executionId,
|
|
2597
|
+
timestamp: input.timestamp,
|
|
2598
|
+
createdAt: input.createdAt,
|
|
2599
|
+
provider: input.provider,
|
|
2600
|
+
model: input.model,
|
|
2601
|
+
modelVersion: input.modelVersion ?? null,
|
|
2602
|
+
prompt: extractPrompt(input.input, input.metadata),
|
|
2603
|
+
input: normalizeCerValue(input.input),
|
|
2604
|
+
output: normalizeCerValue(input.output),
|
|
2605
|
+
parameters: resolveParameters(input.parameters),
|
|
2606
|
+
appId: typeof input.metadata?.appId === "string" ? input.metadata.appId : null,
|
|
2607
|
+
runId: typeof input.metadata?.runId === "string" ? input.metadata.runId : void 0,
|
|
2608
|
+
workflowId: typeof input.metadata?.workflowId === "string" ? input.metadata.workflowId : void 0,
|
|
2609
|
+
conversationId: typeof input.metadata?.conversationId === "string" ? input.metadata.conversationId : void 0,
|
|
2610
|
+
meta: buildMeta(input.metadata)
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
function createLangChainCer(input) {
|
|
2614
|
+
const executionId = input.executionId ?? crypto6.randomUUID();
|
|
2615
|
+
const bundle = certifyDecision(buildCertifyParams(input, executionId));
|
|
2616
|
+
return {
|
|
2617
|
+
bundle,
|
|
2618
|
+
certificateHash: bundle.certificateHash,
|
|
2619
|
+
executionId: bundle.snapshot.executionId
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
function certifyLangChainRun(input, _options) {
|
|
2623
|
+
if (input.nodeUrl && input.apiKey) {
|
|
2624
|
+
const executionId = input.executionId ?? crypto6.randomUUID();
|
|
2625
|
+
const certifyParams = buildCertifyParams({ ...input, executionId }, executionId);
|
|
2626
|
+
const attestFn = _options?._attestFn ?? certifyAndAttestDecision;
|
|
2627
|
+
return attestFn(certifyParams, { nodeUrl: input.nodeUrl, apiKey: input.apiKey }).then(
|
|
2628
|
+
({ bundle, receipt }) => ({
|
|
2629
|
+
bundle,
|
|
2630
|
+
receipt,
|
|
2631
|
+
certificateHash: bundle.certificateHash,
|
|
2632
|
+
executionId: bundle.snapshot.executionId,
|
|
2633
|
+
attested: true
|
|
2634
|
+
})
|
|
2635
|
+
);
|
|
2636
|
+
}
|
|
2637
|
+
return createLangChainCer(input);
|
|
2638
|
+
}
|
|
2546
2639
|
export {
|
|
2547
2640
|
CerAttestationError,
|
|
2548
2641
|
CerVerificationError,
|
|
@@ -2555,9 +2648,11 @@ export {
|
|
|
2555
2648
|
certifyAndAttestRun,
|
|
2556
2649
|
certifyDecision,
|
|
2557
2650
|
certifyDecisionFromProviderCall,
|
|
2651
|
+
certifyLangChainRun,
|
|
2558
2652
|
computeInputHash,
|
|
2559
2653
|
computeOutputHash,
|
|
2560
2654
|
createClient,
|
|
2655
|
+
createLangChainCer,
|
|
2561
2656
|
createSnapshot,
|
|
2562
2657
|
exportCer,
|
|
2563
2658
|
exportVerifiableRedacted,
|