@knolo/cli 6.2.5 → 6.2.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 +4 -3
- package/bin/kite.mjs +199 -0
- package/bin/knolo.mjs +8 -1
- package/bin/registry/commands.mjs +234 -33
- package/package.json +3 -3
- package/templates/icp-knowledge-canister/canisters/knolo-core-rust/src/kar/mod.rs +1 -1
- package/templates/icp-knowledge-canister/canisters/knolo-core-rust/src/kite/mod.rs +887 -0
- package/templates/icp-knowledge-canister/canisters/knolo-core-rust/src/lib.rs +2 -0
- package/templates/icp-knowledge-canister/canisters/knolo-core-rust/tests/fixtures/kite-v1/cases.json +1088 -0
package/README.md
CHANGED
|
@@ -19,8 +19,9 @@ reader.
|
|
|
19
19
|
|
|
20
20
|
`knolo compose`, `knolo attest`, and `knolo verify-attestation` cite local
|
|
21
21
|
Knowledge Images and write an attestation sidecar. This tree's `@knolo/cli`
|
|
22
|
-
package file is `6.2.
|
|
23
|
-
`@knolo/exchange` `^0.1.0`. npm `latest` is `6.2.
|
|
22
|
+
package file is `6.2.6` and depends on `@knolo/core` `^6.2.3` and
|
|
23
|
+
`@knolo/exchange` `^0.1.0`. npm `latest` is `6.2.6`. `knolo kite` is in this
|
|
24
|
+
package and in that release. It is not in published `@knolo/cli@6.2.5`. `knolo exchange` hands
|
|
24
25
|
a verified V5 image to another agent. Shipped configs keep `adopt: deny`.
|
|
25
26
|
Discover reads a public advertisement and does not download a pack. They do
|
|
26
27
|
not fetch Hub for that handoff. Verification
|
|
@@ -386,7 +387,7 @@ This ensures:
|
|
|
386
387
|
## 🗺 Roadmap
|
|
387
388
|
|
|
388
389
|
The active roadmap is maintained in [`../../docs/ROADMAP.md`](../../docs/ROADMAP.md).
|
|
389
|
-
The published npm release is `6.2.
|
|
390
|
+
The published npm release is `6.2.6`. This tree's package file is `6.2.6` and adds `knolo kite`. `@knolo/cli@6.2.5` does not include that command. The published release preserves the V4 CLI, keeps V5 verification,
|
|
390
391
|
migration, diagnostics, and read-only Studio management, and adds offline
|
|
391
392
|
composition, attestation, and `knolo cortex`. Cortex verification does not
|
|
392
393
|
mean an answer is true.
|
package/bin/kite.mjs
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knolo kite evaluate | verify
|
|
3
|
+
*
|
|
4
|
+
* Replays a typed contract against a local V5 image.
|
|
5
|
+
* It does not call a model and it does not download an image.
|
|
6
|
+
* A certificate is an integrity check. It does not mean a claim is true.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
11
|
+
import {
|
|
12
|
+
KAR_CLI_MAX_IMAGE_BYTES,
|
|
13
|
+
KAR_CLI_MAX_TEXT_BYTES,
|
|
14
|
+
readBounded,
|
|
15
|
+
} from './kar-limits.mjs';
|
|
16
|
+
|
|
17
|
+
const USAGE = `Usage: knolo kite <evaluate|verify> [options]
|
|
18
|
+
|
|
19
|
+
knolo kite evaluate --image <image.knolo> --contract <contract.json> --rules <rules.json> [--completeness <file>] [--changes <file>] [--bounds <file>] [--graph <file>] [--as-of YYYY-MM-DD] [--out <result.json>] [--json]
|
|
20
|
+
knolo kite verify --image <image.knolo> --contract <contract.json> --rules <rules.json> --certificate <certificate.json> [--completeness <file>] [--changes <file>] [--bounds <file>] [--graph <file>] [--as-of YYYY-MM-DD]
|
|
21
|
+
|
|
22
|
+
Evaluation names unmet obligations and derives a verdict inside the declared changes.
|
|
23
|
+
Verification recomputes that derivation.
|
|
24
|
+
A certificate is an integrity check. It does not mean the claim is true.
|
|
25
|
+
BOUND_EXCEEDED means the search did not finish and is not a certificate.`;
|
|
26
|
+
|
|
27
|
+
export async function runKiteCli(argv) {
|
|
28
|
+
if (
|
|
29
|
+
argv.length === 0 ||
|
|
30
|
+
argv[0] === 'help' ||
|
|
31
|
+
argv[0] === '--help' ||
|
|
32
|
+
argv[0] === '-h'
|
|
33
|
+
) {
|
|
34
|
+
console.log(USAGE);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const command = argv[0];
|
|
38
|
+
if (command !== 'evaluate' && command !== 'verify') {
|
|
39
|
+
throw new Error(`Unknown kite command "${command}".\n${USAGE}`);
|
|
40
|
+
}
|
|
41
|
+
const flags = parseFlags(argv.slice(1));
|
|
42
|
+
if (flags.help) {
|
|
43
|
+
console.log(USAGE);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
if (command === 'evaluate') await evaluate(flags);
|
|
48
|
+
else await verify(flags);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (
|
|
51
|
+
error &&
|
|
52
|
+
typeof error.code === 'string' &&
|
|
53
|
+
error.code.startsWith('KITE')
|
|
54
|
+
) {
|
|
55
|
+
throw new Error(`${error.code}: ${error.message}`);
|
|
56
|
+
}
|
|
57
|
+
if (error && error.code === 'BOUND_EXCEEDED') {
|
|
58
|
+
throw new Error(`${error.code}: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function evaluate(flags) {
|
|
65
|
+
const api = await loadKite();
|
|
66
|
+
const session = createSession(api, flags);
|
|
67
|
+
const result = await api.evaluateKiteSession(session, optionsFrom(flags));
|
|
68
|
+
const body = `${JSON.stringify(result, null, 2)}\n`;
|
|
69
|
+
if (flags.out) writeNew(flags.out, body);
|
|
70
|
+
if (flags.json || !flags.out) {
|
|
71
|
+
if (flags.json) process.stdout.write(body);
|
|
72
|
+
else if (result.certificate) {
|
|
73
|
+
console.log(`${result.verdict} ${result.certificate.invarianceRoot}`);
|
|
74
|
+
} else console.log(result.verdict);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function verify(flags) {
|
|
79
|
+
const api = await loadKite();
|
|
80
|
+
const certificate = readJson(required(flags.certificate, '--certificate'));
|
|
81
|
+
const verified = await api.verifyKiteCertificate({
|
|
82
|
+
...inputFrom(flags),
|
|
83
|
+
...optionsFrom(flags),
|
|
84
|
+
certificate,
|
|
85
|
+
});
|
|
86
|
+
if (!verified.ok) throw new Error(`${verified.code}: ${verified.message}`);
|
|
87
|
+
console.log(`ok ${verified.invarianceRoot}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function createSession(api, flags) {
|
|
91
|
+
return api.createKiteSession(inputFrom(flags));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function inputFrom(flags) {
|
|
95
|
+
const input = {
|
|
96
|
+
image: new Uint8Array(
|
|
97
|
+
readBounded(required(flags.image, '--image'), KAR_CLI_MAX_IMAGE_BYTES)
|
|
98
|
+
),
|
|
99
|
+
contract: readJson(required(flags.contract, '--contract')),
|
|
100
|
+
rules: readJson(required(flags.rules, '--rules')),
|
|
101
|
+
};
|
|
102
|
+
if (flags.completeness) input.completeness = readJson(flags.completeness);
|
|
103
|
+
if (flags.changes) input.changes = readJson(flags.changes);
|
|
104
|
+
if (flags.bounds) input.bounds = readJson(flags.bounds);
|
|
105
|
+
if (flags.graph) input.graph = readJson(flags.graph);
|
|
106
|
+
return input;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function optionsFrom(flags) {
|
|
110
|
+
const options = {};
|
|
111
|
+
if (flags.question) options.question = flags.question;
|
|
112
|
+
if (flags.asOf) options.asOf = flags.asOf;
|
|
113
|
+
return options;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function readJson(file) {
|
|
117
|
+
const bytes = readBounded(file, KAR_CLI_MAX_TEXT_BYTES);
|
|
118
|
+
try {
|
|
119
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
`KITE_CONTRACT_INVALID: ${path.basename(file)} is not JSON.`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function writeNew(file, body) {
|
|
128
|
+
const resolved = path.resolve(process.cwd(), file);
|
|
129
|
+
if (existsSync(resolved)) throw new Error(`Refusing to overwrite ${file}`);
|
|
130
|
+
try {
|
|
131
|
+
writeFileSync(resolved, body, { flag: 'wx' });
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (error && error.code !== 'EEXIST') {
|
|
134
|
+
try {
|
|
135
|
+
unlinkSync(resolved);
|
|
136
|
+
} catch {
|
|
137
|
+
// The file was not created.
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function hasKite(loaded) {
|
|
145
|
+
return Boolean(
|
|
146
|
+
loaded?.createKiteSession &&
|
|
147
|
+
loaded?.evaluateKiteSession &&
|
|
148
|
+
loaded?.verifyKiteCertificate
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function loadKite() {
|
|
153
|
+
const candidate = path.resolve(
|
|
154
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
155
|
+
'../../core/dist/kite/index.js'
|
|
156
|
+
);
|
|
157
|
+
try {
|
|
158
|
+
const loaded = await import(pathToFileURL(candidate).href);
|
|
159
|
+
if (hasKite(loaded)) return loaded;
|
|
160
|
+
} catch {
|
|
161
|
+
// An installed package does not have the checkout dist path.
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const loaded = await import('@knolo/core/kite');
|
|
165
|
+
if (hasKite(loaded)) return loaded;
|
|
166
|
+
} catch {
|
|
167
|
+
// The package fallback is absent until core is installed.
|
|
168
|
+
}
|
|
169
|
+
throw new Error(
|
|
170
|
+
'Could not load @knolo/core/kite. Build packages/core first.'
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function required(value, name) {
|
|
175
|
+
if (!value) throw new Error(`Missing ${name}.\n${USAGE}`);
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function parseFlags(args) {
|
|
180
|
+
const flags = {};
|
|
181
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
182
|
+
const arg = args[index];
|
|
183
|
+
if (arg === '--help' || arg === '-h') flags.help = true;
|
|
184
|
+
else if (arg === '--json') flags.json = true;
|
|
185
|
+
else if (arg === '--image') flags.image = args[++index];
|
|
186
|
+
else if (arg === '--contract') flags.contract = args[++index];
|
|
187
|
+
else if (arg === '--rules') flags.rules = args[++index];
|
|
188
|
+
else if (arg === '--completeness') flags.completeness = args[++index];
|
|
189
|
+
else if (arg === '--changes') flags.changes = args[++index];
|
|
190
|
+
else if (arg === '--bounds') flags.bounds = args[++index];
|
|
191
|
+
else if (arg === '--graph') flags.graph = args[++index];
|
|
192
|
+
else if (arg === '--certificate') flags.certificate = args[++index];
|
|
193
|
+
else if (arg === '--as-of') flags.asOf = args[++index];
|
|
194
|
+
else if (arg === '--question') flags.question = args[++index];
|
|
195
|
+
else if (arg === '--out') flags.out = args[++index];
|
|
196
|
+
else throw new Error(`Unknown kite option "${arg}".\n${USAGE}`);
|
|
197
|
+
}
|
|
198
|
+
return flags;
|
|
199
|
+
}
|
package/bin/knolo.mjs
CHANGED
|
@@ -77,6 +77,7 @@ const SUBCOMMANDS = new Set([
|
|
|
77
77
|
'attest',
|
|
78
78
|
'verify-attestation',
|
|
79
79
|
'cortex',
|
|
80
|
+
'kite',
|
|
80
81
|
'flight',
|
|
81
82
|
'skill',
|
|
82
83
|
'setup',
|
|
@@ -180,6 +181,7 @@ Commands:
|
|
|
180
181
|
compose Compose Knowledge Images, packs, and attestations offline
|
|
181
182
|
attest Create or verify a composition attestation
|
|
182
183
|
cortex Bounded evidence retrieval with a verifiable trace
|
|
184
|
+
kite Check a typed contract and replay its certificate
|
|
183
185
|
flight Pack a flight-events-1 document into a V5 Knowledge Image
|
|
184
186
|
skill Create and share a Knolo skill pack
|
|
185
187
|
research Package local research files into a V5 Knowledge Image
|
|
@@ -207,7 +209,7 @@ function printCommandHelp(command) {
|
|
|
207
209
|
whoami: 'Usage: knolo whoami',
|
|
208
210
|
logout: 'Usage: knolo logout',
|
|
209
211
|
publish:
|
|
210
|
-
'Usage: knolo publish <pack.knolo> --slug <slug> --version <version> --license <SPDX> [--publisher <handle>] [--readme <text>] [--sources <text>] [--intended-use <text>] [--json] [--registry <url>]\n\nUses the stored dashboard token as Authorization: Bearer kno_…. Hub issues a public Blob PUT grant; the CLI never needs PACKS_READ_WRITE_TOKEN.\nUploads go to the grant URL without the kno_ token. Complete sends the public Blob URL, then Hub verifies before release.',
|
|
212
|
+
'Usage: knolo publish <pack.knolo> --slug <slug> --version <version> --license <SPDX> [--publisher <handle>] [--readme <text>] [--sources <text>] [--intended-use <text>] [--private] [--json] [--registry <url>]\n\nUses the stored dashboard token as Authorization: Bearer kno_…. Hub issues a public Blob PUT grant; the CLI never needs PACKS_READ_WRITE_TOKEN.\nUploads go to the grant URL without the kno_ token. Complete sends the public Blob URL, then Hub verifies before release.\n--private releases an owner-only pack on a Business or Enterprise plan. The success text omits the Blob URL.',
|
|
211
213
|
yank: 'Usage: knolo yank <publisher>/<slug>@<version> [--json] [--registry <url>]\n\nUses the stored token as Authorization: Bearer kno_…. Yank is owner-only and leaves the public Blob in place.',
|
|
212
214
|
build: 'Usage: knolo build',
|
|
213
215
|
query:
|
|
@@ -224,6 +226,7 @@ function printCommandHelp(command) {
|
|
|
224
226
|
compose: 'Usage: knolo compose <create|verify|excerpt|query> [options]\n\nOffline composition of Knowledge Images, packs, KAR sidecars, Domain Packs, and bounded excerpts.\n\n knolo compose create --members members.json --out composition/ [--host knowledge.knolo] [--availability material|digest] [--policy policy.json]\n knolo compose verify composition/ [--require-material] [--member alias=path]\n knolo compose excerpt --image knowledge.knolo --object <id> --out excerpt.json\n knolo compose query --composition composition/ --eql "FROM chunk SEARCH \\"valve\\"" [--question "..."] [--json]\n\ncompositionRoot does not change a V5 state root or a KAR root. statement used means a query or evaluation ran. It does not mean SATISFIED, and it does not mean a claim is true or false. Hub attested: true is a listing flag and is not an attestation root. The CLI does not fetch Hub.',
|
|
225
227
|
attest: 'Usage: knolo attest <create|verify> [options]\n\n knolo attest create --composition composition/composition.json --subject composition --statement mount|used|cited --out attestation.json [--sign-key key.json --principal <id> --key-id <id> --issued-at <ms> --expires-at <ms>]\n knolo attest verify attestation.json [--composition composition.json] [--public-key key.json] [--now <ms>] [--content-only]\n\nstatement used means a query or KAR evaluation ran. It does not mean the claim is true or false. Hub attested: true is unrelated. Signing uses the supplied times. The CLI does not read the clock.',
|
|
226
228
|
cortex: 'Usage: knolo cortex <find|ask|explain|verify> [options]\n\nBounded evidence retrieval. The CLI does not call a model.\n\n knolo cortex find <image> --question "..." [--top-k 100] --out candidates.json\n knolo cortex ask <image> --question "..." [--graph file] [--plan plan.json] [--mode find_relevant] --out answer.cortex.json\n knolo cortex explain answer.cortex.json\n knolo cortex verify --image <image> --answer answer.cortex.json [--graph file]\n\nVerification recomputes the trace roots. It does not mean the answer is true. A KAR status of SATISFIED means evidence requirements were met. It does not mean a claim is proven.',
|
|
229
|
+
kite: 'Usage: knolo kite <evaluate|verify> [options]\n\n knolo kite evaluate --image <image.knolo> --contract <contract.json> --rules <rules.json> [--completeness <file>] [--changes <file>] [--bounds <file>] [--graph <file>] [--as-of YYYY-MM-DD] [--out <result.json>] [--json]\n knolo kite verify --image <image.knolo> --contract <contract.json> --rules <rules.json> --certificate <certificate.json> [--completeness <file>] [--changes <file>] [--bounds <file>] [--graph <file>] [--as-of YYYY-MM-DD]\n\nEvaluation names unmet obligations and derives a verdict inside the declared changes. Verification recomputes that derivation. A certificate is an integrity check. It does not mean the claim is true. BOUND_EXCEEDED means the search did not finish and is not a certificate. This command ships in this package. It loads @knolo/core/kite.',
|
|
227
230
|
research:
|
|
228
231
|
'Usage: knolo research package --question <text> --agent <id> --out <image.knolo> --source <file> [--source <file>] [--cite <image.knolo> --trace <answer.cortex.json> [--graph <file>]] [--json]\n\nPacks local files into one V5 Knowledge Image. --agent is the host-supplied caller. --cite and --trace are both required or both omitted. --graph is required when the trace contains KAR evaluations, and it is the same file knolo cortex verify would use. A trace is verified against --cite before any write. A failed check writes nothing. When --cite is set, the image stores a digest-bound composition record for that image and does not copy its bytes. When --graph is set, the checked graph is stored. The command does not call a model and does not download an image. A packed trace is an integrity check. It does not mean a claim is proven. SATISFIED means the trace evidence requirements were met.',
|
|
229
232
|
flight: 'Usage: knolo flight <ingest|verify-log> [options]\n\n knolo flight ingest --events <events.json> --log <file> --out <image.knolo> [--json]\n knolo flight verify-log --image <image.knolo> --log <file> [--json]\n\ningest packs a flight-events-1 document into a V5 Knowledge Image. It hashes --log and writes nothing when the hash or byte length differs. verify-log hashes --log again and compares it with the flight-log object. It writes nothing. A missing flight-log object fails closed. Neither command decodes the log. log.format is ulog, dataflash, or rosbag2. A later KAR status of SATISFIED means evidence requirements were met. It does not mean a flight was safe, legal, or compliant.',
|
|
@@ -1938,6 +1941,10 @@ async function main() {
|
|
|
1938
1941
|
const { runCortexCli } = await import('./cortex.mjs');
|
|
1939
1942
|
return await runCortexCli(commandArgs);
|
|
1940
1943
|
}
|
|
1944
|
+
if (command === 'kite') {
|
|
1945
|
+
const { runKiteCli } = await import('./kite.mjs');
|
|
1946
|
+
return await runKiteCli(commandArgs);
|
|
1947
|
+
}
|
|
1941
1948
|
if (command === 'flight') {
|
|
1942
1949
|
const { runFlightCli } = await import('./flight.mjs');
|
|
1943
1950
|
return await runFlightCli(commandArgs);
|