@atbash/sdk 0.2.1 → 0.3.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 +7 -7
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,12 +13,12 @@ Requires Node.js 18 or higher. Server-side only — private keys are used for lo
|
|
|
13
13
|
## Quickstart
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import {
|
|
16
|
+
import { loadAgent, judgeAction } from "@atbash/sdk";
|
|
17
17
|
|
|
18
18
|
// 1. Load your agent identity — paste the private key from the Atbash
|
|
19
|
-
// dashboard (https://atbash.ai/risk-engine/agents).
|
|
19
|
+
// dashboard (https://atbash.ai/risk-engine/agents). loadAgent()
|
|
20
20
|
// validates the key and derives the matching public key for you.
|
|
21
|
-
const agent =
|
|
21
|
+
const agent = loadAgent(process.env.ATBASH_AGENT_PRIVKEY!);
|
|
22
22
|
|
|
23
23
|
// 2. Submit an action for judgment, before executing it.
|
|
24
24
|
// The SDK signs and broadcasts log_tool_call to the Chromia chain
|
|
@@ -60,11 +60,11 @@ If you need finer control, you can call `logToolCall()` and the judge API separa
|
|
|
60
60
|
Generate one programmatically for local development:
|
|
61
61
|
|
|
62
62
|
```ts
|
|
63
|
-
import { generateKeyPair,
|
|
63
|
+
import { generateKeyPair, loadAgent } from "@atbash/sdk";
|
|
64
64
|
|
|
65
65
|
const { privKey } = generateKeyPair();
|
|
66
66
|
console.log("Save this private key somewhere safe:", privKey);
|
|
67
|
-
const agent =
|
|
67
|
+
const agent = loadAgent(privKey);
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
For production, always create agents in the dashboard so operators can attach policy packs and manage tier / jail state.
|
|
@@ -175,14 +175,14 @@ interface JudgmentStatus {
|
|
|
175
175
|
### Agent identity
|
|
176
176
|
|
|
177
177
|
```ts
|
|
178
|
-
|
|
178
|
+
loadAgent(privkey: string): AgentAuth
|
|
179
179
|
generateKeyPair(): { privKey: string; pubKey: string }
|
|
180
180
|
derivePublicKey(privKeyHex: string): string
|
|
181
181
|
isValidPrivateKey(hex: string): boolean
|
|
182
182
|
toPubkeyHex(val: unknown): string
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
`
|
|
185
|
+
`loadAgent(privkey)` is the canonical loader — pass in the private key from the dashboard, get back `{ pubkey, privkey }` ready for `judgeAction`. It accepts `0x`-prefixed, padded, or mixed-case input and throws on malformed keys. Use `generateKeyPair()` only for local development; for production, create agents in the dashboard so operators can attach policies.
|
|
186
186
|
|
|
187
187
|
### Query APIs
|
|
188
188
|
|
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,6 @@ __export(index_exports, {
|
|
|
33
33
|
DEFAULT_BLOCKCHAIN_RID: () => DEFAULT_BLOCKCHAIN_RID,
|
|
34
34
|
DEFAULT_CHROMIA_NODE_URLS: () => DEFAULT_CHROMIA_NODE_URLS,
|
|
35
35
|
DEFAULT_ENDPOINT: () => DEFAULT_ENDPOINT,
|
|
36
|
-
createAgent: () => createAgent,
|
|
37
36
|
derivePublicKey: () => derivePublicKey,
|
|
38
37
|
generateKeyPair: () => generateKeyPair,
|
|
39
38
|
getAgentDetail: () => getAgentDetail,
|
|
@@ -50,6 +49,7 @@ __export(index_exports, {
|
|
|
50
49
|
getToolCalls: () => getToolCalls,
|
|
51
50
|
isValidPrivateKey: () => isValidPrivateKey,
|
|
52
51
|
judgeAction: () => judgeAction,
|
|
52
|
+
loadAgent: () => loadAgent,
|
|
53
53
|
logToolCall: () => logToolCall,
|
|
54
54
|
toPubkeyHex: () => toPubkeyHex
|
|
55
55
|
});
|
|
@@ -82,7 +82,7 @@ function generateKeyPair() {
|
|
|
82
82
|
pubKey: ecdh.getPublicKey("hex", "compressed")
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function loadAgent(privkey) {
|
|
86
86
|
const clean = privkey.replace(/^0x/, "").trim().toLowerCase();
|
|
87
87
|
if (!isValidPrivateKey(clean)) {
|
|
88
88
|
throw new Error(
|
|
@@ -351,7 +351,6 @@ async function getSafetyStats(opts) {
|
|
|
351
351
|
DEFAULT_BLOCKCHAIN_RID,
|
|
352
352
|
DEFAULT_CHROMIA_NODE_URLS,
|
|
353
353
|
DEFAULT_ENDPOINT,
|
|
354
|
-
createAgent,
|
|
355
354
|
derivePublicKey,
|
|
356
355
|
generateKeyPair,
|
|
357
356
|
getAgentDetail,
|
|
@@ -368,6 +367,7 @@ async function getSafetyStats(opts) {
|
|
|
368
367
|
getToolCalls,
|
|
369
368
|
isValidPrivateKey,
|
|
370
369
|
judgeAction,
|
|
370
|
+
loadAgent,
|
|
371
371
|
logToolCall,
|
|
372
372
|
toPubkeyHex
|
|
373
373
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -19,7 +19,7 @@ interface AgentAuth {
|
|
|
19
19
|
pubkey: string;
|
|
20
20
|
privkey: string;
|
|
21
21
|
}
|
|
22
|
-
declare function
|
|
22
|
+
declare function loadAgent(privkey: string): AgentAuth;
|
|
23
23
|
declare function toPubkeyHex(val: unknown): string;
|
|
24
24
|
interface ClientOpts {
|
|
25
25
|
endpoint?: string;
|
|
@@ -137,4 +137,4 @@ declare function getAgentDetail(agentPubkey: string, opts?: ClientOpts): Promise
|
|
|
137
137
|
declare function getAgentPolicy(agentPubkey: string, opts?: ClientOpts): Promise<AgentPolicy>;
|
|
138
138
|
declare function getSafetyStats(opts?: ClientOpts): Promise<Record<string, unknown>>;
|
|
139
139
|
|
|
140
|
-
export { type AgentAuth, type ChainOpts, type ClientOpts, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, type HeldAction, type HeldActionReview, type JudgeOptions, type JudgeResult, type JudgmentStatus, type TierInfo, type ToolCallFull, type ToolCallRecord, type Verdict,
|
|
140
|
+
export { type AgentAuth, type ChainOpts, type ClientOpts, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, type HeldAction, type HeldActionReview, type JudgeOptions, type JudgeResult, type JudgmentStatus, type TierInfo, type ToolCallFull, type ToolCallRecord, type Verdict, derivePublicKey, generateKeyPair, getAgentDetail, getAgentPolicy, getAgentToolCalls, getHeldActionReviews, getJudgmentStatus, getOrgTierInfo, getOrgToolCalls, getPendingHeldActions, getSafetyStats, getToolCallCount, getToolCallFull, getToolCalls, isValidPrivateKey, judgeAction, loadAgent, logToolCall, toPubkeyHex };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ interface AgentAuth {
|
|
|
19
19
|
pubkey: string;
|
|
20
20
|
privkey: string;
|
|
21
21
|
}
|
|
22
|
-
declare function
|
|
22
|
+
declare function loadAgent(privkey: string): AgentAuth;
|
|
23
23
|
declare function toPubkeyHex(val: unknown): string;
|
|
24
24
|
interface ClientOpts {
|
|
25
25
|
endpoint?: string;
|
|
@@ -137,4 +137,4 @@ declare function getAgentDetail(agentPubkey: string, opts?: ClientOpts): Promise
|
|
|
137
137
|
declare function getAgentPolicy(agentPubkey: string, opts?: ClientOpts): Promise<AgentPolicy>;
|
|
138
138
|
declare function getSafetyStats(opts?: ClientOpts): Promise<Record<string, unknown>>;
|
|
139
139
|
|
|
140
|
-
export { type AgentAuth, type ChainOpts, type ClientOpts, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, type HeldAction, type HeldActionReview, type JudgeOptions, type JudgeResult, type JudgmentStatus, type TierInfo, type ToolCallFull, type ToolCallRecord, type Verdict,
|
|
140
|
+
export { type AgentAuth, type ChainOpts, type ClientOpts, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, type HeldAction, type HeldActionReview, type JudgeOptions, type JudgeResult, type JudgmentStatus, type TierInfo, type ToolCallFull, type ToolCallRecord, type Verdict, derivePublicKey, generateKeyPair, getAgentDetail, getAgentPolicy, getAgentToolCalls, getHeldActionReviews, getJudgmentStatus, getOrgTierInfo, getOrgToolCalls, getPendingHeldActions, getSafetyStats, getToolCallCount, getToolCallFull, getToolCalls, isValidPrivateKey, judgeAction, loadAgent, logToolCall, toPubkeyHex };
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ function generateKeyPair() {
|
|
|
25
25
|
pubKey: ecdh.getPublicKey("hex", "compressed")
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function loadAgent(privkey) {
|
|
29
29
|
const clean = privkey.replace(/^0x/, "").trim().toLowerCase();
|
|
30
30
|
if (!isValidPrivateKey(clean)) {
|
|
31
31
|
throw new Error(
|
|
@@ -293,7 +293,6 @@ export {
|
|
|
293
293
|
DEFAULT_BLOCKCHAIN_RID,
|
|
294
294
|
DEFAULT_CHROMIA_NODE_URLS,
|
|
295
295
|
DEFAULT_ENDPOINT,
|
|
296
|
-
createAgent,
|
|
297
296
|
derivePublicKey,
|
|
298
297
|
generateKeyPair,
|
|
299
298
|
getAgentDetail,
|
|
@@ -310,6 +309,7 @@ export {
|
|
|
310
309
|
getToolCalls,
|
|
311
310
|
isValidPrivateKey,
|
|
312
311
|
judgeAction,
|
|
312
|
+
loadAgent,
|
|
313
313
|
logToolCall,
|
|
314
314
|
toPubkeyHex
|
|
315
315
|
};
|