@tenova/swt3-ai 0.3.4 → 0.3.5

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.
Files changed (54) hide show
  1. package/README.md +77 -2
  2. package/dist/adapters/anthropic.d.ts +32 -0
  3. package/dist/adapters/anthropic.d.ts.map +1 -0
  4. package/dist/adapters/anthropic.js +299 -0
  5. package/dist/adapters/anthropic.js.map +1 -0
  6. package/dist/adapters/bedrock.d.ts +33 -0
  7. package/dist/adapters/bedrock.d.ts.map +1 -0
  8. package/dist/adapters/bedrock.js +267 -0
  9. package/dist/adapters/bedrock.js.map +1 -0
  10. package/dist/adapters/openai.d.ts +19 -0
  11. package/dist/adapters/openai.d.ts.map +1 -0
  12. package/dist/adapters/openai.js +288 -0
  13. package/dist/adapters/openai.js.map +1 -0
  14. package/dist/adapters/vercel-ai.d.ts +64 -0
  15. package/dist/adapters/vercel-ai.d.ts.map +1 -0
  16. package/dist/adapters/vercel-ai.js +68 -0
  17. package/dist/adapters/vercel-ai.js.map +1 -0
  18. package/dist/buffer.d.ts +42 -0
  19. package/dist/buffer.d.ts.map +1 -0
  20. package/dist/buffer.js +161 -0
  21. package/dist/buffer.js.map +1 -0
  22. package/dist/clearing.d.ts +29 -0
  23. package/dist/clearing.d.ts.map +1 -0
  24. package/dist/clearing.js +308 -0
  25. package/dist/clearing.js.map +1 -0
  26. package/dist/demo.d.ts +11 -0
  27. package/dist/demo.d.ts.map +1 -0
  28. package/dist/demo.js +238 -0
  29. package/dist/demo.js.map +1 -0
  30. package/dist/fingerprint.d.ts +29 -0
  31. package/dist/fingerprint.d.ts.map +1 -0
  32. package/dist/fingerprint.js +57 -0
  33. package/dist/fingerprint.js.map +1 -0
  34. package/dist/handoff.d.ts +17 -0
  35. package/dist/handoff.d.ts.map +1 -0
  36. package/dist/handoff.js +82 -0
  37. package/dist/handoff.js.map +1 -0
  38. package/dist/index.d.ts +22 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +20 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/signing.d.ts +20 -0
  43. package/dist/signing.d.ts.map +1 -0
  44. package/dist/signing.js +28 -0
  45. package/dist/signing.js.map +1 -0
  46. package/dist/types.d.ts +98 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/types.js +17 -0
  49. package/dist/types.js.map +1 -0
  50. package/dist/witness.d.ts +142 -0
  51. package/dist/witness.d.ts.map +1 -0
  52. package/dist/witness.js +345 -0
  53. package/dist/witness.js.map +1 -0
  54. package/package.json +1 -1
@@ -0,0 +1,98 @@
1
+ /**
2
+ * SWT3 AI Witness SDK — Type definitions.
3
+ */
4
+ export interface WitnessConfig {
5
+ endpoint: string;
6
+ apiKey: string;
7
+ tenantId: string;
8
+ clearingLevel: 0 | 1 | 2 | 3;
9
+ bufferSize: number;
10
+ flushInterval: number;
11
+ timeout: number;
12
+ maxRetries: number;
13
+ latencyThresholdMs: number;
14
+ guardrailsRequired: number;
15
+ guardrailNames: string[];
16
+ procedures?: string[];
17
+ factorHandoff?: "file";
18
+ factorHandoffPath?: string;
19
+ agentId?: string;
20
+ signingKey?: string;
21
+ cycleId?: string;
22
+ policyVersion?: string;
23
+ }
24
+ export interface WitnessPayload {
25
+ procedure_id: string;
26
+ factor_a: number;
27
+ factor_b: number;
28
+ factor_c: number;
29
+ clearing_level: number;
30
+ anchor_fingerprint: string;
31
+ anchor_epoch: number;
32
+ fingerprint_timestamp_ms: number;
33
+ ai_model_id?: string;
34
+ ai_prompt_hash?: string;
35
+ ai_response_hash?: string;
36
+ ai_system_prompt_hash?: string;
37
+ ai_latency_ms?: number;
38
+ ai_input_tokens?: number;
39
+ ai_output_tokens?: number;
40
+ ai_context?: {
41
+ provider?: string;
42
+ guardrails?: string[];
43
+ system_fingerprint?: string;
44
+ tool_name?: string;
45
+ tool_call_id?: string;
46
+ access_target?: string;
47
+ access_scope?: string;
48
+ access_granted?: boolean;
49
+ cycle_id?: string;
50
+ };
51
+ agent_id?: string;
52
+ cycle_id?: string;
53
+ payload_signature?: string;
54
+ policy_version_hash?: string;
55
+ }
56
+ export interface WitnessReceipt {
57
+ procedure_id: string;
58
+ verdict: "PASS" | "FAIL" | string;
59
+ swt3_anchor: string;
60
+ clearing_level: number;
61
+ witnessed_at: string;
62
+ verification_url: string;
63
+ ok: boolean;
64
+ error?: string;
65
+ }
66
+ export interface BatchResponse {
67
+ ok: boolean;
68
+ tenant_id: string;
69
+ total: number;
70
+ accepted: number;
71
+ rejected: number;
72
+ receipts: WitnessReceipt[];
73
+ }
74
+ export interface InferenceRecord {
75
+ modelId: string;
76
+ modelHash: string;
77
+ promptHash: string;
78
+ responseHash: string;
79
+ latencyMs: number;
80
+ inputTokens?: number;
81
+ outputTokens?: number;
82
+ guardrailsActive: number;
83
+ guardrailsRequired: number;
84
+ guardrailPassed: boolean;
85
+ hasRefusal: boolean;
86
+ provider: string;
87
+ systemFingerprint?: string;
88
+ systemPromptHash?: string;
89
+ guardrailNames: string[];
90
+ toolName?: string;
91
+ toolCallId?: string;
92
+ accessTarget?: string;
93
+ accessGranted?: boolean;
94
+ accessScope?: string;
95
+ }
96
+ /** Valid AI procedure IDs from SWT3 Spec v1.2.0 */
97
+ export declare const AI_PROCEDURES: Set<string>;
98
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAA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,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,mDAAmD;AACnD,eAAO,MAAM,aAAa,aAWxB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * SWT3 AI Witness SDK — Type definitions.
3
+ */
4
+ /** Valid AI procedure IDs from SWT3 Spec v1.2.0 */
5
+ export const AI_PROCEDURES = new Set([
6
+ "AI-INF.1", "AI-INF.2", "AI-INF.3",
7
+ "AI-MDL.1", "AI-MDL.2", "AI-MDL.3",
8
+ "AI-GRD.1", "AI-GRD.2", "AI-GRD.3",
9
+ "AI-FAIR.1", "AI-FAIR.2",
10
+ "AI-DATA.1", "AI-DATA.2",
11
+ "AI-HITL.1", "AI-HITL.2",
12
+ "AI-EXPL.1", "AI-EXPL.2",
13
+ "AI-TOOL.1",
14
+ "AI-ID.1",
15
+ "AI-ACC.1",
16
+ ]);
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmGH,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IACnC,UAAU,EAAE,UAAU,EAAE,UAAU;IAClC,UAAU,EAAE,UAAU,EAAE,UAAU;IAClC,UAAU,EAAE,UAAU,EAAE,UAAU;IAClC,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,WAAW;IACxB,WAAW;IACX,SAAS;IACT,UAAU;CACX,CAAC,CAAC"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * SWT3 AI Witness SDK — Core Witness class.
3
+ *
4
+ * Usage:
5
+ * import { Witness } from "@tenova/swt3-ai";
6
+ * import OpenAI from "openai";
7
+ *
8
+ * const witness = new Witness({
9
+ * endpoint: "https://sovereign.tenova.io",
10
+ * apiKey: "axm_live_...",
11
+ * tenantId: "YOUR_TENANT_ID",
12
+ * });
13
+ *
14
+ * const client = witness.wrap(new OpenAI()) as OpenAI;
15
+ * const response = await client.chat.completions.create({ ... });
16
+ *
17
+ * // Graceful shutdown
18
+ * await witness.flush();
19
+ *
20
+ * Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
21
+ */
22
+ import { type VercelOnFinishOptions } from "./adapters/vercel-ai.js";
23
+ import type { WitnessReceipt, InferenceRecord } from "./types.js";
24
+ export interface WitnessOptions {
25
+ endpoint: string;
26
+ apiKey: string;
27
+ tenantId: string;
28
+ clearingLevel?: 0 | 1 | 2 | 3;
29
+ bufferSize?: number;
30
+ flushInterval?: number;
31
+ timeout?: number;
32
+ maxRetries?: number;
33
+ latencyThresholdMs?: number;
34
+ guardrailsRequired?: number;
35
+ guardrailNames?: string[];
36
+ procedures?: string[];
37
+ factorHandoff?: "file";
38
+ factorHandoffPath?: string;
39
+ agentId?: string;
40
+ signingKey?: string;
41
+ cycleId?: string;
42
+ strict?: boolean;
43
+ policyVersion?: string;
44
+ }
45
+ /**
46
+ * Raised when strict (gatekeeper) mode blocks an inference due to
47
+ * insufficient guardrails. The inference never reaches the AI model.
48
+ */
49
+ export declare class GatekeeperError extends Error {
50
+ readonly required: number;
51
+ readonly active: number;
52
+ readonly missingNames: string[];
53
+ constructor(required: number, active: number, missingNames?: string[]);
54
+ }
55
+ export declare class Witness {
56
+ private config;
57
+ private buffer;
58
+ private handoffWarned;
59
+ private _strict;
60
+ constructor(options: WitnessOptions);
61
+ /**
62
+ * Wrap an AI client with transparent witnessing.
63
+ *
64
+ * Supported: OpenAI, Anthropic
65
+ * Returns a proxy that behaves identically to the original client.
66
+ *
67
+ * Usage:
68
+ * const client = witness.wrap(new OpenAI()) as OpenAI;
69
+ * const client = witness.wrap(new Anthropic()) as Anthropic;
70
+ */
71
+ wrap(client: unknown): unknown;
72
+ /** Whether strict (gatekeeper) mode is enabled. Used by adapters. */
73
+ get strict(): boolean;
74
+ /**
75
+ * Pre-call guardrail gate (strict mode only).
76
+ *
77
+ * Evaluates whether configured guardrail requirements are met BEFORE
78
+ * the inference call reaches the AI model. If requirements are not met,
79
+ * throws `GatekeeperError` and mints an AI-GRD.3 anchor recording
80
+ * the rejection. The rejection is evidence — it is enqueued for flush.
81
+ *
82
+ * This method is SYNCHRONOUS — evaluates local config only, no network.
83
+ *
84
+ * @throws {GatekeeperError} if guardrail requirements are not met
85
+ */
86
+ gateCheck(_messages?: unknown, _model?: string): void;
87
+ /**
88
+ * Wrap a function as a witnessed tool call (AI-TOOL.1).
89
+ *
90
+ * Usage:
91
+ * const search = witness.wrapTool(searchDatabase, "search_db");
92
+ * const result = await search("SELECT ...");
93
+ *
94
+ * Each call mints an AI-TOOL.1 anchor with:
95
+ * factor_a = 1 (tool was called)
96
+ * factor_b = latency_ms
97
+ * factor_c = 1 if succeeded, 0 if exception raised
98
+ */
99
+ wrapTool<T extends (...args: any[]) => any>(fn: T, toolName?: string): T;
100
+ /**
101
+ * Wrap a function as a witnessed access attempt (AI-ACC.1).
102
+ *
103
+ * Usage:
104
+ * const queryDb = witness.wrapAccess(dbQuery, "prod-database", "read-only analytics");
105
+ * const result = await queryDb("SELECT ...");
106
+ *
107
+ * Each call mints an AI-ACC.1 anchor with:
108
+ * factor_a = 1 (access attempt occurred)
109
+ * factor_b = 1 if within declared scope (or no scope set), 0 if out of scope
110
+ * factor_c = 1 if access granted, 0 if denied/failed
111
+ */
112
+ wrapAccess<T extends (...args: any[]) => any>(fn: T, resourceName?: string, scope?: string): T;
113
+ /**
114
+ * Record a witnessed inference. Extracts factors, applies clearing,
115
+ * and enqueues payloads for background flush.
116
+ *
117
+ * If factorHandoff is configured, factors are written to the handoff
118
+ * destination BEFORE clearing proceeds. If the handoff fails, the
119
+ * payload is NOT transmitted.
120
+ */
121
+ record(inference: InferenceRecord): void;
122
+ /**
123
+ * Create a Vercel AI SDK `onFinish` callback for streamText / generateText.
124
+ *
125
+ * Usage:
126
+ * const result = await streamText({
127
+ * model: openai("gpt-4o"),
128
+ * prompt: myPrompt,
129
+ * onFinish: witness.vercelOnFinish({ promptText: myPrompt }),
130
+ * });
131
+ */
132
+ vercelOnFinish(options?: VercelOnFinishOptions): (result: unknown) => void;
133
+ /** Force-flush all buffered payloads. */
134
+ flush(): Promise<WitnessReceipt[]>;
135
+ /** Stop the witness and flush remaining payloads. */
136
+ stop(): Promise<WitnessReceipt[]>;
137
+ /** Number of payloads waiting. */
138
+ get pending(): number;
139
+ /** All receipts from completed flushes. */
140
+ get receipts(): WitnessReceipt[];
141
+ }
142
+ //# sourceMappingURL=witness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"witness.d.ts","sourceRoot":"","sources":["../src/witness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,KAAK,EAAiC,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEjG,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,CAA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AG,EAC1C,EAAE,EAAE,CAAC,EACL,YAAY,CAAC,EAAE,MAAM,EACrB,KAAK,CAAC,EAAE,MAAM,GACb,CAAC;IAiEJ;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IA0CxC;;;;;;;;;OASG;IACH,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI;IAI1E,yCAAyC;IACnC,KAAK,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIxC,qDAAqD;IAC/C,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIvC,kCAAkC;IAClC,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,2CAA2C;IAC3C,IAAI,QAAQ,IAAI,cAAc,EAAE,CAE/B;CACF"}
@@ -0,0 +1,345 @@
1
+ /**
2
+ * SWT3 AI Witness SDK — Core Witness class.
3
+ *
4
+ * Usage:
5
+ * import { Witness } from "@tenova/swt3-ai";
6
+ * import OpenAI from "openai";
7
+ *
8
+ * const witness = new Witness({
9
+ * endpoint: "https://sovereign.tenova.io",
10
+ * apiKey: "axm_live_...",
11
+ * tenantId: "YOUR_TENANT_ID",
12
+ * });
13
+ *
14
+ * const client = witness.wrap(new OpenAI()) as OpenAI;
15
+ * const response = await client.chat.completions.create({ ... });
16
+ *
17
+ * // Graceful shutdown
18
+ * await witness.flush();
19
+ *
20
+ * Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
21
+ */
22
+ import { randomUUID } from "node:crypto";
23
+ import { sha256Truncated } from "./fingerprint.js";
24
+ import { extractPayloads, extractGatekeeperPayload } from "./clearing.js";
25
+ import { WitnessBuffer } from "./buffer.js";
26
+ import { writeHandoffFiles } from "./handoff.js";
27
+ import { wrapOpenAI } from "./adapters/openai.js";
28
+ import { wrapAnthropic } from "./adapters/anthropic.js";
29
+ import { wrapBedrock } from "./adapters/bedrock.js";
30
+ import { createVercelOnFinish } from "./adapters/vercel-ai.js";
31
+ /**
32
+ * Raised when strict (gatekeeper) mode blocks an inference due to
33
+ * insufficient guardrails. The inference never reaches the AI model.
34
+ */
35
+ export class GatekeeperError extends Error {
36
+ required;
37
+ active;
38
+ missingNames;
39
+ constructor(required, active, missingNames = []) {
40
+ const msg = `Gatekeeper blocked: ${active} guardrails active, ${required} required` +
41
+ (missingNames.length ? `. Missing: ${missingNames.join(", ")}` : "");
42
+ super(msg);
43
+ this.name = "GatekeeperError";
44
+ this.required = required;
45
+ this.active = active;
46
+ this.missingNames = missingNames;
47
+ }
48
+ }
49
+ export class Witness {
50
+ config;
51
+ buffer;
52
+ handoffWarned = false;
53
+ _strict;
54
+ constructor(options) {
55
+ if (!options.endpoint)
56
+ throw new Error("endpoint is required");
57
+ if (!options.apiKey)
58
+ throw new Error("apiKey is required");
59
+ if (!options.apiKey.startsWith("axm_"))
60
+ throw new Error("apiKey must start with 'axm_'");
61
+ if (!options.tenantId)
62
+ throw new Error("tenantId is required");
63
+ if (options.factorHandoff && options.factorHandoff !== "file") {
64
+ throw new Error("factorHandoff must be 'file' (other methods planned for v0.4.0)");
65
+ }
66
+ if (options.factorHandoff === "file" && !options.factorHandoffPath) {
67
+ throw new Error("factorHandoffPath is required when factorHandoff is 'file'");
68
+ }
69
+ this.config = {
70
+ endpoint: options.endpoint.replace(/\/+$/, ""),
71
+ apiKey: options.apiKey,
72
+ tenantId: options.tenantId,
73
+ clearingLevel: options.clearingLevel ?? 1,
74
+ bufferSize: options.bufferSize ?? 10,
75
+ flushInterval: options.flushInterval ?? 5.0,
76
+ timeout: options.timeout ?? 10000,
77
+ maxRetries: options.maxRetries ?? 3,
78
+ latencyThresholdMs: options.latencyThresholdMs ?? 30000,
79
+ guardrailsRequired: options.guardrailsRequired ?? 0,
80
+ guardrailNames: options.guardrailNames ?? [],
81
+ procedures: options.procedures,
82
+ factorHandoff: options.factorHandoff,
83
+ factorHandoffPath: options.factorHandoffPath,
84
+ agentId: options.agentId,
85
+ signingKey: options.signingKey,
86
+ cycleId: options.cycleId,
87
+ policyVersion: options.policyVersion,
88
+ };
89
+ this._strict = options.strict ?? false;
90
+ this.buffer = new WitnessBuffer(this.config);
91
+ }
92
+ /**
93
+ * Wrap an AI client with transparent witnessing.
94
+ *
95
+ * Supported: OpenAI, Anthropic
96
+ * Returns a proxy that behaves identically to the original client.
97
+ *
98
+ * Usage:
99
+ * const client = witness.wrap(new OpenAI()) as OpenAI;
100
+ * const client = witness.wrap(new Anthropic()) as Anthropic;
101
+ */
102
+ wrap(client) {
103
+ const proto = Object.getPrototypeOf(client);
104
+ const name = proto?.constructor?.name ?? "";
105
+ const obj = client;
106
+ // OpenAI: has client.chat.completions
107
+ if (name === "OpenAI" || obj?.chat) {
108
+ return wrapOpenAI(client, this);
109
+ }
110
+ // Anthropic: has client.messages
111
+ if (name === "Anthropic" || (obj?.messages && !obj?.chat)) {
112
+ return wrapAnthropic(client, this);
113
+ }
114
+ // AWS Bedrock: has client.send and client.config
115
+ if (name === "BedrockRuntimeClient" || (obj?.send && obj?.config)) {
116
+ return wrapBedrock(client, this);
117
+ }
118
+ throw new TypeError(`Unsupported client: ${name || "unknown"}. Supported: OpenAI, Anthropic, BedrockRuntimeClient.`);
119
+ }
120
+ /** Whether strict (gatekeeper) mode is enabled. Used by adapters. */
121
+ get strict() {
122
+ return this._strict;
123
+ }
124
+ /**
125
+ * Pre-call guardrail gate (strict mode only).
126
+ *
127
+ * Evaluates whether configured guardrail requirements are met BEFORE
128
+ * the inference call reaches the AI model. If requirements are not met,
129
+ * throws `GatekeeperError` and mints an AI-GRD.3 anchor recording
130
+ * the rejection. The rejection is evidence — it is enqueued for flush.
131
+ *
132
+ * This method is SYNCHRONOUS — evaluates local config only, no network.
133
+ *
134
+ * @throws {GatekeeperError} if guardrail requirements are not met
135
+ */
136
+ gateCheck(_messages, _model) {
137
+ const required = this.config.guardrailsRequired;
138
+ const active = this.config.guardrailNames.length;
139
+ const gatePassed = active >= required;
140
+ // Mint AI-GRD.3 anchor regardless of outcome — rejection is evidence
141
+ const policyHash = this.config.policyVersion
142
+ ? sha256Truncated(this.config.policyVersion, 12)
143
+ : undefined;
144
+ const payload = extractGatekeeperPayload(this.config.tenantId, required, active, gatePassed, this.config.clearingLevel, this.config.agentId, this.config.signingKey, this.config.cycleId, policyHash);
145
+ this.buffer.enqueueMany([payload]);
146
+ if (!gatePassed) {
147
+ throw new GatekeeperError(required, active);
148
+ }
149
+ }
150
+ /**
151
+ * Wrap a function as a witnessed tool call (AI-TOOL.1).
152
+ *
153
+ * Usage:
154
+ * const search = witness.wrapTool(searchDatabase, "search_db");
155
+ * const result = await search("SELECT ...");
156
+ *
157
+ * Each call mints an AI-TOOL.1 anchor with:
158
+ * factor_a = 1 (tool was called)
159
+ * factor_b = latency_ms
160
+ * factor_c = 1 if succeeded, 0 if exception raised
161
+ */
162
+ wrapTool(fn, toolName) {
163
+ const name = toolName ?? fn.name ?? "anonymous";
164
+ const self = this;
165
+ const wrapper = function (...args) {
166
+ const callId = randomUUID().replace(/-/g, "").slice(0, 12);
167
+ const start = performance.now();
168
+ let succeeded = true;
169
+ let result;
170
+ const finish = () => {
171
+ const elapsedMs = Math.round(performance.now() - start);
172
+ const inputHash = sha256Truncated(JSON.stringify(args));
173
+ const outputHash = sha256Truncated(succeeded ? JSON.stringify(result) : "ERROR");
174
+ const record = {
175
+ modelId: name,
176
+ modelHash: sha256Truncated(name),
177
+ promptHash: inputHash,
178
+ responseHash: outputHash,
179
+ latencyMs: elapsedMs,
180
+ guardrailsActive: 0,
181
+ guardrailsRequired: 0,
182
+ guardrailPassed: true,
183
+ hasRefusal: !succeeded,
184
+ provider: "tool",
185
+ guardrailNames: [],
186
+ toolName: name,
187
+ toolCallId: callId,
188
+ };
189
+ self.record(record);
190
+ };
191
+ try {
192
+ result = fn.apply(this, args);
193
+ }
194
+ catch (err) {
195
+ succeeded = false;
196
+ finish();
197
+ throw err;
198
+ }
199
+ // Handle async functions (Promise detection)
200
+ if (result && typeof result.then === "function") {
201
+ return result.then((v) => {
202
+ result = v;
203
+ finish();
204
+ return v;
205
+ }, (err) => {
206
+ succeeded = false;
207
+ finish();
208
+ throw err;
209
+ });
210
+ }
211
+ finish();
212
+ return result;
213
+ };
214
+ return wrapper;
215
+ }
216
+ /**
217
+ * Wrap a function as a witnessed access attempt (AI-ACC.1).
218
+ *
219
+ * Usage:
220
+ * const queryDb = witness.wrapAccess(dbQuery, "prod-database", "read-only analytics");
221
+ * const result = await queryDb("SELECT ...");
222
+ *
223
+ * Each call mints an AI-ACC.1 anchor with:
224
+ * factor_a = 1 (access attempt occurred)
225
+ * factor_b = 1 if within declared scope (or no scope set), 0 if out of scope
226
+ * factor_c = 1 if access granted, 0 if denied/failed
227
+ */
228
+ wrapAccess(fn, resourceName, scope) {
229
+ const name = resourceName ?? fn.name ?? "unknown-resource";
230
+ const self = this;
231
+ const wrapper = function (...args) {
232
+ const start = performance.now();
233
+ let granted = true;
234
+ let result;
235
+ const finish = () => {
236
+ const elapsedMs = Math.round(performance.now() - start);
237
+ const inputHash = sha256Truncated(JSON.stringify(args));
238
+ const outputHash = sha256Truncated(granted ? JSON.stringify(result) : "ACCESS_DENIED");
239
+ const record = {
240
+ modelId: name,
241
+ modelHash: sha256Truncated(name),
242
+ promptHash: inputHash,
243
+ responseHash: outputHash,
244
+ latencyMs: elapsedMs,
245
+ guardrailsActive: 0,
246
+ guardrailsRequired: 0,
247
+ guardrailPassed: true,
248
+ hasRefusal: !granted,
249
+ provider: "access",
250
+ guardrailNames: [],
251
+ accessTarget: name,
252
+ accessGranted: granted,
253
+ accessScope: scope,
254
+ };
255
+ self.record(record);
256
+ };
257
+ try {
258
+ result = fn.apply(this, args);
259
+ }
260
+ catch (err) {
261
+ granted = false;
262
+ finish();
263
+ throw err;
264
+ }
265
+ // Handle async functions (Promise detection)
266
+ if (result && typeof result.then === "function") {
267
+ return result.then((v) => {
268
+ result = v;
269
+ finish();
270
+ return v;
271
+ }, (err) => {
272
+ granted = false;
273
+ finish();
274
+ throw err;
275
+ });
276
+ }
277
+ finish();
278
+ return result;
279
+ };
280
+ return wrapper;
281
+ }
282
+ /**
283
+ * Record a witnessed inference. Extracts factors, applies clearing,
284
+ * and enqueues payloads for background flush.
285
+ *
286
+ * If factorHandoff is configured, factors are written to the handoff
287
+ * destination BEFORE clearing proceeds. If the handoff fails, the
288
+ * payload is NOT transmitted.
289
+ */
290
+ record(inference) {
291
+ // Merge guardrail config
292
+ if (this.config.guardrailNames.length > 0 && inference.guardrailNames.length === 0) {
293
+ inference.guardrailNames = this.config.guardrailNames;
294
+ inference.guardrailsActive = this.config.guardrailNames.length;
295
+ inference.guardrailsRequired = this.config.guardrailsRequired;
296
+ }
297
+ const policyHash = this.config.policyVersion
298
+ ? sha256Truncated(this.config.policyVersion, 12)
299
+ : undefined;
300
+ const payloads = extractPayloads(inference, this.config.tenantId, this.config.clearingLevel, this.config.latencyThresholdMs, this.config.guardrailsRequired, this.config.procedures, this.config.agentId, this.config.signingKey, this.config.cycleId, policyHash);
301
+ // Factor handoff: write full (uncleared) data to custody destination
302
+ // BEFORE enqueuing the cleared payload for transmission.
303
+ // If this fails, we do NOT proceed.
304
+ if (this.config.factorHandoff === "file" && this.config.factorHandoffPath) {
305
+ writeHandoffFiles(payloads, inference, this.config.tenantId, this.config.factorHandoffPath);
306
+ if (!this.handoffWarned) {
307
+ this.handoffWarned = true;
308
+ console.info(`\n [SWT3] ${payloads.length} anchors saved locally to ${this.config.factorHandoffPath}` +
309
+ `\n [SWT3] \u26a0 Local anchors won\u2019t survive a compliance audit.` +
310
+ `\n [SWT3] Connect to Axiom Engine \u2192 https://sovereign.tenova.io/signup?ref=sdk (free)\n`);
311
+ }
312
+ }
313
+ this.buffer.enqueueMany(payloads);
314
+ }
315
+ /**
316
+ * Create a Vercel AI SDK `onFinish` callback for streamText / generateText.
317
+ *
318
+ * Usage:
319
+ * const result = await streamText({
320
+ * model: openai("gpt-4o"),
321
+ * prompt: myPrompt,
322
+ * onFinish: witness.vercelOnFinish({ promptText: myPrompt }),
323
+ * });
324
+ */
325
+ vercelOnFinish(options) {
326
+ return createVercelOnFinish(this, options);
327
+ }
328
+ /** Force-flush all buffered payloads. */
329
+ async flush() {
330
+ return this.buffer.flush();
331
+ }
332
+ /** Stop the witness and flush remaining payloads. */
333
+ async stop() {
334
+ return this.buffer.stop();
335
+ }
336
+ /** Number of payloads waiting. */
337
+ get pending() {
338
+ return this.buffer.pending;
339
+ }
340
+ /** All receipts from completed flushes. */
341
+ get receipts() {
342
+ return this.buffer.receipts;
343
+ }
344
+ }
345
+ //# sourceMappingURL=witness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"witness.js","sourceRoot":"","sources":["../src/witness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAA8B,MAAM,yBAAyB,CAAC;AAyB3F;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,QAAQ,CAAS;IACjB,MAAM,CAAS;IACf,YAAY,CAAW;IAEhC,YAAY,QAAgB,EAAE,MAAc,EAAE,eAAyB,EAAE;QACvE,MAAM,GAAG,GAAG,uBAAuB,MAAM,uBAAuB,QAAQ,WAAW;YACjF,CAAC,YAAY,CAAC,MAAM,CAAC,CA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AAC;IAC9B,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenova/swt3-ai",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "SWT3 AI Witness SDK: cryptographic attestation for AI inference",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",