@tenova/swt3-ai 0.1.0 → 0.2.1
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 +44 -14
- package/dist/adapters/bedrock.d.ts +33 -0
- package/dist/adapters/bedrock.d.ts.map +1 -0
- package/dist/adapters/bedrock.js +259 -0
- package/dist/adapters/bedrock.js.map +1 -0
- package/dist/handoff.d.ts +17 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +82 -0
- package/dist/handoff.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/witness.d.ts +8 -0
- package/dist/witness.d.ts.map +1 -1
- package/dist/witness.js +27 -1
- package/dist/witness.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@ Cryptographic AI Governance for the Edge. Zero Latency. Zero Data Retention.
|
|
|
2
2
|
|
|
3
3
|
# @tenova/swt3-ai
|
|
4
4
|
|
|
5
|
-
**SWT3 AI Witness SDK for TypeScript
|
|
5
|
+
**SWT3 AI Witness SDK for TypeScript**: continuous, cryptographic attestation for AI systems. Prove your models are running approved weights, safety guardrails are active, and inferences are traceable. All without a single prompt or response ever leaving your infrastructure.
|
|
6
6
|
|
|
7
7
|
Works with OpenAI, Anthropic, Vercel AI SDK, and any OpenAI-compatible endpoint (vLLM, Ollama, Azure, Llama.cpp).
|
|
8
8
|
|
|
@@ -22,14 +22,14 @@ const witness = new Witness({
|
|
|
22
22
|
|
|
23
23
|
const client = witness.wrap(new OpenAI()) as OpenAI;
|
|
24
24
|
|
|
25
|
-
// Non-streaming
|
|
25
|
+
// Non-streaming, works exactly as before
|
|
26
26
|
const response = await client.chat.completions.create({
|
|
27
27
|
model: "gpt-4o",
|
|
28
28
|
messages: [{ role: "user", content: "Summarize this contract..." }],
|
|
29
29
|
});
|
|
30
30
|
console.log(response.choices[0].message.content);
|
|
31
31
|
|
|
32
|
-
// Streaming
|
|
32
|
+
// Streaming, also works. Chunks arrive in real-time, witnessing happens after.
|
|
33
33
|
const stream = await client.chat.completions.create({
|
|
34
34
|
model: "gpt-4o",
|
|
35
35
|
messages: [{ role: "user", content: "Explain quantum computing" }],
|
|
@@ -93,17 +93,17 @@ const result = await streamText({
|
|
|
93
93
|
onFinish: witness.vercelOnFinish({ promptText: prompt }),
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
// Works with any Vercel AI SDK provider
|
|
96
|
+
// Works with any Vercel AI SDK provider:OpenAI, Anthropic, Google, Mistral, custom
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
The `onFinish` hook is framework-idiomatic: no wrapping, no proxying, no monkey-patching. It fires after the stream completes and receives a normalized result regardless of provider.
|
|
100
100
|
|
|
101
101
|
## Sovereign Cloud Support
|
|
102
102
|
|
|
103
|
-
The SDK works out-of-the-box with any OpenAI-compatible endpoint. Run Llama 3 on vLLM, Mistral on Ollama, or any model behind an OpenAI-compatible API
|
|
103
|
+
The SDK works out-of-the-box with any OpenAI-compatible endpoint. Run Llama 3 on vLLM, Mistral on Ollama, or any model behind an OpenAI-compatible API:every inference is witnessed identically.
|
|
104
104
|
|
|
105
105
|
```typescript
|
|
106
|
-
// vLLM with Llama 3
|
|
106
|
+
// vLLM with Llama 3, sovereign cloud, your hardware
|
|
107
107
|
const client = witness.wrap(
|
|
108
108
|
new OpenAI({ baseURL: "http://gpu-cluster.internal:8000/v1" }),
|
|
109
109
|
) as OpenAI;
|
|
@@ -112,7 +112,7 @@ const response = await client.chat.completions.create({
|
|
|
112
112
|
model: "meta-llama/Meta-Llama-3-70B-Instruct",
|
|
113
113
|
messages: [{ role: "user", content: "Classify this threat indicator" }],
|
|
114
114
|
});
|
|
115
|
-
// Same SWT3 anchor, same ledger, same audit trail
|
|
115
|
+
// Same SWT3 anchor, same ledger, same audit trail:regardless of where the model runs
|
|
116
116
|
|
|
117
117
|
// Ollama (local development)
|
|
118
118
|
const localClient = witness.wrap(
|
|
@@ -130,12 +130,12 @@ const azureClient = witness.wrap(
|
|
|
130
130
|
|
|
131
131
|
## What Happens Per Inference
|
|
132
132
|
|
|
133
|
-
1. **Intercept
|
|
134
|
-
2. **Hash
|
|
135
|
-
3. **Extract
|
|
136
|
-
4. **Clear
|
|
137
|
-
5. **Buffer
|
|
138
|
-
6. **Return
|
|
133
|
+
1. **Intercept**: ES6 Proxy wraps your AI client transparently
|
|
134
|
+
2. **Hash**: Prompts and responses are SHA-256 hashed in-process
|
|
135
|
+
3. **Extract**: Model hash, latency, token count, refusal status as numeric factors
|
|
136
|
+
4. **Clear**: Raw text is purged from the wire payload (configurable clearing level)
|
|
137
|
+
5. **Buffer**: Factors queued in background, flushed to the SWT3 ledger asynchronously
|
|
138
|
+
6. **Return**: Your original response returns untouched, zero added latency
|
|
139
139
|
|
|
140
140
|
For streaming: chunks arrive to the developer in real-time. The SDK accumulates content in the background and witnesses after the stream completes.
|
|
141
141
|
|
|
@@ -148,7 +148,7 @@ For streaming: chunks arrive to the developer in real-time. The SDK accumulates
|
|
|
148
148
|
| 2 | Sensitive | Hashes + factors + model only | Healthcare, legal, PII |
|
|
149
149
|
| 3 | Classified | Numeric factors only. Model ID hashed. | Defense, air-gapped |
|
|
150
150
|
|
|
151
|
-
At Level 1+, raw prompts and responses **never leave your infrastructure**. The witness endpoint is a "Blind Registrar"
|
|
151
|
+
At Level 1+, raw prompts and responses **never leave your infrastructure**. The witness endpoint is a "Blind Registrar":it stores cryptographic proofs, not data.
|
|
152
152
|
|
|
153
153
|
```typescript
|
|
154
154
|
// Healthcare deployment: Level 2
|
|
@@ -224,6 +224,8 @@ npm install @anthropic-ai/sdk # for Anthropic adapter
|
|
|
224
224
|
| `timeout` | `10000` | HTTP timeout (ms) |
|
|
225
225
|
| `maxRetries` | `3` | Retries before dead-letter |
|
|
226
226
|
| `guardrailNames` | `[]` | Active guardrail names |
|
|
227
|
+
| `factorHandoff` | - | `"file"` to enable local factor export |
|
|
228
|
+
| `factorHandoffPath` | - | Directory for factor handoff files |
|
|
227
229
|
|
|
228
230
|
### `witness.wrap(client)`
|
|
229
231
|
|
|
@@ -241,6 +243,34 @@ Force-flush all buffered payloads. Returns receipts.
|
|
|
241
243
|
|
|
242
244
|
Stop the witness and flush remaining payloads.
|
|
243
245
|
|
|
246
|
+
## Factor Handoff (Clearing Level 2+)
|
|
247
|
+
|
|
248
|
+
At Clearing Level 2 or 3, some or all verifiable data is stripped before it reaches the witness endpoint. The Factor Handoff writes your factors to a local directory **before** clearing proceeds. If the write fails, the payload is not transmitted.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
const witness = new Witness({
|
|
252
|
+
endpoint: "https://sovereign.tenova.io",
|
|
253
|
+
apiKey: "axm_live_...",
|
|
254
|
+
tenantId: "YOUR_ENCLAVE",
|
|
255
|
+
clearingLevel: 3,
|
|
256
|
+
factorHandoff: "file",
|
|
257
|
+
factorHandoffPath: "/secure/vault/factors/",
|
|
258
|
+
});
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Each anchor gets its own JSON file containing the full uncleared factors and metadata for independent re-verification.
|
|
262
|
+
|
|
263
|
+
For the full protocol specification, see the [Factor Handoff Protocol](https://sovereign.tenova.io/docs/factor-handoff-protocol.html).
|
|
264
|
+
|
|
265
|
+
## Documentation
|
|
266
|
+
|
|
267
|
+
- [SDK Developer Docs](https://sovereign.tenova.io/docs/) - Quickstart, providers, clearing levels, configuration
|
|
268
|
+
- [Factor Handoff Protocol](https://sovereign.tenova.io/docs/factor-handoff-protocol.html) - How factors are securely transferred to your custody
|
|
269
|
+
- [Clearing Protocol Terms](https://sovereign.tenova.io/terms/clearing-addendum) - Shared responsibility model and liability
|
|
270
|
+
- [CMMC Compliance Overlay](https://sovereign.tenova.io/guides/cmmc-overlay.html) - Control mappings for defense industrial base
|
|
271
|
+
|
|
244
272
|
---
|
|
245
273
|
|
|
246
274
|
*SWT3: Sovereign Witness Traceability. We don't run your models. We witness them.*
|
|
275
|
+
|
|
276
|
+
SWT3 and Sovereign Witness Traceability are trademarks of Tenable Nova LLC. Patent pending. Apache 2.0 licensed.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK — AWS Bedrock Adapter (ES6 Proxy).
|
|
3
|
+
*
|
|
4
|
+
* Wraps the @aws-sdk/client-bedrock-runtime client so that
|
|
5
|
+
* `client.send(new ConverseCommand(...))` and
|
|
6
|
+
* `client.send(new InvokeModelCommand(...))` are intercepted.
|
|
7
|
+
*
|
|
8
|
+
* AWS Bedrock uses the Command pattern:
|
|
9
|
+
* const response = await client.send(new ConverseCommand({ modelId, messages }));
|
|
10
|
+
*
|
|
11
|
+
* The adapter intercepts `send()` and checks if the command is a
|
|
12
|
+
* ConverseCommand or InvokeModelCommand to extract factors.
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
15
|
+
*/
|
|
16
|
+
import type { Witness } from "../witness.js";
|
|
17
|
+
/**
|
|
18
|
+
* Wrap a BedrockRuntimeClient with transparent witnessing.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* import { BedrockRuntimeClient, ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
|
|
22
|
+
* import { Witness } from "@tenova/swt3-ai";
|
|
23
|
+
*
|
|
24
|
+
* const witness = new Witness({ endpoint, apiKey, tenantId });
|
|
25
|
+
* const client = witness.wrap(new BedrockRuntimeClient({ region: "us-east-1" }));
|
|
26
|
+
*
|
|
27
|
+
* const response = await client.send(new ConverseCommand({
|
|
28
|
+
* modelId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
29
|
+
* messages: [{ role: "user", content: [{ text: "Hello" }] }],
|
|
30
|
+
* }));
|
|
31
|
+
*/
|
|
32
|
+
export declare function wrapBedrock(client: unknown, witness: Witness): unknown;
|
|
33
|
+
//# sourceMappingURL=bedrock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bedrock.d.ts","sourceRoot":"","sources":["../../src/adapters/bedrock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAatE"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK — AWS Bedrock Adapter (ES6 Proxy).
|
|
3
|
+
*
|
|
4
|
+
* Wraps the @aws-sdk/client-bedrock-runtime client so that
|
|
5
|
+
* `client.send(new ConverseCommand(...))` and
|
|
6
|
+
* `client.send(new InvokeModelCommand(...))` are intercepted.
|
|
7
|
+
*
|
|
8
|
+
* AWS Bedrock uses the Command pattern:
|
|
9
|
+
* const response = await client.send(new ConverseCommand({ modelId, messages }));
|
|
10
|
+
*
|
|
11
|
+
* The adapter intercepts `send()` and checks if the command is a
|
|
12
|
+
* ConverseCommand or InvokeModelCommand to extract factors.
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
15
|
+
*/
|
|
16
|
+
import { sha256Truncated } from "../fingerprint.js";
|
|
17
|
+
/**
|
|
18
|
+
* Wrap a BedrockRuntimeClient with transparent witnessing.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* import { BedrockRuntimeClient, ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
|
|
22
|
+
* import { Witness } from "@tenova/swt3-ai";
|
|
23
|
+
*
|
|
24
|
+
* const witness = new Witness({ endpoint, apiKey, tenantId });
|
|
25
|
+
* const client = witness.wrap(new BedrockRuntimeClient({ region: "us-east-1" }));
|
|
26
|
+
*
|
|
27
|
+
* const response = await client.send(new ConverseCommand({
|
|
28
|
+
* modelId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
29
|
+
* messages: [{ role: "user", content: [{ text: "Hello" }] }],
|
|
30
|
+
* }));
|
|
31
|
+
*/
|
|
32
|
+
export function wrapBedrock(client, witness) {
|
|
33
|
+
return new Proxy(client, {
|
|
34
|
+
get(target, prop) {
|
|
35
|
+
if (typeof prop === "symbol")
|
|
36
|
+
return Reflect.get(target, prop);
|
|
37
|
+
const real = Reflect.get(target, prop);
|
|
38
|
+
if (prop === "send" && typeof real === "function") {
|
|
39
|
+
return createSendInterceptor(real, witness, target);
|
|
40
|
+
}
|
|
41
|
+
return real;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function createSendInterceptor(realSend, witness, thisArg) {
|
|
46
|
+
return async function interceptedSend(...args) {
|
|
47
|
+
const command = args[0];
|
|
48
|
+
if (!command)
|
|
49
|
+
return realSend.call(thisArg, ...args);
|
|
50
|
+
// Detect command type by constructor name
|
|
51
|
+
const commandName = command.constructor?.name ?? "";
|
|
52
|
+
if (commandName === "ConverseCommand") {
|
|
53
|
+
return handleConverse(realSend, thisArg, command, witness, args);
|
|
54
|
+
}
|
|
55
|
+
if (commandName === "InvokeModelCommand") {
|
|
56
|
+
return handleInvokeModel(realSend, thisArg, command, witness, args);
|
|
57
|
+
}
|
|
58
|
+
// Not a command we intercept — pass through
|
|
59
|
+
return realSend.call(thisArg, ...args);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// ── Converse Command Handler ──────────────────────────────────────
|
|
63
|
+
async function handleConverse(realSend, thisArg, command, witness, args) {
|
|
64
|
+
const input = command.input ?? command;
|
|
65
|
+
const modelId = input.modelId ?? "unknown";
|
|
66
|
+
const messages = input.messages ?? [];
|
|
67
|
+
const promptText = extractConversePrompt(messages);
|
|
68
|
+
const promptHash = sha256Truncated(promptText);
|
|
69
|
+
const start = performance.now();
|
|
70
|
+
const response = await realSend.call(thisArg, ...args);
|
|
71
|
+
const elapsedMs = Math.round(performance.now() - start);
|
|
72
|
+
const resp = response;
|
|
73
|
+
const record = extractConverseRecord(resp, modelId, promptHash, elapsedMs);
|
|
74
|
+
witness.record(record);
|
|
75
|
+
return response;
|
|
76
|
+
}
|
|
77
|
+
// ── InvokeModel Command Handler ──────────────────────────────────
|
|
78
|
+
async function handleInvokeModel(realSend, thisArg, command, witness, args) {
|
|
79
|
+
const input = command.input ?? command;
|
|
80
|
+
const modelId = input.modelId ?? "unknown";
|
|
81
|
+
// Parse the body to get prompt
|
|
82
|
+
let body = {};
|
|
83
|
+
const rawBody = input.body;
|
|
84
|
+
if (typeof rawBody === "string") {
|
|
85
|
+
try {
|
|
86
|
+
body = JSON.parse(rawBody);
|
|
87
|
+
}
|
|
88
|
+
catch { /* empty */ }
|
|
89
|
+
}
|
|
90
|
+
else if (rawBody instanceof Uint8Array) {
|
|
91
|
+
try {
|
|
92
|
+
body = JSON.parse(new TextDecoder().decode(rawBody));
|
|
93
|
+
}
|
|
94
|
+
catch { /* empty */ }
|
|
95
|
+
}
|
|
96
|
+
const promptText = extractInvokePrompt(body, modelId);
|
|
97
|
+
const promptHash = sha256Truncated(promptText);
|
|
98
|
+
const start = performance.now();
|
|
99
|
+
const response = await realSend.call(thisArg, ...args);
|
|
100
|
+
const elapsedMs = Math.round(performance.now() - start);
|
|
101
|
+
const resp = response;
|
|
102
|
+
const record = extractInvokeRecord(resp, modelId, promptHash, elapsedMs);
|
|
103
|
+
witness.record(record);
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
// ── Prompt Extraction ─────────────────────────────────────────────
|
|
107
|
+
function extractConversePrompt(messages) {
|
|
108
|
+
const parts = [];
|
|
109
|
+
for (const msg of messages) {
|
|
110
|
+
const m = msg;
|
|
111
|
+
const content = m.content;
|
|
112
|
+
if (Array.isArray(content)) {
|
|
113
|
+
for (const block of content) {
|
|
114
|
+
const b = block;
|
|
115
|
+
if (b.text)
|
|
116
|
+
parts.push(b.text);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (typeof content === "string") {
|
|
120
|
+
parts.push(content);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return parts.join("\n");
|
|
124
|
+
}
|
|
125
|
+
function extractInvokePrompt(body, modelId) {
|
|
126
|
+
// Anthropic on Bedrock
|
|
127
|
+
const messages = body.messages;
|
|
128
|
+
if (messages?.length) {
|
|
129
|
+
const parts = [];
|
|
130
|
+
for (const msg of messages) {
|
|
131
|
+
const m = msg;
|
|
132
|
+
const content = m.content;
|
|
133
|
+
if (typeof content === "string") {
|
|
134
|
+
parts.push(content);
|
|
135
|
+
}
|
|
136
|
+
else if (Array.isArray(content)) {
|
|
137
|
+
for (const block of content) {
|
|
138
|
+
const b = block;
|
|
139
|
+
if (b.type === "text" && b.text)
|
|
140
|
+
parts.push(b.text);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (parts.length)
|
|
145
|
+
return parts.join("\n");
|
|
146
|
+
}
|
|
147
|
+
// Amazon Titan
|
|
148
|
+
if (body.inputText)
|
|
149
|
+
return body.inputText;
|
|
150
|
+
// Meta Llama
|
|
151
|
+
if (body.prompt)
|
|
152
|
+
return body.prompt;
|
|
153
|
+
return JSON.stringify(body);
|
|
154
|
+
}
|
|
155
|
+
// ── Record Extraction ─────────────────────────────────────────────
|
|
156
|
+
function extractConverseRecord(response, modelId, promptHash, elapsedMs) {
|
|
157
|
+
let responseText = "";
|
|
158
|
+
let hasRefusal = false;
|
|
159
|
+
const output = response.output;
|
|
160
|
+
const message = output?.message;
|
|
161
|
+
const content = message?.content;
|
|
162
|
+
if (content) {
|
|
163
|
+
for (const block of content) {
|
|
164
|
+
if (block.text)
|
|
165
|
+
responseText += block.text;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const stopReason = response.stopReason;
|
|
169
|
+
if (stopReason === "content_filtered")
|
|
170
|
+
hasRefusal = true;
|
|
171
|
+
const usage = response.usage;
|
|
172
|
+
const inputTokens = usage?.inputTokens;
|
|
173
|
+
const outputTokens = usage?.outputTokens;
|
|
174
|
+
return {
|
|
175
|
+
modelId: modelId,
|
|
176
|
+
modelHash: sha256Truncated(modelId),
|
|
177
|
+
promptHash: promptHash,
|
|
178
|
+
responseHash: sha256Truncated(responseText || ""),
|
|
179
|
+
latencyMs: elapsedMs,
|
|
180
|
+
inputTokens: inputTokens ?? undefined,
|
|
181
|
+
outputTokens: outputTokens ?? undefined,
|
|
182
|
+
hasRefusal: hasRefusal,
|
|
183
|
+
provider: "bedrock",
|
|
184
|
+
systemFingerprint: undefined,
|
|
185
|
+
guardrailsActive: 0,
|
|
186
|
+
guardrailsRequired: 0,
|
|
187
|
+
guardrailPassed: true,
|
|
188
|
+
guardrailNames: [],
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function extractInvokeRecord(response, modelId, promptHash, elapsedMs) {
|
|
192
|
+
let responseText = "";
|
|
193
|
+
let hasRefusal = false;
|
|
194
|
+
let inputTokens = null;
|
|
195
|
+
let outputTokens = null;
|
|
196
|
+
try {
|
|
197
|
+
let body = {};
|
|
198
|
+
const rawBody = response.body;
|
|
199
|
+
if (rawBody instanceof Uint8Array) {
|
|
200
|
+
body = JSON.parse(new TextDecoder().decode(rawBody));
|
|
201
|
+
}
|
|
202
|
+
else if (typeof rawBody === "string") {
|
|
203
|
+
body = JSON.parse(rawBody);
|
|
204
|
+
}
|
|
205
|
+
// Anthropic on Bedrock
|
|
206
|
+
if (body.content) {
|
|
207
|
+
const content = body.content;
|
|
208
|
+
if (Array.isArray(content)) {
|
|
209
|
+
for (const block of content) {
|
|
210
|
+
if (block.type === "text" && block.text)
|
|
211
|
+
responseText += block.text;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (typeof content === "string") {
|
|
215
|
+
responseText = content;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Amazon Titan
|
|
219
|
+
else if (body.results) {
|
|
220
|
+
const results = body.results;
|
|
221
|
+
if (results[0]?.outputText)
|
|
222
|
+
responseText = results[0].outputText;
|
|
223
|
+
}
|
|
224
|
+
// Meta Llama
|
|
225
|
+
else if (body.generation) {
|
|
226
|
+
responseText = body.generation;
|
|
227
|
+
}
|
|
228
|
+
// Usage
|
|
229
|
+
const usage = body.usage;
|
|
230
|
+
if (usage) {
|
|
231
|
+
inputTokens = (usage.input_tokens ?? usage.inputTokens ?? null);
|
|
232
|
+
outputTokens = (usage.output_tokens ?? usage.outputTokens ?? null);
|
|
233
|
+
}
|
|
234
|
+
// Refusal
|
|
235
|
+
const stopReason = (body.stop_reason ?? body.stopReason ?? "");
|
|
236
|
+
if (stopReason.toLowerCase().includes("content_filter"))
|
|
237
|
+
hasRefusal = true;
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// Parse failure — still witness with what we have
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
modelId: modelId,
|
|
244
|
+
modelHash: sha256Truncated(modelId),
|
|
245
|
+
promptHash: promptHash,
|
|
246
|
+
responseHash: sha256Truncated(responseText || ""),
|
|
247
|
+
latencyMs: elapsedMs,
|
|
248
|
+
inputTokens: inputTokens ?? undefined,
|
|
249
|
+
outputTokens: outputTokens ?? undefined,
|
|
250
|
+
hasRefusal: hasRefusal,
|
|
251
|
+
provider: "bedrock",
|
|
252
|
+
systemFingerprint: undefined,
|
|
253
|
+
guardrailsActive: 0,
|
|
254
|
+
guardrailsRequired: 0,
|
|
255
|
+
guardrailPassed: true,
|
|
256
|
+
guardrailNames: [],
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=bedrock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bedrock.js","sourceRoot":"","sources":["../../src/adapters/bedrock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU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S;QACvC,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,SAAS;QACnB,iBAAiB,EAAE,SAAS;QAC5B,gBAAgB,EAAE,CAAC;QACnB,kBAAkB,EAAE,CAAC;QACrB,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK — Factor Handoff (Local File Export).
|
|
3
|
+
*
|
|
4
|
+
* Writes factor data to local JSON files before the clearing engine strips
|
|
5
|
+
* them from the wire payload. If the write fails, clearing does NOT proceed.
|
|
6
|
+
*
|
|
7
|
+
* Spec: SWT3 Factor Handoff Protocol v1.0.0
|
|
8
|
+
*/
|
|
9
|
+
import type { WitnessPayload, InferenceRecord } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Write one JSON file per payload to the handoff directory.
|
|
12
|
+
*
|
|
13
|
+
* Throws on failure — the caller must NOT proceed with clearing
|
|
14
|
+
* if this function throws.
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeHandoffFiles(payloads: WitnessPayload[], inference: InferenceRecord, tenantId: string, handoffPath: string): void;
|
|
17
|
+
//# sourceMappingURL=handoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAoClE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,cAAc,EAAE,EAC1B,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,IAAI,CA+BN"}
|
package/dist/handoff.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK — Factor Handoff (Local File Export).
|
|
3
|
+
*
|
|
4
|
+
* Writes factor data to local JSON files before the clearing engine strips
|
|
5
|
+
* them from the wire payload. If the write fails, clearing does NOT proceed.
|
|
6
|
+
*
|
|
7
|
+
* Spec: SWT3 Factor Handoff Protocol v1.0.0
|
|
8
|
+
*/
|
|
9
|
+
import { writeFileSync, mkdirSync, renameSync, unlinkSync, chmodSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
const HANDOFF_VERSION = "1.0.0";
|
|
12
|
+
/**
|
|
13
|
+
* Write one JSON file per payload to the handoff directory.
|
|
14
|
+
*
|
|
15
|
+
* Throws on failure — the caller must NOT proceed with clearing
|
|
16
|
+
* if this function throws.
|
|
17
|
+
*/
|
|
18
|
+
export function writeHandoffFiles(payloads, inference, tenantId, handoffPath) {
|
|
19
|
+
mkdirSync(handoffPath, { recursive: true });
|
|
20
|
+
for (const payload of payloads) {
|
|
21
|
+
const record = buildHandoffRecord(payload, inference, tenantId);
|
|
22
|
+
const filename = `${payload.anchor_fingerprint}.json`;
|
|
23
|
+
const filepath = join(handoffPath, filename);
|
|
24
|
+
const tmpPath = filepath + ".tmp";
|
|
25
|
+
try {
|
|
26
|
+
writeFileSync(tmpPath, JSON.stringify(record, null, 2) + "\n", "utf-8");
|
|
27
|
+
// Set restrictive permissions (owner read/write only, 0o600)
|
|
28
|
+
try {
|
|
29
|
+
chmodSync(tmpPath, 0o600);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// chmod may not be supported on all platforms (e.g., Windows)
|
|
33
|
+
}
|
|
34
|
+
// Atomic rename
|
|
35
|
+
renameSync(tmpPath, filepath);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
// Clean up temp file on failure
|
|
39
|
+
try {
|
|
40
|
+
unlinkSync(tmpPath);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// ignore cleanup errors
|
|
44
|
+
}
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function buildHandoffRecord(payload, inference, tenantId) {
|
|
50
|
+
return {
|
|
51
|
+
handoff_version: HANDOFF_VERSION,
|
|
52
|
+
handoff_type: `clearing_level_${payload.clearing_level}`,
|
|
53
|
+
tenant_id: tenantId,
|
|
54
|
+
timestamp_iso: new Date(payload.anchor_epoch * 1000).toISOString(),
|
|
55
|
+
anchor_fingerprint: payload.anchor_fingerprint,
|
|
56
|
+
anchor_epoch: payload.anchor_epoch,
|
|
57
|
+
fingerprint_timestamp_ms: payload.fingerprint_timestamp_ms,
|
|
58
|
+
clearing_level: payload.clearing_level,
|
|
59
|
+
factors: {
|
|
60
|
+
procedure_id: payload.procedure_id,
|
|
61
|
+
factor_a: payload.factor_a,
|
|
62
|
+
factor_b: payload.factor_b,
|
|
63
|
+
factor_c: payload.factor_c,
|
|
64
|
+
},
|
|
65
|
+
metadata: {
|
|
66
|
+
ai_model_id: inference.modelId,
|
|
67
|
+
ai_model_hash: inference.modelHash,
|
|
68
|
+
ai_prompt_hash: inference.promptHash,
|
|
69
|
+
ai_response_hash: inference.responseHash,
|
|
70
|
+
ai_latency_ms: inference.latencyMs,
|
|
71
|
+
ai_input_tokens: inference.inputTokens,
|
|
72
|
+
ai_output_tokens: inference.outputTokens,
|
|
73
|
+
ai_provider: inference.provider,
|
|
74
|
+
ai_system_fingerprint: inference.systemFingerprint,
|
|
75
|
+
ai_guardrail_names: inference.guardrailNames ?? [],
|
|
76
|
+
ai_guardrails_active: inference.guardrailsActive,
|
|
77
|
+
ai_guardrails_required: inference.guardrailsRequired,
|
|
78
|
+
ai_guardrail_passed: inference.guardrailPassed,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAE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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,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
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,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAA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AM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,mDAAmD;AACnD,eAAO,MAAM,aAAa,aAQxB,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AA8EH,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;CACzB,CAAC,CAAC"}
|
package/dist/witness.d.ts
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
*
|
|
17
17
|
* // Graceful shutdown
|
|
18
18
|
* await witness.flush();
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
19
21
|
*/
|
|
20
22
|
import { type VercelOnFinishOptions } from "./adapters/vercel-ai.js";
|
|
21
23
|
import type { WitnessReceipt, InferenceRecord } from "./types.js";
|
|
@@ -32,6 +34,8 @@ export interface WitnessOptions {
|
|
|
32
34
|
guardrailsRequired?: number;
|
|
33
35
|
guardrailNames?: string[];
|
|
34
36
|
procedures?: string[];
|
|
37
|
+
factorHandoff?: "file";
|
|
38
|
+
factorHandoffPath?: string;
|
|
35
39
|
}
|
|
36
40
|
export declare class Witness {
|
|
37
41
|
private config;
|
|
@@ -51,6 +55,10 @@ export declare class Witness {
|
|
|
51
55
|
/**
|
|
52
56
|
* Record a witnessed inference. Extracts factors, applies clearing,
|
|
53
57
|
* and enqueues payloads for background flush.
|
|
58
|
+
*
|
|
59
|
+
* If factorHandoff is configured, factors are written to the handoff
|
|
60
|
+
* destination BEFORE clearing proceeds. If the handoff fails, the
|
|
61
|
+
* payload is NOT transmitted.
|
|
54
62
|
*/
|
|
55
63
|
record(inference: InferenceRecord): void;
|
|
56
64
|
/**
|
package/dist/witness.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"witness.d.ts","sourceRoot":"","sources":["../src/witness.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"witness.d.ts","sourceRoot":"","sources":["../src/witness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AASH,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,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAgB;gBAElB,OAAO,EAAE,cAAc;IAgCnC;;;;;;;;;OASG;IACH,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;IAyB9B;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IA2BxC;;;;;;;;;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"}
|
package/dist/witness.js
CHANGED
|
@@ -16,11 +16,15 @@
|
|
|
16
16
|
*
|
|
17
17
|
* // Graceful shutdown
|
|
18
18
|
* await witness.flush();
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
19
21
|
*/
|
|
20
22
|
import { extractPayloads } from "./clearing.js";
|
|
21
23
|
import { WitnessBuffer } from "./buffer.js";
|
|
24
|
+
import { writeHandoffFiles } from "./handoff.js";
|
|
22
25
|
import { wrapOpenAI } from "./adapters/openai.js";
|
|
23
26
|
import { wrapAnthropic } from "./adapters/anthropic.js";
|
|
27
|
+
import { wrapBedrock } from "./adapters/bedrock.js";
|
|
24
28
|
import { createVercelOnFinish } from "./adapters/vercel-ai.js";
|
|
25
29
|
export class Witness {
|
|
26
30
|
config;
|
|
@@ -34,6 +38,12 @@ export class Witness {
|
|
|
34
38
|
throw new Error("apiKey must start with 'axm_'");
|
|
35
39
|
if (!options.tenantId)
|
|
36
40
|
throw new Error("tenantId is required");
|
|
41
|
+
if (options.factorHandoff && options.factorHandoff !== "file") {
|
|
42
|
+
throw new Error("factorHandoff must be 'file' (other methods planned for v0.4.0)");
|
|
43
|
+
}
|
|
44
|
+
if (options.factorHandoff === "file" && !options.factorHandoffPath) {
|
|
45
|
+
throw new Error("factorHandoffPath is required when factorHandoff is 'file'");
|
|
46
|
+
}
|
|
37
47
|
this.config = {
|
|
38
48
|
endpoint: options.endpoint.replace(/\/+$/, ""),
|
|
39
49
|
apiKey: options.apiKey,
|
|
@@ -47,6 +57,8 @@ export class Witness {
|
|
|
47
57
|
guardrailsRequired: options.guardrailsRequired ?? 0,
|
|
48
58
|
guardrailNames: options.guardrailNames ?? [],
|
|
49
59
|
procedures: options.procedures,
|
|
60
|
+
factorHandoff: options.factorHandoff,
|
|
61
|
+
factorHandoffPath: options.factorHandoffPath,
|
|
50
62
|
};
|
|
51
63
|
this.buffer = new WitnessBuffer(this.config);
|
|
52
64
|
}
|
|
@@ -72,11 +84,19 @@ export class Witness {
|
|
|
72
84
|
if (name === "Anthropic" || (obj?.messages && !obj?.chat)) {
|
|
73
85
|
return wrapAnthropic(client, this);
|
|
74
86
|
}
|
|
75
|
-
|
|
87
|
+
// AWS Bedrock: has client.send and client.config
|
|
88
|
+
if (name === "BedrockRuntimeClient" || (obj?.send && obj?.config)) {
|
|
89
|
+
return wrapBedrock(client, this);
|
|
90
|
+
}
|
|
91
|
+
throw new TypeError(`Unsupported client: ${name || "unknown"}. Supported: OpenAI, Anthropic, BedrockRuntimeClient.`);
|
|
76
92
|
}
|
|
77
93
|
/**
|
|
78
94
|
* Record a witnessed inference. Extracts factors, applies clearing,
|
|
79
95
|
* and enqueues payloads for background flush.
|
|
96
|
+
*
|
|
97
|
+
* If factorHandoff is configured, factors are written to the handoff
|
|
98
|
+
* destination BEFORE clearing proceeds. If the handoff fails, the
|
|
99
|
+
* payload is NOT transmitted.
|
|
80
100
|
*/
|
|
81
101
|
record(inference) {
|
|
82
102
|
// Merge guardrail config
|
|
@@ -86,6 +106,12 @@ export class Witness {
|
|
|
86
106
|
inference.guardrailsRequired = this.config.guardrailsRequired;
|
|
87
107
|
}
|
|
88
108
|
const payloads = extractPayloads(inference, this.config.tenantId, this.config.clearingLevel, this.config.latencyThresholdMs, this.config.guardrailsRequired, this.config.procedures);
|
|
109
|
+
// Factor handoff: write full (uncleared) data to custody destination
|
|
110
|
+
// BEFORE enqueuing the cleared payload for transmission.
|
|
111
|
+
// If this fails, we do NOT proceed.
|
|
112
|
+
if (this.config.factorHandoff === "file" && this.config.factorHandoffPath) {
|
|
113
|
+
writeHandoffFiles(payloads, inference, this.config.tenantId, this.config.factorHandoffPath);
|
|
114
|
+
}
|
|
89
115
|
this.buffer.enqueueMany(payloads);
|
|
90
116
|
}
|
|
91
117
|
/**
|
package/dist/witness.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"witness.js","sourceRoot":"","sources":["../src/witness.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"witness.js","sourceRoot":"","sources":["../src/witness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,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,MAA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,CAAC;IAED,qDAAqD;IACrD,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,kCAAkC;IAClC,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED,2CAA2C;IAC3C,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenova/swt3-ai",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "SWT3 AI Witness SDK
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "SWT3 AI Witness SDK: cryptographic attestation for AI inference",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"openai",
|
|
33
33
|
"anthropic"
|
|
34
34
|
],
|
|
35
|
-
"author": "TeNova <engineering@
|
|
35
|
+
"author": "TeNova <engineering@tenovaai.com>",
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"
|
|
51
|
-
"vitest": "^2.0.0",
|
|
50
|
+
"openai": "^4.70.0",
|
|
52
51
|
"tsx": "^4.0.0",
|
|
53
|
-
"
|
|
52
|
+
"typescript": "^5.5.0",
|
|
53
|
+
"vitest": "^4.1.2"
|
|
54
54
|
}
|
|
55
55
|
}
|