@mytegroupinc/myte-core 0.0.33 → 0.0.34
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/mytecody-cli.js +64 -20
- package/package.json +1 -1
package/mytecody-cli.js
CHANGED
|
@@ -179,6 +179,29 @@ function installedClientCommand() {
|
|
|
179
179
|
return { cmd: enginePath, args: [], source: "myte-installed-engine" };
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
function installedClientMatchesManifest(manifest, artifact) {
|
|
183
|
+
const current = readCurrentClientManifest();
|
|
184
|
+
if (!current || !installedClientCommand()) return false;
|
|
185
|
+
if (manifest && manifest.version && current.version !== manifest.version) return false;
|
|
186
|
+
|
|
187
|
+
const currentArtifact = current.artifact || {};
|
|
188
|
+
if (artifact && artifact.sha256) {
|
|
189
|
+
if (String(currentArtifact.sha256 || "").toLowerCase() !== String(artifact.sha256 || "").toLowerCase()) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const expectedInstalledSha =
|
|
195
|
+
artifact && (artifact.installed_sha256 || artifact.executable_sha256 || artifact.uncompressed_sha256);
|
|
196
|
+
if (expectedInstalledSha) {
|
|
197
|
+
if (String(currentArtifact.installed_sha256 || "").toLowerCase() !== String(expectedInstalledSha).toLowerCase()) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
|
|
182
205
|
function printHelp() {
|
|
183
206
|
console.log(`MYTE CODY - Your Tech Your Way
|
|
184
207
|
|
|
@@ -681,23 +704,25 @@ async function runCodex(rawArgs, args = {}, envPath = null) {
|
|
|
681
704
|
return 1;
|
|
682
705
|
}
|
|
683
706
|
writeCodexConfig(args);
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
console.error(
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
console.error(`MyteCody engine installed: ${install.payload.installed.version}`);
|
|
691
|
-
}
|
|
692
|
-
} catch (error) {
|
|
693
|
-
console.error(`MyteCody engine auto-install failed: ${error && error.message ? error.message : error}`);
|
|
694
|
-
}
|
|
695
|
-
command = resolveCodexCommand();
|
|
696
|
-
if (!command) {
|
|
697
|
-
console.error("MyteCody branded engine is not installed.");
|
|
707
|
+
try {
|
|
708
|
+
const install = await ensureBrandedEngineInstalled(args, envPath);
|
|
709
|
+
if (install.ok && install.installed) {
|
|
710
|
+
console.error(`MyteCody engine installed: ${install.payload.installed.version}`);
|
|
711
|
+
} else if (!install.ok) {
|
|
712
|
+
console.error(`MyteCody branded engine could not be verified: ${install.reason || "unknown"}.`);
|
|
698
713
|
console.error("Run `mytecody update` with access to the Myte release manifest.");
|
|
699
714
|
return 1;
|
|
700
715
|
}
|
|
716
|
+
} catch (error) {
|
|
717
|
+
console.error(`MyteCody engine verification failed: ${error && error.message ? error.message : error}`);
|
|
718
|
+
return 1;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
const command = resolveCodexCommand();
|
|
722
|
+
if (!command) {
|
|
723
|
+
console.error("MyteCody branded engine is not installed.");
|
|
724
|
+
console.error("Run `mytecody update` with access to the Myte release manifest.");
|
|
725
|
+
return 1;
|
|
701
726
|
}
|
|
702
727
|
const launchArgs = [...command.args, ...codexLaunchArgs(rawArgs, args)];
|
|
703
728
|
const env = {
|
|
@@ -820,18 +845,36 @@ function autoInstallEnabled(args = {}) {
|
|
|
820
845
|
}
|
|
821
846
|
|
|
822
847
|
async function ensureBrandedEngineInstalled(args = {}, envPath = null) {
|
|
823
|
-
if (installedClientCommand()) {
|
|
824
|
-
return { ok: true, installed: false, reason: "already-installed" };
|
|
825
|
-
}
|
|
826
|
-
if (!autoInstallEnabled(args)) {
|
|
827
|
-
return { ok: false, installed: false, reason: "auto-install-disabled" };
|
|
828
|
-
}
|
|
829
848
|
const updateArgs = {
|
|
830
849
|
...args,
|
|
831
850
|
"fetch-manifest": true,
|
|
832
851
|
};
|
|
833
852
|
delete updateArgs["dry-run"];
|
|
834
853
|
delete updateArgs.json;
|
|
854
|
+
|
|
855
|
+
const source = manifestUrl(updateArgs);
|
|
856
|
+
const manifestResult = await readManifest(source, { fetchManifest: true });
|
|
857
|
+
const manifest = manifestResult.manifest;
|
|
858
|
+
if (!manifest) {
|
|
859
|
+
return { ok: false, installed: false, reason: "manifest-unavailable", manifest_status: manifestResult.status };
|
|
860
|
+
}
|
|
861
|
+
const signature = signatureAccepted(manifest, updateArgs);
|
|
862
|
+
if (!signature.ok) {
|
|
863
|
+
return { ok: false, installed: false, reason: "manifest-untrusted", signature: signature.signature };
|
|
864
|
+
}
|
|
865
|
+
const artifact = artifactForPlatform(manifest);
|
|
866
|
+
const artifactMetadata = validateArtifactMetadata(artifact);
|
|
867
|
+
if (!artifactMetadata.ok) {
|
|
868
|
+
return { ok: false, installed: false, reason: "artifact-metadata-invalid", artifact: artifactMetadata };
|
|
869
|
+
}
|
|
870
|
+
if (installedClientMatchesManifest(manifest, artifact)) {
|
|
871
|
+
return { ok: true, installed: false, reason: "already-current" };
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
if (!autoInstallEnabled(args)) {
|
|
875
|
+
return { ok: false, installed: false, reason: "update-required-auto-install-disabled" };
|
|
876
|
+
}
|
|
877
|
+
|
|
835
878
|
const payload = await buildUpdatePayload(updateArgs, envPath, { dryRun: false });
|
|
836
879
|
return {
|
|
837
880
|
ok: Boolean(payload.installed && payload.installed.ok),
|
|
@@ -907,6 +950,7 @@ module.exports = {
|
|
|
907
950
|
codexProviderArgs,
|
|
908
951
|
codyInferenceBase,
|
|
909
952
|
codyGatewayUrl,
|
|
953
|
+
currentClientManifestPath,
|
|
910
954
|
currentEnginePath,
|
|
911
955
|
ensureBrandedEngineInstalled,
|
|
912
956
|
gatewayRoot,
|