@tenova/swt3-ai 0.5.5 → 0.5.7
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 -15
- package/dist/adapters/a2a.d.ts +26 -0
- package/dist/adapters/a2a.d.ts.map +1 -0
- package/dist/adapters/a2a.js +86 -0
- package/dist/adapters/a2a.js.map +1 -0
- package/dist/adapters/cohere.d.ts +28 -0
- package/dist/adapters/cohere.d.ts.map +1 -0
- package/dist/adapters/cohere.js +292 -0
- package/dist/adapters/cohere.js.map +1 -0
- package/dist/adapters/crewai.d.ts +26 -0
- package/dist/adapters/crewai.d.ts.map +1 -0
- package/dist/adapters/crewai.js +78 -0
- package/dist/adapters/crewai.js.map +1 -0
- package/dist/adapters/foundry.d.ts +26 -0
- package/dist/adapters/foundry.d.ts.map +1 -0
- package/dist/adapters/foundry.js +118 -0
- package/dist/adapters/foundry.js.map +1 -0
- package/dist/adapters/google-adk.d.ts +25 -0
- package/dist/adapters/google-adk.d.ts.map +1 -0
- package/dist/adapters/google-adk.js +81 -0
- package/dist/adapters/google-adk.js.map +1 -0
- package/dist/adapters/ollama.d.ts +20 -0
- package/dist/adapters/ollama.d.ts.map +1 -1
- package/dist/adapters/ollama.js +22 -0
- package/dist/adapters/ollama.js.map +1 -1
- package/dist/adapters/qdrant.d.ts +28 -0
- package/dist/adapters/qdrant.d.ts.map +1 -0
- package/dist/adapters/qdrant.js +136 -0
- package/dist/adapters/qdrant.js.map +1 -0
- package/dist/chain.d.ts +33 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +94 -0
- package/dist/chain.js.map +1 -0
- package/dist/clearing.d.ts +7 -2
- package/dist/clearing.d.ts.map +1 -1
- package/dist/clearing.js +16 -5
- package/dist/clearing.js.map +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +123 -6
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -0
- package/dist/config.js.map +1 -1
- package/dist/demo.d.ts.map +1 -1
- package/dist/demo.js +173 -10
- package/dist/demo.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +39 -16
- package/dist/doctor.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/procedures.d.ts +20 -0
- package/dist/procedures.d.ts.map +1 -0
- package/dist/procedures.js +167 -0
- package/dist/procedures.js.map +1 -0
- package/dist/profile.d.ts +50 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +109 -0
- package/dist/profile.js.map +1 -0
- package/dist/trust.d.ts +96 -2
- package/dist/trust.d.ts.map +1 -1
- package/dist/trust.js +200 -9
- package/dist/trust.js.map +1 -1
- package/dist/types.d.ts +120 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +177 -1
- package/dist/types.js.map +1 -1
- package/dist/witness.d.ts +595 -0
- package/dist/witness.d.ts.map +1 -1
- package/dist/witness.js +1708 -202
- package/dist/witness.js.map +1 -1
- package/package.json +2 -2
- package/templates/healthcare-clinical.yaml +4 -0
- package/templates/multi-silicon.yaml +48 -0
package/README.md
CHANGED
|
@@ -13,17 +13,44 @@ Works with OpenAI, Anthropic, AWS Bedrock, Vercel AI SDK, and any OpenAI-compati
|
|
|
13
13
|
|
|
14
14
|
GPAI transparency obligations are enforceable now. EU AI Act high-risk enforcement begins **December 2, 2027**. This SDK gives you the evidence chain.
|
|
15
15
|
|
|
16
|
-
## What's New in v0.5.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
## What's New in v0.5.7
|
|
17
|
+
|
|
18
|
+
**Autonomous Agent Attestation** -- Autonomous agents make decisions, delegate tasks, consume resources, and cross jurisdictions without human intervention at every step. SWT3 witnesses each transition as immutable evidence. When an examiner asks "what did this agent do and who authorized it?", these procedures provide the cryptographic answer. Every delegation, capability change, autonomy transition, resource draw, and lifecycle event is attested independently of the agent's own logs.
|
|
19
|
+
|
|
20
|
+
- **Delegation Tree Attestation (AI-DEL.1)** -- `witnessDelegation()` attests authority delegation between agents: scope hash, depth from human authorization, TTL, cascade revocation, and sub-delegation control. Evidence for EU AI Act Art. 14 human oversight.
|
|
21
|
+
- **Capability Attestation (AI-CAP.1)** -- `witnessCapabilityAttestation()` attests declared vs observed agent capabilities with manifest hashing and drift detection. Autonomy level binding for Art. 15 robustness.
|
|
22
|
+
- **Autonomy Level Transition (AI-AUTO.3)** -- `witnessAutonomyTransition()` attests agent promotion and demotion between autonomy levels 0-3. Risk-triggered downgrades, HITL checkpoints, and transition justification.
|
|
23
|
+
- **Resource Consumption Attestation (AI-COST.1)** -- `witnessResourceConsumption()` attests token usage, API call counts, and estimated cost as compliance evidence. Budget threshold awareness without billing enforcement.
|
|
24
|
+
- **Lifecycle Event Attestation (AI-LCM.1)** -- `witnessLifecycle()` attests spawn, checkpoint, migrate, terminate, and crash events with context size and state hash.
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// Autonomous agent lifecycle: spawn -> delegate -> attest capabilities -> transition -> terminate
|
|
28
|
+
witness.witnessLifecycle("spawn", { contextTokens: 0 });
|
|
29
|
+
witness.witnessDelegation({ scope: "fraud-review", delegator: "orchestrator", depth: 1, ttlSeconds: 3600 });
|
|
30
|
+
witness.witnessCapabilityAttestation({ manifest: ["tool:search", "tool:flag"], autonomyLevel: 2 });
|
|
31
|
+
witness.witnessAutonomyTransition({ fromLevel: 2, toLevel: 1, trigger: "risk_threshold" });
|
|
32
|
+
witness.witnessLifecycle("terminate", { contextTokens: 8400 });
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Cross-Silicon Hardware Attestation** -- auto-detect and attest accelerator inventory across competing silicon vendors. 6 discovery paths: NVIDIA GPU (`nvidia-smi`), Google TPU (JAX), AMD MI (`rocm-smi`), AWS Trainium (`neuron-ls`), Intel Gaudi (`hl-smi`), and PCI fallback. New `multi-silicon` profile for workloads that migrate between vendors. When your model moves from NVIDIA to TPU, the attestation follows.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
witness.witnessHardware(); // auto-detects silicon vendor, GPU count, VRAM, driver version
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Endpoint Attestation** -- witness the infrastructure decisions that shape how agents operate across boundaries.
|
|
42
|
+
|
|
43
|
+
- **Agent Transaction Witnessing (AI-FIN.1)** -- `witnessTransaction()` for autonomous agent financial operations. Authorization type, amount, and settlement status anchored before execution.
|
|
44
|
+
- **Tool Permission Attestation (AI-TOOL.2)** -- `witnessToolPermissions()` attests runtime tool sets against agent charter. Detects permission drift and escalation.
|
|
45
|
+
- **Cross-Border Inference Routing (AI-JUR.1)** -- `witnessRouting()` witnesses routing decisions with ISO 3166 region codes and compliance status.
|
|
46
|
+
|
|
47
|
+
**Adapters**
|
|
48
|
+
|
|
49
|
+
- **Cohere Adapter** -- `wrapCohere()` for Cohere V2 API. Chat and streaming witnessed transparently.
|
|
50
|
+
- **Qdrant RAG Witness** -- `wrapQdrant()` for database-level RAG pipeline compliance. Every vector search mints AI-RAG.1.
|
|
51
|
+
- **Ollama 0.30+ Refresh** -- explicit `wrapOllama()` export, GGUF model name normalization.
|
|
52
|
+
|
|
53
|
+
103 procedures, 54 namespaces, 28 frameworks, 15 profiles, 16 integrations, 7 languages
|
|
27
54
|
|
|
28
55
|
## MCP Server -- Official Registry
|
|
29
56
|
|
|
@@ -93,7 +120,7 @@ All verification is local. Zero cloud overhead. No data exchanged until both age
|
|
|
93
120
|
|
|
94
121
|
## Offline Verification
|
|
95
122
|
|
|
96
|
-
Verify any witness anchor without network calls. The fingerprint formula is deterministic and identical across all
|
|
123
|
+
Verify any witness anchor without network calls. The fingerprint formula is deterministic and identical across all 7 SDK languages -- recompute it anywhere in microseconds.
|
|
97
124
|
|
|
98
125
|
```typescript
|
|
99
126
|
import { verifyAnchor } from "@tenova/swt3-ai";
|
|
@@ -107,7 +134,7 @@ const result = verifyAnchor(anchor, {
|
|
|
107
134
|
// result.status: "CERTIFIED TRUTH" | "TAMPERED"
|
|
108
135
|
```
|
|
109
136
|
|
|
110
|
-
Zero vendor dependency. Zero network calls. Works air-gapped. The same formula runs in Python, TypeScript, Rust, C#, and Ruby with identical output for identical inputs.
|
|
137
|
+
Zero vendor dependency. Zero network calls. Works air-gapped. The same formula runs in Python, TypeScript, Swift, Rust, C#, and Ruby with identical output for identical inputs.
|
|
111
138
|
|
|
112
139
|
## See It Work (No Account Needed)
|
|
113
140
|
|
|
@@ -704,7 +731,7 @@ Each inference produces anchors for these checks. Every check maps to a regulati
|
|
|
704
731
|
|
|
705
732
|
### EU AI Act Article Mapping
|
|
706
733
|
|
|
707
|
-
All
|
|
734
|
+
All 76 SWT3 AI witnessing procedures map to specific EU AI Act obligations:
|
|
708
735
|
|
|
709
736
|
| Procedure | EU AI Act Article | Obligation | Demo | Production |
|
|
710
737
|
|-----------|-------------------|------------|------|------------|
|
|
@@ -721,7 +748,7 @@ All 65 SWT3 AI witnessing procedures map to specific EU AI Act obligations:
|
|
|
721
748
|
| AI-EXPL.1 | Art. 13(1) | Transparency & Explainability | -| ✓ |
|
|
722
749
|
| AI-EXPL.2 | Art. 13(3b) | Confidence Calibration | -| ✓ |
|
|
723
750
|
|
|
724
|
-
The demo demonstrates 5 procedures using simulated data. All
|
|
751
|
+
The demo demonstrates 5 procedures using simulated data. All 76 are available in production with real inference data. 207 cross-language test vectors ensure fingerprint parity across Python, TypeScript, Swift, Rust, C#, and Ruby. [See live conformity →](https://sovereign.tenova.io/audit/axm_audit_demo_eu_ai_act_public)
|
|
725
752
|
|
|
726
753
|
## How Verdicts Work
|
|
727
754
|
|
|
@@ -1057,3 +1084,5 @@ Your prompts and responses **never leave your infrastructure**. The SDK computes
|
|
|
1057
1084
|
*SWT3: Sovereign Witness Traceability. We don't run your models. We witness them.*
|
|
1058
1085
|
|
|
1059
1086
|
SWT3 and Sovereign Witness Traceability are trademarks of Tenable Nova LLC. Patent pending. Apache 2.0 licensed.
|
|
1087
|
+
|
|
1088
|
+
This project is not affiliated with, endorsed by, or sponsored by any third-party AI provider. All third-party trademarks are the property of their respective owners: OpenAI and GPT (OpenAI, Inc.); Claude and Anthropic (Anthropic PBC); Google, Gemini, Vertex AI, and ADK (Google LLC); Azure, Foundry, and Microsoft (Microsoft Corporation); AWS and Bedrock (Amazon Web Services, Inc.); NVIDIA and Dynamo (NVIDIA Corporation); Meta and Llama (Meta Platforms, Inc.); Ollama (Ollama, Inc.); CrewAI (CrewAI, Inc.); Vercel and Next.js (Vercel, Inc.); MCP (Anthropic PBC); vLLM (vLLM Project). Use of these names is for identification and interoperability purposes only.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK -- A2A (Agent-to-Agent) Protocol Adapter.
|
|
3
|
+
*
|
|
4
|
+
* Wraps any object with a send() method (Google A2A protocol pattern),
|
|
5
|
+
* minting witness anchors on each inter-agent message without modifying
|
|
6
|
+
* the agent logic or adding protocol dependencies.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { wrapA2A } from "@tenova/swt3-ai/adapters/a2a";
|
|
10
|
+
* const witnessed = wrapA2A(agent, witness);
|
|
11
|
+
* const result = await witnessed.send({ text: "Analyze this data" });
|
|
12
|
+
*
|
|
13
|
+
* Duck-typed: works with any object that has a send() method.
|
|
14
|
+
* No A2A protocol import required.
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
17
|
+
*/
|
|
18
|
+
import type { Witness } from "../witness.js";
|
|
19
|
+
export interface A2AAgent {
|
|
20
|
+
send(message: unknown, ...args: unknown[]): unknown;
|
|
21
|
+
handleMessage?(message: unknown, ...args: unknown[]): unknown;
|
|
22
|
+
name?: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function wrapA2A<T extends A2AAgent>(agent: T, witness: Witness, modelId?: string): T;
|
|
26
|
+
//# sourceMappingURL=a2a.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a.d.ts","sourceRoot":"","sources":["../../src/adapters/a2a.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACpD,aAAa,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAgED,wBAAgB,OAAO,CAAC,CAAC,SAAS,QAAQ,EACxC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,CAUH"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK -- A2A (Agent-to-Agent) Protocol Adapter.
|
|
3
|
+
*
|
|
4
|
+
* Wraps any object with a send() method (Google A2A protocol pattern),
|
|
5
|
+
* minting witness anchors on each inter-agent message without modifying
|
|
6
|
+
* the agent logic or adding protocol dependencies.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { wrapA2A } from "@tenova/swt3-ai/adapters/a2a";
|
|
10
|
+
* const witnessed = wrapA2A(agent, witness);
|
|
11
|
+
* const result = await witnessed.send({ text: "Analyze this data" });
|
|
12
|
+
*
|
|
13
|
+
* Duck-typed: works with any object that has a send() method.
|
|
14
|
+
* No A2A protocol import required.
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
17
|
+
*/
|
|
18
|
+
import { sha256Truncated } from "../fingerprint.js";
|
|
19
|
+
function resolveModelId(agent, explicit) {
|
|
20
|
+
if (explicit)
|
|
21
|
+
return explicit;
|
|
22
|
+
if (typeof process !== "undefined" && process.env.SWT3_MODEL_ID) {
|
|
23
|
+
return process.env.SWT3_MODEL_ID;
|
|
24
|
+
}
|
|
25
|
+
if (agent.model)
|
|
26
|
+
return agent.model;
|
|
27
|
+
if (agent.name)
|
|
28
|
+
return `a2a-${agent.name}`;
|
|
29
|
+
return "a2a-agent";
|
|
30
|
+
}
|
|
31
|
+
function stringifyMessage(msg) {
|
|
32
|
+
if (msg === null || msg === undefined)
|
|
33
|
+
return "";
|
|
34
|
+
if (typeof msg === "string")
|
|
35
|
+
return msg;
|
|
36
|
+
try {
|
|
37
|
+
return JSON.stringify(msg);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return String(msg);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function wrapMethod(target, methodName, witness, mid) {
|
|
44
|
+
const original = target[methodName];
|
|
45
|
+
if (typeof original !== "function")
|
|
46
|
+
return;
|
|
47
|
+
const bound = original.bind(target);
|
|
48
|
+
target[methodName] = (message, ...args) => {
|
|
49
|
+
const start = performance.now();
|
|
50
|
+
const result = bound(message, ...args);
|
|
51
|
+
const finish = (res) => {
|
|
52
|
+
const elapsed = Math.round(performance.now() - start);
|
|
53
|
+
const record = {
|
|
54
|
+
modelId: mid,
|
|
55
|
+
modelHash: sha256Truncated(mid),
|
|
56
|
+
promptHash: sha256Truncated(stringifyMessage(message)),
|
|
57
|
+
responseHash: sha256Truncated(stringifyMessage(res)),
|
|
58
|
+
latencyMs: elapsed,
|
|
59
|
+
inputTokens: 0,
|
|
60
|
+
outputTokens: 0,
|
|
61
|
+
guardrailsActive: 0,
|
|
62
|
+
guardrailsRequired: 0,
|
|
63
|
+
guardrailPassed: true,
|
|
64
|
+
hasRefusal: false,
|
|
65
|
+
provider: "a2a",
|
|
66
|
+
guardrailNames: [],
|
|
67
|
+
};
|
|
68
|
+
witness.record(record);
|
|
69
|
+
return res;
|
|
70
|
+
};
|
|
71
|
+
if (result && typeof result.then === "function") {
|
|
72
|
+
return result.then(finish);
|
|
73
|
+
}
|
|
74
|
+
return finish(result);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function wrapA2A(agent, witness, modelId) {
|
|
78
|
+
const mid = resolveModelId(agent, modelId);
|
|
79
|
+
const wrapped = Object.create(agent);
|
|
80
|
+
wrapMethod(wrapped, "send", witness, mid);
|
|
81
|
+
if (agent.handleMessage) {
|
|
82
|
+
wrapMethod(wrapped, "handleMessage", witness, mid);
|
|
83
|
+
}
|
|
84
|
+
return wrapped;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=a2a.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a.js","sourceRoot":"","sources":["../../src/adapters/a2a.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AASpD,SAAS,cAAc,CAAC,KAAe,EAAE,QAAiB;IACxD,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAChE,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IACnC,CAAC;IACD,IAAI,KAAK,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IACpC,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3C,OAAO,WAAW,CAAC;AACrB,CAA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gBACf,gBAAgB,EAAE,CAAC;gBACnB,kBAAkB,EAAE,CAAC;gBACrB,eAAe,EAAE,IAAI;gBACrB,UAAU,EAAE,KAAK;gBACjB,QAAQ,EAAE,KAAK;gBACf,cAAc,EAAE,EAAE;aACnB,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACvB,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;QAEF,IAAI,MAAM,IAAI,OAAQ,MAAc,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACzD,OAAQ,MAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,KAAQ,EACR,OAAgB,EAChB,OAAgB;IAEhB,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAM,CAAC;IAE1C,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1C,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;QACxB,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK -- Cohere Adapter (ES6 Proxy).
|
|
3
|
+
*
|
|
4
|
+
* Wraps the Cohere client so that chat() and chatStream() are
|
|
5
|
+
* intercepted for witnessing. Flat API -- only one level of proxy.
|
|
6
|
+
*
|
|
7
|
+
* Cohere V2 response structure:
|
|
8
|
+
* response.message.content[0].text -> response text
|
|
9
|
+
* response.model -> string
|
|
10
|
+
* response.finishReason -> "COMPLETE" | "MAX_TOKENS" | "ERROR"
|
|
11
|
+
* response.usage.tokens.inputTokens / outputTokens
|
|
12
|
+
*
|
|
13
|
+
* Cohere streaming:
|
|
14
|
+
* chat_stream() returns an async iterable of events:
|
|
15
|
+
* message-start, content-delta, message-end
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
18
|
+
*/
|
|
19
|
+
import type { Witness } from "../witness.js";
|
|
20
|
+
/**
|
|
21
|
+
* Wrap a Cohere client with an ES6 Proxy for transparent witnessing.
|
|
22
|
+
*
|
|
23
|
+
* Works with both sync and async Cohere clients. Intercepts:
|
|
24
|
+
* - chat() for non-streaming completions
|
|
25
|
+
* - chatStream() for streaming completions
|
|
26
|
+
*/
|
|
27
|
+
export declare function wrapCohere(client: unknown, witness: Witness): unknown;
|
|
28
|
+
//# sourceMappingURL=cohere.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cohere.d.ts","sourceRoot":"","sources":["../../src/adapters/cohere.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAuBrE"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK -- Cohere Adapter (ES6 Proxy).
|
|
3
|
+
*
|
|
4
|
+
* Wraps the Cohere client so that chat() and chatStream() are
|
|
5
|
+
* intercepted for witnessing. Flat API -- only one level of proxy.
|
|
6
|
+
*
|
|
7
|
+
* Cohere V2 response structure:
|
|
8
|
+
* response.message.content[0].text -> response text
|
|
9
|
+
* response.model -> string
|
|
10
|
+
* response.finishReason -> "COMPLETE" | "MAX_TOKENS" | "ERROR"
|
|
11
|
+
* response.usage.tokens.inputTokens / outputTokens
|
|
12
|
+
*
|
|
13
|
+
* Cohere streaming:
|
|
14
|
+
* chat_stream() returns an async iterable of events:
|
|
15
|
+
* message-start, content-delta, message-end
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
18
|
+
*/
|
|
19
|
+
import { sha256Truncated } from "../fingerprint.js";
|
|
20
|
+
/**
|
|
21
|
+
* Wrap a Cohere client with an ES6 Proxy for transparent witnessing.
|
|
22
|
+
*
|
|
23
|
+
* Works with both sync and async Cohere clients. Intercepts:
|
|
24
|
+
* - chat() for non-streaming completions
|
|
25
|
+
* - chatStream() for streaming completions
|
|
26
|
+
*/
|
|
27
|
+
export function wrapCohere(client, witness) {
|
|
28
|
+
return new Proxy(client, {
|
|
29
|
+
get(target, prop) {
|
|
30
|
+
if (typeof prop === "symbol")
|
|
31
|
+
return Reflect.get(target, prop);
|
|
32
|
+
const real = Reflect.get(target, prop);
|
|
33
|
+
if (prop === "chat") {
|
|
34
|
+
return createChatInterceptor(real, witness);
|
|
35
|
+
}
|
|
36
|
+
if (prop === "chatStream" || prop === "chat_stream") {
|
|
37
|
+
return createStreamInterceptor(real, witness);
|
|
38
|
+
}
|
|
39
|
+
return real;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// -- chat() interceptor -------------------------------------------------------
|
|
44
|
+
function createChatInterceptor(realMethod, witness) {
|
|
45
|
+
return function interceptedChat(...args) {
|
|
46
|
+
const kwargs = (args[0] ?? {});
|
|
47
|
+
const messages = kwargs.messages;
|
|
48
|
+
const model = kwargs.model ?? "unknown";
|
|
49
|
+
const promptText = extractPromptText(messages);
|
|
50
|
+
const promptHash = sha256Truncated(promptText);
|
|
51
|
+
// Hash system prompt separately (instruction drift detection)
|
|
52
|
+
const systemPromptText = extractSystemPrompt(messages);
|
|
53
|
+
const systemPromptHash = systemPromptText
|
|
54
|
+
? sha256Truncated(systemPromptText)
|
|
55
|
+
: undefined;
|
|
56
|
+
// Gatekeeper pre-call check (strict mode only)
|
|
57
|
+
let authorizationId;
|
|
58
|
+
if (witness.strict) {
|
|
59
|
+
authorizationId = witness.gateCheck(messages, model);
|
|
60
|
+
}
|
|
61
|
+
const start = performance.now();
|
|
62
|
+
const result = realMethod.call(this, ...args);
|
|
63
|
+
// Result is Promise<ChatResponse>
|
|
64
|
+
return result.then((response) => {
|
|
65
|
+
const elapsedMs = Math.round(performance.now() - start);
|
|
66
|
+
const record = extractRecord(response, model, promptHash, elapsedMs, systemPromptHash);
|
|
67
|
+
witness.record(record, authorizationId);
|
|
68
|
+
return response;
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// -- chatStream() interceptor -------------------------------------------------
|
|
73
|
+
function createStreamInterceptor(realMethod, witness) {
|
|
74
|
+
return function interceptedStream(...args) {
|
|
75
|
+
const kwargs = (args[0] ?? {});
|
|
76
|
+
const messages = kwargs.messages;
|
|
77
|
+
const model = kwargs.model ?? "unknown";
|
|
78
|
+
const promptText = extractPromptText(messages);
|
|
79
|
+
const promptHash = sha256Truncated(promptText);
|
|
80
|
+
const systemPromptText = extractSystemPrompt(messages);
|
|
81
|
+
const systemPromptHash = systemPromptText
|
|
82
|
+
? sha256Truncated(systemPromptText)
|
|
83
|
+
: undefined;
|
|
84
|
+
let authorizationId;
|
|
85
|
+
if (witness.strict) {
|
|
86
|
+
authorizationId = witness.gateCheck(messages, model);
|
|
87
|
+
}
|
|
88
|
+
const start = performance.now();
|
|
89
|
+
const result = realMethod.call(this, ...args);
|
|
90
|
+
// chat_stream may return an async iterable directly or a Promise
|
|
91
|
+
if (result && typeof result.then === "function") {
|
|
92
|
+
return result.then((stream) => wrapCohereStream(stream, witness, model, promptHash, start, systemPromptHash, authorizationId));
|
|
93
|
+
}
|
|
94
|
+
return wrapCohereStream(result, witness, model, promptHash, start, systemPromptHash, authorizationId);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// -- Stream Accumulator -------------------------------------------------------
|
|
98
|
+
async function* streamAccumulator(stream, witness, model, promptHash, startTime, systemPromptHash, authorizationId) {
|
|
99
|
+
const textParts = [];
|
|
100
|
+
let actualModel = model;
|
|
101
|
+
let inputTokens;
|
|
102
|
+
let outputTokens;
|
|
103
|
+
for await (const event of stream) {
|
|
104
|
+
// Yield to developer immediately
|
|
105
|
+
yield event;
|
|
106
|
+
const e = event;
|
|
107
|
+
const type = e.type;
|
|
108
|
+
if (type === "message-start") {
|
|
109
|
+
const delta = e.delta;
|
|
110
|
+
if (delta) {
|
|
111
|
+
const message = delta.message;
|
|
112
|
+
if (message?.model)
|
|
113
|
+
actualModel = message.model;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (type === "content-delta") {
|
|
117
|
+
const delta = e.delta;
|
|
118
|
+
if (delta) {
|
|
119
|
+
const message = delta.message;
|
|
120
|
+
if (message) {
|
|
121
|
+
const content = message.content;
|
|
122
|
+
if (content?.text) {
|
|
123
|
+
textParts.push(content.text);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (type === "message-end") {
|
|
129
|
+
const delta = e.delta;
|
|
130
|
+
if (delta) {
|
|
131
|
+
const usage = delta.usage;
|
|
132
|
+
if (usage) {
|
|
133
|
+
const tokens = usage.tokens;
|
|
134
|
+
if (tokens) {
|
|
135
|
+
if (tokens.input_tokens !== undefined)
|
|
136
|
+
inputTokens = tokens.input_tokens;
|
|
137
|
+
if (tokens.output_tokens !== undefined)
|
|
138
|
+
outputTokens = tokens.output_tokens;
|
|
139
|
+
}
|
|
140
|
+
// Also check camelCase variants
|
|
141
|
+
if (tokens === undefined) {
|
|
142
|
+
if (usage.inputTokens !== undefined)
|
|
143
|
+
inputTokens = usage.inputTokens;
|
|
144
|
+
if (usage.outputTokens !== undefined)
|
|
145
|
+
outputTokens = usage.outputTokens;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Stream complete -- witness
|
|
152
|
+
const elapsedMs = Math.round(performance.now() - startTime);
|
|
153
|
+
const responseText = textParts.join("");
|
|
154
|
+
const record = {
|
|
155
|
+
modelId: actualModel,
|
|
156
|
+
modelHash: sha256Truncated(actualModel),
|
|
157
|
+
promptHash,
|
|
158
|
+
responseHash: sha256Truncated(responseText),
|
|
159
|
+
latencyMs: elapsedMs,
|
|
160
|
+
inputTokens,
|
|
161
|
+
outputTokens,
|
|
162
|
+
guardrailsActive: 0,
|
|
163
|
+
guardrailsRequired: 0,
|
|
164
|
+
guardrailPassed: true,
|
|
165
|
+
hasRefusal: false,
|
|
166
|
+
provider: "cohere",
|
|
167
|
+
guardrailNames: [],
|
|
168
|
+
systemPromptHash,
|
|
169
|
+
};
|
|
170
|
+
witness.record(record, authorizationId);
|
|
171
|
+
}
|
|
172
|
+
function wrapCohereStream(stream, witness, model, promptHash, startTime, systemPromptHash, authorizationId) {
|
|
173
|
+
const s = stream;
|
|
174
|
+
const gen = streamAccumulator(s, witness, model, promptHash, startTime, systemPromptHash, authorizationId);
|
|
175
|
+
return new Proxy(s, {
|
|
176
|
+
get(target, prop) {
|
|
177
|
+
if (prop === Symbol.asyncIterator) {
|
|
178
|
+
return () => gen;
|
|
179
|
+
}
|
|
180
|
+
const value = Reflect.get(target, prop);
|
|
181
|
+
if (typeof value === "function") {
|
|
182
|
+
return value.bind(target);
|
|
183
|
+
}
|
|
184
|
+
return value;
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
// -- Factor Extraction --------------------------------------------------------
|
|
189
|
+
function extractSystemPrompt(messages) {
|
|
190
|
+
if (!Array.isArray(messages))
|
|
191
|
+
return undefined;
|
|
192
|
+
for (const msg of messages) {
|
|
193
|
+
if (typeof msg !== "object" || msg === null)
|
|
194
|
+
continue;
|
|
195
|
+
const m = msg;
|
|
196
|
+
if (m.role !== "system")
|
|
197
|
+
continue;
|
|
198
|
+
const content = m.content;
|
|
199
|
+
if (typeof content === "string")
|
|
200
|
+
return content;
|
|
201
|
+
if (Array.isArray(content)) {
|
|
202
|
+
const parts = [];
|
|
203
|
+
for (const block of content) {
|
|
204
|
+
if (typeof block === "object" && block !== null) {
|
|
205
|
+
const b = block;
|
|
206
|
+
if (typeof b.text === "string")
|
|
207
|
+
parts.push(b.text);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return parts.length > 0 ? parts.join("\n") : undefined;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
function extractPromptText(messages) {
|
|
216
|
+
const parts = [];
|
|
217
|
+
if (Array.isArray(messages)) {
|
|
218
|
+
for (const msg of messages) {
|
|
219
|
+
if (typeof msg !== "object" || msg === null)
|
|
220
|
+
continue;
|
|
221
|
+
const m = msg;
|
|
222
|
+
const content = m.content;
|
|
223
|
+
if (typeof content === "string") {
|
|
224
|
+
parts.push(content);
|
|
225
|
+
}
|
|
226
|
+
else if (Array.isArray(content)) {
|
|
227
|
+
for (const block of content) {
|
|
228
|
+
if (typeof block === "object" && block !== null) {
|
|
229
|
+
const b = block;
|
|
230
|
+
if (typeof b.text === "string")
|
|
231
|
+
parts.push(b.text);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return parts.join("\n");
|
|
238
|
+
}
|
|
239
|
+
function extractRecord(response, model, promptHash, elapsedMs, systemPromptHash) {
|
|
240
|
+
const r = response;
|
|
241
|
+
// Extract text from message.content
|
|
242
|
+
let responseText = "";
|
|
243
|
+
const message = r.message;
|
|
244
|
+
if (message) {
|
|
245
|
+
const content = message.content;
|
|
246
|
+
if (Array.isArray(content)) {
|
|
247
|
+
const texts = [];
|
|
248
|
+
for (const block of content) {
|
|
249
|
+
if (typeof block.text === "string")
|
|
250
|
+
texts.push(block.text);
|
|
251
|
+
}
|
|
252
|
+
responseText = texts.join("\n");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// Finish reason
|
|
256
|
+
const finishReason = r.finish_reason ?? r.finishReason ?? "";
|
|
257
|
+
const hasRefusal = !["COMPLETE", "MAX_TOKENS", "TOOL_CALL"].includes(finishReason);
|
|
258
|
+
// Token usage
|
|
259
|
+
const usage = r.usage;
|
|
260
|
+
let inputTokens;
|
|
261
|
+
let outputTokens;
|
|
262
|
+
if (usage) {
|
|
263
|
+
const tokens = usage.tokens;
|
|
264
|
+
if (tokens) {
|
|
265
|
+
inputTokens = tokens.input_tokens;
|
|
266
|
+
outputTokens = tokens.output_tokens;
|
|
267
|
+
// camelCase fallback
|
|
268
|
+
if (inputTokens === undefined)
|
|
269
|
+
inputTokens = tokens.inputTokens;
|
|
270
|
+
if (outputTokens === undefined)
|
|
271
|
+
outputTokens = tokens.outputTokens;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const actualModel = r.model ?? model;
|
|
275
|
+
return {
|
|
276
|
+
modelId: actualModel,
|
|
277
|
+
modelHash: sha256Truncated(actualModel),
|
|
278
|
+
promptHash,
|
|
279
|
+
responseHash: sha256Truncated(responseText),
|
|
280
|
+
latencyMs: elapsedMs,
|
|
281
|
+
inputTokens,
|
|
282
|
+
outputTokens,
|
|
283
|
+
guardrailsActive: 0,
|
|
284
|
+
guardrailsRequired: 0,
|
|
285
|
+
guardrailPassed: true,
|
|
286
|
+
hasRefusal,
|
|
287
|
+
provider: "cohere",
|
|
288
|
+
systemPromptHash,
|
|
289
|
+
guardrailNames: [],
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=cohere.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cohere.js","sourceRoot":"","sources":["../../src/adapters/cohere.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD;;;;;;GAMG;AACH,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AAI,KAAK,CAAC;IAEjD,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC;QACvC,UAAU;QACV,YAAY,EAAE,eAAe,CAAC,YAAY,CAAC;QAC3C,SAAS,EAAE,SAAS;QACpB,WAAW;QACX,YAAY;QACZ,gBAAgB,EAAE,CAAC;QACnB,kBAAkB,EAAE,CAAC;QACrB,eAAe,EAAE,IAAI;QACrB,UAAU;QACV,QAAQ,EAAE,QAAQ;QAClB,gBAAgB;QAChB,cAAc,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWT3 AI Witness SDK -- CrewAI Adapter.
|
|
3
|
+
*
|
|
4
|
+
* Wraps any object with a kickoff() method (CrewAI Crew pattern),
|
|
5
|
+
* minting witness anchors on each crew execution without modifying
|
|
6
|
+
* the crew logic or adding framework dependencies.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { wrapCrewAI } from "@tenova/swt3-ai/adapters/crewai";
|
|
10
|
+
* const witnessed = wrapCrewAI(crew, witness);
|
|
11
|
+
* const result = await witnessed.kickoff();
|
|
12
|
+
*
|
|
13
|
+
* Duck-typed: works with any object that has a kickoff() method.
|
|
14
|
+
* No crewai import required.
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2026 Tenable Nova LLC. Apache 2.0. Patent pending.
|
|
17
|
+
*/
|
|
18
|
+
import type { Witness } from "../witness.js";
|
|
19
|
+
export interface CrewAICrew {
|
|
20
|
+
kickoff(inputs?: Record<string, unknown>): unknown;
|
|
21
|
+
name?: string;
|
|
22
|
+
agents?: unknown[];
|
|
23
|
+
tasks?: unknown[];
|
|
24
|
+
}
|
|
25
|
+
export declare function wrapCrewAI<T extends CrewAICrew>(crew: T, witness: Witness, modelId?: string): T;
|
|
26
|
+
//# sourceMappingURL=crewai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai.d.ts","sourceRoot":"","sources":["../../src/adapters/crewai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;CACnB;AAqBD,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAC7C,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,CAyCH"}
|