@bonginkan/maria 4.2.5 → 4.2.6
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/dist/bin/maria.cjs +183 -25
- package/dist/bin/maria.cjs.map +1 -1
- package/dist/cli.cjs +181 -25
- package/dist/cli.cjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -8,6 +8,7 @@ var chalk17 = require('chalk');
|
|
|
8
8
|
var os = require('os');
|
|
9
9
|
var fsp = require('fs/promises');
|
|
10
10
|
var crypto2 = require('crypto');
|
|
11
|
+
var secretManager = require('@google-cloud/secret-manager');
|
|
11
12
|
var http = require('http');
|
|
12
13
|
var url = require('url');
|
|
13
14
|
var open = require('open');
|
|
@@ -18,7 +19,6 @@ var buffer = require('buffer');
|
|
|
18
19
|
var net = require('net');
|
|
19
20
|
var https = require('https');
|
|
20
21
|
var zlib = require('zlib');
|
|
21
|
-
var secretManager = require('@google-cloud/secret-manager');
|
|
22
22
|
var readline = require('readline');
|
|
23
23
|
var zod = require('zod');
|
|
24
24
|
require('strip-ansi');
|
|
@@ -685,37 +685,195 @@ var init_TokenStorage = __esm({
|
|
|
685
685
|
};
|
|
686
686
|
}
|
|
687
687
|
});
|
|
688
|
+
var AuthSecretManager;
|
|
689
|
+
var init_AuthSecretManager = __esm({
|
|
690
|
+
"src/services/cli-auth/AuthSecretManager.ts"() {
|
|
691
|
+
AuthSecretManager = class {
|
|
692
|
+
client;
|
|
693
|
+
cache = /* @__PURE__ */ new Map();
|
|
694
|
+
cacheExpiry = /* @__PURE__ */ new Map();
|
|
695
|
+
CACHE_TTL = 36e5;
|
|
696
|
+
// 1 hour
|
|
697
|
+
projectId;
|
|
698
|
+
constructor() {
|
|
699
|
+
this.projectId = process.env.GCLOUD_PROJECT || "maria-code-470602";
|
|
700
|
+
this.client = new secretManager.SecretManagerServiceClient();
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Get authentication configuration from Secret Manager
|
|
704
|
+
*/
|
|
705
|
+
async getAuthConfig() {
|
|
706
|
+
const [authBase, apiBase, clientId] = await Promise.all([
|
|
707
|
+
this.getSecret("maria-auth-server-url").catch(() => null),
|
|
708
|
+
this.getSecret("maria-api-server-url").catch(() => null),
|
|
709
|
+
this.getSecret("maria-cli-client-id").catch(() => null)
|
|
710
|
+
]);
|
|
711
|
+
return {
|
|
712
|
+
authBase: authBase || this.getAuthBaseUrlFallback(),
|
|
713
|
+
apiBase: apiBase || this.getApiBaseUrlFallback(),
|
|
714
|
+
clientId: clientId || process.env.MARIA_CLIENT_ID || "maria-cli"
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Get a specific secret from Secret Manager
|
|
719
|
+
*/
|
|
720
|
+
async getSecret(secretName) {
|
|
721
|
+
const cached = this.getCachedSecret(secretName);
|
|
722
|
+
if (cached) {
|
|
723
|
+
return cached;
|
|
724
|
+
}
|
|
725
|
+
try {
|
|
726
|
+
const name2 = `projects/${this.projectId}/secrets/${secretName}/versions/latest`;
|
|
727
|
+
const [version] = await this.client.accessSecretVersion({ name: name2 });
|
|
728
|
+
const payload = version.payload?.data;
|
|
729
|
+
if (!payload) {
|
|
730
|
+
return null;
|
|
731
|
+
}
|
|
732
|
+
const secret = payload.toString();
|
|
733
|
+
this.cacheSecret(secretName, secret);
|
|
734
|
+
return secret;
|
|
735
|
+
} catch (error2) {
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Get all OAuth configuration secrets
|
|
741
|
+
*/
|
|
742
|
+
async getOAuthSecrets() {
|
|
743
|
+
const secretNames = [
|
|
744
|
+
"google-client-id",
|
|
745
|
+
"google-client-secret",
|
|
746
|
+
"github-client-id",
|
|
747
|
+
"github-client-secret",
|
|
748
|
+
"nextauth-secret",
|
|
749
|
+
"firebase-project-id",
|
|
750
|
+
"session-keys"
|
|
751
|
+
];
|
|
752
|
+
const results = await Promise.allSettled(
|
|
753
|
+
secretNames.map((name2) => this.getSecret(name2))
|
|
754
|
+
);
|
|
755
|
+
return {
|
|
756
|
+
googleClientId: results[0].status === "fulfilled" ? results[0].value || void 0 : void 0,
|
|
757
|
+
googleClientSecret: results[1].status === "fulfilled" ? results[1].value || void 0 : void 0,
|
|
758
|
+
githubClientId: results[2].status === "fulfilled" ? results[2].value || void 0 : void 0,
|
|
759
|
+
githubClientSecret: results[3].status === "fulfilled" ? results[3].value || void 0 : void 0,
|
|
760
|
+
nextAuthSecret: results[4].status === "fulfilled" ? results[4].value || void 0 : void 0,
|
|
761
|
+
firebaseProjectId: results[5].status === "fulfilled" ? results[5].value || void 0 : void 0,
|
|
762
|
+
sessionKeys: results[6].status === "fulfilled" ? results[6].value || void 0 : void 0
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Cache a secret value
|
|
767
|
+
*/
|
|
768
|
+
cacheSecret(name2, value) {
|
|
769
|
+
this.cache.set(name2, value);
|
|
770
|
+
this.cacheExpiry.set(name2, Date.now() + this.CACHE_TTL);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Get cached secret if not expired
|
|
774
|
+
*/
|
|
775
|
+
getCachedSecret(name2) {
|
|
776
|
+
const expiry = this.cacheExpiry.get(name2);
|
|
777
|
+
if (!expiry || Date.now() > expiry) {
|
|
778
|
+
this.cache.delete(name2);
|
|
779
|
+
this.cacheExpiry.delete(name2);
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
return this.cache.get(name2) || null;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Clear all cached secrets
|
|
786
|
+
*/
|
|
787
|
+
clearCache() {
|
|
788
|
+
this.cache.clear();
|
|
789
|
+
this.cacheExpiry.clear();
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Fallback for auth base URL
|
|
793
|
+
*/
|
|
794
|
+
getAuthBaseUrlFallback() {
|
|
795
|
+
if (process.env.MARIA_AUTH_MODE === "local") {
|
|
796
|
+
return "http://localhost:3001";
|
|
797
|
+
}
|
|
798
|
+
if (process.env.MARIA_AUTH_BASE) {
|
|
799
|
+
return process.env.MARIA_AUTH_BASE;
|
|
800
|
+
}
|
|
801
|
+
const cloudRunUrl = "https://auth-server-i227ftjidq-uc.a.run.app";
|
|
802
|
+
return cloudRunUrl;
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Fallback for API base URL
|
|
806
|
+
*/
|
|
807
|
+
getApiBaseUrlFallback() {
|
|
808
|
+
if (process.env.MARIA_AUTH_MODE === "local") {
|
|
809
|
+
return "http://localhost:3000/api";
|
|
810
|
+
}
|
|
811
|
+
if (process.env.MARIA_API_BASE) {
|
|
812
|
+
return process.env.MARIA_API_BASE;
|
|
813
|
+
}
|
|
814
|
+
const cloudRunApiUrl = "https://maria-code-i227ftjidq-uc.a.run.app";
|
|
815
|
+
return cloudRunApiUrl;
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
new AuthSecretManager();
|
|
819
|
+
}
|
|
820
|
+
});
|
|
688
821
|
var AuthenticationManager, authManager;
|
|
689
822
|
var init_AuthenticationManager = __esm({
|
|
690
823
|
"src/services/cli-auth/AuthenticationManager.ts"() {
|
|
691
824
|
init_types();
|
|
692
825
|
init_TokenStorage();
|
|
826
|
+
init_AuthSecretManager();
|
|
693
827
|
AuthenticationManager = class {
|
|
694
828
|
tokenStorage;
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
829
|
+
secretManager;
|
|
830
|
+
authBase = "";
|
|
831
|
+
apiBase = "";
|
|
832
|
+
clientId = "";
|
|
833
|
+
initialized = false;
|
|
834
|
+
initPromise = null;
|
|
698
835
|
REFRESH_THRESHOLD = 5 * 60 * 1e3;
|
|
699
836
|
// 5 minutes
|
|
700
837
|
CLOCK_SKEW = 2 * 60 * 1e3;
|
|
701
838
|
// 2 minutes clock skew tolerance
|
|
702
839
|
constructor() {
|
|
703
840
|
this.tokenStorage = new TokenStorage();
|
|
704
|
-
this.
|
|
705
|
-
this.
|
|
706
|
-
|
|
841
|
+
this.secretManager = new AuthSecretManager();
|
|
842
|
+
this.initPromise = this.initialize();
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Initialize configuration from Secret Manager
|
|
846
|
+
*/
|
|
847
|
+
async initialize() {
|
|
848
|
+
try {
|
|
849
|
+
const config2 = await this.secretManager.getAuthConfig();
|
|
850
|
+
this.authBase = config2.authBase;
|
|
851
|
+
this.apiBase = config2.apiBase;
|
|
852
|
+
this.clientId = config2.clientId;
|
|
853
|
+
this.initialized = true;
|
|
854
|
+
} catch (error2) {
|
|
855
|
+
this.authBase = this.getAuthBaseUrl();
|
|
856
|
+
this.apiBase = this.getApiBaseUrl();
|
|
857
|
+
this.clientId = process.env.MARIA_CLIENT_ID || "maria-cli";
|
|
858
|
+
this.initialized = true;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Ensure the manager is initialized before use
|
|
863
|
+
*/
|
|
864
|
+
async ensureInitialized() {
|
|
865
|
+
if (!this.initialized && this.initPromise) {
|
|
866
|
+
await this.initPromise;
|
|
867
|
+
}
|
|
707
868
|
}
|
|
708
869
|
getAuthBaseUrl() {
|
|
709
870
|
if (process.env.MARIA_AUTH_MODE === "local") {
|
|
710
|
-
console.debug("Using local auth server (development mode)");
|
|
711
871
|
return "http://localhost:3001";
|
|
712
872
|
}
|
|
713
873
|
const cloudRunUrl = "https://auth-server-i227ftjidq-uc.a.run.app";
|
|
714
874
|
if (process.env.MARIA_USE_CUSTOM_DOMAIN === "true") {
|
|
715
|
-
console.debug("Attempting to use custom domain auth.maria-code.ai");
|
|
716
875
|
return "https://auth.maria-code.ai";
|
|
717
876
|
}
|
|
718
|
-
console.debug("Using Cloud Run URL for auth:", cloudRunUrl);
|
|
719
877
|
return cloudRunUrl;
|
|
720
878
|
}
|
|
721
879
|
getApiBaseUrl() {
|
|
@@ -732,6 +890,7 @@ var init_AuthenticationManager = __esm({
|
|
|
732
890
|
* Check if user is authenticated
|
|
733
891
|
*/
|
|
734
892
|
async isAuthenticated() {
|
|
893
|
+
await this.ensureInitialized();
|
|
735
894
|
try {
|
|
736
895
|
const tokens = await this.tokenStorage.load();
|
|
737
896
|
if (!tokens) return false;
|
|
@@ -747,6 +906,7 @@ var init_AuthenticationManager = __esm({
|
|
|
747
906
|
* Require authenticated user (throws if not authenticated)
|
|
748
907
|
*/
|
|
749
908
|
async requireUser() {
|
|
909
|
+
await this.ensureInitialized();
|
|
750
910
|
if (!await this.isAuthenticated()) {
|
|
751
911
|
throw new AuthenticationRequiredError(ERROR_MESSAGES.AUTH_REQUIRED);
|
|
752
912
|
}
|
|
@@ -756,6 +916,7 @@ var init_AuthenticationManager = __esm({
|
|
|
756
916
|
* Get current authenticated user
|
|
757
917
|
*/
|
|
758
918
|
async getCurrentUser() {
|
|
919
|
+
await this.ensureInitialized();
|
|
759
920
|
if (process.env.MARIA_AUTH_MODE === "local") {
|
|
760
921
|
const tokens2 = await this.tokenStorage.load();
|
|
761
922
|
if (!tokens2) {
|
|
@@ -765,16 +926,14 @@ var init_AuthenticationManager = __esm({
|
|
|
765
926
|
id: "local-dev-user",
|
|
766
927
|
email: "developer@localhost",
|
|
767
928
|
name: "Local Developer",
|
|
768
|
-
plan: "
|
|
929
|
+
plan: "ULTRA",
|
|
769
930
|
usage: {
|
|
770
931
|
requests: Math.floor(Math.random() * 100),
|
|
771
932
|
// Random usage for testing
|
|
772
933
|
requestLimit: 999999,
|
|
773
|
-
requestsRemaining: 999999,
|
|
774
934
|
resetAt: Date.now() + 30 * 24 * 60 * 60 * 1e3
|
|
775
935
|
},
|
|
776
|
-
|
|
777
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
936
|
+
models: []
|
|
778
937
|
};
|
|
779
938
|
}
|
|
780
939
|
const tokens = await this.getValidTokens();
|
|
@@ -797,7 +956,8 @@ var init_AuthenticationManager = __esm({
|
|
|
797
956
|
if (!response2.ok) {
|
|
798
957
|
throw new Error(`Failed to fetch user profile: ${response2.statusText}`);
|
|
799
958
|
}
|
|
800
|
-
|
|
959
|
+
const userData = await response2.json();
|
|
960
|
+
return userData;
|
|
801
961
|
} catch (error2) {
|
|
802
962
|
if (error2 instanceof AuthenticationRequiredError || error2 instanceof QuotaExceededError) {
|
|
803
963
|
throw error2;
|
|
@@ -809,6 +969,7 @@ var init_AuthenticationManager = __esm({
|
|
|
809
969
|
* Login with OAuth2 PKCE flow
|
|
810
970
|
*/
|
|
811
971
|
async login(options = {}) {
|
|
972
|
+
await this.ensureInitialized();
|
|
812
973
|
try {
|
|
813
974
|
if (await this.isAuthenticated() && !options.force) {
|
|
814
975
|
const user2 = await this.getCurrentUser();
|
|
@@ -868,16 +1029,14 @@ var init_AuthenticationManager = __esm({
|
|
|
868
1029
|
id: "local-dev-user",
|
|
869
1030
|
email: "developer@localhost",
|
|
870
1031
|
name: "Local Developer",
|
|
871
|
-
plan: "
|
|
1032
|
+
plan: "ULTRA",
|
|
872
1033
|
// Give full access in dev mode
|
|
873
1034
|
usage: {
|
|
874
1035
|
requests: 0,
|
|
875
1036
|
requestLimit: 999999,
|
|
876
|
-
requestsRemaining: 999999,
|
|
877
1037
|
resetAt: Date.now() + 30 * 24 * 60 * 60 * 1e3
|
|
878
1038
|
},
|
|
879
|
-
|
|
880
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1039
|
+
models: []
|
|
881
1040
|
};
|
|
882
1041
|
console.log("\u2705 Logged in as developer@localhost (Local Mode)");
|
|
883
1042
|
console.log(" Plan: Ultra (Development)");
|
|
@@ -892,6 +1051,7 @@ var init_AuthenticationManager = __esm({
|
|
|
892
1051
|
* Logout and clean up
|
|
893
1052
|
*/
|
|
894
1053
|
async logout(options = {}) {
|
|
1054
|
+
await this.ensureInitialized();
|
|
895
1055
|
try {
|
|
896
1056
|
const tokens = await this.tokenStorage.load();
|
|
897
1057
|
if (tokens && !options.force) {
|
|
@@ -913,6 +1073,7 @@ var init_AuthenticationManager = __esm({
|
|
|
913
1073
|
* Refresh authentication token
|
|
914
1074
|
*/
|
|
915
1075
|
async refreshToken() {
|
|
1076
|
+
await this.ensureInitialized();
|
|
916
1077
|
try {
|
|
917
1078
|
const tokens = await this.tokenStorage.load();
|
|
918
1079
|
if (!tokens?.refreshToken) return false;
|
|
@@ -9310,16 +9471,12 @@ var init_SecretManagerIntegration = __esm({
|
|
|
9310
9471
|
const [version] = await this.client.accessSecretVersion({ name: name2 });
|
|
9311
9472
|
const payload = version.payload?.data;
|
|
9312
9473
|
if (!payload) {
|
|
9313
|
-
console.error(`Secret ${secretName} has no payload`);
|
|
9314
9474
|
return void 0;
|
|
9315
9475
|
}
|
|
9316
9476
|
const secret = payload.toString();
|
|
9317
9477
|
this.cacheSecret(secretName, secret);
|
|
9318
9478
|
return secret;
|
|
9319
9479
|
} catch (error2) {
|
|
9320
|
-
if (error2.code !== 5) {
|
|
9321
|
-
console.error(`Failed to access secret ${secretName}:`, error2);
|
|
9322
|
-
}
|
|
9323
9480
|
return this.getFallbackFromEnv(provider);
|
|
9324
9481
|
}
|
|
9325
9482
|
}
|
|
@@ -9402,7 +9559,6 @@ var init_SecretManagerIntegration = __esm({
|
|
|
9402
9559
|
this.cacheExpiry.delete(secretName);
|
|
9403
9560
|
return true;
|
|
9404
9561
|
} catch (error2) {
|
|
9405
|
-
console.error(`Failed to create/update secret ${secretName}:`, error2);
|
|
9406
9562
|
return false;
|
|
9407
9563
|
}
|
|
9408
9564
|
}
|
|
@@ -32354,7 +32510,7 @@ var init_package = __esm({
|
|
|
32354
32510
|
"package.json"() {
|
|
32355
32511
|
package_default = {
|
|
32356
32512
|
name: "@bonginkan/maria",
|
|
32357
|
-
version: "4.2.
|
|
32513
|
+
version: "4.2.6",
|
|
32358
32514
|
description: "\u{1F680} MARIA v4.2.0 - Enterprise AI Development Platform with 100% Command Availability. Features 74 production-ready commands with comprehensive fallback implementation, local LLM support, and zero external dependencies. Includes natural language coding, AI safety evaluation, intelligent evolution system, episodic memory with PII masking, and real-time monitoring dashboard. Built with TypeScript AST-powered code generation, OAuth2.0 + PKCE authentication, quantum-resistant cryptography, and enterprise-grade performance.",
|
|
32359
32515
|
keywords: [
|
|
32360
32516
|
"ai",
|