@cavelon/cli 0.1.5 → 0.1.7
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 +56 -18
- package/dist/command.js +10 -0
- package/dist/commands/api.js +40 -36
- package/dist/commands/chat.js +183 -0
- package/dist/commands/docs.js +77 -9
- package/dist/commands/fmt.js +61 -6
- package/dist/commands/index.js +3 -0
- package/dist/commands/init.js +61 -26
- package/dist/commands/inventory.js +21 -0
- package/dist/commands/limits-set.js +10 -6
- package/dist/commands/loops.js +22 -11
- package/dist/commands/models.js +11 -7
- package/dist/commands/sandboxes.js +11 -5
- package/dist/commands/schema.js +230 -48
- package/dist/commands/session.js +100 -14
- package/dist/commands/setup.js +22 -6
- package/dist/commands/solution.js +493 -86
- package/dist/commands/tenants.js +43 -10
- package/dist/commands/values.js +20 -11
- package/dist/commands/work.js +167 -33
- package/dist/confirm-token.js +72 -0
- package/dist/format.js +4 -4
- package/dist/harness-ref.js +17 -4
- package/dist/http.js +6 -0
- package/dist/kit-codes.js +11 -1
- package/dist/local-state.js +46 -10
- package/dist/main.js +38 -6
- package/dist/mcp.js +65 -14
- package/dist/openapi.js +30 -0
- package/dist/package-check.js +206 -18
- package/dist/package-files.js +98 -40
- package/dist/package-format.js +81 -8
- package/dist/package-references.js +77 -10
- package/dist/results.js +21 -1
- package/dist/session.js +9 -0
- package/dist/skills/cavelon-authoring/SKILL.md +54 -21
- package/dist/skills/cavelon-long-running/SKILL.md +13 -9
- package/dist/skills/cavelon-loop/SKILL.md +124 -28
- package/dist/skills/cavelon-testing/SKILL.md +69 -16
- package/dist/tenant-choice.js +19 -0
- package/dist/trace-view.js +172 -0
- package/package.json +1 -1
package/dist/package-format.js
CHANGED
|
@@ -59,13 +59,43 @@ export function sectionFields(schema, section) {
|
|
|
59
59
|
return undefined;
|
|
60
60
|
return Object.fromEntries(Object.entries(props).map(([k, v]) => [k, resolve(schema, v) ?? {}]));
|
|
61
61
|
}
|
|
62
|
-
export function
|
|
62
|
+
export function canonical(value) {
|
|
63
|
+
return JSON.stringify(value, (_key, v) => {
|
|
64
|
+
if (v && typeof v === "object" && !Array.isArray(v)) {
|
|
65
|
+
return Object.fromEntries(Object.entries(v).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
66
|
+
}
|
|
67
|
+
return v;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const requiredOf = (shape) => new Set(Array.isArray(shape?.required) ? shape.required : []);
|
|
71
|
+
function nullable(schema, field) {
|
|
72
|
+
if (field.type === "null" || (Array.isArray(field.type) && field.type.includes("null")))
|
|
73
|
+
return true;
|
|
74
|
+
return branches(schema, field).some((b) => b.type === "null");
|
|
75
|
+
}
|
|
76
|
+
function implicitDefault(schema, key, sub, required, position) {
|
|
77
|
+
const field = resolve(schema, sub);
|
|
78
|
+
if (!field || required.has(key))
|
|
79
|
+
return undefined;
|
|
80
|
+
if (position !== undefined && key.endsWith("_order") && field.type === "integer" && typeof field.default === "number")
|
|
81
|
+
return field.default + position;
|
|
82
|
+
if (field.default !== undefined)
|
|
83
|
+
return field.default === null ? undefined : field.default;
|
|
84
|
+
if (nullable(schema, field))
|
|
85
|
+
return undefined;
|
|
86
|
+
if (field.type === "array")
|
|
87
|
+
return [];
|
|
88
|
+
if (field.type === "object" || propertiesOf(field))
|
|
89
|
+
return {};
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
export function exportForm(schema, node, value, depth = 0, position) {
|
|
63
93
|
const resolved = resolve(schema, node);
|
|
64
94
|
if (!resolved || depth > 40)
|
|
65
95
|
return value;
|
|
66
96
|
if (Array.isArray(value)) {
|
|
67
97
|
const array = arrayBranch(schema, resolved);
|
|
68
|
-
return array?.items ? value.map((item) => exportForm(schema, array.items, item, depth + 1)) : value;
|
|
98
|
+
return array?.items ? value.map((item, i) => exportForm(schema, array.items, item, depth + 1, i)) : value;
|
|
69
99
|
}
|
|
70
100
|
if (!isObject(value))
|
|
71
101
|
return value;
|
|
@@ -73,13 +103,14 @@ export function exportForm(schema, node, value, depth = 0) {
|
|
|
73
103
|
const props = propertiesOf(object);
|
|
74
104
|
if (!props)
|
|
75
105
|
return value;
|
|
106
|
+
const required = requiredOf(object);
|
|
76
107
|
const out = {};
|
|
77
108
|
for (const [key, sub] of Object.entries(props)) {
|
|
78
109
|
if (key in value)
|
|
79
110
|
out[key] = exportForm(schema, sub, value[key], depth + 1);
|
|
80
111
|
else {
|
|
81
|
-
const fallback =
|
|
82
|
-
if (fallback !== undefined
|
|
112
|
+
const fallback = implicitDefault(schema, key, sub, required, position);
|
|
113
|
+
if (fallback !== undefined)
|
|
83
114
|
out[key] = structuredClone(fallback);
|
|
84
115
|
}
|
|
85
116
|
}
|
|
@@ -110,12 +141,54 @@ export function withoutNulls(value) {
|
|
|
110
141
|
function isEmpty(value) {
|
|
111
142
|
return value === null || value === undefined || (isObject(value) && Object.keys(value).length === 0);
|
|
112
143
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
144
|
+
const isUnset = (value) => isEmpty(value) || (Array.isArray(value) && value.length === 0);
|
|
145
|
+
export function settledForm(schema, node, value, depth = 0) {
|
|
146
|
+
const resolved = resolve(schema, node);
|
|
147
|
+
if (!resolved || depth > 40)
|
|
148
|
+
return withoutNulls(value);
|
|
149
|
+
if (Array.isArray(value)) {
|
|
150
|
+
const array = arrayBranch(schema, resolved);
|
|
151
|
+
return array?.items ? value.map((item) => settledForm(schema, array.items, item, depth + 1)) : withoutNulls(value);
|
|
152
|
+
}
|
|
153
|
+
if (!isObject(value))
|
|
154
|
+
return value;
|
|
155
|
+
const object = objectBranch(schema, resolved, value);
|
|
156
|
+
const props = propertiesOf(object);
|
|
157
|
+
if (!props)
|
|
158
|
+
return withoutNulls(value);
|
|
159
|
+
const required = requiredOf(object);
|
|
160
|
+
const out = {};
|
|
161
|
+
for (const [key, inner] of Object.entries(value)) {
|
|
162
|
+
if (!(key in props)) {
|
|
163
|
+
if (inner !== null)
|
|
164
|
+
out[key] = withoutNulls(inner);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const settled = settledForm(schema, props[key], inner, depth + 1);
|
|
168
|
+
if (!required.has(key)) {
|
|
169
|
+
const fallback = implicitDefault(schema, key, props[key], required, undefined);
|
|
170
|
+
if (isUnset(settled) && (fallback === undefined || isUnset(fallback)))
|
|
171
|
+
continue;
|
|
172
|
+
if (fallback !== undefined && canonical(settled) === canonical(settledForm(schema, props[key], fallback, depth + 1)))
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
out[key] = settled;
|
|
176
|
+
}
|
|
177
|
+
return out;
|
|
178
|
+
}
|
|
179
|
+
export function sameSectionValue(section, a, b, schema = null) {
|
|
180
|
+
const node = schema?.properties?.[section];
|
|
181
|
+
const left = schema && node ? settledForm(schema, node, a) : withoutNulls(a);
|
|
182
|
+
const right = schema && node ? settledForm(schema, node, b) : withoutNulls(b);
|
|
116
183
|
if (section === PERSONA_SECTION && isEmpty(left) && isEmpty(right))
|
|
117
184
|
return true;
|
|
118
|
-
return
|
|
185
|
+
return canonical(left) === canonical(right);
|
|
186
|
+
}
|
|
187
|
+
export function sameEntry(section, a, b, schema = null) {
|
|
188
|
+
const node = schema?.properties?.[section];
|
|
189
|
+
if (!schema || !node)
|
|
190
|
+
return canonical(withoutNulls(a)) === canonical(withoutNulls(b));
|
|
191
|
+
return canonical(settledForm(schema, node, [a])) === canonical(settledForm(schema, node, [b]));
|
|
119
192
|
}
|
|
120
193
|
function placeholder(key, field) {
|
|
121
194
|
const fallback = field.default !== undefined ? field.default : field.type === "array" ? [] : null;
|
|
@@ -5,6 +5,8 @@ export const REFERENCE_UNKNOWN_CODE = "package_reference_unknown";
|
|
|
5
5
|
export const FIELD_UNKNOWN_CODE = "package_field_unknown";
|
|
6
6
|
export const MODEL_UNKNOWN_CODE = "package_model_unknown";
|
|
7
7
|
export const SEARCH_TOOL_KEYS = new Set(["search_documents", "search_knowledge_base", "search_kb"]);
|
|
8
|
+
export const KNOWLEDGE_TOOL_KEYS = new Set([...SEARCH_TOOL_KEYS, "list_documents", "list_kb_docs"]);
|
|
9
|
+
const DOCUMENT_TOOL_KEYS = new Set([...KNOWLEDGE_TOOL_KEYS, "read_document", "save_document"]);
|
|
8
10
|
const asObject = (v) => (v && typeof v === "object" && !Array.isArray(v) ? v : undefined);
|
|
9
11
|
const list = (v) => (Array.isArray(v) ? v.map(asObject) : []);
|
|
10
12
|
const text = (v) => (typeof v === "string" && v !== "" ? v : undefined);
|
|
@@ -26,18 +28,29 @@ export function closest(word, candidates, preferred = []) {
|
|
|
26
28
|
if (d <= allowance && (!best || d < best.d))
|
|
27
29
|
best = { name, d };
|
|
28
30
|
};
|
|
29
|
-
|
|
31
|
+
const names = [...candidates];
|
|
32
|
+
const wanted = [...preferred];
|
|
33
|
+
for (const name of wanted)
|
|
30
34
|
consider(name, Math.ceil(Math.max(word.length, name.length) / 2));
|
|
31
|
-
for (const name of
|
|
35
|
+
for (const name of names)
|
|
32
36
|
consider(name, typoAllowance(word));
|
|
33
|
-
|
|
37
|
+
if (best)
|
|
38
|
+
return best.name;
|
|
39
|
+
const lower = word.toLowerCase();
|
|
40
|
+
if (lower.length < 4)
|
|
41
|
+
return undefined;
|
|
42
|
+
const related = [...wanted, ...names].filter((name) => {
|
|
43
|
+
const other = name.toLowerCase();
|
|
44
|
+
return other !== lower && (other.startsWith(lower) || lower.startsWith(other) || other.includes(lower)) && Math.min(other.length, lower.length) >= 4;
|
|
45
|
+
});
|
|
46
|
+
return related.sort((a, b) => Math.abs(a.length - word.length) - Math.abs(b.length - word.length))[0];
|
|
34
47
|
}
|
|
35
48
|
const typoAllowance = (word) => Math.max(2, Math.floor(word.length / 3));
|
|
36
49
|
const didYouMean = (name) => (name ? ` Did you mean "${name}"?` : "");
|
|
37
50
|
const suggested = (message, suggestion) => ({ message: message + didYouMean(suggestion), ...(suggestion ? { suggestion } : {}) });
|
|
38
51
|
const AGENT = { label: "agent", section: "agents", key: "slug" };
|
|
39
52
|
const SKILL = { label: "skill", section: "skills", key: "slug", inventory: "skills" };
|
|
40
|
-
const TOOL = { label: "tool", section: "tools", key: "slug", inventory: "tools", builtin:
|
|
53
|
+
const TOOL = { label: "tool", section: "tools", key: "slug", inventory: "tools", builtin: DOCUMENT_TOOL_KEYS };
|
|
41
54
|
const KNOWLEDGE_BASE = { label: "knowledge base", section: "knowledge_bases", key: "name", inventory: "knowledge_bases" };
|
|
42
55
|
const SOLUTION = { label: "solution", section: "harnesses", key: "slug", inventory: "solutions" };
|
|
43
56
|
const KEYED = [AGENT, SKILL, TOOL, KNOWLEDGE_BASE, SOLUTION, { label: "guardrail", section: "guardrails", key: "slug" }];
|
|
@@ -48,12 +61,19 @@ const INVENTORY_LABEL = {
|
|
|
48
61
|
skills: "skills",
|
|
49
62
|
models: "models",
|
|
50
63
|
};
|
|
64
|
+
const ASSERTION_TARGETS = {
|
|
65
|
+
answered_by: { target: AGENT, field: "value" },
|
|
66
|
+
handoff_to: { target: AGENT, field: "value" },
|
|
67
|
+
tool_called: { target: TOOL, field: "value" },
|
|
68
|
+
tool_not_called: { target: TOOL, field: "value" },
|
|
69
|
+
min_results: { target: TOOL, field: "tool" },
|
|
70
|
+
};
|
|
51
71
|
function references(pkg) {
|
|
52
72
|
const found = [];
|
|
53
|
-
const add = (pointer, from, value, target) => {
|
|
73
|
+
const add = (pointer, from, value, target, how) => {
|
|
54
74
|
const name = text(value);
|
|
55
75
|
if (name)
|
|
56
|
-
found.push({ pointer, from, name, target });
|
|
76
|
+
found.push({ pointer, from, name, target, ...(how ? { how } : {}) });
|
|
57
77
|
};
|
|
58
78
|
list(pkg.agents).forEach((agent, i) => {
|
|
59
79
|
if (!agent)
|
|
@@ -71,6 +91,21 @@ function references(pkg) {
|
|
|
71
91
|
list(skill.knowledge_base_assignments).forEach((a, j) => add(`/skills/${i}/knowledge_base_assignments/${j}/knowledge_base_name`, from, a?.knowledge_base_name, KNOWLEDGE_BASE));
|
|
72
92
|
list(skill.tool_assignments).forEach((a, j) => add(`/skills/${i}/tool_assignments/${j}/tool_slug`, from, a?.tool_slug, TOOL));
|
|
73
93
|
});
|
|
94
|
+
list(pkg.test_suites).forEach((suite, s) => {
|
|
95
|
+
list(suite?.test_cases).forEach((testCase, c) => {
|
|
96
|
+
const from = `The test case "${text(testCase?.name) ?? c}"${text(suite?.name) ? ` of the suite "${suite.name}"` : ""}`;
|
|
97
|
+
list(testCase?.steps).forEach((step, t) => {
|
|
98
|
+
list(step?.evaluation_criteria).forEach((criterion, k) => {
|
|
99
|
+
const type = text(criterion?.type);
|
|
100
|
+
const named = type !== undefined && Object.hasOwn(ASSERTION_TARGETS, type) ? ASSERTION_TARGETS[type] : undefined;
|
|
101
|
+
if (!named)
|
|
102
|
+
return;
|
|
103
|
+
const pointer = `/test_suites/${s}/test_cases/${c}/steps/${t}/evaluation_criteria/${k}/${named.field}`;
|
|
104
|
+
add(pointer, from, criterion[named.field], named.target, `checks ${type}`);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
74
109
|
return found;
|
|
75
110
|
}
|
|
76
111
|
function keysIn(pkg, target) {
|
|
@@ -82,6 +117,7 @@ function pulledAt(inventory, kind) {
|
|
|
82
117
|
export function checkReferences(disk, inventory) {
|
|
83
118
|
const pkg = disk.package;
|
|
84
119
|
const findings = [];
|
|
120
|
+
const unreadable = new Set(disk.unreadable ?? []);
|
|
85
121
|
for (const target of KEYED) {
|
|
86
122
|
const seen = new Map();
|
|
87
123
|
list(pkg[target.section]).forEach((entry, i) => {
|
|
@@ -104,16 +140,20 @@ export function checkReferences(disk, inventory) {
|
|
|
104
140
|
}
|
|
105
141
|
for (const ref of references(pkg)) {
|
|
106
142
|
const { target } = ref;
|
|
143
|
+
if (unreadable.has(target.section))
|
|
144
|
+
continue;
|
|
107
145
|
const inPackage = keysIn(pkg, target);
|
|
108
146
|
if (inPackage.includes(ref.name) || target.builtin?.has(ref.name))
|
|
109
147
|
continue;
|
|
110
148
|
const tenant = target.inventory ? inventory?.names[target.inventory] : undefined;
|
|
111
149
|
if (target === AGENT) {
|
|
150
|
+
if (ref.how && !Array.isArray(pkg.agents))
|
|
151
|
+
continue;
|
|
112
152
|
findings.push({
|
|
113
153
|
code: REFERENCE_MISSING_CODE,
|
|
114
154
|
severity: "error",
|
|
115
155
|
...locate(disk, ref.pointer),
|
|
116
|
-
...suggested(`${ref.from} hands off to the agent "${ref.name}", which is not in the package.`, closest(ref.name, inPackage)),
|
|
156
|
+
...suggested(`${ref.from} ${ref.how ?? "hands off to"} the agent "${ref.name}", which is not in the package.`, closest(ref.name, inPackage)),
|
|
117
157
|
});
|
|
118
158
|
continue;
|
|
119
159
|
}
|
|
@@ -124,8 +164,8 @@ export function checkReferences(disk, inventory) {
|
|
|
124
164
|
code: REFERENCE_UNKNOWN_CODE,
|
|
125
165
|
severity: "warning",
|
|
126
166
|
...locate(disk, ref.pointer),
|
|
127
|
-
...suggested(`${ref.from} names the ${target.label} "${ref.name}", which is neither in the package nor among the tenant's ${kind} ` +
|
|
128
|
-
`at the last pull (${pulledAt(inventory, target.inventory)}).`, closest(ref.name, [...inPackage, ...tenant])),
|
|
167
|
+
...suggested(`${ref.from} ${ref.how ?? "names"} the ${target.label} "${ref.name}", which is neither in the package nor among the tenant's ${kind} ` +
|
|
168
|
+
`at the last pull (${pulledAt(inventory, target.inventory)}).`, closest(ref.name, [...inPackage, ...tenant, ...(target.builtin ?? [])])),
|
|
129
169
|
});
|
|
130
170
|
}
|
|
131
171
|
return findings;
|
|
@@ -140,7 +180,7 @@ function resolve(schema, node) {
|
|
|
140
180
|
}
|
|
141
181
|
return current;
|
|
142
182
|
}
|
|
143
|
-
function branches(schema, node) {
|
|
183
|
+
export function branches(schema, node) {
|
|
144
184
|
const resolved = resolve(schema, node);
|
|
145
185
|
if (!resolved)
|
|
146
186
|
return [];
|
|
@@ -190,6 +230,9 @@ export function checkUnknownFields(disk, schema, schemaFindings = []) {
|
|
|
190
230
|
if (required) {
|
|
191
231
|
required.message += ` ("${key}" is set, which the package schema does not have; did you mean "${suggestion}"?)`;
|
|
192
232
|
required.suggestion = suggestion;
|
|
233
|
+
const misspelt = locate(disk, at);
|
|
234
|
+
if (misspelt.line !== undefined && misspelt.file === required.file)
|
|
235
|
+
required.line = misspelt.line;
|
|
193
236
|
continue;
|
|
194
237
|
}
|
|
195
238
|
const where = locate(disk, at);
|
|
@@ -213,6 +256,8 @@ export function checkModels(disk, inventory) {
|
|
|
213
256
|
const tenant = inventory?.names.models;
|
|
214
257
|
if (!Array.isArray(tenant) || !tenant.length)
|
|
215
258
|
return [];
|
|
259
|
+
if (disk.unreadable?.includes("model_registry"))
|
|
260
|
+
return [];
|
|
216
261
|
const known = new Set([...tenant, ...list(disk.package.model_registry).flatMap((row) => (text(row?.model_id) ? [row.model_id] : []))]);
|
|
217
262
|
const findings = [];
|
|
218
263
|
list(disk.package.agents).forEach((agent, i) => {
|
|
@@ -229,3 +274,25 @@ export function checkModels(disk, inventory) {
|
|
|
229
274
|
});
|
|
230
275
|
return findings;
|
|
231
276
|
}
|
|
277
|
+
const CHECKED_BY = {
|
|
278
|
+
solutions: "the solutions the package names",
|
|
279
|
+
knowledge_bases: "the knowledge bases the package names",
|
|
280
|
+
tools: "the tools the package names",
|
|
281
|
+
skills: "the skills the package names",
|
|
282
|
+
models: "the agents' models",
|
|
283
|
+
};
|
|
284
|
+
export const checkedBy = (kind) => CHECKED_BY[kind];
|
|
285
|
+
export function missingInventory(disk, inventory) {
|
|
286
|
+
const needed = new Set();
|
|
287
|
+
const pkg = disk.package;
|
|
288
|
+
for (const ref of references(pkg)) {
|
|
289
|
+
const kind = ref.target.inventory;
|
|
290
|
+
if (!kind || keysIn(pkg, ref.target).includes(ref.name) || ref.target.builtin?.has(ref.name))
|
|
291
|
+
continue;
|
|
292
|
+
needed.add(kind);
|
|
293
|
+
}
|
|
294
|
+
const own = new Set(list(pkg.model_registry).flatMap((row) => (text(row?.model_id) ? [row.model_id] : [])));
|
|
295
|
+
if (list(pkg.agents).some((agent) => text(agent?.llm_model) && !own.has(agent.llm_model)))
|
|
296
|
+
needed.add("models");
|
|
297
|
+
return [...needed].filter((kind) => !Array.isArray(inventory?.names[kind]));
|
|
298
|
+
}
|
package/dist/results.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { CavelonError } from "./errors.js";
|
|
2
2
|
import { clip } from "./format.js";
|
|
3
|
+
import { failedAssertions } from "./trace-view.js";
|
|
3
4
|
import { callStable } from "./invoke.js";
|
|
4
5
|
import { cavelonCommand } from "./shell.js";
|
|
6
|
+
export function caseKnowledgeOutcomes(r) {
|
|
7
|
+
if (!Array.isArray(r.tool_calls))
|
|
8
|
+
return null;
|
|
9
|
+
const outcomes = [];
|
|
10
|
+
for (const row of r.tool_calls) {
|
|
11
|
+
const outcome = row && typeof row === "object" ? row.knowledge_outcome : undefined;
|
|
12
|
+
if (typeof outcome === "string" && outcome && !outcomes.includes(outcome))
|
|
13
|
+
outcomes.push(outcome);
|
|
14
|
+
}
|
|
15
|
+
return outcomes.length ? outcomes : null;
|
|
16
|
+
}
|
|
5
17
|
export const NOT_PASSED = new Set(["fail", "error"]);
|
|
6
18
|
export function caseCounts(summary) {
|
|
7
19
|
return { failed: summaryCount(summary, "failed"), errors: summaryCount(summary, "errors") };
|
|
@@ -92,6 +104,7 @@ function explainedStatuses(counts) {
|
|
|
92
104
|
}
|
|
93
105
|
const MAX_CASES = 5;
|
|
94
106
|
const REASON_CHARS = 500;
|
|
107
|
+
const ANSWER_CHARS = 200;
|
|
95
108
|
export function failedCase(r, max = REASON_CHARS) {
|
|
96
109
|
const reason = r.error_message ?? r.llm_judge_reasoning ?? null;
|
|
97
110
|
return {
|
|
@@ -100,6 +113,8 @@ export function failedCase(r, max = REASON_CHARS) {
|
|
|
100
113
|
status: r.status,
|
|
101
114
|
reason: reason ? clip(reason, max) : null,
|
|
102
115
|
run_id: r.agent_run_id ?? null,
|
|
116
|
+
failed_assertions: failedAssertions(r.judge_breakdown),
|
|
117
|
+
answer: r.generated_answer ? clip(r.generated_answer.replace(/\s+/g, " ").trim(), ANSWER_CHARS) : null,
|
|
103
118
|
};
|
|
104
119
|
}
|
|
105
120
|
export async function resultFailure(ctx, op) {
|
|
@@ -150,8 +165,13 @@ export function failureLines(failure) {
|
|
|
150
165
|
];
|
|
151
166
|
if (failure.comparable === false && failure.non_comparable_reasons.length)
|
|
152
167
|
lines.push(` Not comparable: ${failure.non_comparable_reasons.join(", ")}`);
|
|
153
|
-
for (const c of failure.cases)
|
|
168
|
+
for (const c of failure.cases) {
|
|
154
169
|
lines.push(` ${caseLabel(c)} ${c.status}${c.reason ? ": " + c.reason : ""}`);
|
|
170
|
+
if (c.failed_assertions.length)
|
|
171
|
+
lines.push(` failed: ${c.failed_assertions.join(", ")}`);
|
|
172
|
+
if (c.answer)
|
|
173
|
+
lines.push(` answer: ${c.answer}`);
|
|
174
|
+
}
|
|
155
175
|
const shown = failure.cases.length;
|
|
156
176
|
const total = failure.failed_cases + failure.errored_cases + WAITING_COUNTS.reduce((sum, key) => sum + (failure.counts[key] ?? 0), 0);
|
|
157
177
|
if (total > shown)
|
package/dist/session.js
CHANGED
|
@@ -6,10 +6,19 @@ import { readTenantless } from "./principal.js";
|
|
|
6
6
|
import { listsTenants, searchTenants, tenantMissError } from "./tenant-choice.js";
|
|
7
7
|
import { findProject, readEnvFile } from "./project.js";
|
|
8
8
|
import { loadUserConfig, tokenKind, updateInstance } from "./user-config.js";
|
|
9
|
+
import { shellWord } from "./shell.js";
|
|
9
10
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10
11
|
export function isUuid(value) {
|
|
11
12
|
return UUID.test(value);
|
|
12
13
|
}
|
|
14
|
+
export function contextFlags(session) {
|
|
15
|
+
let flags = "";
|
|
16
|
+
if (session.urlSource === "option" && session.url)
|
|
17
|
+
flags += ` --instance ${shellWord(session.url)}`;
|
|
18
|
+
if (session.tenantSource === "option" && session.tenant)
|
|
19
|
+
flags += ` --tenant ${shellWord(session.tenant)}`;
|
|
20
|
+
return flags;
|
|
21
|
+
}
|
|
13
22
|
function isLocalHost(hostname) {
|
|
14
23
|
return (hostname === "localhost" ||
|
|
15
24
|
hostname.endsWith(".localhost") ||
|
|
@@ -53,7 +53,9 @@ for a public widget), **propose the change; the person decides.**
|
|
|
53
53
|
person with your reason (what fails or waits now), and wait for their answer.
|
|
54
54
|
- Only after they agreed, run the confirm command it printed (the `confirm`
|
|
55
55
|
field in `--json`) as it stands: it keeps the `--env` and `--tenant` of the
|
|
56
|
-
preview, so it changes the limit the preview showed.
|
|
56
|
+
preview, so it changes the limit the preview showed. Over MCP, call
|
|
57
|
+
`limits_set` again with the same arguments and `confirm` set to the
|
|
58
|
+
preview's `confirm_token`. Never raise a limit on
|
|
57
59
|
your own, never pick a value higher than the need you named, and never change
|
|
58
60
|
one without telling them.
|
|
59
61
|
- The same goes for the tenant's monthly inference budget
|
|
@@ -106,13 +108,14 @@ endpoint.
|
|
|
106
108
|
- On rows that already exist, `cavelon models list` shows each row's endpoint
|
|
107
109
|
and `max_concurrent_requests` (never a key). `cavelon models set-limit
|
|
108
110
|
<model_id> <n|none>` shows the old and the new value and changes nothing;
|
|
109
|
-
|
|
111
|
+
the confirm command it prints changes the row (from your shell it carries the
|
|
112
|
+
preview's token, `--confirm <token>`). It refuses a row without a `base_url`.
|
|
110
113
|
Where this instance's package format does not carry the field, `validate`
|
|
111
114
|
warns that the import ignores it; set it this way instead.
|
|
112
115
|
|
|
113
116
|
**Propose a limit; the person decides.** Say which value you would set and
|
|
114
117
|
why (what the endpoint serves, which rows share it, what waits or fails now),
|
|
115
|
-
then wait for the person's answer. Run `models set-limit
|
|
118
|
+
then wait for the person's answer. Run the confirm command of `models set-limit` only after
|
|
116
119
|
they agreed, and never raise or lower a limit without telling them. A limit
|
|
117
120
|
`cavelon limits` names as the operator's (the run caps, the slot waits, the
|
|
118
121
|
licence) is not yours or the tenant's to change: tell the person who changes
|
|
@@ -147,15 +150,24 @@ with `cavelon harness default`).
|
|
|
147
150
|
2. The schema: `cavelon schema` lists the sections and the file each is kept
|
|
148
151
|
in; `cavelon schema <section>` (the `package_schema` tool) lists a section's
|
|
149
152
|
fields with type, required, allowed values and default, and prints the
|
|
150
|
-
smallest entry with every required field, to copy into the file
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
smallest entry with every required field, to copy into the file, and one
|
|
154
|
+
with an entry of each nested list. A nested entry has its own fields: reach
|
|
155
|
+
them by path or type name, as the section's output lists them
|
|
156
|
+
(`cavelon schema agents.handoffs`, `cavelon schema test_suites.test_cases.steps`,
|
|
157
|
+
`cavelon schema PackageAgentHandoff`); where entries take several shapes
|
|
158
|
+
(`test_suites.test_cases.steps.evaluation_criteria`), each shape is listed.
|
|
159
|
+
A pulled file that is `[]` shows no shape; this does. `cavelon validate`
|
|
160
|
+
checks the files against the same schema, and each error names the file,
|
|
161
|
+
line and field. It also checks the references: a duplicate slug, and a
|
|
162
|
+
handoff or a test assertion (`answered_by`, `handoff_to`) naming an agent
|
|
163
|
+
the package lacks, are errors; a skill, tool, knowledge base or solution
|
|
164
|
+
that is neither in the package nor in the tenant's list, a field the schema
|
|
165
|
+
does not have (`package_field_unknown`, "did you mean temperature?"), an
|
|
166
|
+
`llm_model` outside the tenant's model list, and a package naming another
|
|
167
|
+
solution than `cavelon.yaml` (`solution_slug_mismatch`) are warnings. A
|
|
168
|
+
finding's `suggestion` (with `--json`) is the closest name. The import
|
|
169
|
+
preview blocks a name the instance does not have: then `validate` does not
|
|
170
|
+
say "Valid", and `cavelon validate --strict` fails on every warning.
|
|
159
171
|
3. Concepts and fields: `cavelon docs search <topic>` (for example "agent
|
|
160
172
|
graph", "tools", "knowledge base", "triggers"), then `cavelon docs get
|
|
161
173
|
<page>`.
|
|
@@ -219,12 +231,28 @@ and fill the field in to set it. A file of comments only sets nothing.
|
|
|
219
231
|
The preview names them with the Admin path where a person sets them.
|
|
220
232
|
- **Knowledge-base documents** are not in the repository: the package declares
|
|
221
233
|
the knowledge bases; `cavelon kb upload` brings the documents.
|
|
222
|
-
- **A knowledge base reaches an agent only through a
|
|
223
|
-
in a skill's `knowledge_base_assignments` only scopes the
|
|
224
|
-
(or the agent) also needs
|
|
225
|
-
|
|
226
|
-
|
|
234
|
+
- **A knowledge base reaches an agent only through a tool that reads it.**
|
|
235
|
+
Naming it in a skill's `knowledge_base_assignments` only scopes the tools;
|
|
236
|
+
the skill (or the agent) also needs a built-in that reads a knowledge base in
|
|
237
|
+
its `tool_assignments`: `search_documents` searches it, `list_documents`
|
|
238
|
+
lists its documents by their metadata, and `read_document` reads one by the
|
|
239
|
+
id a search or list returned (`cavelon docs get reference/builtin-tools`).
|
|
240
|
+
A tenant tool whose `builtin_key` is one of them counts too; naming
|
|
241
|
+
`knowledge_base_names` on any other tool (a webhook, an MCP tool) reaches
|
|
242
|
+
nothing. Without such a tool the
|
|
243
|
+
agent answers from memory; `cavelon validate` warns
|
|
227
244
|
(`knowledge_base_without_search_tool`).
|
|
245
|
+
- **The model comes from the tenant.** Set an agent's `llm_model` and
|
|
246
|
+
`llm_provider` to a row of `cavelon models list` (MODEL_ID, PROVIDER); the
|
|
247
|
+
models differ per instance and tenant, and the preview blocks one the tenant
|
|
248
|
+
does not have. On a reasoning model (the GPT-5 family, the o-series) from
|
|
249
|
+
OpenAI, Azure OpenAI or Anthropic the instance sends no `temperature` (the
|
|
250
|
+
schema still requires one: keep the default 0.4, and the preview flags any
|
|
251
|
+
other value); the reasoning level is what tunes such a model. Ask the
|
|
252
|
+
person to set it in the agent's **Model** tab in the Admin (Node
|
|
253
|
+
Workbench), then `cavelon pull` brings what the instance stored into
|
|
254
|
+
`package/agents.yaml`. `cavelon docs get concepts/choosing-models` says which
|
|
255
|
+
models take a temperature.
|
|
228
256
|
- **Who approves goes on the Approval node, not into the memo.** When the
|
|
229
257
|
brief says who approves, or that nobody approves their own request, set the
|
|
230
258
|
node's `approvers` (tenant roles or access groups, directly or in `tiers`
|
|
@@ -272,11 +300,16 @@ schema has them: `cavelon validate` reports an unknown section):
|
|
|
272
300
|
|
|
273
301
|
## After each edit
|
|
274
302
|
|
|
275
|
-
1. `cavelon validate` until it reports no errors
|
|
276
|
-
|
|
277
|
-
|
|
303
|
+
1. `cavelon validate` until it reports no errors (`--strict` before an apply
|
|
304
|
+
you expect to pass: it fails on the warnings the preview would block on).
|
|
305
|
+
After writing files by hand, `cavelon fmt` brings them into the form the
|
|
306
|
+
instance's export gives them (field order, the schema's defaults filled in,
|
|
307
|
+
test cases and steps numbered in their written order), so the first `pull`
|
|
278
308
|
after `apply` shows only what changed on the instance; `cavelon fmt
|
|
279
|
-
--check` changes nothing and exits 3 when a file would change.
|
|
309
|
+
--check` changes nothing and exits 3 when a file would change. fmt keeps
|
|
310
|
+
no comments (pull keeps none either) and names each file whose comments
|
|
311
|
+
it drops, as the example files' explanations: keep what the person needs
|
|
312
|
+
elsewhere before running it.
|
|
280
313
|
2. `cavelon apply --env test` to see what the instance makes of it; the
|
|
281
314
|
preview re-checks everything on the server, including rules that only the
|
|
282
315
|
instance can check (graph rules, references between sections).
|
|
@@ -47,7 +47,9 @@ Do not work around it; use the other column.
|
|
|
47
47
|
iteration, activate the parent (cavelon-loop skill, "A Masterloop parent and
|
|
48
48
|
its iteration solution"). `activate` never forces.
|
|
49
49
|
5. **Seed it.** Isolated container: `cavelon sandbox seed <sandbox> <folder>`
|
|
50
|
-
shows what it would send
|
|
50
|
+
shows what it would send and the confirm command that sends it: run that
|
|
51
|
+
one (from your shell it carries the preview's token, `--confirm <token>`;
|
|
52
|
+
a bare `--confirm` exits 5 and sends nothing). The archive **replaces
|
|
51
53
|
the workspace**, so confirm only for a test Sandbox or after the person
|
|
52
54
|
agreed. Customer VM: the files go onto the VM, then `cavelon sandbox refresh
|
|
53
55
|
<sandbox>`.
|
|
@@ -79,14 +81,15 @@ seconds).
|
|
|
79
81
|
`invalid_continuation`, …) resumes only with `--reason <the pause reason>`,
|
|
80
82
|
exactly as the loop names it, once the person reviewed the cause; `--reason`
|
|
81
83
|
is never free text. A pause that cannot be resumed is cancelled
|
|
82
|
-
(`cavelon loop cancel <run
|
|
83
|
-
watch prints both commands.
|
|
84
|
+
(`cavelon loop cancel <run>`, then the confirm command it prints) and started
|
|
85
|
+
again after the fix; the watch prints both commands.
|
|
84
86
|
- An iteration reads **accepted** (with its outcome: continue, wait, done,
|
|
85
87
|
blocked), **rejected**, or **failed** when its child failed. A run that ended
|
|
86
88
|
without a loop names the stage that recorded an error.
|
|
87
89
|
`cavelon trace <child_run_id>` reads one iteration's run.
|
|
88
|
-
- **Stop** a run and its loops: `cavelon loop cancel <run>` shows what stops
|
|
89
|
-
|
|
90
|
+
- **Stop** a run and its loops: `cavelon loop cancel <run>` shows what stops
|
|
91
|
+
and the confirm command (`--confirm <token>` from your shell) that stops it.
|
|
92
|
+
Stop runs you started, not someone else's.
|
|
90
93
|
- A run that waits at an **Approval** node, or a loop paused by a guardrail,
|
|
91
94
|
needs a person: `wait` prints the reason and the Admin link. An approval is
|
|
92
95
|
decided by a person, or by an API key an owner granted the explicit scope
|
|
@@ -121,7 +124,8 @@ Two reasons end work for capacity; each has its code in `cavelon explain`:
|
|
|
121
124
|
`model_endpoint_slot_wait_seconds`. Retry later, or, if the endpoint can serve
|
|
122
125
|
more, propose raising the Model Registry row's `max_concurrent_requests`
|
|
123
126
|
(`cavelon models list` shows it). The person decides; only then run
|
|
124
|
-
`cavelon models set-limit <model_id> <n
|
|
127
|
+
`cavelon models set-limit <model_id> <n>` and the confirm command it prints
|
|
128
|
+
(`--confirm <token>` from your shell).
|
|
125
129
|
|
|
126
130
|
`cavelon limits` shows the caps, their source and origin, the slot waits, and
|
|
127
131
|
branch concurrency (how many items of a Map loop run at once, and whether they
|
|
@@ -155,9 +159,9 @@ A scheduled or webhook run has no caller, so it acts as an **API key** bound to
|
|
|
155
159
|
its trigger. `apply` never binds one; it lists unbound triggers in the preview.
|
|
156
160
|
|
|
157
161
|
```bash
|
|
158
|
-
cavelon trigger identity <trigger>
|
|
159
|
-
cavelon trigger identity <trigger> <key-name>
|
|
160
|
-
cavelon trigger identity <trigger> <key-name> --confirm
|
|
162
|
+
cavelon trigger identity <trigger> # who it runs as, what the key must reach
|
|
163
|
+
cavelon trigger identity <trigger> <key-name> # shows the change and its confirm token
|
|
164
|
+
cavelon trigger identity <trigger> <key-name> --confirm <token> # from your shell; a person's terminal takes a bare --confirm
|
|
161
165
|
```
|
|
162
166
|
|
|
163
167
|
Binding gives the trigger standing authority over its Sandboxes: show the person
|