@2kw/ai 6.3.0-dev.8 → 6.3.0-dev.85
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 +3 -0
- package/dist/agent-config/schema.d.ts +3 -0
- package/dist/agent-config/schema.js +7 -1
- package/dist/agent-config/template.js +1 -1
- package/dist/commands/agent-apply.js +1 -1
- package/dist/commands/agent-policy.d.ts +2 -1
- package/dist/commands/agent-policy.js +9 -2
- package/dist/commands/agent-run.d.ts +5 -0
- package/dist/commands/agent-run.js +37 -17
- package/dist/commands/agents.js +15 -1
- package/dist/commands/ai.js +2 -2
- package/dist/commands/auth.js +6 -1
- package/dist/commands/billing.js +5 -3
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +16 -2
- package/dist/commands/connectors.js +2 -1
- package/dist/commands/conversations.js +16 -0
- package/dist/commands/experiments.js +2 -2
- package/dist/commands/files.js +10 -28
- package/dist/commands/knowledge-documents.js +12 -32
- package/dist/commands/memory.d.ts +10 -0
- package/dist/commands/memory.js +132 -0
- package/dist/commands/settings.d.ts +13 -0
- package/dist/commands/settings.js +80 -0
- package/dist/commands/skill-versions.js +27 -1
- package/dist/commands/skills.js +29 -0
- package/dist/commands/tracing.js +5 -12
- package/dist/index.js +4 -0
- package/dist/lib/agent-decide.d.ts +3 -2
- package/dist/lib/agent-decide.js +5 -2
- package/dist/lib/agent-run.d.ts +49 -3
- package/dist/lib/agent-run.js +152 -9
- package/dist/lib/approval-prompt.js +31 -1
- package/dist/lib/client.d.ts +8 -0
- package/dist/lib/client.js +20 -1
- package/dist/lib/config.d.ts +16 -0
- package/dist/lib/config.js +39 -0
- package/dist/lib/errors.d.ts +6 -0
- package/dist/lib/errors.js +5 -2
- package/dist/lib/skills-apply-preview.d.ts +19 -0
- package/dist/lib/skills-apply-preview.js +94 -0
- package/dist/lib/tracing-settings.d.ts +26 -0
- package/dist/lib/tracing-settings.js +25 -0
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { getClient, runAction } from "../lib/client.js";
|
|
4
|
+
import { isJsonOutput } from "../lib/config.js";
|
|
5
|
+
import { CliUsageError } from "../lib/errors.js";
|
|
6
|
+
import { formatDetail, formatList, formatSuccess } from "../lib/output.js";
|
|
7
|
+
/** The If-Match value for a version a GET returned: the quoted ETag the API expects. */
|
|
8
|
+
export function ifMatchHeader(version) {
|
|
9
|
+
if (!/^\d{1,18}$/.test(version)) {
|
|
10
|
+
throw new CliUsageError(`--if-match takes the file's version, a whole number: ${version}`);
|
|
11
|
+
}
|
|
12
|
+
return `"${version}"`;
|
|
13
|
+
}
|
|
14
|
+
function requireYes(opts, what) {
|
|
15
|
+
if (!opts.yes) {
|
|
16
|
+
throw new CliUsageError(`${what} cannot be undone. Pass --yes to confirm.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Agent memory (agent memory spec §7.1, §7.4). `ls`, `cat`, `put`, `rm` and `forget` act on
|
|
21
|
+
* the caller's own memory; `members` and `erase` are for ADMIN and OWNER and never show
|
|
22
|
+
* paths or content. Content is lossless: `cat` prints it raw, `put` sends the file as is.
|
|
23
|
+
*/
|
|
24
|
+
export function makeMemoryCommand() {
|
|
25
|
+
const cmd = new Command("memory").description("Your agent memory files; member totals and erasure for admins");
|
|
26
|
+
cmd
|
|
27
|
+
.command("ls")
|
|
28
|
+
.description("List your memory files")
|
|
29
|
+
.action(async (_opts, command) => {
|
|
30
|
+
await runAction(command, async () => {
|
|
31
|
+
const client = getClient(command);
|
|
32
|
+
const { data } = await client.GET("/v1/memories/me/files");
|
|
33
|
+
formatList(data, command, [
|
|
34
|
+
"path",
|
|
35
|
+
"sizeBytes",
|
|
36
|
+
"version",
|
|
37
|
+
"updatedAt",
|
|
38
|
+
"lastWrittenByAgentId",
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
cmd
|
|
43
|
+
.command("cat <path>")
|
|
44
|
+
.description("Print one of your memory files, raw (--json for the file object)")
|
|
45
|
+
.action(async (path, _opts, command) => {
|
|
46
|
+
await runAction(command, async () => {
|
|
47
|
+
const client = getClient(command);
|
|
48
|
+
const { data } = await client.GET("/v1/memories/me/file", {
|
|
49
|
+
params: { query: { path } },
|
|
50
|
+
});
|
|
51
|
+
if (isJsonOutput(command)) {
|
|
52
|
+
formatDetail(data, command);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
process.stdout.write(data.content);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
cmd
|
|
60
|
+
.command("put <path>")
|
|
61
|
+
.description("Create or replace one of your memory files from a local UTF-8 file")
|
|
62
|
+
.requiredOption("--file <file>", "Local file whose content is stored")
|
|
63
|
+
.option("--if-match <version>", "Only replace the file if it still has this version")
|
|
64
|
+
.action(async (path, opts, command) => {
|
|
65
|
+
await runAction(command, async () => {
|
|
66
|
+
// An empty --if-match (e.g. an unset shell variable) must be refused, never dropped
|
|
67
|
+
// into an unconditional overwrite.
|
|
68
|
+
const headers = opts.ifMatch !== undefined ? { "If-Match": ifMatchHeader(opts.ifMatch) } : undefined;
|
|
69
|
+
const content = readFileSync(opts.file, "utf8");
|
|
70
|
+
const client = getClient(command);
|
|
71
|
+
const { data } = await client.PUT("/v1/memories/me/file", {
|
|
72
|
+
params: { query: { path } },
|
|
73
|
+
body: { content },
|
|
74
|
+
headers,
|
|
75
|
+
});
|
|
76
|
+
formatDetail(data, command);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
cmd
|
|
80
|
+
.command("rm <path>")
|
|
81
|
+
.description("Delete one of your memory files, or a directory with everything below it")
|
|
82
|
+
.action(async (path, _opts, command) => {
|
|
83
|
+
await runAction(command, async () => {
|
|
84
|
+
const client = getClient(command);
|
|
85
|
+
await client.DELETE("/v1/memories/me/file", { params: { query: { path } } });
|
|
86
|
+
formatSuccess(`Deleted ${path}`, command);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
cmd
|
|
90
|
+
.command("forget")
|
|
91
|
+
.description("Delete your whole memory (cannot be undone)")
|
|
92
|
+
.option("--yes", "Confirm")
|
|
93
|
+
.action(async (opts, command) => {
|
|
94
|
+
await runAction(command, async () => {
|
|
95
|
+
requireYes(opts, "Forgetting your whole memory");
|
|
96
|
+
const client = getClient(command);
|
|
97
|
+
await client.DELETE("/v1/memories/me");
|
|
98
|
+
formatSuccess("Forgot your whole memory", command);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
cmd
|
|
102
|
+
.command("members")
|
|
103
|
+
.description("Memory totals per member, without paths or content (ADMIN+)")
|
|
104
|
+
.action(async (_opts, command) => {
|
|
105
|
+
await runAction(command, async () => {
|
|
106
|
+
const client = getClient(command);
|
|
107
|
+
const { data } = await client.GET("/v1/memories/users");
|
|
108
|
+
formatList(data, command, [
|
|
109
|
+
"userId",
|
|
110
|
+
"fileCount",
|
|
111
|
+
"totalBytes",
|
|
112
|
+
"lastUpdatedAt",
|
|
113
|
+
]);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
cmd
|
|
117
|
+
.command("erase <userId>")
|
|
118
|
+
.description("Erase a member's whole memory (ADMIN+, cannot be undone)")
|
|
119
|
+
.option("--yes", "Confirm")
|
|
120
|
+
.action(async (userId, opts, command) => {
|
|
121
|
+
await runAction(command, async () => {
|
|
122
|
+
requireYes(opts, "Erasing a member's memory");
|
|
123
|
+
const client = getClient(command);
|
|
124
|
+
await client.DELETE("/v1/memories/users/{userId}", {
|
|
125
|
+
params: { path: { userId } },
|
|
126
|
+
});
|
|
127
|
+
formatSuccess(`Erased the memory of ${userId}`, command);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
return cmd;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* Parses the value a setting takes: a JSON object. The server checks its shape per key
|
|
4
|
+
* (for agents.default: {"agentId": "<id>"}); this only refuses what can never be valid.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseSettingValue(raw: string): Record<string, unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Organization and member settings (agent-first chat spec §3.1, §4). Without --org every
|
|
9
|
+
* write targets the caller's own member tier; --org writes the organization's, which needs
|
|
10
|
+
* the key's write role (ADMIN or OWNER for agents.default).
|
|
11
|
+
*/
|
|
12
|
+
export declare function makeSettingsCommand(): Command;
|
|
13
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { getClient, runAction } from "../lib/client.js";
|
|
3
|
+
import { CliUsageError } from "../lib/errors.js";
|
|
4
|
+
import { formatDetail } from "../lib/output.js";
|
|
5
|
+
/**
|
|
6
|
+
* Parses the value a setting takes: a JSON object. The server checks its shape per key
|
|
7
|
+
* (for agents.default: {"agentId": "<id>"}); this only refuses what can never be valid.
|
|
8
|
+
*/
|
|
9
|
+
export function parseSettingValue(raw) {
|
|
10
|
+
let parsed;
|
|
11
|
+
try {
|
|
12
|
+
parsed = JSON.parse(raw);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new CliUsageError(`Setting value is not valid JSON: ${raw}`);
|
|
16
|
+
}
|
|
17
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
18
|
+
throw new CliUsageError('Setting value must be a JSON object, e.g. \'{"agentId":"agt_123"}\'');
|
|
19
|
+
}
|
|
20
|
+
return parsed;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Organization and member settings (agent-first chat spec §3.1, §4). Without --org every
|
|
24
|
+
* write targets the caller's own member tier; --org writes the organization's, which needs
|
|
25
|
+
* the key's write role (ADMIN or OWNER for agents.default).
|
|
26
|
+
*/
|
|
27
|
+
export function makeSettingsCommand() {
|
|
28
|
+
const cmd = new Command("settings").description("Organization and member settings (e.g. agents.default)");
|
|
29
|
+
cmd
|
|
30
|
+
.command("get <key>")
|
|
31
|
+
.description("Show a setting: the effective value, its source and both tiers")
|
|
32
|
+
.action(async (key, _opts, command) => {
|
|
33
|
+
await runAction(command, async () => {
|
|
34
|
+
const client = getClient(command);
|
|
35
|
+
const { data } = await client.GET("/v1/settings/{key}", {
|
|
36
|
+
params: { path: { key } },
|
|
37
|
+
});
|
|
38
|
+
formatDetail(data, command);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
cmd
|
|
42
|
+
.command("set <key> <json>")
|
|
43
|
+
.description("Set your own value, or the organization's with --org (ADMIN+)")
|
|
44
|
+
.option("--org", "Write the organization's value instead of your own")
|
|
45
|
+
.action(async (key, json, opts, command) => {
|
|
46
|
+
await runAction(command, async () => {
|
|
47
|
+
const client = getClient(command);
|
|
48
|
+
const body = { value: parseSettingValue(json) };
|
|
49
|
+
const { data } = opts.org
|
|
50
|
+
? await client.PUT("/v1/settings/{key}/org", {
|
|
51
|
+
params: { path: { key } },
|
|
52
|
+
body,
|
|
53
|
+
})
|
|
54
|
+
: await client.PUT("/v1/settings/{key}/member", {
|
|
55
|
+
params: { path: { key } },
|
|
56
|
+
body,
|
|
57
|
+
});
|
|
58
|
+
formatDetail(data, command);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
cmd
|
|
62
|
+
.command("unset <key>")
|
|
63
|
+
.description("Clear your own value, or the organization's with --org (ADMIN+)")
|
|
64
|
+
.option("--org", "Clear the organization's value instead of your own")
|
|
65
|
+
.action(async (key, opts, command) => {
|
|
66
|
+
await runAction(command, async () => {
|
|
67
|
+
const client = getClient(command);
|
|
68
|
+
const { data } = opts.org
|
|
69
|
+
? await client.DELETE("/v1/settings/{key}/org", {
|
|
70
|
+
params: { path: { key } },
|
|
71
|
+
})
|
|
72
|
+
: await client.DELETE("/v1/settings/{key}/member", {
|
|
73
|
+
params: { path: { key } },
|
|
74
|
+
});
|
|
75
|
+
formatDetail(data, command);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
return cmd;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
1
|
+
import { Command, InvalidArgumentError } from "commander";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { getClient, runAction } from "../lib/client.js";
|
|
4
4
|
import { formatPage, formatDetail } from "../lib/output.js";
|
|
@@ -48,6 +48,32 @@ export function makeSkillVersionsCommand() {
|
|
|
48
48
|
formatDetail(data, command);
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
|
+
cmd
|
|
52
|
+
.command("restore")
|
|
53
|
+
.description("Restore a version as a new version; latest moves to it (the newest version is reused when it already has the content)")
|
|
54
|
+
.argument("<id>", "Skill ID")
|
|
55
|
+
.argument("<versionNumber>", "Version number to restore", parseVersionNumber)
|
|
56
|
+
.action(async (id, versionNumber, _opts, command) => {
|
|
57
|
+
await runAction(command, async () => {
|
|
58
|
+
const client = getClient(command);
|
|
59
|
+
const { data, response } = await client.POST("/v1/skills/{id}/versions/{versionNumber}/restore", {
|
|
60
|
+
params: { path: { id, versionNumber } },
|
|
61
|
+
});
|
|
62
|
+
// 200, not 201: the newest version already had the content and latest moved to it.
|
|
63
|
+
if (response.status === 200 && data) {
|
|
64
|
+
console.error(`No new version: v${data.versionNumber} already has the content of v${versionNumber}; latest now points at v${data.versionNumber}.`);
|
|
65
|
+
}
|
|
66
|
+
formatDetail(data, command);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
51
69
|
return cmd;
|
|
52
70
|
}
|
|
71
|
+
/** A restore names an existing version by number; refuse anything else before calling the API (#783). */
|
|
72
|
+
function parseVersionNumber(value) {
|
|
73
|
+
const n = Number(value);
|
|
74
|
+
if (!/^\d+$/.test(value) || n < 1) {
|
|
75
|
+
throw new InvalidArgumentError("Version number must be a positive integer.");
|
|
76
|
+
}
|
|
77
|
+
return n;
|
|
78
|
+
}
|
|
53
79
|
//# sourceMappingURL=skill-versions.js.map
|
package/dist/commands/skills.js
CHANGED
|
@@ -21,6 +21,17 @@ async function checkResponse(res) {
|
|
|
21
21
|
timestamp: body.timestamp ?? new Date().toISOString(),
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
const MIN_ROLES = ["user", "viewer", "member", "admin", "owner"];
|
|
25
|
+
/** A role word as the API's `Role`, or null for `none` (#785). */
|
|
26
|
+
function parseMinRole(word) {
|
|
27
|
+
const lower = word.trim().toLowerCase();
|
|
28
|
+
if (lower === "none")
|
|
29
|
+
return null;
|
|
30
|
+
if (MIN_ROLES.includes(lower)) {
|
|
31
|
+
return lower.toUpperCase();
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Role must be one of: ${MIN_ROLES.join(", ")}, none`);
|
|
34
|
+
}
|
|
24
35
|
/** Manage skills, versions and labels (#642). */
|
|
25
36
|
export function makeSkillsCommand() {
|
|
26
37
|
const cmd = new Command("skills").description("Manage skills");
|
|
@@ -75,6 +86,24 @@ export function makeSkillsCommand() {
|
|
|
75
86
|
formatDetail(data, command);
|
|
76
87
|
});
|
|
77
88
|
});
|
|
89
|
+
cmd
|
|
90
|
+
.command("min-role")
|
|
91
|
+
.description("Set the minimum organization role that sees this skill in agent runs (admin only); none removes it")
|
|
92
|
+
.argument("<id>", "Skill ID")
|
|
93
|
+
.argument("<role>", "user, viewer, member, admin, owner or none")
|
|
94
|
+
.action(async (id, role, _opts, command) => {
|
|
95
|
+
await runAction(command, async () => {
|
|
96
|
+
const minRole = parseMinRole(role);
|
|
97
|
+
const client = getClient(command);
|
|
98
|
+
const { data } = await client.PUT("/v1/skills/{id}/min-role", {
|
|
99
|
+
params: { path: { id } },
|
|
100
|
+
// The spec publishes minRole without null (springdoc marks no record component
|
|
101
|
+
// nullable); the operation documents null as "remove the minimum", and it is sent as such.
|
|
102
|
+
body: { minRole: minRole },
|
|
103
|
+
});
|
|
104
|
+
formatDetail(data, command);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
78
107
|
cmd
|
|
79
108
|
.command("delete")
|
|
80
109
|
.description("Delete a skill")
|
package/dist/commands/tracing.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { getClient, runAction } from "../lib/client.js";
|
|
3
3
|
import { formatDetail, formatList } from "../lib/output.js";
|
|
4
|
+
import { tracingSettingsBody } from "../lib/tracing-settings.js";
|
|
4
5
|
export function makeTracingCommand() {
|
|
5
6
|
const cmd = new Command("tracing").description("Traces and per-org tracing settings (prompt / completion capture)");
|
|
6
7
|
// ── settings ──────────────────────────────────────────────────
|
|
7
|
-
const settings = new Command("settings").description("Manage per-org tracing settings (
|
|
8
|
+
const settings = new Command("settings").description("Manage per-org tracing settings (PII capture and trace retention)");
|
|
8
9
|
settings
|
|
9
10
|
.command("get")
|
|
10
11
|
.description("Show current tracing settings")
|
|
@@ -20,6 +21,7 @@ export function makeTracingCommand() {
|
|
|
20
21
|
.description("Update tracing settings. Both toggles control PII capture — default is false for both.")
|
|
21
22
|
.option("--include-prompts <bool>", "Retain prompt content on ingested spans (true/false)")
|
|
22
23
|
.option("--include-completions <bool>", "Retain completion content on ingested spans (true/false)")
|
|
24
|
+
.option("--retention-days <days>", 'Trace retention in days, at most your plan\'s limit, or "plan" to follow the plan. Shortening deletes older traces at the next daily sweep.')
|
|
23
25
|
.action(async (opts, command) => {
|
|
24
26
|
await runAction(command, async () => {
|
|
25
27
|
const client = getClient(command);
|
|
@@ -27,17 +29,8 @@ export function makeTracingCommand() {
|
|
|
27
29
|
// resetting the other. Otherwise an unset flag defaults to false
|
|
28
30
|
// and silently disables capture the admin had already enabled.
|
|
29
31
|
const { data: current } = await client.GET("/v1/tracing/settings");
|
|
30
|
-
const body =
|
|
31
|
-
|
|
32
|
-
? opts.includePrompts === "true"
|
|
33
|
-
: (current?.includePrompts ?? false),
|
|
34
|
-
includeCompletions: opts.includeCompletions !== undefined
|
|
35
|
-
? opts.includeCompletions === "true"
|
|
36
|
-
: (current?.includeCompletions ?? false),
|
|
37
|
-
};
|
|
38
|
-
const { data } = await client.PUT("/v1/tracing/settings", {
|
|
39
|
-
body,
|
|
40
|
-
});
|
|
32
|
+
const body = tracingSettingsBody(current, opts);
|
|
33
|
+
const { data } = await client.PUT("/v1/tracing/settings", { body });
|
|
41
34
|
formatDetail(data, command);
|
|
42
35
|
});
|
|
43
36
|
});
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ import { makeDocsCommand } from "./commands/docs.js";
|
|
|
21
21
|
import { makeContextCommand } from "./commands/context.js";
|
|
22
22
|
import { makeExperimentsCommand } from "./commands/experiments.js";
|
|
23
23
|
import { makeTracingCommand } from "./commands/tracing.js";
|
|
24
|
+
import { makeSettingsCommand } from "./commands/settings.js";
|
|
25
|
+
import { makeMemoryCommand } from "./commands/memory.js";
|
|
24
26
|
import { makeEvaluatorsCommand } from "./commands/evaluators.js";
|
|
25
27
|
import { makeScoresCommand } from "./commands/scores.js";
|
|
26
28
|
import { makeQueuesCommand } from "./commands/queues.js";
|
|
@@ -62,6 +64,8 @@ program.addCommand(makeEvaluatorsCommand());
|
|
|
62
64
|
program.addCommand(makeScoresCommand());
|
|
63
65
|
program.addCommand(makeQueuesCommand());
|
|
64
66
|
program.addCommand(makeTracingCommand());
|
|
67
|
+
program.addCommand(makeSettingsCommand());
|
|
68
|
+
program.addCommand(makeMemoryCommand());
|
|
65
69
|
program.addCommand(makeAgentsCommand());
|
|
66
70
|
program.addCommand(makeConversationsCommand());
|
|
67
71
|
program.addCommand(makeKnowledgeCommand());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { components } from "../generated/openapi.js";
|
|
2
2
|
import type { ApiClient } from "./agent-lookup.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type ConversationMode, type ResponsesResult } from "./agent-run.js";
|
|
4
4
|
export type ApprovalRow = components["schemas"]["ToolApprovalDTO"];
|
|
5
5
|
export interface DecideOptions {
|
|
6
6
|
approve?: string[];
|
|
@@ -36,6 +36,7 @@ export declare function toApprovalItems(decisions: Decision[]): Record<string, s
|
|
|
36
36
|
* server resolves the continuation's tools, instructions and model from this reference, so both must match
|
|
37
37
|
* the run's or the continuation drops to another version or the agent's default model.
|
|
38
38
|
* Never the echoed `name@<versionNumber>` (it would 404 as a label).
|
|
39
|
+
* With `mode`, the `backbone:mode` item follows the decisions (#656 D7); without it, nothing is added (D2).
|
|
39
40
|
*/
|
|
40
|
-
export declare function continueWithDecisions(client: ApiClient, agentId: string, responseId: string, decisions: Decision[], label?: string, model?: string): Promise<ResponsesResult>;
|
|
41
|
+
export declare function continueWithDecisions(client: ApiClient, agentId: string, responseId: string, decisions: Decision[], label?: string, model?: string, mode?: ConversationMode): Promise<ResponsesResult>;
|
|
41
42
|
//# sourceMappingURL=agent-decide.d.ts.map
|
package/dist/lib/agent-decide.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modeItem } from "./agent-run.js";
|
|
1
2
|
import { CliUsageError } from "./errors.js";
|
|
2
3
|
import { paginationParams } from "./pagination.js";
|
|
3
4
|
const MAX_PAGES = 50;
|
|
@@ -113,13 +114,15 @@ export function toApprovalItems(decisions) {
|
|
|
113
114
|
* server resolves the continuation's tools, instructions and model from this reference, so both must match
|
|
114
115
|
* the run's or the continuation drops to another version or the agent's default model.
|
|
115
116
|
* Never the echoed `name@<versionNumber>` (it would 404 as a label).
|
|
117
|
+
* With `mode`, the `backbone:mode` item follows the decisions (#656 D7); without it, nothing is added (D2).
|
|
116
118
|
*/
|
|
117
|
-
export async function continueWithDecisions(client, agentId, responseId, decisions, label, model) {
|
|
119
|
+
export async function continueWithDecisions(client, agentId, responseId, decisions, label, model, mode) {
|
|
120
|
+
const approvals = toApprovalItems(decisions);
|
|
118
121
|
const body = {
|
|
119
122
|
model: `agent/${agentId}${label ? `@${label}` : ""}${model ? `#${model}` : ""}`,
|
|
120
123
|
previous_response_id: responseId,
|
|
121
124
|
stream: false,
|
|
122
|
-
input:
|
|
125
|
+
input: mode ? [...approvals, modeItem(mode)] : approvals,
|
|
123
126
|
};
|
|
124
127
|
// The generated body type does not model backbone: extension items, hence the cast.
|
|
125
128
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/dist/lib/agent-run.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { components } from "../generated/openapi.js";
|
|
1
2
|
type AnyRecord = Record<string, any>;
|
|
2
3
|
export type RunStatus = "completed" | "requires_approval" | "requires_tool_output" | "incomplete";
|
|
4
|
+
/** A built-in SkillsApply approval's preview (#781, spec §6); the generated type, fields all optional. */
|
|
5
|
+
export type SkillsApplyPreview = components["schemas"]["SkillsApplyPreview"];
|
|
3
6
|
export interface PendingApproval {
|
|
4
7
|
approvalId: string;
|
|
5
8
|
callId: string;
|
|
@@ -8,6 +11,8 @@ export interface PendingApproval {
|
|
|
8
11
|
policyClass: string;
|
|
9
12
|
/** Why the automatic approver escalated this request to a human (#634); null when it did not. */
|
|
10
13
|
reason: string | null;
|
|
14
|
+
/** What a built-in SkillsApply change does (#781); null for every other approval. Keyed on presence, not on the tool name (#948). */
|
|
15
|
+
preview: SkillsApplyPreview | null;
|
|
11
16
|
}
|
|
12
17
|
export interface ToolCallSummary {
|
|
13
18
|
tool: string;
|
|
@@ -20,10 +25,43 @@ export interface PendingToolCall {
|
|
|
20
25
|
callId: string;
|
|
21
26
|
arguments: unknown;
|
|
22
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* A connector the run waits for the user to connect, allow or reconnect in chat.2kw.ai: an open
|
|
30
|
+
* `backbone:connector_auth_request` (#807 R12). The caller never answers the connect call; the
|
|
31
|
+
* continuation re-checks access itself.
|
|
32
|
+
*/
|
|
33
|
+
export interface PendingConnection {
|
|
34
|
+
serverLabel: string;
|
|
35
|
+
host: string;
|
|
36
|
+
/** `connect`, `allow` or `reconnect`. */
|
|
37
|
+
reason: string;
|
|
38
|
+
/** The egress difference an allow is re-asked for; absent otherwise. */
|
|
39
|
+
destinations?: string[];
|
|
40
|
+
}
|
|
41
|
+
/** The end user's conversation mode (epic &59); the server matches these three values exactly. */
|
|
42
|
+
export type ConversationMode = "plan" | "ask" | "auto";
|
|
43
|
+
export declare const CONVERSATION_MODES: readonly ConversationMode[];
|
|
44
|
+
/** `--mode` help text, in the words of the embedded chat's mode chip (#655). */
|
|
45
|
+
export declare const MODE_OPTION_HELP: string;
|
|
46
|
+
/**
|
|
47
|
+
* The `--mode` value, checked before any request is sent: anything but the three exact values is a
|
|
48
|
+
* usage error (exit 2). Commander's `.choices()` is not used because it exits 1 through `process.exit`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseModeOption(raw: string | undefined): ConversationMode | undefined;
|
|
51
|
+
/** The `backbone:mode` input item (S1 D7); always appended last. */
|
|
52
|
+
export declare function modeItem(mode: ConversationMode): {
|
|
53
|
+
type: "backbone:mode";
|
|
54
|
+
mode: ConversationMode;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The mode the response ran under (`conversation_mode`, #656). An absent key (a server before #656)
|
|
58
|
+
* and any value other than the three read as null, which also means "none set".
|
|
59
|
+
*/
|
|
60
|
+
export declare function responseMode(result: ResponsesResult | undefined): ConversationMode | null;
|
|
23
61
|
export interface RunEnvelope {
|
|
24
62
|
status: RunStatus;
|
|
25
|
-
/**
|
|
26
|
-
mode: null;
|
|
63
|
+
/** The conversation mode the request ran under (`conversation_mode`); null when none is set. */
|
|
64
|
+
mode: ConversationMode | null;
|
|
27
65
|
agent: string | null;
|
|
28
66
|
version: number | null;
|
|
29
67
|
responseId: string | null;
|
|
@@ -32,6 +70,7 @@ export interface RunEnvelope {
|
|
|
32
70
|
toolCalls: ToolCallSummary[];
|
|
33
71
|
pendingApprovals: PendingApproval[];
|
|
34
72
|
pendingToolCalls: PendingToolCall[];
|
|
73
|
+
pendingConnections: PendingConnection[];
|
|
35
74
|
incompleteReason: string | null;
|
|
36
75
|
usage: {
|
|
37
76
|
inputTokens: number;
|
|
@@ -56,6 +95,7 @@ export interface ResponsesResult {
|
|
|
56
95
|
incomplete_details?: {
|
|
57
96
|
reason?: string;
|
|
58
97
|
} | null;
|
|
98
|
+
conversation_mode?: string | null;
|
|
59
99
|
}
|
|
60
100
|
export declare const EXIT_CODES: Record<RunStatus, number>;
|
|
61
101
|
/** The assistant's text: every `output_text` part of every `message` item, in order. */
|
|
@@ -76,7 +116,13 @@ export declare function parseAgentModel(model?: string): {
|
|
|
76
116
|
*/
|
|
77
117
|
export declare function stripControl(s: string): string;
|
|
78
118
|
export declare function shellQuote(value: string): string;
|
|
79
|
-
|
|
119
|
+
/** "Connect a (h), allow the agent to use b (h) and reconnect c (h)". */
|
|
120
|
+
export declare function connectionsSentence(connections: PendingConnection[]): string;
|
|
121
|
+
/**
|
|
122
|
+
* @param chatUrl the chat web host of the API the run went to ({@link chatUrlFor}); a connect pause's
|
|
123
|
+
* `next` sends the user to its Connectors page.
|
|
124
|
+
*/
|
|
125
|
+
export declare function buildRunEnvelope(result: ResponsesResult | undefined, agentRef?: string, chatUrl?: string): RunEnvelope;
|
|
80
126
|
/** Human-readable rendering of an envelope on stdout. Every value printed is passed through {@link stripControl}. */
|
|
81
127
|
export declare function printRunText(env: RunEnvelope): void;
|
|
82
128
|
export {};
|