@knolo/cli 5.0.0 → 5.1.0
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/package.json +2 -2
- package/templates/icp-knowledge-canister/canisters/knolo-core-rust/Cargo.toml +1 -1
- package/templates/icp-knowledge-canister/canisters/knolo-core-rust/src/lib.rs +136 -0
- package/templates/icp-knowledge-canister/canisters/knolo-icp-canister/Cargo.lock +2 -2
- package/templates/icp-knowledge-canister/canisters/knolo-icp-canister/Cargo.toml +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knolo/cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"knolo": "bin/knolo.mjs"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "npm run build --prefix ../core && node --test test/cli.test.mjs"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@knolo/core": "^5.
|
|
34
|
+
"@knolo/core": "^5.1.0"
|
|
35
35
|
},
|
|
36
36
|
"private": false
|
|
37
37
|
}
|
|
@@ -578,6 +578,47 @@ pub struct KnowledgeImageVerification {
|
|
|
578
578
|
pub segments: Vec<KnowledgeImageSegment>,
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
+
#[derive(Debug, Clone, PartialEq)]
|
|
582
|
+
pub struct KnowledgeRuntimeDiagnosticsImageV1 {
|
|
583
|
+
pub state_root: String,
|
|
584
|
+
pub commit_digest: String,
|
|
585
|
+
pub sequence: u64,
|
|
586
|
+
pub object_count: usize,
|
|
587
|
+
pub event_count: usize,
|
|
588
|
+
pub segment_count: usize,
|
|
589
|
+
pub active_superblock: char,
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
#[derive(Debug, Clone, PartialEq)]
|
|
593
|
+
pub struct KnowledgeRuntimeDiagnosticsV1 {
|
|
594
|
+
pub version: u64,
|
|
595
|
+
pub valid: bool,
|
|
596
|
+
pub image: KnowledgeRuntimeDiagnosticsImageV1,
|
|
597
|
+
pub diagnostics_root: String,
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
#[derive(Debug, Clone, PartialEq)]
|
|
601
|
+
pub struct KnowledgeStudioCapabilitiesV1 {
|
|
602
|
+
pub inspect_image: bool,
|
|
603
|
+
pub verify_image: bool,
|
|
604
|
+
pub inspect_query_index: bool,
|
|
605
|
+
pub inspect_query_history: bool,
|
|
606
|
+
pub inspect_run: bool,
|
|
607
|
+
pub inspect_replay: bool,
|
|
608
|
+
pub mutate_image: bool,
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
#[derive(Debug, Clone, PartialEq)]
|
|
612
|
+
pub struct KnowledgeStudioManagementV1 {
|
|
613
|
+
pub version: u64,
|
|
614
|
+
pub surface: String,
|
|
615
|
+
pub valid: bool,
|
|
616
|
+
pub read_only: bool,
|
|
617
|
+
pub diagnostics: KnowledgeRuntimeDiagnosticsV1,
|
|
618
|
+
pub capabilities: KnowledgeStudioCapabilitiesV1,
|
|
619
|
+
pub management_root: String,
|
|
620
|
+
}
|
|
621
|
+
|
|
581
622
|
#[derive(Debug, Clone, PartialEq)]
|
|
582
623
|
pub struct MigrationMapping {
|
|
583
624
|
pub legacy_block_id: usize,
|
|
@@ -625,6 +666,101 @@ pub fn verify_knowledge_image(bytes: &[u8]) -> Result<KnowledgeImageVerification
|
|
|
625
666
|
inspect_knowledge_image(bytes)
|
|
626
667
|
}
|
|
627
668
|
|
|
669
|
+
pub fn inspect_knowledge_runtime_v5(bytes: &[u8]) -> Result<KnowledgeRuntimeDiagnosticsV1, KnoloError> {
|
|
670
|
+
let image = mount_knowledge_image(bytes)?;
|
|
671
|
+
let diagnostics = KnowledgeRuntimeDiagnosticsV1 {
|
|
672
|
+
version: 1,
|
|
673
|
+
valid: true,
|
|
674
|
+
image: KnowledgeRuntimeDiagnosticsImageV1 {
|
|
675
|
+
state_root: image.state_root,
|
|
676
|
+
commit_digest: image.commit_digest,
|
|
677
|
+
sequence: image.commit.sequence,
|
|
678
|
+
object_count: image.objects.len(),
|
|
679
|
+
event_count: image.events.len(),
|
|
680
|
+
segment_count: image.segments.len(),
|
|
681
|
+
active_superblock: image.active_superblock,
|
|
682
|
+
},
|
|
683
|
+
diagnostics_root: String::new(),
|
|
684
|
+
};
|
|
685
|
+
let diagnostics_root = runtime_diagnostics_root_v5(&diagnostics);
|
|
686
|
+
Ok(KnowledgeRuntimeDiagnosticsV1 { diagnostics_root, ..diagnostics })
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
pub fn runtime_diagnostics_root_v5(diagnostics: &KnowledgeRuntimeDiagnosticsV1) -> String {
|
|
690
|
+
digest_domain("runtime-diagnostics", &encode_cbor(&runtime_diagnostics_body(diagnostics)))
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
pub fn inspect_knowledge_studio_management_v5(bytes: &[u8]) -> Result<KnowledgeStudioManagementV1, KnoloError> {
|
|
694
|
+
let diagnostics = inspect_knowledge_runtime_v5(bytes)?;
|
|
695
|
+
let management = KnowledgeStudioManagementV1 {
|
|
696
|
+
version: 1,
|
|
697
|
+
surface: "studio-management".into(),
|
|
698
|
+
valid: true,
|
|
699
|
+
read_only: true,
|
|
700
|
+
diagnostics,
|
|
701
|
+
capabilities: KnowledgeStudioCapabilitiesV1 {
|
|
702
|
+
inspect_image: true,
|
|
703
|
+
verify_image: true,
|
|
704
|
+
inspect_query_index: false,
|
|
705
|
+
inspect_query_history: false,
|
|
706
|
+
inspect_run: false,
|
|
707
|
+
inspect_replay: false,
|
|
708
|
+
mutate_image: false,
|
|
709
|
+
},
|
|
710
|
+
management_root: String::new(),
|
|
711
|
+
};
|
|
712
|
+
let management_root = studio_management_root_v5(&management);
|
|
713
|
+
Ok(KnowledgeStudioManagementV1 { management_root, ..management })
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
pub fn studio_management_root_v5(management: &KnowledgeStudioManagementV1) -> String {
|
|
717
|
+
digest_domain("studio-management", &encode_cbor(&CborValue::Map(vec![
|
|
718
|
+
("capabilities".into(), studio_capabilities_value(&management.capabilities)),
|
|
719
|
+
("diagnostics".into(), runtime_diagnostics_value(&management.diagnostics)),
|
|
720
|
+
("readOnly".into(), CborValue::Bool(management.read_only)),
|
|
721
|
+
("surface".into(), CborValue::Text(management.surface.clone())),
|
|
722
|
+
("valid".into(), CborValue::Bool(management.valid)),
|
|
723
|
+
("version".into(), CborValue::UInt(management.version)),
|
|
724
|
+
])))
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
fn runtime_diagnostics_body(diagnostics: &KnowledgeRuntimeDiagnosticsV1) -> CborValue {
|
|
728
|
+
CborValue::Map(vec![
|
|
729
|
+
("image".into(), CborValue::Map(vec![
|
|
730
|
+
("activeSuperblock".into(), CborValue::Text(diagnostics.image.active_superblock.to_string())),
|
|
731
|
+
("commitDigest".into(), CborValue::Text(diagnostics.image.commit_digest.clone())),
|
|
732
|
+
("eventCount".into(), CborValue::UInt(diagnostics.image.event_count as u64)),
|
|
733
|
+
("objectCount".into(), CborValue::UInt(diagnostics.image.object_count as u64)),
|
|
734
|
+
("segmentCount".into(), CborValue::UInt(diagnostics.image.segment_count as u64)),
|
|
735
|
+
("sequence".into(), CborValue::UInt(diagnostics.image.sequence)),
|
|
736
|
+
("stateRoot".into(), CborValue::Text(diagnostics.image.state_root.clone())),
|
|
737
|
+
])),
|
|
738
|
+
("valid".into(), CborValue::Bool(diagnostics.valid)),
|
|
739
|
+
("version".into(), CborValue::UInt(diagnostics.version)),
|
|
740
|
+
])
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
fn runtime_diagnostics_value(diagnostics: &KnowledgeRuntimeDiagnosticsV1) -> CborValue {
|
|
744
|
+
let mut entries = match runtime_diagnostics_body(diagnostics) {
|
|
745
|
+
CborValue::Map(entries) => entries,
|
|
746
|
+
_ => Vec::new(),
|
|
747
|
+
};
|
|
748
|
+
entries.push(("diagnosticsRoot".into(), CborValue::Text(diagnostics.diagnostics_root.clone())));
|
|
749
|
+
CborValue::Map(entries)
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
fn studio_capabilities_value(capabilities: &KnowledgeStudioCapabilitiesV1) -> CborValue {
|
|
753
|
+
CborValue::Map(vec![
|
|
754
|
+
("inspectImage".into(), CborValue::Bool(capabilities.inspect_image)),
|
|
755
|
+
("inspectQueryHistory".into(), CborValue::Bool(capabilities.inspect_query_history)),
|
|
756
|
+
("inspectQueryIndex".into(), CborValue::Bool(capabilities.inspect_query_index)),
|
|
757
|
+
("inspectReplay".into(), CborValue::Bool(capabilities.inspect_replay)),
|
|
758
|
+
("inspectRun".into(), CborValue::Bool(capabilities.inspect_run)),
|
|
759
|
+
("mutateImage".into(), CborValue::Bool(capabilities.mutate_image)),
|
|
760
|
+
("verifyImage".into(), CborValue::Bool(capabilities.verify_image)),
|
|
761
|
+
])
|
|
762
|
+
}
|
|
763
|
+
|
|
628
764
|
pub fn state_root(image: &KnowledgeImage) -> &str {
|
|
629
765
|
&image.state_root
|
|
630
766
|
}
|
|
@@ -245,11 +245,11 @@ dependencies = [
|
|
|
245
245
|
|
|
246
246
|
[[package]]
|
|
247
247
|
name = "knolo-core-rust"
|
|
248
|
-
version = "5.
|
|
248
|
+
version = "5.1.0"
|
|
249
249
|
|
|
250
250
|
[[package]]
|
|
251
251
|
name = "knolo-icp-canister"
|
|
252
|
-
version = "5.
|
|
252
|
+
version = "5.1.0"
|
|
253
253
|
dependencies = [
|
|
254
254
|
"candid",
|
|
255
255
|
"ic-cdk",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "knolo-icp-canister"
|
|
3
|
-
version = "5.
|
|
3
|
+
version = "5.1.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
description = "ICP canister adapter for Knolo retrieval over Candid"
|
|
@@ -16,5 +16,5 @@ path = "src/lib.rs"
|
|
|
16
16
|
candid = "0.10"
|
|
17
17
|
ic-cdk = "0.17"
|
|
18
18
|
ic-cdk-macros = "0.17"
|
|
19
|
-
knolo-core-rust = { path = "../knolo-core-rust", version = "5.
|
|
19
|
+
knolo-core-rust = { path = "../knolo-core-rust", version = "5.1.0" }
|
|
20
20
|
serde = { version = "1", features = ["derive"] }
|