@bonginkan/maria 4.2.0 → 4.2.2
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 +67 -13
- package/dist/bin/maria.cjs +222 -7
- package/dist/bin/maria.cjs.map +1 -1
- package/dist/cli.cjs +222 -7
- package/dist/cli.cjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -18,6 +18,7 @@ var buffer = require('buffer');
|
|
|
18
18
|
var net = require('net');
|
|
19
19
|
var https = require('https');
|
|
20
20
|
var zlib = require('zlib');
|
|
21
|
+
var secretManager = require('@google-cloud/secret-manager');
|
|
21
22
|
var readline = require('readline');
|
|
22
23
|
var zod = require('zod');
|
|
23
24
|
require('strip-ansi');
|
|
@@ -9181,6 +9182,201 @@ var init_base_provider = __esm({
|
|
|
9181
9182
|
}
|
|
9182
9183
|
});
|
|
9183
9184
|
|
|
9185
|
+
// src/services/intelligent-model-selector/SecretManagerIntegration.ts
|
|
9186
|
+
var SecretManagerIntegration_exports = {};
|
|
9187
|
+
__export(SecretManagerIntegration_exports, {
|
|
9188
|
+
SecretManagerIntegration: () => SecretManagerIntegration
|
|
9189
|
+
});
|
|
9190
|
+
var SecretManagerIntegration;
|
|
9191
|
+
var init_SecretManagerIntegration = __esm({
|
|
9192
|
+
"src/services/intelligent-model-selector/SecretManagerIntegration.ts"() {
|
|
9193
|
+
SecretManagerIntegration = class {
|
|
9194
|
+
// 1 hour
|
|
9195
|
+
constructor(config2) {
|
|
9196
|
+
this.config = config2;
|
|
9197
|
+
this.client = new secretManager.SecretManagerServiceClient();
|
|
9198
|
+
}
|
|
9199
|
+
client;
|
|
9200
|
+
cache = /* @__PURE__ */ new Map();
|
|
9201
|
+
cacheExpiry = /* @__PURE__ */ new Map();
|
|
9202
|
+
CACHE_TTL = 36e5;
|
|
9203
|
+
/**
|
|
9204
|
+
* Get API key from Secret Manager with caching
|
|
9205
|
+
*/
|
|
9206
|
+
async getApiKey(provider) {
|
|
9207
|
+
const secretName = this.getSecretName(provider);
|
|
9208
|
+
if (!secretName) {
|
|
9209
|
+
return void 0;
|
|
9210
|
+
}
|
|
9211
|
+
const cached = this.getCachedSecret(secretName);
|
|
9212
|
+
if (cached) {
|
|
9213
|
+
return cached;
|
|
9214
|
+
}
|
|
9215
|
+
try {
|
|
9216
|
+
const name2 = `projects/${this.config.projectId}/secrets/${secretName}/versions/latest`;
|
|
9217
|
+
const [version] = await this.client.accessSecretVersion({ name: name2 });
|
|
9218
|
+
const payload = version.payload?.data;
|
|
9219
|
+
if (!payload) {
|
|
9220
|
+
console.error(`Secret ${secretName} has no payload`);
|
|
9221
|
+
return void 0;
|
|
9222
|
+
}
|
|
9223
|
+
const secret = payload.toString();
|
|
9224
|
+
this.cacheSecret(secretName, secret);
|
|
9225
|
+
return secret;
|
|
9226
|
+
} catch (error2) {
|
|
9227
|
+
if (error2.code !== 5) {
|
|
9228
|
+
console.error(`Failed to access secret ${secretName}:`, error2);
|
|
9229
|
+
}
|
|
9230
|
+
return this.getFallbackFromEnv(provider);
|
|
9231
|
+
}
|
|
9232
|
+
}
|
|
9233
|
+
/**
|
|
9234
|
+
* Get all API keys
|
|
9235
|
+
*/
|
|
9236
|
+
async getAllApiKeys() {
|
|
9237
|
+
const [googleApiKey, openaiApiKey, anthropicApiKey, groqApiKey] = await Promise.all([
|
|
9238
|
+
this.getApiKey("google"),
|
|
9239
|
+
this.getApiKey("openai"),
|
|
9240
|
+
this.getApiKey("anthropic"),
|
|
9241
|
+
this.getApiKey("groq")
|
|
9242
|
+
]);
|
|
9243
|
+
return {
|
|
9244
|
+
googleApiKey,
|
|
9245
|
+
openaiApiKey,
|
|
9246
|
+
anthropicApiKey,
|
|
9247
|
+
groqApiKey
|
|
9248
|
+
};
|
|
9249
|
+
}
|
|
9250
|
+
/**
|
|
9251
|
+
* Verify that required secrets exist
|
|
9252
|
+
*/
|
|
9253
|
+
async verifySecrets() {
|
|
9254
|
+
const available = [];
|
|
9255
|
+
const missing = [];
|
|
9256
|
+
const providers = ["google", "openai", "anthropic", "groq"];
|
|
9257
|
+
for (const provider of providers) {
|
|
9258
|
+
const secretName = this.getSecretName(provider);
|
|
9259
|
+
if (!secretName) continue;
|
|
9260
|
+
try {
|
|
9261
|
+
const name2 = `projects/${this.config.projectId}/secrets/${secretName}`;
|
|
9262
|
+
await this.client.getSecret({ name: name2 });
|
|
9263
|
+
available.push(provider);
|
|
9264
|
+
} catch (error2) {
|
|
9265
|
+
missing.push(provider);
|
|
9266
|
+
}
|
|
9267
|
+
}
|
|
9268
|
+
return { available, missing };
|
|
9269
|
+
}
|
|
9270
|
+
/**
|
|
9271
|
+
* Create or update a secret
|
|
9272
|
+
*/
|
|
9273
|
+
async createOrUpdateSecret(provider, apiKey) {
|
|
9274
|
+
const secretName = this.getSecretName(provider);
|
|
9275
|
+
if (!secretName) {
|
|
9276
|
+
return false;
|
|
9277
|
+
}
|
|
9278
|
+
const secretId = `projects/${this.config.projectId}/secrets/${secretName}`;
|
|
9279
|
+
try {
|
|
9280
|
+
let secretExists = false;
|
|
9281
|
+
try {
|
|
9282
|
+
await this.client.getSecret({ name: secretId });
|
|
9283
|
+
secretExists = true;
|
|
9284
|
+
} catch {
|
|
9285
|
+
secretExists = false;
|
|
9286
|
+
}
|
|
9287
|
+
if (!secretExists) {
|
|
9288
|
+
await this.client.createSecret({
|
|
9289
|
+
parent: `projects/${this.config.projectId}`,
|
|
9290
|
+
secretId: secretName,
|
|
9291
|
+
secret: {
|
|
9292
|
+
replication: {
|
|
9293
|
+
automatic: {}
|
|
9294
|
+
},
|
|
9295
|
+
labels: {
|
|
9296
|
+
service: "ims",
|
|
9297
|
+
provider
|
|
9298
|
+
}
|
|
9299
|
+
}
|
|
9300
|
+
});
|
|
9301
|
+
}
|
|
9302
|
+
await this.client.addSecretVersion({
|
|
9303
|
+
parent: secretId,
|
|
9304
|
+
payload: {
|
|
9305
|
+
data: Buffer.from(apiKey, "utf8")
|
|
9306
|
+
}
|
|
9307
|
+
});
|
|
9308
|
+
this.cache.delete(secretName);
|
|
9309
|
+
this.cacheExpiry.delete(secretName);
|
|
9310
|
+
return true;
|
|
9311
|
+
} catch (error2) {
|
|
9312
|
+
console.error(`Failed to create/update secret ${secretName}:`, error2);
|
|
9313
|
+
return false;
|
|
9314
|
+
}
|
|
9315
|
+
}
|
|
9316
|
+
/**
|
|
9317
|
+
* Get secret name for provider
|
|
9318
|
+
*/
|
|
9319
|
+
getSecretName(provider) {
|
|
9320
|
+
switch (provider) {
|
|
9321
|
+
case "google":
|
|
9322
|
+
return this.config.secrets.googleAI || "google-ai-api-key";
|
|
9323
|
+
case "openai":
|
|
9324
|
+
return this.config.secrets.openAI || "openai-api-key";
|
|
9325
|
+
case "anthropic":
|
|
9326
|
+
return this.config.secrets.anthropic || "anthropic-api-key";
|
|
9327
|
+
case "groq":
|
|
9328
|
+
return this.config.secrets.groq || "groq-api-key";
|
|
9329
|
+
default:
|
|
9330
|
+
return void 0;
|
|
9331
|
+
}
|
|
9332
|
+
}
|
|
9333
|
+
/**
|
|
9334
|
+
* Get cached secret if valid
|
|
9335
|
+
*/
|
|
9336
|
+
getCachedSecret(secretName) {
|
|
9337
|
+
const expiry = this.cacheExpiry.get(secretName);
|
|
9338
|
+
if (!expiry || Date.now() > expiry) {
|
|
9339
|
+
this.cache.delete(secretName);
|
|
9340
|
+
this.cacheExpiry.delete(secretName);
|
|
9341
|
+
return void 0;
|
|
9342
|
+
}
|
|
9343
|
+
return this.cache.get(secretName);
|
|
9344
|
+
}
|
|
9345
|
+
/**
|
|
9346
|
+
* Cache a secret
|
|
9347
|
+
*/
|
|
9348
|
+
cacheSecret(secretName, value) {
|
|
9349
|
+
this.cache.set(secretName, value);
|
|
9350
|
+
this.cacheExpiry.set(secretName, Date.now() + this.CACHE_TTL);
|
|
9351
|
+
}
|
|
9352
|
+
/**
|
|
9353
|
+
* Get fallback from environment variable
|
|
9354
|
+
*/
|
|
9355
|
+
getFallbackFromEnv(provider) {
|
|
9356
|
+
switch (provider) {
|
|
9357
|
+
case "google":
|
|
9358
|
+
return process.env.GOOGLE_AI_API_KEY;
|
|
9359
|
+
case "openai":
|
|
9360
|
+
return process.env.OPENAI_API_KEY;
|
|
9361
|
+
case "anthropic":
|
|
9362
|
+
return process.env.ANTHROPIC_API_KEY;
|
|
9363
|
+
case "groq":
|
|
9364
|
+
return process.env.GROQ_API_KEY;
|
|
9365
|
+
default:
|
|
9366
|
+
return void 0;
|
|
9367
|
+
}
|
|
9368
|
+
}
|
|
9369
|
+
/**
|
|
9370
|
+
* Clear cache
|
|
9371
|
+
*/
|
|
9372
|
+
clearCache() {
|
|
9373
|
+
this.cache.clear();
|
|
9374
|
+
this.cacheExpiry.clear();
|
|
9375
|
+
}
|
|
9376
|
+
};
|
|
9377
|
+
}
|
|
9378
|
+
});
|
|
9379
|
+
|
|
9184
9380
|
// src/providers/groq-provider.ts
|
|
9185
9381
|
var groq_provider_exports = {};
|
|
9186
9382
|
__export(groq_provider_exports, {
|
|
@@ -9567,13 +9763,32 @@ var init_manager = __esm({
|
|
|
9567
9763
|
})
|
|
9568
9764
|
);
|
|
9569
9765
|
}
|
|
9570
|
-
/** Register adapters based on
|
|
9766
|
+
/** Register adapters based on Secret Manager or env keys */
|
|
9571
9767
|
async initializeProviders() {
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9768
|
+
let OPENAI_API_KEY = process.env.OPENAI_API_KEY;
|
|
9769
|
+
let ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
|
|
9770
|
+
let GOOGLE_API_KEY = process.env.GOOGLE_API_KEY || process.env.GOOGLE_AI_API_KEY;
|
|
9771
|
+
let GROQ_API_KEY = process.env.GROQ_API_KEY;
|
|
9576
9772
|
const GROK_API_KEY = process.env.GROK_API_KEY || process.env.XAI_API_KEY;
|
|
9773
|
+
try {
|
|
9774
|
+
const { SecretManagerIntegration: SecretManagerIntegration2 } = await Promise.resolve().then(() => (init_SecretManagerIntegration(), SecretManagerIntegration_exports));
|
|
9775
|
+
const secretManager = new SecretManagerIntegration2({
|
|
9776
|
+
projectId: process.env.GOOGLE_CLOUD_PROJECT || "maria-code-470602",
|
|
9777
|
+
secrets: {
|
|
9778
|
+
openAI: "openai-api-key",
|
|
9779
|
+
anthropic: "anthropic-api-key",
|
|
9780
|
+
googleAI: "google-ai-api-key",
|
|
9781
|
+
groq: "groq-api-key"
|
|
9782
|
+
}
|
|
9783
|
+
});
|
|
9784
|
+
const keys = await secretManager.getAllApiKeys();
|
|
9785
|
+
OPENAI_API_KEY = keys.openaiApiKey || OPENAI_API_KEY;
|
|
9786
|
+
ANTHROPIC_API_KEY = keys.anthropicApiKey || ANTHROPIC_API_KEY;
|
|
9787
|
+
GOOGLE_API_KEY = keys.googleApiKey || GOOGLE_API_KEY;
|
|
9788
|
+
GROQ_API_KEY = keys.groqApiKey || GROQ_API_KEY;
|
|
9789
|
+
} catch (error2) {
|
|
9790
|
+
console.debug("Secret Manager not available, using environment variables");
|
|
9791
|
+
}
|
|
9577
9792
|
if (OPENAI_API_KEY) this.register(new UnifiedOpenAIProvider(OPENAI_API_KEY));
|
|
9578
9793
|
if (ANTHROPIC_API_KEY) this.register(new UnifiedAnthropicProvider(ANTHROPIC_API_KEY));
|
|
9579
9794
|
if (GOOGLE_API_KEY) this.register(new UnifiedGoogleProvider(GOOGLE_API_KEY));
|
|
@@ -13533,7 +13748,7 @@ var init_bigquery_telemetry = __esm({
|
|
|
13533
13748
|
httpEndpoint = null;
|
|
13534
13749
|
config = {
|
|
13535
13750
|
projectId: process.env.GOOGLE_CLOUD_PROJECT || "maria-code-470602",
|
|
13536
|
-
datasetId: "
|
|
13751
|
+
datasetId: "maria_telemetry",
|
|
13537
13752
|
tableName: "command_executions",
|
|
13538
13753
|
batchSize: 100,
|
|
13539
13754
|
flushIntervalMs: 3e4,
|
|
@@ -31977,7 +32192,7 @@ var init_package = __esm({
|
|
|
31977
32192
|
"package.json"() {
|
|
31978
32193
|
package_default = {
|
|
31979
32194
|
name: "@bonginkan/maria",
|
|
31980
|
-
version: "4.2.
|
|
32195
|
+
version: "4.2.2",
|
|
31981
32196
|
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.",
|
|
31982
32197
|
keywords: [
|
|
31983
32198
|
"ai",
|