pleumrouter 0.5.53 → 0.5.55
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/package.json +1 -1
- package/src/locales/es.mjs +3 -0
- package/src/locales/ja.mjs +3 -0
- package/src/locales/ko.mjs +3 -0
- package/src/locales/zh.mjs +3 -0
- package/src/recipes.mjs +7 -1
- package/src/wire.mjs +39 -2
package/package.json
CHANGED
package/src/locales/es.mjs
CHANGED
|
@@ -196,6 +196,9 @@ export const ES = {
|
|
|
196
196
|
"Revoked desktop API key {id}.": "Se revocó la clave API de escritorio {id}.",
|
|
197
197
|
"Failed to revoke the desktop API key (HTTP {status})": "No se pudo revocar la clave API de escritorio (HTTP {status})",
|
|
198
198
|
"Failed to create a desktop API key (HTTP {status})": "No se pudo crear la clave API de escritorio (HTTP {status})",
|
|
199
|
+
"The saved desktop API key was rejected (401), so a new one was created. Remove the old key from the dashboard if you no longer use it.": "La clave API de escritorio guardada fue rechazada (401), así que se creó una nueva. Elimina la clave anterior desde el panel si ya no la usas.",
|
|
200
|
+
"The new desktop API key was rejected too — check PLEUM_BASE_URL or your proxy.": "La nueva clave API de escritorio también fue rechazada — revisa PLEUM_BASE_URL o tu proxy.",
|
|
201
|
+
"Still wired with the old key: {list}. Run `pleum wire {cmd}` to switch them to the new key.": "Herramientas que siguen conectadas con la clave anterior: {list}. Ejecuta `pleum wire {cmd}` para pasarlas a la nueva clave.",
|
|
199
202
|
"kept the desktop key on this machine (logout does not delete it)": "la clave de escritorio se queda en esta máquina (logout no la borra)",
|
|
200
203
|
"Unsupported language: {code}\n Available: {list}": "Idioma no compatible: {code}\n Disponibles: {list}",
|
|
201
204
|
"Unsupported tool: {tool}": "Herramienta no compatible: {tool}",
|
package/src/locales/ja.mjs
CHANGED
|
@@ -193,6 +193,9 @@ export const JA = {
|
|
|
193
193
|
"No tools are wired by PleumRouter.": "PleumRouter で配線されたツールはありません。",
|
|
194
194
|
"Other tools still use this key: {tools}. Run `pleum unwire --revoke-key` to unwire all of them first.": "他のツールがまだこのキーを使っています: {tools}。先に `pleum unwire --revoke-key` ですべて解除してください。",
|
|
195
195
|
"Failed to create a desktop API key (HTTP {status})": "デスクトップ API キーの発行に失敗しました (HTTP {status})",
|
|
196
|
+
"The saved desktop API key was rejected (401), so a new one was created. Remove the old key from the dashboard if you no longer use it.": "保存されていたデスクトップ API キーが拒否されたため (401)、新しいキーを発行しました。古いキーが不要なら、ダッシュボードから削除してください。",
|
|
197
|
+
"The new desktop API key was rejected too — check PLEUM_BASE_URL or your proxy.": "新しく発行したデスクトップ API キーも拒否されました — PLEUM_BASE_URL またはプロキシの設定を確認してください。",
|
|
198
|
+
"Still wired with the old key: {list}. Run `pleum wire {cmd}` to switch them to the new key.": "まだ古いキーで配線されているツール: {list}。`pleum wire {cmd}` を実行すると新しいキーに切り替わります。",
|
|
196
199
|
"kept the desktop key on this machine (logout does not delete it)": "このマシンのデスクトップキーは残します(logout では消しません)",
|
|
197
200
|
"Unsupported language: {code}\n Available: {list}": "サポートされていない言語です: {code}\n 利用可能: {list}",
|
|
198
201
|
"Unsupported tool: {tool}": "サポートされていないツールです: {tool}",
|
package/src/locales/ko.mjs
CHANGED
|
@@ -305,6 +305,9 @@ export const KO = {
|
|
|
305
305
|
"Revoked desktop API key {id}.": "데스크톱 API 키 {id}를 폐기했습니다.",
|
|
306
306
|
"Failed to revoke the desktop API key (HTTP {status})": "데스크톱 API 키 폐기에 실패했습니다 (HTTP {status})",
|
|
307
307
|
"Failed to create a desktop API key (HTTP {status})": "데스크톱 API 키 발급에 실패했습니다 (HTTP {status})",
|
|
308
|
+
"The saved desktop API key was rejected (401), so a new one was created. Remove the old key from the dashboard if you no longer use it.": "저장된 데스크톱 API 키가 거절되어(401) 새 키를 발급했습니다. 옛 키를 더 쓰지 않으면 대시보드에서 지워 주세요.",
|
|
309
|
+
"The new desktop API key was rejected too — check PLEUM_BASE_URL or your proxy.": "새로 발급한 데스크톱 API 키도 거절되었습니다 — PLEUM_BASE_URL이나 프록시 설정을 확인하세요.",
|
|
310
|
+
"Still wired with the old key: {list}. Run `pleum wire {cmd}` to switch them to the new key.": "아직 옛 키로 배선된 도구: {list}. `pleum wire {cmd}`를 실행하면 새 키로 바뀝니다.",
|
|
308
311
|
"kept the desktop key on this machine (logout does not delete it)": "이 기기의 데스크톱 키는 남겨 둡니다 (logout이 지우지 않음)",
|
|
309
312
|
|
|
310
313
|
// settings.mjs
|
package/src/locales/zh.mjs
CHANGED
|
@@ -196,6 +196,9 @@ export const ZH = {
|
|
|
196
196
|
"Revoked desktop API key {id}.": "已撤销桌面 API 密钥 {id}。",
|
|
197
197
|
"Failed to revoke the desktop API key (HTTP {status})": "撤销桌面 API 密钥失败(HTTP {status})",
|
|
198
198
|
"Failed to create a desktop API key (HTTP {status})": "签发桌面 API 密钥失败(HTTP {status})",
|
|
199
|
+
"The saved desktop API key was rejected (401), so a new one was created. Remove the old key from the dashboard if you no longer use it.": "已保存的桌面 API 密钥被拒绝(401),因此签发了新密钥。如果不再使用旧密钥,请在控制台中删除。",
|
|
200
|
+
"The new desktop API key was rejected too — check PLEUM_BASE_URL or your proxy.": "新签发的桌面 API 密钥同样被拒绝 — 请检查 PLEUM_BASE_URL 或代理设置。",
|
|
201
|
+
"Still wired with the old key: {list}. Run `pleum wire {cmd}` to switch them to the new key.": "仍在使用旧密钥的工具:{list}。运行 `pleum wire {cmd}` 即可切换到新密钥。",
|
|
199
202
|
"kept the desktop key on this machine (logout does not delete it)": "本机桌面密钥会保留(logout 不会删除)",
|
|
200
203
|
"Unsupported language: {code}\n Available: {list}": "不支持的语言:{code}\n 可用:{list}",
|
|
201
204
|
"Unsupported tool: {tool}": "不支持的工具:{tool}",
|
package/src/recipes.mjs
CHANGED
|
@@ -193,7 +193,13 @@ export const RECIPES = {
|
|
|
193
193
|
title: "Goose",
|
|
194
194
|
referer: "https://block.github.io/goose",
|
|
195
195
|
},
|
|
196
|
-
env: (key) => ({
|
|
196
|
+
env: (key) => ({
|
|
197
|
+
GOOSE_PROVIDER: "openai",
|
|
198
|
+
OPENAI_HOST: ROOT,
|
|
199
|
+
OPENAI_BASE_PATH: "v1/chat/completions",
|
|
200
|
+
OPENAI_API_BASE: V1,
|
|
201
|
+
OPENAI_API_KEY: key,
|
|
202
|
+
}),
|
|
197
203
|
args: () => [],
|
|
198
204
|
},
|
|
199
205
|
openhands: {
|
package/src/wire.mjs
CHANGED
|
@@ -756,10 +756,33 @@ function withWorkspace(record, workspaceId) {
|
|
|
756
756
|
return next;
|
|
757
757
|
}
|
|
758
758
|
|
|
759
|
+
// 키가 서버에서 지금도 통하는지 본다. 목록(`/keys`)은 만료·재발급된 키도 active로 보여주므로 비밀값으로 직접 묻는다.
|
|
760
|
+
// authFetch는 Authorization을 JWT로 덮어써서 원시 fetch를 쓴다. 상태코드만 돌려주고 오류·시간 초과는 null.
|
|
761
|
+
export async function probeKeyStatus(key) {
|
|
762
|
+
try {
|
|
763
|
+
const res = await fetch(`${V1}/credits`, { headers: { Authorization: `Bearer ${key}` }, signal: AbortSignal.timeout(5000) });
|
|
764
|
+
return res.status;
|
|
765
|
+
} catch {
|
|
766
|
+
return null;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// 옛 키는 지우지 않았다 — 대시보드에서 재발급한 같은 id의 살아 있는 키일 수 있다.
|
|
771
|
+
// 이번에 다시 배선하지 않는 도구(launch는 전부)는 옛 키를 그대로 들고 있으니 알린다.
|
|
772
|
+
function announceRecoveredKey(paths, rewiring) {
|
|
773
|
+
console.error(t("The saved desktop API key was rejected (401), so a new one was created. Remove the old key from the dashboard if you no longer use it."));
|
|
774
|
+
const stale = wiredTools(paths).filter((tool) => !rewiring.includes(tool));
|
|
775
|
+
if (stale.length) {
|
|
776
|
+
console.error(t("Still wired with the old key: {list}. Run `pleum wire {cmd}` to switch them to the new key.", { list: stale.join(", "), cmd: stale.join(" ") }));
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
759
780
|
export async function ensureWireKey({
|
|
760
781
|
auth = authFetch,
|
|
761
782
|
paths = wirePaths(),
|
|
762
783
|
activeContext = getActiveContext(),
|
|
784
|
+
probe = probeKeyStatus,
|
|
785
|
+
rewiring = [],
|
|
763
786
|
} = {}) {
|
|
764
787
|
// 과금 귀속은 키의 workspace_id가 정한다. 공유 공간이면 그 공간, 개인이면 소유자의 기본 공간.
|
|
765
788
|
const shared = activeContext?.type === "workspace" ? activeContext.workspace_id : null;
|
|
@@ -770,13 +793,17 @@ export async function ensureWireKey({
|
|
|
770
793
|
return null;
|
|
771
794
|
}
|
|
772
795
|
})();
|
|
796
|
+
let stale = false; // 목록에서는 살아 있는데 서버가 401로 거절하는 저장 키(만료·재발급)
|
|
773
797
|
if (stored?.key && stored?.id) {
|
|
774
798
|
const listed = await auth("/keys");
|
|
775
799
|
if (listed.ok) {
|
|
776
800
|
const data = await parseJsonBody(listed);
|
|
777
801
|
const items = Array.isArray(data.items) ? data.items : [];
|
|
778
802
|
const found = items.find((item) => String(item.id) === String(stored.id));
|
|
779
|
-
|
|
803
|
+
const live = Boolean(found) && found.is_active !== false;
|
|
804
|
+
// 401만 낡은 키로 본다. 403(IP 허용목록)·429·5xx·네트워크 오류는 저장 키를 그대로 쓴다(fail-safe).
|
|
805
|
+
stale = live && (await probe(stored.key)) === 401;
|
|
806
|
+
if (live && !stale) {
|
|
780
807
|
const target = shared ?? (await findDefaultWorkspaceId(auth));
|
|
781
808
|
const current = String(found.workspace_id ?? "");
|
|
782
809
|
if (target && current !== String(target)) {
|
|
@@ -822,7 +849,16 @@ export async function ensureWireKey({
|
|
|
822
849
|
name: data.name ?? WIRE_KEY_NAME,
|
|
823
850
|
...(shared ? { workspace_id: shared } : {}),
|
|
824
851
|
};
|
|
852
|
+
// 복구로 만든 새 키도 401이면 base_url·프록시 오설정이다. 이번에 만든 키만 지우고(저장돼 있던 키는 건드리지 않는다) 멈춘다 —
|
|
853
|
+
// 개인 키 개수 상한이 없어 그대로 두면 실행마다 키가 쌓인다.
|
|
854
|
+
if (stale && (await probe(data.key)) === 401) {
|
|
855
|
+
try {
|
|
856
|
+
await auth(`/keys/${data.id}`, { method: "DELETE" });
|
|
857
|
+
} catch {}
|
|
858
|
+
throw new Error(t("The new desktop API key was rejected too — check PLEUM_BASE_URL or your proxy."));
|
|
859
|
+
}
|
|
825
860
|
writeSecretFile(paths.wire, `${JSON.stringify(record, null, 2)}\n`);
|
|
861
|
+
if (stale) announceRecoveredKey(paths, rewiring);
|
|
826
862
|
return record;
|
|
827
863
|
}
|
|
828
864
|
|
|
@@ -1089,6 +1125,7 @@ export async function wire(args = [], {
|
|
|
1089
1125
|
models,
|
|
1090
1126
|
billingOnly = false,
|
|
1091
1127
|
activeContext,
|
|
1128
|
+
probe,
|
|
1092
1129
|
} = {}) {
|
|
1093
1130
|
const parsed = parseWireArgs(args);
|
|
1094
1131
|
const tools = parsed.tools;
|
|
@@ -1097,7 +1134,7 @@ export async function wire(args = [], {
|
|
|
1097
1134
|
const paths = wirePaths(home);
|
|
1098
1135
|
// 메뉴 경로는 호출자가 이미 고른 값을 넘긴다(중복 질문 방지).
|
|
1099
1136
|
const billing = activeContext ?? (await pickBillingContext(auth));
|
|
1100
|
-
const record = await ensureWireKey({ auth, paths, activeContext: billing });
|
|
1137
|
+
const record = await ensureWireKey({ auth, paths, activeContext: billing, probe, rewiring: tools });
|
|
1101
1138
|
|
|
1102
1139
|
// 한 도구가 깨져도 나머지는 배선한다. 실패 목록은 마지막에 한 번에 던져 exit 1이 되게 한다.
|
|
1103
1140
|
const failures = [];
|