pleumrouter 0.5.44 → 0.5.46
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/bin/pleum.mjs +8 -3
- package/package.json +1 -1
- package/src/balance.mjs +38 -137
- package/src/config.mjs +5 -18
- package/src/interactive.mjs +130 -0
- package/src/launch.mjs +2 -6
- package/src/locales/es.mjs +41 -0
- package/src/locales/ja.mjs +41 -0
- package/src/locales/ko.mjs +41 -0
- package/src/locales/zh.mjs +41 -0
- package/src/menu.mjs +218 -5
- package/src/run.mjs +19 -2
- package/src/settings.mjs +3 -6
- package/src/wire.mjs +766 -70
- package/src/workspace.mjs +58 -1
package/src/workspace.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { authFetch, getActiveContext, setActiveContext } from "./config.mjs";
|
|
2
2
|
import { sanitizeTerminalText, style } from "./ansi.mjs";
|
|
3
|
+
import { select } from "./interactive.mjs";
|
|
3
4
|
import { t } from "./i18n.mjs";
|
|
4
5
|
|
|
5
6
|
// 서버가 계산한 활성 컨텍스트 = CLI 세션 키의 workspace_id(과금 귀속 진실).
|
|
@@ -61,7 +62,7 @@ export function formatWorkspaceList(context, candidates = []) {
|
|
|
61
62
|
for (const candidate of candidates) {
|
|
62
63
|
const mark = String(candidate.workspace_id) === activeId ? style.bold(style.plum("▸ ")) : " ";
|
|
63
64
|
lines.push(
|
|
64
|
-
`${mark}${candidate.workspace_id} ${sanitizeTerminalText(candidate.name)} (${candidate.role})`,
|
|
65
|
+
`${mark}${candidate.workspace_id} ${sanitizeTerminalText(candidate.name)} (${sanitizeTerminalText(candidate.role)})`,
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
68
|
return lines.join("\n");
|
|
@@ -96,3 +97,59 @@ export async function workspace(args = [], { auth = authFetch, save = setActiveC
|
|
|
96
97
|
console.log(`✓ ${t("Active credit set to: {name}", { name: workspaceLabel(next) })}`);
|
|
97
98
|
return next;
|
|
98
99
|
}
|
|
100
|
+
|
|
101
|
+
export async function selectAndBindWorkspace({
|
|
102
|
+
auth = authFetch,
|
|
103
|
+
save = setActiveContext,
|
|
104
|
+
selectFn = select,
|
|
105
|
+
} = {}) {
|
|
106
|
+
let data;
|
|
107
|
+
try {
|
|
108
|
+
data = await fetchWorkspaceContext(auth);
|
|
109
|
+
} catch {
|
|
110
|
+
return getActiveContext();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const candidates = data?.workspace_candidates ?? [];
|
|
114
|
+
if (candidates.length === 0) {
|
|
115
|
+
return data?.active_context ?? getActiveContext();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const active = data?.active_context ?? getActiveContext();
|
|
119
|
+
const activeId = active?.type === "workspace" ? String(active.workspace_id) : null;
|
|
120
|
+
|
|
121
|
+
const options = [
|
|
122
|
+
{
|
|
123
|
+
id: "personal",
|
|
124
|
+
type: "personal",
|
|
125
|
+
title: t("Personal Credit"),
|
|
126
|
+
label: `${activeId ? " " : "✓ "}${t("Personal Credit")}`,
|
|
127
|
+
},
|
|
128
|
+
...candidates.map((c) => ({
|
|
129
|
+
id: String(c.workspace_id),
|
|
130
|
+
type: "workspace",
|
|
131
|
+
workspace_id: c.workspace_id,
|
|
132
|
+
name: c.name,
|
|
133
|
+
title: `${sanitizeTerminalText(c.name)} (${sanitizeTerminalText(c.role)})`,
|
|
134
|
+
label: `${activeId === String(c.workspace_id) ? "✓ " : " "}${sanitizeTerminalText(c.name)} (${sanitizeTerminalText(c.role)})`,
|
|
135
|
+
})),
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
const picked = await selectFn(options, {
|
|
139
|
+
message: t("Select billing workspace for this agent"),
|
|
140
|
+
formatItem: (x) => x.label,
|
|
141
|
+
limit: 10,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (!picked) return active;
|
|
145
|
+
|
|
146
|
+
if (picked.type === "personal") {
|
|
147
|
+
const next = await bindWorkspaceContext(null, auth);
|
|
148
|
+
save(next);
|
|
149
|
+
return next;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const next = await bindWorkspaceContext(picked.workspace_id, auth);
|
|
153
|
+
save(next);
|
|
154
|
+
return next;
|
|
155
|
+
}
|