auto-mode 0.4.4 → 0.6.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 +39 -23
- package/dist/cli.js +23 -88
- package/dist/index.d.ts +27 -36
- package/dist/index.js +2 -2
- package/dist/{classify-locally-BdXQYjfj.js → render-verdict-9pnm4JBS.js} +746 -724
- package/mods/auto-mode/hooks/build-prompt-context.claude-check.ts +0 -1
- package/mods/auto-mode/hooks/build-prompt-context.ts +0 -2
- package/mods/auto-mode/hooks/parse-decision.ts +12 -24
- package/mods/auto-mode/hooks/register.claude-check.ts +140 -93
- package/mods/auto-mode/hooks/register.ts +21 -31
- package/mods/auto-mode/hooks/types.ts +1 -2
- package/package.json +3 -5
- package/policy/denial.md +1 -0
package/README.md
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
</p>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
**auto-mode** judges
|
|
10
|
-
|
|
11
|
-
cleanup; Jev evaluates the remaining actions against
|
|
9
|
+
**auto-mode** judges the tool calls that Claude Code would prompt for. It is a core library and a
|
|
10
|
+
Claude Code mod. The mod returns allow, deny, or no verdict before the permission dialog appears.
|
|
11
|
+
Local rules settle read-only actions and build cleanup; Jev evaluates the remaining actions against
|
|
12
|
+
a written policy.
|
|
12
13
|
|
|
13
14
|
The Jev request includes the policy, your configured environment and permissions, the complete
|
|
14
15
|
proposed action, and the last direct user message. It excludes the rest of the session. Configure
|
|
@@ -19,12 +20,12 @@ classifier.
|
|
|
19
20
|
|
|
20
21
|
```sh
|
|
21
22
|
npm i -g auto-mode
|
|
22
|
-
|
|
23
|
+
claude --plugin-dir "$(npm root -g)/auto-mode/mods/auto-mode"
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
The package ships the mod in `mods/auto-mode`. The mod runs the `auto-mode` executable on `PATH`;
|
|
27
|
+
its `command` option takes another executable. [Claude permission mod](./docs/guides/claude-mod.md)
|
|
28
|
+
covers the mod, its time limits, and a trial session.
|
|
28
29
|
|
|
29
30
|
Create the classifier configuration:
|
|
30
31
|
|
|
@@ -35,8 +36,8 @@ Create the classifier configuration:
|
|
|
35
36
|
}
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
Save it as `~/.config/auto-mode/config.json` and export your TypeSafe API key
|
|
39
|
-
|
|
39
|
+
Save it as `~/.config/auto-mode/config.json` and export your TypeSafe API key, or set
|
|
40
|
+
`provider.apiKeyCommand` to a command that prints it.
|
|
40
41
|
[Configuration](./docs/guides/configuration.md) covers credentials and provider overrides.
|
|
41
42
|
|
|
42
43
|
## Standing permissions
|
|
@@ -51,44 +52,59 @@ consent. [False-positive clarification](./docs/guides/policy.md#false-positive-c
|
|
|
51
52
|
clear Policy Tampering and Audit Tampering. The last direct user message can supply the exact action
|
|
52
53
|
and target that a soft block needs; replies such as “go ahead” cannot supply an unseen proposal.
|
|
53
54
|
|
|
54
|
-
Read [the policy](./policy/rules.md) before you enable the
|
|
55
|
+
Read [the policy](./policy/rules.md) before you enable the mod.
|
|
55
56
|
[Writing a policy](./docs/guides/policy.md) covers the precedence and the limits of an action-only
|
|
56
57
|
assessment.
|
|
57
58
|
|
|
58
59
|
## Decisions and failures
|
|
59
60
|
|
|
60
61
|
Jev evaluates each named rule with a typed choice. auto-mode returns a denial for a confident block,
|
|
61
|
-
approval when every rule confidently allows the action, and
|
|
62
|
-
|
|
62
|
+
approval when every rule confidently allows the action, and a denial for uncertain decisions. Every
|
|
63
|
+
denial names its rule, the harm, and what clears it, and the agent continues on another path. The
|
|
64
|
+
confidence threshold is configurable and needs evaluation against your actions.
|
|
63
65
|
|
|
64
66
|
A missing key, failed API call, malformed response, or oversized request follows `onFailure`. The
|
|
65
|
-
default `defer` writes no verdict and
|
|
66
|
-
|
|
67
|
+
default `defer` writes no verdict and keeps the prompt; `deny` fails closed. Failures write a
|
|
68
|
+
diagnostic to stderr. auto-mode never truncates a Jev action to make it fit.
|
|
67
69
|
|
|
68
70
|
## Commands
|
|
69
71
|
|
|
70
72
|
| Command | Effect |
|
|
71
73
|
| ---------------------------- | ----------------------------------------- |
|
|
72
|
-
| `auto-mode run` | Read a
|
|
74
|
+
| `auto-mode run` | Read a mod request and write a verdict |
|
|
73
75
|
| `auto-mode run --explain` | Write decision details to stderr |
|
|
74
76
|
| `auto-mode run --local-only` | Skip the model tier |
|
|
75
77
|
| `auto-mode run --jev-only` | Require Jev with a 5-second API timeout |
|
|
76
78
|
| `auto-mode print-prompt` | Print the selected provider's base policy |
|
|
77
|
-
| `auto-mode init <harness>` | Print a hook entry |
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
The mod evaluates only ask decisions and preserves existing allow and deny decisions. It runs the
|
|
81
|
+
CLI as a bounded child process with `--jev-only`. The `spark`, `claude`, and `glm` presets use the
|
|
82
|
+
Messages API and serve library callers.
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
## Library
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { classifyAction, loadConfig, parseActionRequest } from 'auto-mode';
|
|
88
|
+
|
|
89
|
+
const request = parseActionRequest(body);
|
|
90
|
+
|
|
91
|
+
if (request !== null) {
|
|
92
|
+
const outcome = await classifyAction(request, await loadConfig());
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`classifyAction` runs both tiers and returns the verdict, a note, and diagnostics. A request carries
|
|
97
|
+
the session identity, the action, and the task context; `parseActionRequest` builds one from the
|
|
98
|
+
mod's JSON.
|
|
84
99
|
|
|
85
100
|
## Documentation
|
|
86
101
|
|
|
87
|
-
- [Architecture](./docs/architecture/overview.md) covers the request, decision combination, and
|
|
88
|
-
contract.
|
|
102
|
+
- [Architecture](./docs/architecture/overview.md) covers the request, decision combination, and the
|
|
103
|
+
mod contract.
|
|
89
104
|
- [Configuration](./docs/guides/configuration.md) covers every setting and the imported Claude
|
|
90
105
|
rules.
|
|
91
|
-
- [
|
|
106
|
+
- [Claude permission mod](./docs/guides/claude-mod.md) covers the request, the verdict, and the time
|
|
107
|
+
limits.
|
|
92
108
|
- [Writing a policy](./docs/guides/policy.md) covers rule edits and evaluation.
|
|
93
109
|
|
|
94
110
|
## Licence
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { n as parseActionRequest, r as classifyAction, s as loadPolicy, t as renderVerdict, u as loadConfig } from "./render-verdict-9pnm4JBS.js";
|
|
3
3
|
import { appendFile, mkdir } from "node:fs/promises";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
@@ -24,15 +24,12 @@ async function writeActionDiagnostic(payload, entry) {
|
|
|
24
24
|
const stateDir = stateHome === void 0 || stateHome === "" ? join(homedir(), ".local", "state") : stateHome;
|
|
25
25
|
const path = process.env["AUTO_MODE_DIAGNOSTICS_PATH"] ?? join(stateDir, "auto-mode", "actions.jsonl");
|
|
26
26
|
if (path === "") return;
|
|
27
|
-
const actionID = payload.raw["tool_use_id"] ?? payload.raw["prompt_id"] ?? payload.raw["turn_id"];
|
|
28
27
|
const record = {
|
|
29
|
-
schemaVersion:
|
|
28
|
+
schemaVersion: 2,
|
|
30
29
|
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
31
30
|
invocationID: entry.invocationID,
|
|
32
|
-
sessionHash: toHash(payload.
|
|
33
|
-
actionHash:
|
|
34
|
-
harness: payload.harness,
|
|
35
|
-
event: payload.event,
|
|
31
|
+
sessionHash: toHash(payload.sessionID),
|
|
32
|
+
actionHash: payload.toolUseID === void 0 ? null : toHash(payload.toolUseID),
|
|
36
33
|
status: entry.status,
|
|
37
34
|
verdict: entry.verdict ?? null,
|
|
38
35
|
diagnostics: entry.diagnostics ?? null
|
|
@@ -52,17 +49,15 @@ function toHash(value) {
|
|
|
52
49
|
}
|
|
53
50
|
//#endregion
|
|
54
51
|
//#region src/cli.ts
|
|
55
|
-
const USAGE = `auto-mode — a permission classifier
|
|
52
|
+
const USAGE = `auto-mode — a permission classifier for the auto-mode Claude Code mod
|
|
56
53
|
|
|
57
54
|
Usage:
|
|
58
|
-
auto-mode run Read
|
|
55
|
+
auto-mode run Read an action request on stdin, write a verdict on stdout
|
|
59
56
|
auto-mode print-prompt Print the system prompt the classifier receives
|
|
60
|
-
auto-mode init <harness> Print the hook entry to add: claude, codex or muse
|
|
61
57
|
|
|
62
58
|
Options:
|
|
63
59
|
--classifier <path> Use this framework file instead of the shipped one
|
|
64
60
|
--rules <path> Use this rule list instead of the shipped one
|
|
65
|
-
--event <event> With init: pre-tool-use, the default, or permission-request
|
|
66
61
|
--explain With run: also write the reasoning to stderr
|
|
67
62
|
--local-only With run: skip the model tier
|
|
68
63
|
--jev-only With run: require Jev and cap its API timeout at 5 seconds
|
|
@@ -79,10 +74,10 @@ async function run(explain, localOnly, jevOnly, deadline) {
|
|
|
79
74
|
} catch {
|
|
80
75
|
return printNote(explain, "stdin is not JSON, so no verdict");
|
|
81
76
|
}
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
77
|
+
const request = parseActionRequest(body);
|
|
78
|
+
if (request === null) return printNote(explain, "not an action request this classifier judges, so no verdict");
|
|
84
79
|
const invocationID = randomUUID();
|
|
85
|
-
await writeActionDiagnostic(
|
|
80
|
+
await writeActionDiagnostic(request, {
|
|
86
81
|
invocationID,
|
|
87
82
|
status: "started"
|
|
88
83
|
});
|
|
@@ -90,64 +85,30 @@ async function run(explain, localOnly, jevOnly, deadline) {
|
|
|
90
85
|
try {
|
|
91
86
|
loaded = await loadConfig();
|
|
92
87
|
} catch {
|
|
93
|
-
await writeActionDiagnostic(
|
|
88
|
+
await writeActionDiagnostic(request, {
|
|
94
89
|
invocationID,
|
|
95
90
|
status: "failure",
|
|
96
91
|
verdict: "defer"
|
|
97
92
|
});
|
|
98
|
-
return printNote(true, "configuration unreadable;
|
|
93
|
+
return printNote(true, "configuration unreadable; no verdict");
|
|
99
94
|
}
|
|
100
95
|
const config = jevOnly ? buildJevOnlyConfig(loaded) : loaded;
|
|
101
96
|
if (config === null) {
|
|
102
|
-
await writeActionDiagnostic(
|
|
97
|
+
await writeActionDiagnostic(request, {
|
|
103
98
|
invocationID,
|
|
104
99
|
status: "failure",
|
|
105
100
|
verdict: "defer"
|
|
106
101
|
});
|
|
107
|
-
return printNote(true, "Jev-only evaluation requires system-one;
|
|
108
|
-
}
|
|
109
|
-
let configured = null;
|
|
110
|
-
if (config.provider.protocol === "system-one") try {
|
|
111
|
-
configured = await loadClaudeRules(config.claudeSettingsPath);
|
|
112
|
-
} catch {
|
|
113
|
-
if (config.onFailure === "deny") writeVerdict(payload.event, {
|
|
114
|
-
kind: "deny",
|
|
115
|
-
rule: "Classifier Unavailable",
|
|
116
|
-
reason: "Claude settings unreadable"
|
|
117
|
-
});
|
|
118
|
-
await writeActionDiagnostic(payload, {
|
|
119
|
-
invocationID,
|
|
120
|
-
status: "failure",
|
|
121
|
-
verdict: config.onFailure === "deny" ? "deny" : "defer"
|
|
122
|
-
});
|
|
123
|
-
return printNote(true, "Claude settings unreadable; classifier unavailable");
|
|
124
|
-
}
|
|
125
|
-
const local = configured !== null && (configured.hard_deny.length > 0 || configured.soft_deny.length > 0) ? { kind: "escalate" } : classifyLocally(payload);
|
|
126
|
-
if (local.kind === "allow") {
|
|
127
|
-
writeVerdict(payload.event, { kind: "allow" });
|
|
128
|
-
await writeActionDiagnostic(payload, {
|
|
129
|
-
invocationID,
|
|
130
|
-
status: "allow",
|
|
131
|
-
verdict: "allow"
|
|
132
|
-
});
|
|
133
|
-
return printNote(explain, `allowed by ${local.exception} (${payload.harness}, local)`);
|
|
134
|
-
}
|
|
135
|
-
if (localOnly) {
|
|
136
|
-
await writeActionDiagnostic(payload, {
|
|
137
|
-
invocationID,
|
|
138
|
-
status: "skipped",
|
|
139
|
-
verdict: "defer"
|
|
140
|
-
});
|
|
141
|
-
return printNote(explain, `${payload.toolName} needs the model tier, which --local-only skipped`);
|
|
102
|
+
return printNote(true, "Jev-only evaluation requires system-one; no verdict");
|
|
142
103
|
}
|
|
143
104
|
const deadlineAt = deadline === void 0 ? void 0 : Number(deadline);
|
|
144
105
|
if (deadlineAt !== void 0 && (!jevOnly || !Number.isSafeInteger(deadlineAt) || deadlineAt <= 0)) {
|
|
145
|
-
await writeActionDiagnostic(
|
|
106
|
+
await writeActionDiagnostic(request, {
|
|
146
107
|
invocationID,
|
|
147
108
|
status: "failure",
|
|
148
109
|
verdict: "defer"
|
|
149
110
|
});
|
|
150
|
-
return printNote(true, "invalid Jev evaluation deadline;
|
|
111
|
+
return printNote(true, "invalid Jev evaluation deadline; no verdict");
|
|
151
112
|
}
|
|
152
113
|
const controller = new AbortController();
|
|
153
114
|
const stopEvaluation = () => {
|
|
@@ -158,14 +119,15 @@ async function run(explain, localOnly, jevOnly, deadline) {
|
|
|
158
119
|
process.on("SIGINT", stopEvaluation);
|
|
159
120
|
}
|
|
160
121
|
try {
|
|
161
|
-
const outcome = await
|
|
122
|
+
const outcome = await classifyAction(request, config, {
|
|
123
|
+
localOnly,
|
|
162
124
|
deadlineAt,
|
|
163
125
|
signal: controller.signal
|
|
164
126
|
});
|
|
165
|
-
if (outcome.verdict !== null) writeVerdict(
|
|
166
|
-
await writeActionDiagnostic(
|
|
127
|
+
if (outcome.verdict !== null) writeVerdict(outcome.verdict);
|
|
128
|
+
await writeActionDiagnostic(request, {
|
|
167
129
|
invocationID,
|
|
168
|
-
status: outcome.
|
|
130
|
+
status: outcome.status,
|
|
169
131
|
verdict: outcome.verdict?.kind ?? "defer",
|
|
170
132
|
...outcome.diagnostics === void 0 ? {} : { diagnostics: outcome.diagnostics }
|
|
171
133
|
});
|
|
@@ -175,18 +137,13 @@ async function run(explain, localOnly, jevOnly, deadline) {
|
|
|
175
137
|
process.off("SIGINT", stopEvaluation);
|
|
176
138
|
}
|
|
177
139
|
}
|
|
178
|
-
function writeVerdict(
|
|
179
|
-
|
|
180
|
-
if (rendered !== null) process.stdout.write(rendered);
|
|
140
|
+
function writeVerdict(verdict) {
|
|
141
|
+
process.stdout.write(renderVerdict(verdict));
|
|
181
142
|
}
|
|
182
143
|
function printNote(explain, message) {
|
|
183
144
|
if (explain) process.stderr.write(`auto-mode: ${message}\n`);
|
|
184
145
|
return 0;
|
|
185
146
|
}
|
|
186
|
-
const HOOK_EVENTS = {
|
|
187
|
-
"pre-tool-use": "PreToolUse",
|
|
188
|
-
"permission-request": "PermissionRequest"
|
|
189
|
-
};
|
|
190
147
|
async function main(argv) {
|
|
191
148
|
const args = parseArgs({
|
|
192
149
|
args: [...argv],
|
|
@@ -194,7 +151,6 @@ async function main(argv) {
|
|
|
194
151
|
options: {
|
|
195
152
|
classifier: { type: "string" },
|
|
196
153
|
rules: { type: "string" },
|
|
197
|
-
event: { type: "string" },
|
|
198
154
|
explain: { type: "boolean" },
|
|
199
155
|
"local-only": { type: "boolean" },
|
|
200
156
|
"jev-only": { type: "boolean" },
|
|
@@ -213,28 +169,7 @@ async function main(argv) {
|
|
|
213
169
|
if (command === "run") try {
|
|
214
170
|
return await run(args.values.explain === true, args.values["local-only"] === true, args.values["jev-only"] === true, args.values["evaluation-deadline"]);
|
|
215
171
|
} catch {
|
|
216
|
-
process.stderr.write("auto-mode: configuration unreadable;
|
|
217
|
-
return 0;
|
|
218
|
-
}
|
|
219
|
-
if (command === "init") {
|
|
220
|
-
const [, harness] = args.positionals;
|
|
221
|
-
if (harness !== "claude" && harness !== "codex" && harness !== "muse") {
|
|
222
|
-
process.stderr.write("auto-mode init: name a harness — claude, codex or muse\n");
|
|
223
|
-
return 2;
|
|
224
|
-
}
|
|
225
|
-
const event = HOOK_EVENTS[args.values.event ?? "pre-tool-use"];
|
|
226
|
-
if (event === void 0) {
|
|
227
|
-
process.stderr.write("auto-mode init: --event takes pre-tool-use or permission-request\n");
|
|
228
|
-
return 2;
|
|
229
|
-
}
|
|
230
|
-
if (event === "PermissionRequest" && harness !== "claude") {
|
|
231
|
-
process.stderr.write(`auto-mode init: only Claude Code sends PermissionRequest\n`);
|
|
232
|
-
return 2;
|
|
233
|
-
}
|
|
234
|
-
process.stdout.write(`# Add this to ${SETTINGS_PATHS[harness]}\n`);
|
|
235
|
-
process.stdout.write(`# Configuration lives at ${resolveConfigPath()}\n`);
|
|
236
|
-
process.stdout.write(`${buildHookConfig(harness, `${process.execPath} ${process.argv[1] ?? "auto-mode"} run`, event)}\n`);
|
|
237
|
-
for (const line of [...SETUP_NOTES[harness], ...EVENT_NOTES[event]]) process.stdout.write(`# ${line}\n`);
|
|
172
|
+
process.stderr.write("auto-mode: configuration unreadable; no verdict\n");
|
|
238
173
|
return 0;
|
|
239
174
|
}
|
|
240
175
|
if (command === "print-prompt") {
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ interface Config {
|
|
|
19
19
|
readonly provider: ProviderConfig;
|
|
20
20
|
readonly classifierPath?: string | undefined;
|
|
21
21
|
readonly rulesPath?: string | undefined;
|
|
22
|
-
readonly transcriptEntries: number;
|
|
23
22
|
readonly onFailure: 'defer' | 'deny';
|
|
24
23
|
readonly claudeSettingsPath?: string | null | undefined;
|
|
25
24
|
readonly minConfidence?: number | undefined;
|
|
@@ -30,9 +29,7 @@ export declare function resolveConfigPath(): string;
|
|
|
30
29
|
export declare function loadConfig(path?: string): Promise<Config>;
|
|
31
30
|
export declare function resolveApiKey(provider: ProviderConfig, options?: EvaluationOptions): Promise<string | null>;
|
|
32
31
|
//#endregion
|
|
33
|
-
//#region src/
|
|
34
|
-
type Harness = 'claude' | 'codex' | 'muse';
|
|
35
|
-
type HookEvent = 'PreToolUse' | 'PermissionRequest';
|
|
32
|
+
//#region src/request/types.d.ts
|
|
36
33
|
interface UserTask {
|
|
37
34
|
readonly text: string;
|
|
38
35
|
readonly origin: 'composer' | 'bridge' | 'sdk';
|
|
@@ -50,40 +47,22 @@ interface DecisionContext {
|
|
|
50
47
|
readonly reason: 'unavailable' | 'budget';
|
|
51
48
|
}[];
|
|
52
49
|
}
|
|
53
|
-
interface
|
|
54
|
-
readonly
|
|
55
|
-
readonly
|
|
56
|
-
readonly sessionId: string;
|
|
50
|
+
interface ActionRequest {
|
|
51
|
+
readonly sessionID: string;
|
|
52
|
+
readonly toolUseID?: string | undefined;
|
|
57
53
|
readonly cwd: string;
|
|
58
54
|
readonly toolName: string;
|
|
59
55
|
readonly toolInput: Readonly<Record<string, unknown>>;
|
|
60
|
-
readonly transcriptPath?: string | undefined;
|
|
61
56
|
readonly decisionContext?: DecisionContext | undefined;
|
|
62
|
-
readonly raw: Readonly<Record<string, unknown>>;
|
|
63
57
|
}
|
|
64
58
|
type Verdict = {
|
|
65
59
|
readonly kind: 'allow';
|
|
66
|
-
} | {
|
|
67
|
-
readonly kind: 'ask';
|
|
68
60
|
} | {
|
|
69
61
|
readonly kind: 'deny';
|
|
70
62
|
readonly rule: string;
|
|
71
63
|
readonly reason: string;
|
|
72
64
|
};
|
|
73
65
|
//#endregion
|
|
74
|
-
//#region src/harness/detect-harness.d.ts
|
|
75
|
-
export declare function detectHarness(payload: Readonly<Record<string, unknown>>): Harness | null;
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/harness/parse-payload.d.ts
|
|
78
|
-
export declare function parsePayload(body: unknown): HookPayload | null;
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region src/harness/render-verdict.d.ts
|
|
81
|
-
export declare function renderVerdict(event: HookEvent, verdict: Verdict): string | null;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/install/hook-config.d.ts
|
|
84
|
-
export declare function buildHookConfig(harness: Harness, command: string, event?: HookEvent): string;
|
|
85
|
-
export declare const SETTINGS_PATHS: Readonly<Record<Harness, string>>;
|
|
86
|
-
//#endregion
|
|
87
66
|
//#region src/model/types.d.ts
|
|
88
67
|
interface DecisionRule {
|
|
89
68
|
readonly name: string;
|
|
@@ -99,7 +78,7 @@ interface DecisionAnswer {
|
|
|
99
78
|
}
|
|
100
79
|
type DecisionFailureReason = 'request-too-large' | 'aborted' | 'network' | 'http-status' | 'invalid-response';
|
|
101
80
|
interface DecisionDiagnostics {
|
|
102
|
-
readonly status: 'allow' | 'deny' | '
|
|
81
|
+
readonly status: 'allow' | 'deny' | 'failure' | 'timeout' | 'cancelled';
|
|
103
82
|
readonly stage: 'credential' | 'evidence' | 'request' | 'response';
|
|
104
83
|
readonly keyResolved: boolean;
|
|
105
84
|
readonly keySource: 'environment' | 'command' | 'none';
|
|
@@ -117,6 +96,19 @@ interface DecisionDiagnostics {
|
|
|
117
96
|
}[];
|
|
118
97
|
}
|
|
119
98
|
//#endregion
|
|
99
|
+
//#region src/classify-action.d.ts
|
|
100
|
+
interface ActionOutcome {
|
|
101
|
+
readonly verdict: Verdict | null;
|
|
102
|
+
readonly note: string;
|
|
103
|
+
readonly status: 'allow' | 'skipped' | 'failure' | DecisionDiagnostics['status'];
|
|
104
|
+
readonly unavailable?: boolean;
|
|
105
|
+
readonly diagnostics?: DecisionDiagnostics;
|
|
106
|
+
}
|
|
107
|
+
interface ClassifyOptions extends EvaluationOptions {
|
|
108
|
+
readonly localOnly?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export declare function classifyAction(request: ActionRequest, config: Config, options?: ClassifyOptions): Promise<ActionOutcome>;
|
|
111
|
+
//#endregion
|
|
120
112
|
//#region src/model/classify-with-model.d.ts
|
|
121
113
|
interface ModelOutcome {
|
|
122
114
|
readonly verdict: Verdict | null;
|
|
@@ -124,7 +116,7 @@ interface ModelOutcome {
|
|
|
124
116
|
readonly unavailable?: boolean;
|
|
125
117
|
readonly diagnostics?: DecisionDiagnostics;
|
|
126
118
|
}
|
|
127
|
-
export declare function classifyWithModel(payload:
|
|
119
|
+
export declare function classifyWithModel(payload: ActionRequest, config: Config, options?: EvaluationOptions): Promise<ModelOutcome>;
|
|
128
120
|
//#endregion
|
|
129
121
|
//#region src/model/parse-verdict.d.ts
|
|
130
122
|
export declare function parseModelVerdict(text: string): Verdict;
|
|
@@ -136,6 +128,12 @@ interface PolicyPaths {
|
|
|
136
128
|
}
|
|
137
129
|
export declare function loadPolicy(paths?: PolicyPaths, framework?: 'classifier.md' | 'decision.md'): Promise<string>;
|
|
138
130
|
//#endregion
|
|
131
|
+
//#region src/request/parse-action-request.d.ts
|
|
132
|
+
export declare function parseActionRequest(body: unknown): ActionRequest | null;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/request/render-verdict.d.ts
|
|
135
|
+
export declare function renderVerdict(verdict: Verdict): string;
|
|
136
|
+
//#endregion
|
|
139
137
|
//#region src/rules/classify-locally.d.ts
|
|
140
138
|
type LocalVerdict = {
|
|
141
139
|
readonly kind: 'allow';
|
|
@@ -143,13 +141,6 @@ type LocalVerdict = {
|
|
|
143
141
|
} | {
|
|
144
142
|
readonly kind: 'escalate';
|
|
145
143
|
};
|
|
146
|
-
export declare function classifyLocally(payload:
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/transcript/read-transcript.d.ts
|
|
149
|
-
interface TranscriptEntry {
|
|
150
|
-
readonly role: string;
|
|
151
|
-
readonly text: string;
|
|
152
|
-
}
|
|
153
|
-
export declare function readTranscript(path: string | undefined, limit: number): Promise<readonly TranscriptEntry[]>;
|
|
144
|
+
export declare function classifyLocally(payload: ActionRequest): LocalVerdict;
|
|
154
145
|
//#endregion
|
|
155
|
-
export type {
|
|
146
|
+
export type { ActionOutcome, ActionRequest, ClassifyOptions, Config, DecisionContext, LocalVerdict, ModelOutcome, PolicyPaths, ProviderConfig, Verdict };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { DEFAULT_CONFIG, PRESETS,
|
|
1
|
+
import { a as classifyWithModel, c as DEFAULT_CONFIG, d as resolveApiKey, f as resolveConfigPath, i as classifyLocally, l as PRESETS, n as parseActionRequest, o as parseModelVerdict, r as classifyAction, s as loadPolicy, t as renderVerdict, u as loadConfig } from "./render-verdict-9pnm4JBS.js";
|
|
2
|
+
export { DEFAULT_CONFIG, PRESETS, classifyAction, classifyLocally, classifyWithModel, loadConfig, loadPolicy, parseActionRequest, parseModelVerdict, renderVerdict, resolveApiKey, resolveConfigPath };
|