@2kw/ai 8.4.0-dev.2 → 8.4.0-dev.33
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/dist/commands/agent-live.d.ts +11 -0
- package/dist/commands/agent-live.js +95 -0
- package/dist/commands/agent-versions.js +11 -0
- package/dist/commands/agents.js +6 -2
- package/dist/commands/conversations.js +9 -2
- package/dist/commands/skill-versions.d.ts +2 -0
- package/dist/commands/skill-versions.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* `agents go-live`, `follow-latest` and `live-history` (#1825): the version users get.
|
|
4
|
+
*
|
|
5
|
+
* Both writes send the Live version and mode the agent read just showed as `expectedVersionId` /
|
|
6
|
+
* `expectedLiveMode`, so a Live another admin moved in between answers 409 instead of being overwritten.
|
|
7
|
+
*/
|
|
8
|
+
export declare function makeAgentGoLiveCommand(): Command;
|
|
9
|
+
export declare function makeAgentFollowLatestCommand(): Command;
|
|
10
|
+
export declare function makeAgentLiveHistoryCommand(): Command;
|
|
11
|
+
//# sourceMappingURL=agent-live.d.ts.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { getClient, runAction } from "../lib/client.js";
|
|
3
|
+
import { formatDetail, formatPage } from "../lib/output.js";
|
|
4
|
+
import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
|
|
5
|
+
import { resolveAgent } from "../lib/agent-lookup.js";
|
|
6
|
+
import { CliUsageError } from "../lib/errors.js";
|
|
7
|
+
import { parseVersionNumber } from "./skill-versions.js";
|
|
8
|
+
const PAGE_SIZE = 100;
|
|
9
|
+
const MAX_PAGES = 50;
|
|
10
|
+
/**
|
|
11
|
+
* `agents go-live`, `follow-latest` and `live-history` (#1825): the version users get.
|
|
12
|
+
*
|
|
13
|
+
* Both writes send the Live version and mode the agent read just showed as `expectedVersionId` /
|
|
14
|
+
* `expectedLiveMode`, so a Live another admin moved in between answers 409 instead of being overwritten.
|
|
15
|
+
*/
|
|
16
|
+
export function makeAgentGoLiveCommand() {
|
|
17
|
+
return new Command("go-live")
|
|
18
|
+
.description("Put an agent version live and pin it there (an older version is a roll back); ADMIN or OWNER")
|
|
19
|
+
.argument("<agent>", "Agent ID or name")
|
|
20
|
+
.requiredOption("--version <number>", "Version number to put live", parseVersionNumber)
|
|
21
|
+
.option("--note <text>", "Why, shown in the Live history")
|
|
22
|
+
.action(async (agentRef, opts, command) => {
|
|
23
|
+
await runAction(command, async () => {
|
|
24
|
+
const client = getClient(command);
|
|
25
|
+
const agent = await resolveAgent(client, agentRef);
|
|
26
|
+
const agentId = agent.id;
|
|
27
|
+
const versionId = await findVersionId(client, agentId, opts.version);
|
|
28
|
+
if (!versionId) {
|
|
29
|
+
throw new CliUsageError(`Agent '${agent.name}' has no version ${opts.version}.`);
|
|
30
|
+
}
|
|
31
|
+
const { data } = await client.PUT("/v1/agents/{agentId}/labels/{labelName}", {
|
|
32
|
+
params: { path: { agentId, labelName: "live" } },
|
|
33
|
+
body: { agentVersionId: versionId, ...expectedLive(agent), note: opts.note },
|
|
34
|
+
});
|
|
35
|
+
formatDetail(data, command);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function makeAgentFollowLatestCommand() {
|
|
40
|
+
return new Command("follow-latest")
|
|
41
|
+
.description("Let an agent's Live version move with every save again; ADMIN or OWNER")
|
|
42
|
+
.argument("<agent>", "Agent ID or name")
|
|
43
|
+
.option("--note <text>", "Why, shown in the Live history")
|
|
44
|
+
.action(async (agentRef, opts, command) => {
|
|
45
|
+
await runAction(command, async () => {
|
|
46
|
+
const client = getClient(command);
|
|
47
|
+
const agent = await resolveAgent(client, agentRef);
|
|
48
|
+
const { data } = await client.PUT("/v1/agents/{agentId}/labels/{labelName}", {
|
|
49
|
+
params: { path: { agentId: agent.id, labelName: "live" } },
|
|
50
|
+
body: { liveMode: "follows_latest", ...expectedLive(agent), note: opts.note },
|
|
51
|
+
});
|
|
52
|
+
formatDetail(data, command);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function makeAgentLiveHistoryCommand() {
|
|
57
|
+
const cmd = new Command("live-history")
|
|
58
|
+
.description("List who put which version live, newest first")
|
|
59
|
+
.argument("<agent>", "Agent ID or name");
|
|
60
|
+
addPaginationOptions(cmd);
|
|
61
|
+
cmd.action(async (agentRef, opts, command) => {
|
|
62
|
+
await runAction(command, async () => {
|
|
63
|
+
const client = getClient(command);
|
|
64
|
+
const agent = await resolveAgent(client, agentRef);
|
|
65
|
+
const { data } = await client.GET("/v1/agents/{agentId}/labels/live/history", {
|
|
66
|
+
params: { path: { agentId: agent.id }, query: paginationParams(opts) },
|
|
67
|
+
});
|
|
68
|
+
formatPage(data, command, ["at", "kind", "fromVersionNumber", "toVersionNumber", "liveMode", "actorKind", "note"]);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
return cmd;
|
|
72
|
+
}
|
|
73
|
+
/** The Live state as read; null fields (Live not enabled yet) are left out and the server says why. */
|
|
74
|
+
function expectedLive(agent) {
|
|
75
|
+
return { expectedVersionId: agent.liveVersionId ?? undefined, expectedLiveMode: agent.liveMode ?? undefined };
|
|
76
|
+
}
|
|
77
|
+
async function findVersionId(client, agentId, versionNumber) {
|
|
78
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
79
|
+
const { data } = await client.GET("/v1/agents/{agentId}/versions", {
|
|
80
|
+
params: {
|
|
81
|
+
path: { agentId },
|
|
82
|
+
// A stable sort: offset paging over an unordered result can skip rows between pages.
|
|
83
|
+
query: paginationParams({ page: String(page), size: String(PAGE_SIZE), sort: ["versionNumber,desc"] }),
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
const content = data?.content ?? [];
|
|
87
|
+
const hit = content.find((v) => v.versionNumber === versionNumber);
|
|
88
|
+
if (hit)
|
|
89
|
+
return hit.id;
|
|
90
|
+
if (data?.last !== false || content.length === 0)
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=agent-live.js.map
|
|
@@ -46,6 +46,17 @@ export function makeAgentVersionsCommand() {
|
|
|
46
46
|
formatDetail(maskSecrets(data, []), command);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
|
+
cmd
|
|
50
|
+
.command("live")
|
|
51
|
+
.description("Get the Live version of an agent: the version users get")
|
|
52
|
+
.requiredOption("--agent <id>", "Agent ID")
|
|
53
|
+
.action(async (opts, command) => {
|
|
54
|
+
await runAction(command, async () => {
|
|
55
|
+
const client = getClient(command);
|
|
56
|
+
const { data } = await client.GET("/v1/agents/{agentId}/versions/live", { params: { path: { agentId: opts.agent } } });
|
|
57
|
+
formatDetail(maskSecrets(data, []), command);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
49
60
|
cmd
|
|
50
61
|
.command("create")
|
|
51
62
|
.description("Create a new agent version")
|
package/dist/commands/agents.js
CHANGED
|
@@ -4,6 +4,7 @@ import { formatPage, formatDetail, formatList, formatSuccess } from "../lib/outp
|
|
|
4
4
|
import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
|
|
5
5
|
import { makeAgentVersionsCommand } from "./agent-versions.js";
|
|
6
6
|
import { makeAgentLabelsCommand } from "./agent-labels.js";
|
|
7
|
+
import { makeAgentFollowLatestCommand, makeAgentGoLiveCommand, makeAgentLiveHistoryCommand } from "./agent-live.js";
|
|
7
8
|
import { makeAgentDecideCommand, makeAgentRunCommand } from "./agent-run.js";
|
|
8
9
|
import { makeAgentApplyCommand } from "./agent-apply.js";
|
|
9
10
|
import { makeAgentExportCommand } from "./agent-export.js";
|
|
@@ -248,9 +249,9 @@ export function makeAgentsCommand() {
|
|
|
248
249
|
});
|
|
249
250
|
});
|
|
250
251
|
cmd.addCommand(toolCatalogs);
|
|
251
|
-
// The skills the
|
|
252
|
+
// The skills the version users get (its Live version) binds (#827, #1825) -- readable by a chat-only USER key,
|
|
252
253
|
// which cannot read the version itself. No published version answers [] rather than 404.
|
|
253
|
-
const skills = new Command("skills").description("List the skills an agent
|
|
254
|
+
const skills = new Command("skills").description("List the skills the version of an agent that users get (its Live version) binds");
|
|
254
255
|
skills.requiredOption("--agent <id>", "Agent ID");
|
|
255
256
|
skills.action(async (opts, command) => {
|
|
256
257
|
await runAction(command, async () => {
|
|
@@ -271,6 +272,9 @@ export function makeAgentsCommand() {
|
|
|
271
272
|
cmd.addCommand(makeAgentPolicyCommand());
|
|
272
273
|
cmd.addCommand(makeAgentVersionsCommand());
|
|
273
274
|
cmd.addCommand(makeAgentLabelsCommand());
|
|
275
|
+
cmd.addCommand(makeAgentGoLiveCommand());
|
|
276
|
+
cmd.addCommand(makeAgentFollowLatestCommand());
|
|
277
|
+
cmd.addCommand(makeAgentLiveHistoryCommand());
|
|
274
278
|
return cmd;
|
|
275
279
|
}
|
|
276
280
|
//# sourceMappingURL=agents.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { getClient, runAction } from "../lib/client.js";
|
|
3
|
+
import { CliUsageError } from "../lib/errors.js";
|
|
3
4
|
import { formatDetail, formatSuccess } from "../lib/output.js";
|
|
4
5
|
export function makeConversationsCommand() {
|
|
5
6
|
const cmd = new Command("conversations").description("Manage conversations");
|
|
@@ -119,11 +120,17 @@ export function makeConversationsCommand() {
|
|
|
119
120
|
.command("list")
|
|
120
121
|
.description("List a conversation's items, oldest first")
|
|
121
122
|
.argument("<conversationId>", "Conversation ID")
|
|
122
|
-
.
|
|
123
|
+
.option("--after <responseId>", "List the responses after this one (the response_id of the last item listed)")
|
|
124
|
+
.option("--limit <n>", "Most responses per page, 1 to 100 (default 20)")
|
|
125
|
+
.action(async (conversationId, opts, command) => {
|
|
123
126
|
await runAction(command, async () => {
|
|
127
|
+
const limit = opts.limit === undefined ? undefined : Number(opts.limit);
|
|
128
|
+
if (limit !== undefined && !(/^\d+$/.test(opts.limit) && limit >= 1 && limit <= 100)) {
|
|
129
|
+
throw new CliUsageError(`--limit must be a whole number between 1 and 100, not '${opts.limit}'`);
|
|
130
|
+
}
|
|
124
131
|
const client = getClient(command);
|
|
125
132
|
const { data } = await client.GET("/v1/conversations/{conversationId}/items", {
|
|
126
|
-
params: { path: { conversationId } },
|
|
133
|
+
params: { path: { conversationId }, query: { after: opts.after, limit } },
|
|
127
134
|
});
|
|
128
135
|
formatDetail(data, command);
|
|
129
136
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
/** Manage skill versions (#642). */
|
|
3
3
|
export declare function makeSkillVersionsCommand(): Command;
|
|
4
|
+
/** A restore names an existing version by number; refuse anything else before calling the API (#783). */
|
|
5
|
+
export declare function parseVersionNumber(value: string): number;
|
|
4
6
|
//# sourceMappingURL=skill-versions.d.ts.map
|
|
@@ -69,7 +69,7 @@ export function makeSkillVersionsCommand() {
|
|
|
69
69
|
return cmd;
|
|
70
70
|
}
|
|
71
71
|
/** A restore names an existing version by number; refuse anything else before calling the API (#783). */
|
|
72
|
-
function parseVersionNumber(value) {
|
|
72
|
+
export function parseVersionNumber(value) {
|
|
73
73
|
const n = Number(value);
|
|
74
74
|
if (!/^\d+$/.test(value) || n < 1) {
|
|
75
75
|
throw new InvalidArgumentError("Version number must be a positive integer.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kw/ai",
|
|
3
|
-
"version": "8.4.0-dev.
|
|
3
|
+
"version": "8.4.0-dev.33",
|
|
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",
|