@atbash/autogen 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +16 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# `@atbash/autogen`
|
|
2
|
+
|
|
3
|
+
Atbash safety judge for AutoGen-style multi-agent orchestration loops.
|
|
4
|
+
|
|
5
|
+
This package is intentionally small. It gives you one focused helper to ask Atbash for a verdict at the point where your app decides whether to proceed with an action. It does not own your orchestration model.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @atbash/autogen
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## When To Use It
|
|
14
|
+
|
|
15
|
+
Use this package when:
|
|
16
|
+
|
|
17
|
+
- you already control your own orchestration steps
|
|
18
|
+
- you want one explicit Atbash check before a side effect
|
|
19
|
+
- you do not need a heavier plugin lifecycle
|
|
20
|
+
|
|
21
|
+
Good fits:
|
|
22
|
+
|
|
23
|
+
- AutoGen-style multi-agent loops
|
|
24
|
+
- custom planners
|
|
25
|
+
- supervisor-worker systems
|
|
26
|
+
- approval chains where your app already owns the review UI
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createAtbashClient, loadAgent } from "@atbash/sdk";
|
|
32
|
+
import { judgeForAutoGen } from "@atbash/autogen";
|
|
33
|
+
|
|
34
|
+
const agent = loadAgent(process.env.ATBASH_AGENT_PRIVKEY);
|
|
35
|
+
const client = createAtbashClient({ keyPair: { privKey: agent.privkey, pubKey: agent.pubkey } });
|
|
36
|
+
|
|
37
|
+
const result = await judgeForAutoGen(
|
|
38
|
+
{
|
|
39
|
+
action: "Bank transfer $25 to a new external vendor account",
|
|
40
|
+
context: "AutoGen agent checking transfer before execution",
|
|
41
|
+
toolName: "send_bank_transfer",
|
|
42
|
+
toolArgs: { amount: 25, recipient: "new vendor" },
|
|
43
|
+
},
|
|
44
|
+
client,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (result.allow) {
|
|
48
|
+
// proceed
|
|
49
|
+
} else {
|
|
50
|
+
// stop — surface result.reason to the operator
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
### `judgeForAutoGen(input, client)`
|
|
57
|
+
|
|
58
|
+
| Parameter | Type | Description |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| `input` | `AutoGenJudgeInput` | The action to evaluate |
|
|
61
|
+
| `client` | `AtbashClient` | SDK client created with `createAtbashClient()` |
|
|
62
|
+
|
|
63
|
+
Returns `Promise<Decision>`.
|
|
64
|
+
|
|
65
|
+
### `AutoGenJudgeInput`
|
|
66
|
+
|
|
67
|
+
| Field | Type | Required | Description |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| `action` | `string` | Yes | Human-readable description of the action |
|
|
70
|
+
| `context` | `string` | Yes | Why the agent is taking this action |
|
|
71
|
+
| `toolName` | `string` | No | Name of the tool being called (defaults to `"autogen_action"`) |
|
|
72
|
+
| `toolArgs` | `unknown` | No | Structured payload the judge evaluates (defaults to `{ action }`) |
|
|
73
|
+
|
|
74
|
+
### `Decision`
|
|
75
|
+
|
|
76
|
+
| Field | Type | Description |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| `allow` | `boolean` | Whether to proceed |
|
|
79
|
+
| `verdict` | `"ALLOW" \| "HOLD" \| "BLOCK" \| "ERROR"` | Judge verdict |
|
|
80
|
+
| `reason` | `string?` | Policy reason (present on HOLD/BLOCK) |
|
|
81
|
+
| `toolCallId` | `string?` | ID to pass back on HOLD resolution |
|
|
82
|
+
|
|
83
|
+
## Verdict Handling
|
|
84
|
+
|
|
85
|
+
| Verdict | Meaning | Action |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `ALLOW` | Safe to proceed | Continue orchestration |
|
|
88
|
+
| `HOLD` | Needs human review | Stop and hand off; keep `toolCallId` |
|
|
89
|
+
| `BLOCK` | Policy violation | Stop and surface `reason` |
|
|
90
|
+
| `ERROR` | Judge unreachable | Fail closed by default |
|
|
91
|
+
|
|
92
|
+
## Creating the Client
|
|
93
|
+
|
|
94
|
+
Create the `AtbashClient` once at startup, then pass it to every `judgeForAutoGen` call.
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { createAtbashClient, loadAgent } from "@atbash/sdk";
|
|
98
|
+
|
|
99
|
+
const agent = loadAgent(process.env.ATBASH_AGENT_PRIVKEY);
|
|
100
|
+
const client = createAtbashClient({ keyPair: { privKey: agent.privkey, pubKey: agent.pubkey } });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
To use a custom endpoint:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const client = createAtbashClient({
|
|
107
|
+
keyPair: { privKey: agent.privkey, pubKey: agent.pubkey },
|
|
108
|
+
judge: { endpoint: process.env.ATBASH_ENDPOINT },
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## What This Package Does Not Do
|
|
113
|
+
|
|
114
|
+
- It does not wrap your framework for you.
|
|
115
|
+
- It does not create a review queue.
|
|
116
|
+
- It does not log or execute the real action automatically.
|
|
117
|
+
|
|
118
|
+
That is intentional. The host loop stays in control.
|
|
119
|
+
|
|
120
|
+
## Example
|
|
121
|
+
|
|
122
|
+
A runnable example is in [`examples/autogen-runtime-agent/`](./examples/autogen-runtime-agent/).
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
cd examples/autogen-runtime-agent
|
|
126
|
+
ATBASH_AGENT_PRIVKEY=your_key_here node run.mjs
|
|
127
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AtbashClient, Decision } from '@atbash/sdk';
|
|
2
|
+
|
|
3
|
+
type AutoGenJudgeInput = {
|
|
4
|
+
action: string;
|
|
5
|
+
context: string;
|
|
6
|
+
toolName?: string;
|
|
7
|
+
toolArgs?: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Submit an AutoGen-style action to the Atbash judge for evaluation.
|
|
11
|
+
*
|
|
12
|
+
* Uses the high-level `AtbashClient.auditToolCall` so the call inherits
|
|
13
|
+
* secret redaction, endpoint validation, fail-closed defaults, and the
|
|
14
|
+
* normalised `Decision` shape from the SDK.
|
|
15
|
+
*
|
|
16
|
+
* The user-supplied human-readable `action` description is forwarded to
|
|
17
|
+
* the judge alongside the caller's own `context` string, while the
|
|
18
|
+
* structured `toolArgs` become the action payload the redactor scans
|
|
19
|
+
* and the judge evaluates.
|
|
20
|
+
*/
|
|
21
|
+
declare function judgeForAutoGen(input: AutoGenJudgeInput, client: AtbashClient): Promise<Decision>;
|
|
22
|
+
|
|
23
|
+
export { type AutoGenJudgeInput, judgeForAutoGen };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
async function judgeForAutoGen(input, client) {
|
|
3
|
+
const action = input.action?.trim();
|
|
4
|
+
const context = input.context?.trim();
|
|
5
|
+
if (!action || !context) {
|
|
6
|
+
throw new Error("Both action and context are required");
|
|
7
|
+
}
|
|
8
|
+
return client.auditToolCall({
|
|
9
|
+
toolName: input.toolName ?? "autogen_action",
|
|
10
|
+
args: input.toolArgs ?? { action },
|
|
11
|
+
context: `${action} \u2014 ${context}`
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
judgeForAutoGen
|
|
16
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atbash/autogen",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Atbash safety judge plugin for AutoGen-style multi-agent orchestration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"atbash",
|
|
20
|
+
"autogen",
|
|
21
|
+
"ai-safety",
|
|
22
|
+
"agent-safety",
|
|
23
|
+
"multi-agent",
|
|
24
|
+
"judge",
|
|
25
|
+
"policy"
|
|
26
|
+
],
|
|
27
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest",
|
|
32
|
+
"test:integration": "node examples/autogen-runtime-agent/run.mjs"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@atbash/sdk": "^0.3.8"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^25.7.0",
|
|
39
|
+
"tsup": "^8.0.0",
|
|
40
|
+
"typescript": "^5.0.0",
|
|
41
|
+
"vitest": "^4.1.6"
|
|
42
|
+
}
|
|
43
|
+
}
|