@2kw/ai 6.2.0-dev.42 → 6.2.0-dev.44
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* `agents policy <agent>` — what the policy gate would do to a call of each tool
|
|
4
|
+
* a version configures, without running the agent (&56 S6, #662).
|
|
5
|
+
*
|
|
6
|
+
* Answers the question an operator otherwise has to answer by running the agent
|
|
7
|
+
* and reading the transcript. The version defaults to the agent's latest, which
|
|
8
|
+
* is the one an unlabelled reference resolves to.
|
|
9
|
+
*/
|
|
10
|
+
export declare function makeAgentPolicyCommand(): Command;
|
|
11
|
+
//# sourceMappingURL=agent-policy.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { getClient, runAction } from "../lib/client.js";
|
|
4
|
+
import { isJsonOutput } from "../lib/config.js";
|
|
5
|
+
import { formatDetail, formatList } from "../lib/output.js";
|
|
6
|
+
import { resolveAgent } from "../lib/agent-lookup.js";
|
|
7
|
+
import { CliUsageError } from "../lib/errors.js";
|
|
8
|
+
import { getLatestVersion } from "./agent-apply.js";
|
|
9
|
+
/**
|
|
10
|
+
* `agents policy <agent>` — what the policy gate would do to a call of each tool
|
|
11
|
+
* a version configures, without running the agent (&56 S6, #662).
|
|
12
|
+
*
|
|
13
|
+
* Answers the question an operator otherwise has to answer by running the agent
|
|
14
|
+
* and reading the transcript. The version defaults to the agent's latest, which
|
|
15
|
+
* is the one an unlabelled reference resolves to.
|
|
16
|
+
*/
|
|
17
|
+
export function makeAgentPolicyCommand() {
|
|
18
|
+
return new Command("policy")
|
|
19
|
+
.description("Show the effective tool policy of an agent version")
|
|
20
|
+
.argument("<agent>", "Agent ID or name")
|
|
21
|
+
.option("--version <id>", "Agent version ID (default: the agent's latest version)")
|
|
22
|
+
.option("--tool <name>", "Answer for one tool instead of every configured tool")
|
|
23
|
+
.option("--installation <id>", "Resolve the module tool catalog of this installation")
|
|
24
|
+
.action(async (agentRef, opts, command) => {
|
|
25
|
+
await runAction(command, async () => {
|
|
26
|
+
const client = getClient(command);
|
|
27
|
+
const agent = await resolveAgent(client, agentRef);
|
|
28
|
+
const agentId = agent.id;
|
|
29
|
+
const versionId = opts.version ?? (await getLatestVersion(client, agentId))?.id;
|
|
30
|
+
if (!versionId) {
|
|
31
|
+
throw new CliUsageError(`Agent '${agent.name}' has no versions yet, so it has no policy to read. Create a version first.`);
|
|
32
|
+
}
|
|
33
|
+
const { data } = await client.GET("/v1/agents/{agentId}/versions/{versionId}/policy", {
|
|
34
|
+
params: {
|
|
35
|
+
path: { agentId, versionId },
|
|
36
|
+
query: { tool: opts.tool, installation: opts.installation },
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (isJsonOutput(command)) {
|
|
40
|
+
formatDetail(data, command);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// Both deployment switches decide whether a JUDGE row ever reaches a
|
|
44
|
+
// model, so they belong above the table rather than in a footnote.
|
|
45
|
+
const auto = data?.autoApproval;
|
|
46
|
+
const parts = [
|
|
47
|
+
`auto-approval ${auto?.enabled ? "on" : "off (every auto pauses for a human)"}`,
|
|
48
|
+
`judge ${auto?.judgeConfigured ? "configured" : "not configured (every candidate escalates)"}`,
|
|
49
|
+
];
|
|
50
|
+
if (data?.catalogResolvedAt)
|
|
51
|
+
parts.push(`catalog resolved ${data.catalogResolvedAt}`);
|
|
52
|
+
console.log(chalk.dim(parts.join(", ")));
|
|
53
|
+
formatList(data?.tools, command, [
|
|
54
|
+
"tool",
|
|
55
|
+
"verdict",
|
|
56
|
+
"action",
|
|
57
|
+
"policyClass",
|
|
58
|
+
"source",
|
|
59
|
+
"matchedRules",
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=agent-policy.js.map
|
package/dist/commands/agents.js
CHANGED
|
@@ -7,6 +7,7 @@ import { makeAgentLabelsCommand } from "./agent-labels.js";
|
|
|
7
7
|
import { makeAgentDecideCommand, makeAgentRunCommand } from "./agent-run.js";
|
|
8
8
|
import { makeAgentApplyCommand } from "./agent-apply.js";
|
|
9
9
|
import { makeAgentExportCommand } from "./agent-export.js";
|
|
10
|
+
import { makeAgentPolicyCommand } from "./agent-policy.js";
|
|
10
11
|
import { makeAgentInitCommand, makeAgentSchemaCommand } from "./agent-init.js";
|
|
11
12
|
import { maskSecrets } from "../agent-config/file.js";
|
|
12
13
|
import { collectModel, MODEL_HELP, MODELS_HELP, modelFieldsFromOptions } from "../lib/agent-models.js";
|
|
@@ -162,6 +163,7 @@ export function makeAgentsCommand() {
|
|
|
162
163
|
cmd.addCommand(makeAgentExportCommand());
|
|
163
164
|
cmd.addCommand(makeAgentInitCommand());
|
|
164
165
|
cmd.addCommand(makeAgentSchemaCommand());
|
|
166
|
+
cmd.addCommand(makeAgentPolicyCommand());
|
|
165
167
|
cmd.addCommand(makeAgentVersionsCommand());
|
|
166
168
|
cmd.addCommand(makeAgentLabelsCommand());
|
|
167
169
|
return cmd;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kw/ai",
|
|
3
|
-
"version": "6.2.0-dev.
|
|
3
|
+
"version": "6.2.0-dev.44",
|
|
4
4
|
"description": "CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|