agent-mp 0.5.9 → 0.5.11
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/core/engine.js +29 -12
- package/dist/utils/qwen-auth.js +22 -0
- package/package.json +1 -1
package/dist/core/engine.js
CHANGED
|
@@ -545,6 +545,10 @@ INSTRUCCIONES:
|
|
|
545
545
|
log.warn(`${cliName} session expired — using fallback`);
|
|
546
546
|
return null;
|
|
547
547
|
}
|
|
548
|
+
if (err.message?.startsWith('QWEN_QUOTA_EXCEEDED')) {
|
|
549
|
+
log.warn(`${cliName} quota exhausted — using fallback`);
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
548
552
|
log.warn(`${cliName} direct API call failed: ${err.message}`);
|
|
549
553
|
return null;
|
|
550
554
|
}
|
|
@@ -1129,9 +1133,10 @@ Si es un controller/router:
|
|
|
1129
1133
|
|
|
1130
1134
|
REGLAS:
|
|
1131
1135
|
- Devuelve UNICAMENTE los archivos separados por === path/file.md ===
|
|
1132
|
-
-
|
|
1136
|
+
- USA NOMBRES CORTOS: NO uses rutas absolutas
|
|
1133
1137
|
- El archivo principal SIEMPRE es === architecture.md ===
|
|
1134
|
-
- Para
|
|
1138
|
+
- Para componentes: === nombre-del-componente/architecture.md ===
|
|
1139
|
+
- Para modulos internos: === nombre-del-componente/modules/nombre-modulo.md ===
|
|
1135
1140
|
- Para componentes triviales (scripts, docs): solo mencionarlos en architecture.md principal
|
|
1136
1141
|
- Documenta TODOS los directorios al nivel de DIRECTORIO_TRABAJO (excluyendo .agent)
|
|
1137
1142
|
- Si hay documentacion existente, actualizala con los cambios detectados`;
|
|
@@ -1154,20 +1159,32 @@ REGLAS:
|
|
|
1154
1159
|
targetPath = mainArchPath;
|
|
1155
1160
|
}
|
|
1156
1161
|
else {
|
|
1157
|
-
//
|
|
1158
|
-
// fileName could be: "datamart-data-access-api/architecture.md"
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1162
|
+
// CRITICAL: Extract only the relative path components, strip any absolute path prefix
|
|
1163
|
+
// fileName could be: "datamart-data-access-api/architecture.md"
|
|
1164
|
+
// or "/home/user/project/datamart-data-access-api/architecture.md" (BAD — must ignore prefix)
|
|
1165
|
+
// We only want the components relative to contextDir
|
|
1166
|
+
// Remove any leading absolute path by extracting the last meaningful path segments
|
|
1167
|
+
const cleanName = fileName.replace(/^.*[\/\\]/, ''); // strip any prefix
|
|
1168
|
+
// Check if it's a component architecture file: "component/architecture.md" or "component/modules/mod.md"
|
|
1169
|
+
const pathParts = fileName.split(/[\/\\]/).filter(Boolean);
|
|
1170
|
+
// Keep only the last 2-3 parts (component name + file)
|
|
1171
|
+
// e.g. ["/home", "user", "proj", "datamart", "architecture.md"] → ["datamart", "architecture.md"]
|
|
1172
|
+
// e.g. ["datamart-data-access-api", "architecture.md"] → same
|
|
1173
|
+
// e.g. ["datamart-data-access-api", "modules", "config.md"] → same
|
|
1174
|
+
let relPath;
|
|
1175
|
+
if (pathParts.length >= 3 && pathParts[pathParts.length - 2] === 'modules') {
|
|
1176
|
+
// component/modules/file.md
|
|
1177
|
+
relPath = path.join(pathParts[pathParts.length - 3], 'modules', pathParts[pathParts.length - 1]);
|
|
1163
1178
|
}
|
|
1164
|
-
else if (
|
|
1165
|
-
|
|
1179
|
+
else if (pathParts.length >= 2) {
|
|
1180
|
+
// component/file.md
|
|
1181
|
+
relPath = path.join(pathParts[pathParts.length - 2], pathParts[pathParts.length - 1]);
|
|
1166
1182
|
}
|
|
1167
1183
|
else {
|
|
1168
|
-
//
|
|
1169
|
-
|
|
1184
|
+
// fallback
|
|
1185
|
+
relPath = path.join('modules', cleanName);
|
|
1170
1186
|
}
|
|
1187
|
+
targetPath = path.join(contextDir, relPath);
|
|
1171
1188
|
}
|
|
1172
1189
|
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
|
1173
1190
|
await writeFile(targetPath, content);
|
package/dist/utils/qwen-auth.js
CHANGED
|
@@ -462,6 +462,28 @@ export async function qwenUsage(credsPath) {
|
|
|
462
462
|
return { ok: true, token, model: 'coder-model' };
|
|
463
463
|
}
|
|
464
464
|
catch (err) {
|
|
465
|
+
// If auth failed, try refresh even if expiresAt hasn't passed yet
|
|
466
|
+
if (err.message?.startsWith('QWEN_AUTH_EXPIRED') && token.refreshToken) {
|
|
467
|
+
const refreshed = await doRefreshToken(token.refreshToken);
|
|
468
|
+
if (refreshed) {
|
|
469
|
+
token = refreshed;
|
|
470
|
+
if (!credsPath)
|
|
471
|
+
await saveToken(refreshed);
|
|
472
|
+
else
|
|
473
|
+
await fs.writeFile(credsPath, JSON.stringify(refreshed, null, 2), 'utf-8');
|
|
474
|
+
// Retry with new token
|
|
475
|
+
try {
|
|
476
|
+
await callQwenAPIWithToken(refreshed, 'ping', 'coder-model');
|
|
477
|
+
return { ok: true, token: refreshed, model: 'coder-model' };
|
|
478
|
+
}
|
|
479
|
+
catch (err2) {
|
|
480
|
+
if (err2.message?.startsWith('QWEN_QUOTA_EXCEEDED')) {
|
|
481
|
+
return { ok: false, token: refreshed, error: 'Daily quota exhausted — wait or --login with different account' };
|
|
482
|
+
}
|
|
483
|
+
return { ok: false, token: refreshed, error: err2.message };
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
465
487
|
if (err.message?.startsWith('QWEN_QUOTA_EXCEEDED')) {
|
|
466
488
|
return { ok: false, token, error: 'Daily quota exhausted — wait or --login with different account' };
|
|
467
489
|
}
|