@bonginkan/maria 4.3.41 → 4.3.43

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/cli.cjs CHANGED
@@ -1709,7 +1709,7 @@ var init_AuthenticationManager = __esm({
1709
1709
  const response = await fetch(`${this.apiBase}/api/user/profile`, {
1710
1710
  headers: {
1711
1711
  "Authorization": `Bearer ${tokens2.accessToken}`,
1712
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.41"}`
1712
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.43"}`
1713
1713
  }
1714
1714
  });
1715
1715
  if (response.status === 401) {
@@ -2434,7 +2434,7 @@ async function callApi(path65, init3 = {}) {
2434
2434
  "Authorization": `Bearer ${token}`,
2435
2435
  "X-Device-Id": getDeviceId(),
2436
2436
  "X-Session-Id": getSessionId() || "",
2437
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.41"}`,
2437
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.43"}`,
2438
2438
  "Content-Type": init3.headers?.["Content-Type"] || "application/json"
2439
2439
  });
2440
2440
  const doFetch = async (token) => {
@@ -3136,11 +3136,28 @@ async function callAPI(endpoint, options = {}) {
3136
3136
  }
3137
3137
  }
3138
3138
  async function executeChat(messages) {
3139
- const response = await callAPI("/v1/chat", {
3140
- method: "POST",
3141
- body: { messages }
3142
- });
3143
- return response;
3139
+ const maxAttempts = 4;
3140
+ let lastErr;
3141
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
3142
+ try {
3143
+ const response = await callAPI("/v1/ai-proxy", {
3144
+ method: "POST",
3145
+ body: { messages, taskType: "chat" }
3146
+ });
3147
+ return response;
3148
+ } catch (e2) {
3149
+ lastErr = e2;
3150
+ const isRateLimit = e2?.name === "RateLimitError" || /rate\s*limit|429/i.test(String(e2?.message || ""));
3151
+ if (!isRateLimit || attempt === maxAttempts) {
3152
+ throw e2;
3153
+ }
3154
+ const waitSec = Math.max(1, Math.min(60, Number(e2?.retryAfter || 0)));
3155
+ const baseMs = (waitSec > 0 ? waitSec * 1e3 : 1500) * attempt;
3156
+ const jitter = Math.floor(Math.random() * 400);
3157
+ await new Promise((r2) => setTimeout(r2, Math.min(3e4, baseMs + jitter)));
3158
+ }
3159
+ }
3160
+ throw lastErr;
3144
3161
  }
3145
3162
  async function executeCode(input3) {
3146
3163
  const isOptions = typeof input3 === "object";
@@ -3154,17 +3171,34 @@ async function executeCode(input3) {
3154
3171
  if (attachments && attachments.length > 0) {
3155
3172
  body.metadata = { attachments };
3156
3173
  }
3157
- const response = await callAPI("/v1/ai-proxy", {
3158
- method: "POST",
3159
- body
3160
- });
3161
- if (response.data?.routedModel) {
3162
- response.routedModel = response.data.routedModel;
3163
- }
3164
- if (response.data?.content) {
3165
- response.output = response.data.content;
3174
+ const maxAttempts = 5;
3175
+ let lastErr;
3176
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
3177
+ try {
3178
+ const response = await callAPI("/v1/ai-proxy", {
3179
+ method: "POST",
3180
+ body
3181
+ });
3182
+ if (response.data?.routedModel) {
3183
+ response.routedModel = response.data.routedModel;
3184
+ }
3185
+ if (response.data?.content) {
3186
+ response.output = response.data.content;
3187
+ }
3188
+ return response;
3189
+ } catch (e2) {
3190
+ lastErr = e2;
3191
+ const isRateLimit = e2?.name === "RateLimitError" || /rate\s*limit|429/i.test(String(e2?.message || ""));
3192
+ if (!isRateLimit || attempt === maxAttempts) {
3193
+ throw e2;
3194
+ }
3195
+ const waitSec = Math.max(1, Math.min(60, Number(e2?.retryAfter || 0)));
3196
+ const baseMs = (waitSec > 0 ? waitSec * 1e3 : 2e3) * attempt;
3197
+ const jitter = Math.floor(Math.random() * 500);
3198
+ await new Promise((r2) => setTimeout(r2, Math.min(45e3, baseMs + jitter)));
3199
+ }
3166
3200
  }
3167
- return response;
3201
+ throw lastErr;
3168
3202
  }
3169
3203
  async function executeAIProxy(provider, model, messages, options) {
3170
3204
  return callAPI("/v1/ai-proxy", {
@@ -16382,8 +16416,8 @@ var require_package = __commonJS({
16382
16416
  "package.json"(exports, module) {
16383
16417
  module.exports = {
16384
16418
  name: "@bonginkan/maria",
16385
- version: "4.3.41",
16386
- description: "\u{1F680} MARIA v4.3.41 - Enterprise AI Development Platform with identity system and character voice implementation. 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.",
16419
+ version: "4.3.43",
16420
+ description: "\u{1F680} MARIA v4.3.43 - Enterprise AI Development Platform with identity system and character voice implementation. 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.",
16387
16421
  keywords: [
16388
16422
  "ai",
16389
16423
  "cli",
@@ -26389,7 +26423,7 @@ var init_about_command = __esm({
26389
26423
  async execute(args2, context2) {
26390
26424
  const output3 = [];
26391
26425
  output3.push("");
26392
- output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.3.41"));
26426
+ output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.3.43"));
26393
26427
  output3.push(chalk40__default.default.gray("\u2550".repeat(40)));
26394
26428
  output3.push("");
26395
26429
  output3.push(chalk40__default.default.white.bold("MARIA - Minimal API, Maximum Power"));
@@ -39947,14 +39981,7 @@ ${h2.head}`);
39947
39981
  { role: "user", content: user }
39948
39982
  ]);
39949
39983
  const raw = (resp?.output || "").trim();
39950
- const jsonText = (() => {
39951
- try {
39952
- const m2 = raw.match(/\[[\s\S]*\]/);
39953
- return m2 ? m2[0] : raw;
39954
- } catch {
39955
- return raw;
39956
- }
39957
- })();
39984
+ const jsonText = extractJsonSafe(raw, "array") || raw;
39958
39985
  const arr = JSON.parse(jsonText);
39959
39986
  const set = new Set(candidates.map((c) => c.toLowerCase()));
39960
39987
  const out = [];
@@ -40000,14 +40027,7 @@ ${h2.head}`);
40000
40027
  { role: "user", content: user }
40001
40028
  ]);
40002
40029
  const raw = (resp?.output || "").trim();
40003
- const jsonText = (() => {
40004
- try {
40005
- const m2 = raw.match(/\{[\s\S]*\}/);
40006
- return m2 ? m2[0] : raw;
40007
- } catch {
40008
- return raw;
40009
- }
40010
- })();
40030
+ const jsonText = extractJsonSafe(raw, "object") || raw;
40011
40031
  const parsed = JSON.parse(jsonText);
40012
40032
  if (parsed && (parsed.action === "modify" || parsed.action === "create") && typeof parsed.path === "string") {
40013
40033
  return { action: parsed.action, path: parsed.path.replace(/^\/+/, "") };