@2kw/ai 8.2.1 → 8.3.0-dev.12
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/agent-config/schema.js +2 -0
- package/dist/commands/agents.js +43 -1
- package/dist/commands/billing.js +55 -2
- package/dist/commands/convert.d.ts +1 -0
- package/dist/commands/convert.js +1 -1
- package/dist/commands/scheduled-tasks.d.ts +22 -0
- package/dist/commands/scheduled-tasks.js +163 -0
- package/dist/commands/skills.js +2 -2
- package/dist/commands/tracing.js +5 -1
- package/dist/index.js +2 -0
- package/dist/lib/agent-run.d.ts +14 -0
- package/dist/lib/agent-run.js +24 -0
- package/dist/lib/approval-prompt.js +20 -3
- package/package.json +1 -1
|
@@ -34,6 +34,8 @@ export const NON_AUTHORABLE_TOOL_TYPES = {
|
|
|
34
34
|
"backbone.deliver": "it is added at run time while sandbox outputs are held",
|
|
35
35
|
// #1244: injected wherever backbone.bash is advertised; an authored copy is dropped.
|
|
36
36
|
"backbone.view_image": "it is added at run time wherever the sandboxed shell is",
|
|
37
|
+
// #1801: injected for callers allowed to change knowledge; an authored copy is dropped.
|
|
38
|
+
"backbone.knowledge_apply": "it is added at run time for callers allowed to change knowledge",
|
|
37
39
|
};
|
|
38
40
|
/**
|
|
39
41
|
* The three tools `backbone.canvas` grants (#1698). Listing one is refused on the backend too
|
package/dist/commands/agents.js
CHANGED
|
@@ -13,6 +13,10 @@ import { maskSecrets } from "../agent-config/file.js";
|
|
|
13
13
|
import { ensurePublished } from "../lib/agent-publish.js";
|
|
14
14
|
import { collectModel, MODEL_HELP, MODELS_HELP, modelFieldsFromOptions } from "../lib/agent-models.js";
|
|
15
15
|
import { assertNameNotBlank } from "../lib/overlay.js";
|
|
16
|
+
import { CliUsageError } from "../lib/errors.js";
|
|
17
|
+
function collectTeam(value, previous) {
|
|
18
|
+
return [...previous, value];
|
|
19
|
+
}
|
|
16
20
|
export function makeAgentsCommand() {
|
|
17
21
|
const cmd = new Command("agents").description("Manage agents");
|
|
18
22
|
const list = new Command("list").description("List agents");
|
|
@@ -30,7 +34,7 @@ export function makeAgentsCommand() {
|
|
|
30
34
|
});
|
|
31
35
|
cmd.addCommand(list);
|
|
32
36
|
// The chat-facing read (#814): published agents, {id, name, description} only, and the
|
|
33
|
-
// one agent endpoint a chat-only USER key may call. `list` needs
|
|
37
|
+
// one agent endpoint a chat-only USER key may call. `list` needs MEMBER or higher.
|
|
34
38
|
const catalog = new Command("catalog").description("List published agents (id, name, description)");
|
|
35
39
|
addPaginationOptions(catalog);
|
|
36
40
|
catalog.option("-s, --search <term>", "Filter by name");
|
|
@@ -69,8 +73,17 @@ export function makeAgentsCommand() {
|
|
|
69
73
|
.option("--tools <json>", "Tool definitions as JSON")
|
|
70
74
|
.option("--skills <json>", "Skill definitions as JSON")
|
|
71
75
|
.option("--hitl-policy <json>", "Human-in-the-loop policy as JSON")
|
|
76
|
+
.option("--visibility <visibility>", "Who may use it: organization (default) or restricted to the --team teams")
|
|
77
|
+
.option("--team <id>", "A team a restricted agent is open to (repeatable); a member names only own teams", collectTeam, [])
|
|
72
78
|
.action(async (opts, command) => {
|
|
73
79
|
await runAction(command, async () => {
|
|
80
|
+
if (opts.visibility === undefined && opts.team.length > 0) {
|
|
81
|
+
throw new CliUsageError("--team needs --visibility restricted.");
|
|
82
|
+
}
|
|
83
|
+
if (opts.visibility !== undefined && opts.visibility !== "organization" && opts.visibility !== "restricted") {
|
|
84
|
+
throw new CliUsageError("--visibility must be organization or restricted.");
|
|
85
|
+
}
|
|
86
|
+
const access = opts.visibility === undefined ? {} : { visibility: opts.visibility, teamIds: opts.team };
|
|
74
87
|
const models = modelFieldsFromOptions(opts, true);
|
|
75
88
|
const client = getClient(command);
|
|
76
89
|
const tools = opts.tools ? JSON.parse(opts.tools) : undefined;
|
|
@@ -81,6 +94,7 @@ export function makeAgentsCommand() {
|
|
|
81
94
|
body: {
|
|
82
95
|
name: opts.name,
|
|
83
96
|
...models,
|
|
97
|
+
...access,
|
|
84
98
|
description: opts.description,
|
|
85
99
|
instructions: opts.instructions,
|
|
86
100
|
options,
|
|
@@ -172,6 +186,34 @@ export function makeAgentsCommand() {
|
|
|
172
186
|
formatSuccess(`Agent ${id} deleted.`, command);
|
|
173
187
|
});
|
|
174
188
|
});
|
|
189
|
+
// Who may use an agent: everyone in the organization, or members of the listed teams.
|
|
190
|
+
// Without --visibility it reads; with it, it replaces (administrators and owners).
|
|
191
|
+
cmd
|
|
192
|
+
.command("access")
|
|
193
|
+
.description("Show or set who may use an agent: the whole organization, or members of listed teams")
|
|
194
|
+
.argument("<id>", "Agent ID")
|
|
195
|
+
.option("--visibility <visibility>", "Set access: organization or restricted")
|
|
196
|
+
.option("--team <id>", "A team a restricted agent is open to (repeatable)", collectTeam, [])
|
|
197
|
+
.action(async (id, opts, command) => {
|
|
198
|
+
await runAction(command, async () => {
|
|
199
|
+
const client = getClient(command);
|
|
200
|
+
if (opts.visibility === undefined) {
|
|
201
|
+
if (opts.team.length > 0)
|
|
202
|
+
throw new CliUsageError("--team needs --visibility restricted.");
|
|
203
|
+
const { data } = await client.GET("/v1/agents/{id}/access", { params: { path: { id } } });
|
|
204
|
+
formatDetail(data, command);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (opts.visibility !== "organization" && opts.visibility !== "restricted") {
|
|
208
|
+
throw new CliUsageError("--visibility must be organization or restricted.");
|
|
209
|
+
}
|
|
210
|
+
const { data } = await client.PUT("/v1/agents/{id}/access", {
|
|
211
|
+
params: { path: { id } },
|
|
212
|
+
body: { visibility: opts.visibility, teamIds: opts.team },
|
|
213
|
+
});
|
|
214
|
+
formatDetail(data, command);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
175
217
|
const approvals = new Command("approvals").description("List tool approvals raised by an agent");
|
|
176
218
|
addPaginationOptions(approvals);
|
|
177
219
|
approvals.requiredOption("--agent <id>", "Agent ID");
|
package/dist/commands/billing.js
CHANGED
|
@@ -185,7 +185,25 @@ function makeUsageCommand() {
|
|
|
185
185
|
console.log(`Period: ${data.periodStart?.slice(0, 10)} → ${data.periodEnd?.slice(0, 10)} (${plan})`);
|
|
186
186
|
console.log(`Used: ${data.usedPercent == null ? "no included usage" : `${data.usedPercent} %`}`);
|
|
187
187
|
for (const meter of data.meters ?? []) {
|
|
188
|
-
|
|
188
|
+
if (!meter.tokens) {
|
|
189
|
+
console.log(` ${(meter.meter ?? "").padEnd(18)} ${meter.percent ?? "-"} % ${meter.quantity} ${meter.unit}`);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
// Token meters show each kind on its own line, never one summed number (#1766).
|
|
193
|
+
console.log(` ${(meter.meter ?? "").padEnd(18)} ${meter.percent ?? "-"} %`);
|
|
194
|
+
for (const [key, label] of TOKEN_KINDS) {
|
|
195
|
+
const share = meter.kindSharePercent?.[key];
|
|
196
|
+
console.log(` ${label.padEnd(16)} ${tokenCount(meter.tokens[key])}${share == null ? "" : ` ${share} %`}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (data.byModel?.length) {
|
|
200
|
+
console.log("By model:");
|
|
201
|
+
formatList(data.byModel.map((group) => ({
|
|
202
|
+
model: group.label,
|
|
203
|
+
requests: group.requests,
|
|
204
|
+
...kindColumns(group.tokens),
|
|
205
|
+
share: group.sharePercent == null ? "-" : `${group.sharePercent} %`,
|
|
206
|
+
})), command, ["model", "requests", "input", "cachedInput", "cacheWrite", "output", "share"]);
|
|
189
207
|
}
|
|
190
208
|
if (data.extraUsage) {
|
|
191
209
|
const state = data.extraUsage.enabled ? "" : chalk.dim(" (off)");
|
|
@@ -228,13 +246,48 @@ function makeUsageCommand() {
|
|
|
228
246
|
provider: row.provider ?? "-",
|
|
229
247
|
model: row.model,
|
|
230
248
|
requests: row.requests,
|
|
249
|
+
...kindColumns({
|
|
250
|
+
uncachedInput: row.uncachedInputTokens,
|
|
251
|
+
cachedInput: row.cachedInputTokens,
|
|
252
|
+
cacheWrite: row.cacheWriteTokens,
|
|
253
|
+
output: row.outputTokens,
|
|
254
|
+
}),
|
|
231
255
|
estimate: row.estimatedCostEur == null ? "-" : `~€${row.estimatedCostEur}`,
|
|
232
256
|
}));
|
|
233
|
-
|
|
257
|
+
const cacheWritten = (data.rows ?? []).some((row) => row.cacheWriteTokens != null && row.cacheWriteTokens !== 0);
|
|
258
|
+
formatList(rows, command, [
|
|
259
|
+
"provider",
|
|
260
|
+
"model",
|
|
261
|
+
"requests",
|
|
262
|
+
"input",
|
|
263
|
+
"cachedInput",
|
|
264
|
+
...(cacheWritten ? ["cacheWrite"] : []),
|
|
265
|
+
"output",
|
|
266
|
+
"estimate",
|
|
267
|
+
]);
|
|
234
268
|
});
|
|
235
269
|
});
|
|
236
270
|
return cmd;
|
|
237
271
|
}
|
|
272
|
+
/** The four token kinds in display order, with their customer words (#1766). */
|
|
273
|
+
const TOKEN_KINDS = [
|
|
274
|
+
["uncachedInput", "Input"],
|
|
275
|
+
["cachedInput", "Cached input"],
|
|
276
|
+
["cacheWrite", "Cache write"],
|
|
277
|
+
["output", "Output"],
|
|
278
|
+
];
|
|
279
|
+
/** A token count, or a dash when the provider did not report it (never 0). */
|
|
280
|
+
function tokenCount(value) {
|
|
281
|
+
return value == null ? "-" : String(value);
|
|
282
|
+
}
|
|
283
|
+
function kindColumns(tokens) {
|
|
284
|
+
return {
|
|
285
|
+
input: tokenCount(tokens?.uncachedInput),
|
|
286
|
+
cachedInput: tokenCount(tokens?.cachedInput),
|
|
287
|
+
cacheWrite: tokenCount(tokens?.cacheWrite),
|
|
288
|
+
output: tokenCount(tokens?.output),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
238
291
|
/** Whole euros from cents, e.g. 1234 → "€12.34". Amounts are net of VAT (#973 D-O). */
|
|
239
292
|
function euros(cents) {
|
|
240
293
|
return `€${((cents ?? 0) / 100).toFixed(2)}`;
|
package/dist/commands/convert.js
CHANGED
|
@@ -32,7 +32,7 @@ function getPrimaryContent(doc, formats) {
|
|
|
32
32
|
return JSON.stringify(doc.jsonContent.content ?? doc.jsonContent, null, 2);
|
|
33
33
|
return doc.mdContent ?? doc.textContent ?? doc.htmlContent ?? "";
|
|
34
34
|
}
|
|
35
|
-
function formatBytes(bytes) {
|
|
35
|
+
export function formatBytes(bytes) {
|
|
36
36
|
if (bytes < 1024)
|
|
37
37
|
return `${bytes} B`;
|
|
38
38
|
if (bytes < 1024 * 1024)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
interface RecurrenceOpts {
|
|
3
|
+
recurrence?: string;
|
|
4
|
+
time?: string;
|
|
5
|
+
date?: string;
|
|
6
|
+
day?: string;
|
|
7
|
+
dayOfMonth?: string;
|
|
8
|
+
minute?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The recurrence the flags describe, or undefined when none is given. The API owns the rules
|
|
12
|
+
* per kind (which fields a kind needs, their ranges), so the fields are passed on as given and
|
|
13
|
+
* its invalid_recurrence detail reaches the user.
|
|
14
|
+
*/
|
|
15
|
+
export declare function recurrenceFrom(opts: RecurrenceOpts): Record<string, unknown> | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Scheduled tasks: an agent that runs on a schedule as you, each run in a new conversation (#1747).
|
|
18
|
+
* The API has no read-by-id, so `get` picks the task out of the list.
|
|
19
|
+
*/
|
|
20
|
+
export declare function makeScheduledTasksCommand(): Command;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=scheduled-tasks.d.ts.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { getClient, runAction } from "../lib/client.js";
|
|
3
|
+
import { CliUsageError } from "../lib/errors.js";
|
|
4
|
+
import { formatDetail, formatList, formatSuccess } from "../lib/output.js";
|
|
5
|
+
const KINDS = ["once", "hourly", "daily", "weekdays", "weekly", "monthly", "manual"];
|
|
6
|
+
function wholeNumber(value, flag) {
|
|
7
|
+
if (!/^\d{1,3}$/.test(value))
|
|
8
|
+
throw new CliUsageError(`${flag} takes a whole number: ${value}`);
|
|
9
|
+
return Number(value);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The recurrence the flags describe, or undefined when none is given. The API owns the rules
|
|
13
|
+
* per kind (which fields a kind needs, their ranges), so the fields are passed on as given and
|
|
14
|
+
* its invalid_recurrence detail reaches the user.
|
|
15
|
+
*/
|
|
16
|
+
export function recurrenceFrom(opts) {
|
|
17
|
+
const { recurrence: kind, time, date, day, dayOfMonth, minute } = opts;
|
|
18
|
+
if (kind === undefined) {
|
|
19
|
+
if ([time, date, day, dayOfMonth, minute].some((v) => v !== undefined)) {
|
|
20
|
+
throw new CliUsageError(`--time, --date, --day, --day-of-month and --minute need --recurrence <${KINDS.join("|")}>`);
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (!KINDS.includes(kind)) {
|
|
25
|
+
throw new CliUsageError(`--recurrence must be one of ${KINDS.join(", ")}: ${kind}`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
kind,
|
|
29
|
+
...(time !== undefined && { time }),
|
|
30
|
+
...(date !== undefined && { date }),
|
|
31
|
+
...(day !== undefined && { day: day.toLowerCase() }),
|
|
32
|
+
...(dayOfMonth !== undefined && { day_of_month: wholeNumber(dayOfMonth, "--day-of-month") }),
|
|
33
|
+
...(minute !== undefined && { minute: wholeNumber(minute, "--minute") }),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function withRecurrenceOptions(cmd) {
|
|
37
|
+
return cmd
|
|
38
|
+
.option("--recurrence <kind>", `When it runs: ${KINDS.join(", ")}`)
|
|
39
|
+
.option("--time <HH:MM>", "Time of day (once, daily, weekdays, weekly, monthly)")
|
|
40
|
+
.option("--date <YYYY-MM-DD>", "Date of a once task")
|
|
41
|
+
.option("--day <weekday>", "Day of a weekly task, e.g. monday")
|
|
42
|
+
.option("--day-of-month <1-31>", "Day of a monthly task")
|
|
43
|
+
.option("--minute <0-59>", "Minute past each hour of an hourly task");
|
|
44
|
+
}
|
|
45
|
+
const COLUMNS = ["id", "name", "state", "next_run_at", "agent_id"];
|
|
46
|
+
/**
|
|
47
|
+
* Scheduled tasks: an agent that runs on a schedule as you, each run in a new conversation (#1747).
|
|
48
|
+
* The API has no read-by-id, so `get` picks the task out of the list.
|
|
49
|
+
*/
|
|
50
|
+
export function makeScheduledTasksCommand() {
|
|
51
|
+
const cmd = new Command("scheduled-tasks").description("Agents that run on a schedule as you, each run in a new conversation");
|
|
52
|
+
cmd
|
|
53
|
+
.command("list")
|
|
54
|
+
.description("List your scheduled tasks with their next and last run")
|
|
55
|
+
.action(async (_opts, command) => {
|
|
56
|
+
await runAction(command, async () => {
|
|
57
|
+
const client = getClient(command);
|
|
58
|
+
const { data } = await client.GET("/v1/scheduled-tasks");
|
|
59
|
+
formatList(data, command, COLUMNS);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
cmd
|
|
63
|
+
.command("get <id>")
|
|
64
|
+
.description("Show one scheduled task, including the connectors it needs before its first run")
|
|
65
|
+
.action(async (id, _opts, command) => {
|
|
66
|
+
await runAction(command, async () => {
|
|
67
|
+
const client = getClient(command);
|
|
68
|
+
const { data } = await client.GET("/v1/scheduled-tasks");
|
|
69
|
+
const task = data?.find((t) => t.id === id);
|
|
70
|
+
if (!task)
|
|
71
|
+
throw new CliUsageError(`No scheduled task of yours has the id ${id}`);
|
|
72
|
+
formatDetail(task, command);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
withRecurrenceOptions(cmd
|
|
76
|
+
.command("create")
|
|
77
|
+
.description("Schedule an agent to run a message at a recurrence (at most once an hour)")
|
|
78
|
+
.requiredOption("--agent <agentId>", "The agent to run")
|
|
79
|
+
.requiredOption("--name <name>", "1 to 80 characters")
|
|
80
|
+
.requiredOption("--instructions <text>", "The message each run starts with, 1 to 4,000 characters")
|
|
81
|
+
.requiredOption("--time-zone <zone>", "IANA time zone, e.g. Europe/Berlin")).action(async (opts, command) => {
|
|
82
|
+
await runAction(command, async () => {
|
|
83
|
+
const recurrence = recurrenceFrom(opts);
|
|
84
|
+
if (!recurrence)
|
|
85
|
+
throw new CliUsageError("create needs --recurrence");
|
|
86
|
+
const client = getClient(command);
|
|
87
|
+
const { data } = await client.POST("/v1/scheduled-tasks", {
|
|
88
|
+
body: {
|
|
89
|
+
agent_id: opts.agent,
|
|
90
|
+
name: opts.name,
|
|
91
|
+
instructions: opts.instructions,
|
|
92
|
+
time_zone: opts.timeZone,
|
|
93
|
+
recurrence,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
formatDetail(data, command);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
withRecurrenceOptions(cmd
|
|
100
|
+
.command("update <id>")
|
|
101
|
+
.description("Change a scheduled task; fields you leave out stay as they are")
|
|
102
|
+
.option("--name <name>", "1 to 80 characters")
|
|
103
|
+
.option("--instructions <text>", "The message each run starts with")
|
|
104
|
+
.option("--time-zone <zone>", "IANA time zone")).action(async (id, opts, command) => {
|
|
105
|
+
await runAction(command, async () => {
|
|
106
|
+
const recurrence = recurrenceFrom(opts);
|
|
107
|
+
const body = {
|
|
108
|
+
...(opts.name !== undefined && { name: opts.name }),
|
|
109
|
+
...(opts.instructions !== undefined && { instructions: opts.instructions }),
|
|
110
|
+
...(opts.timeZone !== undefined && { time_zone: opts.timeZone }),
|
|
111
|
+
...(recurrence && { recurrence }),
|
|
112
|
+
};
|
|
113
|
+
if (Object.keys(body).length === 0) {
|
|
114
|
+
throw new CliUsageError("Nothing to change: pass --name, --instructions, --time-zone or --recurrence");
|
|
115
|
+
}
|
|
116
|
+
await patch(command, id, body);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
cmd
|
|
120
|
+
.command("pause <id>")
|
|
121
|
+
.description("Stop the schedule; resume starts it again")
|
|
122
|
+
.action(async (id, _opts, command) => {
|
|
123
|
+
await runAction(command, () => patch(command, id, { state: "paused" }));
|
|
124
|
+
});
|
|
125
|
+
cmd
|
|
126
|
+
.command("resume <id>")
|
|
127
|
+
.description("Start a paused or stopped task again; the next run is the next time after now")
|
|
128
|
+
.action(async (id, _opts, command) => {
|
|
129
|
+
await runAction(command, () => patch(command, id, { state: "active" }));
|
|
130
|
+
});
|
|
131
|
+
cmd
|
|
132
|
+
.command("delete <id>")
|
|
133
|
+
.description("Delete a scheduled task; a run in progress finishes and past conversations stay yours")
|
|
134
|
+
.action(async (id, _opts, command) => {
|
|
135
|
+
await runAction(command, async () => {
|
|
136
|
+
const client = getClient(command);
|
|
137
|
+
await client.DELETE("/v1/scheduled-tasks/{id}", { params: { path: { id } } });
|
|
138
|
+
formatSuccess(`Deleted scheduled task ${id}`, command);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
cmd
|
|
142
|
+
.command("run <id>")
|
|
143
|
+
.description("Run a scheduled task now in a new conversation, without changing its schedule")
|
|
144
|
+
.action(async (id, _opts, command) => {
|
|
145
|
+
await runAction(command, async () => {
|
|
146
|
+
const client = getClient(command);
|
|
147
|
+
const { data } = await client.POST("/v1/scheduled-tasks/{id}/run", {
|
|
148
|
+
params: { path: { id } },
|
|
149
|
+
});
|
|
150
|
+
formatDetail(data, command);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
return cmd;
|
|
154
|
+
}
|
|
155
|
+
async function patch(command, id, body) {
|
|
156
|
+
const client = getClient(command);
|
|
157
|
+
const { data } = await client.PATCH("/v1/scheduled-tasks/{id}", {
|
|
158
|
+
params: { path: { id } },
|
|
159
|
+
body: body,
|
|
160
|
+
});
|
|
161
|
+
formatDetail(data, command);
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=scheduled-tasks.js.map
|
package/dist/commands/skills.js
CHANGED
|
@@ -21,7 +21,7 @@ async function checkResponse(res) {
|
|
|
21
21
|
timestamp: body.timestamp ?? new Date().toISOString(),
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
const MIN_ROLES = ["user", "
|
|
24
|
+
const MIN_ROLES = ["user", "member", "admin", "owner"];
|
|
25
25
|
/** A role word as the API's `Role`, or null for `none` (#785). */
|
|
26
26
|
function parseMinRole(word) {
|
|
27
27
|
const lower = word.trim().toLowerCase();
|
|
@@ -90,7 +90,7 @@ export function makeSkillsCommand() {
|
|
|
90
90
|
.command("min-role")
|
|
91
91
|
.description("Set the minimum organization role that sees this skill in agent runs (admin only); none removes it")
|
|
92
92
|
.argument("<id>", "Skill ID")
|
|
93
|
-
.argument("<role>", "user,
|
|
93
|
+
.argument("<role>", "user, member, admin, owner or none")
|
|
94
94
|
.action(async (id, role, _opts, command) => {
|
|
95
95
|
await runAction(command, async () => {
|
|
96
96
|
const minRole = parseMinRole(role);
|
package/dist/commands/tracing.js
CHANGED
|
@@ -40,6 +40,8 @@ export function makeTracingCommand() {
|
|
|
40
40
|
list.option("--source-service <name>", "Filter by source_service");
|
|
41
41
|
list.option("--status <code>", "Filter by status (OK, ERROR, UNSET — comma-separated for multiple)");
|
|
42
42
|
list.option("--search <query>", "Free-text search across trace id, span name, service, operation");
|
|
43
|
+
list.option("--from <iso>", "Start of time range (ISO-8601). Default: the 7 days before --to, or before now");
|
|
44
|
+
list.option("--to <iso>", "End of time range (ISO-8601)");
|
|
43
45
|
list.option("--page <n>", "Page index (0-based)", "0");
|
|
44
46
|
list.option("--size <n>", "Page size", "20");
|
|
45
47
|
list.action(async (opts, command) => {
|
|
@@ -51,6 +53,8 @@ export function makeTracingCommand() {
|
|
|
51
53
|
sourceService: opts.sourceService,
|
|
52
54
|
statusCode: opts.status,
|
|
53
55
|
search: opts.search,
|
|
56
|
+
from: opts.from,
|
|
57
|
+
to: opts.to,
|
|
54
58
|
page: parseInt(opts.page, 10),
|
|
55
59
|
size: parseInt(opts.size, 10),
|
|
56
60
|
},
|
|
@@ -78,7 +82,7 @@ export function makeTracingCommand() {
|
|
|
78
82
|
const sessionsList = new Command("list").description("List trace sessions");
|
|
79
83
|
sessionsList.option("--search <query>", "Free-text search across session id and name");
|
|
80
84
|
sessionsList.option("--session-id <sessionId>", "Exact match on the session.id the exporter stamped (slashes allowed)");
|
|
81
|
-
sessionsList.option("--from <iso>", "Start of time range (ISO-8601)");
|
|
85
|
+
sessionsList.option("--from <iso>", "Start of time range (ISO-8601). Default: the 7 days before --to, or before now");
|
|
82
86
|
sessionsList.option("--to <iso>", "End of time range (ISO-8601)");
|
|
83
87
|
sessionsList.option("--page <n>", "Page index (0-based)", "0");
|
|
84
88
|
sessionsList.option("--size <n>", "Page size", "20");
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { makeExperimentsCommand } from "./commands/experiments.js";
|
|
|
23
23
|
import { makeTracingCommand } from "./commands/tracing.js";
|
|
24
24
|
import { makeSettingsCommand } from "./commands/settings.js";
|
|
25
25
|
import { makeMemoryCommand } from "./commands/memory.js";
|
|
26
|
+
import { makeScheduledTasksCommand } from "./commands/scheduled-tasks.js";
|
|
26
27
|
import { makeEvaluatorsCommand } from "./commands/evaluators.js";
|
|
27
28
|
import { makeScoresCommand } from "./commands/scores.js";
|
|
28
29
|
import { makeQueuesCommand } from "./commands/queues.js";
|
|
@@ -68,6 +69,7 @@ program.addCommand(makeQueuesCommand());
|
|
|
68
69
|
program.addCommand(makeTracingCommand());
|
|
69
70
|
program.addCommand(makeSettingsCommand());
|
|
70
71
|
program.addCommand(makeMemoryCommand());
|
|
72
|
+
program.addCommand(makeScheduledTasksCommand());
|
|
71
73
|
program.addCommand(makeAgentsCommand());
|
|
72
74
|
program.addCommand(makeConversationsCommand());
|
|
73
75
|
program.addCommand(makeResponsesCommand());
|
package/dist/lib/agent-run.d.ts
CHANGED
|
@@ -14,6 +14,20 @@ export interface PendingApproval {
|
|
|
14
14
|
reason: string | null;
|
|
15
15
|
/** What a built-in SkillsApply change does (#781); null for every other approval. Keyed on presence, not on the tool name (#948). */
|
|
16
16
|
preview: SkillsApplyPreview | null;
|
|
17
|
+
/** Only a human may decide this request (`human_only`): no standing grant is offered (#1801). */
|
|
18
|
+
humanOnly?: boolean;
|
|
19
|
+
/** What a built-in KnowledgeApply change does (#1801); absent for every other approval. */
|
|
20
|
+
knowledgeApply?: KnowledgeApplyEntry[];
|
|
21
|
+
}
|
|
22
|
+
/** One row of a KnowledgeApply approval (#1801); every string is untrusted text. */
|
|
23
|
+
export interface KnowledgeApplyEntry {
|
|
24
|
+
index: number;
|
|
25
|
+
/** `add`, `replace` or `remove`; another value is printed as sent. */
|
|
26
|
+
op: string;
|
|
27
|
+
knowledgeBase?: string;
|
|
28
|
+
knowledgeBaseName?: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
sizeBytes?: number;
|
|
17
31
|
}
|
|
18
32
|
export interface ToolCallSummary {
|
|
19
33
|
tool: string;
|
package/dist/lib/agent-run.js
CHANGED
|
@@ -4,6 +4,28 @@ import { DEFAULT_CHAT_URL } from "./config.js";
|
|
|
4
4
|
import { answerUrlFor, connectCallIds, connectionsPhrase, inputLabelsPhrase, pendingConnectionsOf, pendingInputsOf, } from "./connect-pause.js";
|
|
5
5
|
import { CliUsageError } from "./errors.js";
|
|
6
6
|
import { previewIsIncomplete, previewLines } from "./skills-apply-preview.js";
|
|
7
|
+
const KNOWLEDGE_APPLY_MAX_ENTRIES = 10;
|
|
8
|
+
/** The wire `knowledge_apply` field, defensively: anything but `{entries: [...]}` is undefined; bad rows drop out. */
|
|
9
|
+
function parseKnowledgeApply(raw) {
|
|
10
|
+
const entries = raw?.entries;
|
|
11
|
+
if (!Array.isArray(entries))
|
|
12
|
+
return undefined;
|
|
13
|
+
const str = (v) => (typeof v === "string" ? v : undefined);
|
|
14
|
+
const out = [];
|
|
15
|
+
for (const e of entries.slice(0, KNOWLEDGE_APPLY_MAX_ENTRIES)) {
|
|
16
|
+
if (!e || typeof e !== "object" || typeof e.op !== "string")
|
|
17
|
+
continue;
|
|
18
|
+
out.push({
|
|
19
|
+
index: typeof e.index === "number" ? e.index : out.length,
|
|
20
|
+
op: e.op,
|
|
21
|
+
knowledgeBase: str(e.knowledge_base),
|
|
22
|
+
knowledgeBaseName: str(e.knowledge_base_name),
|
|
23
|
+
name: str(e.name),
|
|
24
|
+
sizeBytes: typeof e.size_bytes === "number" ? e.size_bytes : undefined,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
7
29
|
export const CONVERSATION_MODES = ["plan", "ask", "auto"];
|
|
8
30
|
/** `--mode` help text, in the words of the embedded chat's mode chip (#655). */
|
|
9
31
|
export const MODE_OPTION_HELP = "Conversation mode: plan (read-only), ask (calls that need approval wait for you), " +
|
|
@@ -228,6 +250,8 @@ export function buildRunEnvelope(result, agentRef, chatUrl = DEFAULT_CHAT_URL) {
|
|
|
228
250
|
policyClass: String(i.policy_class),
|
|
229
251
|
reason: typeof i.reason === "string" && i.reason ? i.reason : null,
|
|
230
252
|
preview: i.preview && typeof i.preview === "object" && !Array.isArray(i.preview) ? i.preview : null,
|
|
253
|
+
humanOnly: i.human_only === true ? true : undefined,
|
|
254
|
+
knowledgeApply: parseKnowledgeApply(i.knowledge_apply),
|
|
231
255
|
})),
|
|
232
256
|
...output.filter((i) => i.type === "mcp_approval_request").map(connectorApproval),
|
|
233
257
|
];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
+
import { formatBytes } from "../commands/convert.js";
|
|
3
4
|
import { hasInvisible, revealInvisible, stripControl } from "./agent-run.js";
|
|
4
5
|
import { REMEMBER_NOTE, previewIsIncomplete, previewLines } from "./skills-apply-preview.js";
|
|
5
6
|
/** Raised when the prompt's input closes (EOF, Ctrl+C, Ctrl+D) before an answer arrives. */
|
|
@@ -79,10 +80,15 @@ export async function promptApprovals(pending, ask, write = (line) => console.er
|
|
|
79
80
|
else {
|
|
80
81
|
request();
|
|
81
82
|
}
|
|
83
|
+
// A KnowledgeApply change reads as one line per document (#1801); the excerpt is never printed.
|
|
84
|
+
for (const e of a.knowledgeApply ?? [])
|
|
85
|
+
write(knowledgeLine(e, s));
|
|
82
86
|
if (a.reason)
|
|
83
87
|
write(chalk.dim(`reason: ${s(a.reason)}`));
|
|
84
|
-
|
|
85
|
-
const
|
|
88
|
+
// A human-only request is decided by a human each time: no standing grant (#1801).
|
|
89
|
+
const noRemember = destructive || a.humanOnly === true;
|
|
90
|
+
const question = noRemember ? "[a]pprove / [r]eject? " : "[a]pprove / [r]eject / approve and [R]emember? ";
|
|
91
|
+
const hint = noRemember
|
|
86
92
|
? "Answer a (approve), r (reject)"
|
|
87
93
|
: "Answer a (approve), r (reject), or R (approve and remember)";
|
|
88
94
|
for (;;) {
|
|
@@ -91,7 +97,7 @@ export async function promptApprovals(pending, ask, write = (line) => console.er
|
|
|
91
97
|
answers.set(a.approvalId, { decision: "approve" });
|
|
92
98
|
break;
|
|
93
99
|
}
|
|
94
|
-
if (reply === "R" && !
|
|
100
|
+
if (reply === "R" && !noRemember) {
|
|
95
101
|
answers.set(a.approvalId, { decision: "approve", remember: true });
|
|
96
102
|
break;
|
|
97
103
|
}
|
|
@@ -105,6 +111,17 @@ export async function promptApprovals(pending, ask, write = (line) => console.er
|
|
|
105
111
|
}
|
|
106
112
|
return answers;
|
|
107
113
|
}
|
|
114
|
+
const KNOWLEDGE_MARKS = { add: "+", replace: "~", remove: "-" };
|
|
115
|
+
/** ` + add Price lists prices-2026-q4.pdf (1.2 MB)`; `s` strips control characters from each string. */
|
|
116
|
+
function knowledgeLine(e, s) {
|
|
117
|
+
const parts = [
|
|
118
|
+
`${KNOWLEDGE_MARKS[e.op] ?? "?"} ${s(e.op).padEnd(8)}`,
|
|
119
|
+
s(e.knowledgeBaseName || e.knowledgeBase || ""),
|
|
120
|
+
s(e.name ?? ""),
|
|
121
|
+
e.sizeBytes === undefined ? "" : `(${formatBytes(e.sizeBytes)})`,
|
|
122
|
+
];
|
|
123
|
+
return ` ${parts.filter(Boolean).join(" ")}`;
|
|
124
|
+
}
|
|
108
125
|
/** Diff lines sit indented six spaces under their file; only those are coloured. */
|
|
109
126
|
function colourPreviewLine(line) {
|
|
110
127
|
if (!line.startsWith(" "))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kw/ai",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0-dev.12",
|
|
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",
|