@sunshaobei/dsh-balance-panel 3.0.7 → 3.0.9
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/lib/client.js +13 -1
- package/lib/index.js +18 -0
- package/package.json +1 -1
- package/src/client.ts +9 -1
- package/src/index.ts +16 -0
package/lib/client.js
CHANGED
|
@@ -37,6 +37,10 @@ window.__ModuleLoader__.load({
|
|
|
37
37
|
// (from the host's modelDirectories service) into this tiny store;
|
|
38
38
|
// the indicator component subscribes to it.
|
|
39
39
|
var selStore = { sel: null, listeners: new Set() };
|
|
40
|
+
let clientLogQueue = Promise.resolve();
|
|
41
|
+
function clientLog(line) {
|
|
42
|
+
clientLogQueue = clientLogQueue.then(() => ctx.connection.rpc.call(CHANNEL, 'client-log', { line })).catch(() => { });
|
|
43
|
+
}
|
|
40
44
|
function setSel(next) {
|
|
41
45
|
var cur = selStore.sel;
|
|
42
46
|
if (!cur && !next)
|
|
@@ -46,6 +50,7 @@ window.__ModuleLoader__.load({
|
|
|
46
50
|
if (cur && next && cur.provider === next.provider && cur.model === next.model && cur.src === next.src)
|
|
47
51
|
return;
|
|
48
52
|
selStore.sel = next;
|
|
53
|
+
clientLog('setSel provider=' + JSON.stringify(next && next.provider) + ' model=' + JSON.stringify(next && next.model) + ' src=' + JSON.stringify(next && next.src));
|
|
49
54
|
selStore.listeners.forEach(function (l) { l(next); });
|
|
50
55
|
}
|
|
51
56
|
/** Map a provider/model/spec string to a coarse provider family key. */
|
|
@@ -1148,6 +1153,8 @@ window.__ModuleLoader__.load({
|
|
|
1148
1153
|
// expands the full card with EVERY provider.
|
|
1149
1154
|
var RING_R = 7, RING_C = 2 * Math.PI * RING_R;
|
|
1150
1155
|
var curSpec = matchSpec(specs, sel);
|
|
1156
|
+
if (specs && specs.rows)
|
|
1157
|
+
clientLog('capsule sel=' + JSON.stringify(sel) + ' rows=[' + specs.rows.map(function (r3x) { return r3x.id + ':' + r3x.kind; }).join(',') + '] matched=' + (curSpec ? curSpec.id : 'null'));
|
|
1151
1158
|
var curView = curSpec ? views[curSpec.id] : null;
|
|
1152
1159
|
// Compact window group: small ring first, tiny label beside it.
|
|
1153
1160
|
var makeRing = function (key, pct, status, label) {
|
|
@@ -1320,6 +1327,7 @@ window.__ModuleLoader__.load({
|
|
|
1320
1327
|
var cur = snap && snap.current;
|
|
1321
1328
|
if (cur && cur.provider) {
|
|
1322
1329
|
setSel({ provider: String(cur.provider), model: String(cur.model || ""), src: "service" });
|
|
1330
|
+
clientLog('service publish session=' + (bound && bound.sessionId) + ' provider=' + JSON.stringify(String(cur.provider)) + ' model=' + JSON.stringify(String(cur.model || "")));
|
|
1323
1331
|
}
|
|
1324
1332
|
}
|
|
1325
1333
|
catch (_) { /* transient store read */ }
|
|
@@ -1332,6 +1340,7 @@ window.__ModuleLoader__.load({
|
|
|
1332
1340
|
var id = ordered[i].id;
|
|
1333
1341
|
if (bound && bound.sessionId === id)
|
|
1334
1342
|
return; // already bound
|
|
1343
|
+
clientLog('bind candidate session=' + id + ' (first in updatedAt order)');
|
|
1335
1344
|
try {
|
|
1336
1345
|
var dir = dirs.directoryFor(id);
|
|
1337
1346
|
var unsub = null;
|
|
@@ -1381,7 +1390,10 @@ window.__ModuleLoader__.load({
|
|
|
1381
1390
|
// `conversation.composer.dock` slot — the same flex row that hosts
|
|
1382
1391
|
// the session ContextMeter stats strip; the seat renders right of
|
|
1383
1392
|
// it. No floating widget, no dragging.
|
|
1384
|
-
ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({ name: "conversation.composer.dock", id: "dsh-quota-panel", order: 20, label: () => t("title"), locale: NS }, () =>
|
|
1393
|
+
ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({ name: "conversation.composer.dock", id: "dsh-quota-panel", order: 20, label: () => t("title"), locale: NS }, (props) => { try {
|
|
1394
|
+
clientLog('dock slotProps keys=' + JSON.stringify(Object.keys(props || {})) + ' sessionId=' + JSON.stringify(props && (props.sessionId || (props.entry && props.entry.sessionId))));
|
|
1395
|
+
}
|
|
1396
|
+
catch { } return React.createElement(QuotaPanel, { t: t, slotSessionId: props && (props.sessionId || (props.entry && props.entry.sessionId)) }); }));
|
|
1385
1397
|
}
|
|
1386
1398
|
exports.apply = apply;
|
|
1387
1399
|
exports.inject = inject;
|
package/lib/index.js
CHANGED
|
@@ -2001,8 +2001,26 @@ export function apply(ctx, config = {}) {
|
|
|
2001
2001
|
catalog
|
|
2002
2002
|
});
|
|
2003
2003
|
if (endpoint === 'specs') {
|
|
2004
|
+
try {
|
|
2005
|
+
const fsp2 = await import('node:fs/promises');
|
|
2006
|
+
fsMod.mkdirSync(chatgptDshStoreDir(), { recursive: true });
|
|
2007
|
+
const dbg = path.join(chatgptDshStoreDir(), 'debug.log');
|
|
2008
|
+
await fsp2.appendFile(dbg, new Date().toISOString() + ' specs rows=[' + rows.map(r2 => r2.id + ':' + r2.kind).join(',') + ']\n').catch(() => { });
|
|
2009
|
+
}
|
|
2010
|
+
catch { }
|
|
2004
2011
|
return { ok: true, value: { rows: rows.map(rowSpec), refreshMs } };
|
|
2005
2012
|
}
|
|
2013
|
+
if (endpoint === 'client-log') {
|
|
2014
|
+
try {
|
|
2015
|
+
const fsp2 = await import('node:fs/promises');
|
|
2016
|
+
const line = payload && typeof payload.line === 'string' ? payload.line : '';
|
|
2017
|
+
fsMod.mkdirSync(chatgptDshStoreDir(), { recursive: true });
|
|
2018
|
+
const dbg = path.join(chatgptDshStoreDir(), 'debug.log');
|
|
2019
|
+
await fsp2.appendFile(dbg, new Date().toISOString() + ' client: ' + line + '\n').catch(() => { });
|
|
2020
|
+
}
|
|
2021
|
+
catch { }
|
|
2022
|
+
return { ok: true, value: { logged: true } };
|
|
2023
|
+
}
|
|
2006
2024
|
if (endpoint === 'fetch-all') {
|
|
2007
2025
|
const overrides = {};
|
|
2008
2026
|
const overrideErrors = {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sunshaobei/dsh-balance-panel",
|
|
3
3
|
"description": "Provider quota/balance widget for the dsh web surface: an inline sidebar card above the Settings row (collapsed glanceable row expanding into a Harness-native card with a settings panel), fed by a loopback Connection RPC channel whose host half proxies each provider with credentials that never reach the browser.",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
package/src/client.ts
CHANGED
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
// (from the host's modelDirectories service) into this tiny store;
|
|
40
40
|
// the indicator component subscribes to it.
|
|
41
41
|
var selStore = { sel: null, listeners: new Set() };
|
|
42
|
+
let clientLogQueue = Promise.resolve();
|
|
43
|
+
function clientLog(line) {
|
|
44
|
+
clientLogQueue = clientLogQueue.then(() => ctx.connection.rpc.call(CHANNEL, 'client-log', { line })).catch(() => {});
|
|
45
|
+
}
|
|
42
46
|
function setSel(next) {
|
|
43
47
|
var cur = selStore.sel;
|
|
44
48
|
if (!cur && !next) return;
|
|
@@ -46,6 +50,7 @@
|
|
|
46
50
|
// republishes the same value on every tick).
|
|
47
51
|
if (cur && next && cur.provider === next.provider && cur.model === next.model && cur.src === next.src) return;
|
|
48
52
|
selStore.sel = next;
|
|
53
|
+
clientLog('setSel provider=' + JSON.stringify(next && next.provider) + ' model=' + JSON.stringify(next && next.model) + ' src=' + JSON.stringify(next && next.src));
|
|
49
54
|
selStore.listeners.forEach(function (l) { l(next); });
|
|
50
55
|
}
|
|
51
56
|
/** Map a provider/model/spec string to a coarse provider family key. */
|
|
@@ -1149,6 +1154,7 @@
|
|
|
1149
1154
|
// expands the full card with EVERY provider.
|
|
1150
1155
|
var RING_R = 7, RING_C = 2 * Math.PI * RING_R;
|
|
1151
1156
|
var curSpec = matchSpec(specs, sel);
|
|
1157
|
+
if (specs && specs.rows) clientLog('capsule sel=' + JSON.stringify(sel) + ' rows=[' + specs.rows.map(function (r3x) { return r3x.id + ':' + r3x.kind; }).join(',') + '] matched=' + (curSpec ? curSpec.id : 'null'));
|
|
1152
1158
|
var curView = curSpec ? views[curSpec.id] : null;
|
|
1153
1159
|
// Compact window group: small ring first, tiny label beside it.
|
|
1154
1160
|
var makeRing = function (key, pct, status, label) {
|
|
@@ -1319,6 +1325,7 @@
|
|
|
1319
1325
|
var cur = snap && snap.current;
|
|
1320
1326
|
if (cur && cur.provider) {
|
|
1321
1327
|
setSel({ provider: String(cur.provider), model: String(cur.model || ""), src: "service" });
|
|
1328
|
+
clientLog('service publish session=' + (bound && bound.sessionId) + ' provider=' + JSON.stringify(String(cur.provider)) + ' model=' + JSON.stringify(String(cur.model || "")));
|
|
1322
1329
|
}
|
|
1323
1330
|
} catch (_) { /* transient store read */ }
|
|
1324
1331
|
};
|
|
@@ -1329,6 +1336,7 @@
|
|
|
1329
1336
|
for (var i = 0; i < ordered.length; i++) {
|
|
1330
1337
|
var id = ordered[i].id;
|
|
1331
1338
|
if (bound && bound.sessionId === id) return; // already bound
|
|
1339
|
+
clientLog('bind candidate session=' + id + ' (first in updatedAt order)');
|
|
1332
1340
|
try {
|
|
1333
1341
|
var dir = dirs.directoryFor(id);
|
|
1334
1342
|
var unsub = null;
|
|
@@ -1362,7 +1370,7 @@
|
|
|
1362
1370
|
// it. No floating widget, no dragging.
|
|
1363
1371
|
ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register(
|
|
1364
1372
|
{ name: "conversation.composer.dock", id: "dsh-quota-panel", order: 20, label: () => t("title"), locale: NS },
|
|
1365
|
-
() => React.createElement(QuotaPanel, { t: t })
|
|
1373
|
+
(props) => { try { clientLog('dock slotProps keys=' + JSON.stringify(Object.keys(props || {})) + ' sessionId=' + JSON.stringify(props && (props.sessionId || (props.entry && props.entry.sessionId)))); } catch {} return React.createElement(QuotaPanel, { t: t, slotSessionId: props && (props.sessionId || (props.entry && props.entry.sessionId)) }); }
|
|
1366
1374
|
));
|
|
1367
1375
|
}
|
|
1368
1376
|
|
package/src/index.ts
CHANGED
|
@@ -1942,8 +1942,24 @@ export function apply(ctx, config: Record<string, any> = {}) {
|
|
|
1942
1942
|
catalog
|
|
1943
1943
|
});
|
|
1944
1944
|
if (endpoint === 'specs') {
|
|
1945
|
+
try {
|
|
1946
|
+
const fsp2 = await import('node:fs/promises');
|
|
1947
|
+
fsMod.mkdirSync(chatgptDshStoreDir(), { recursive: true });
|
|
1948
|
+
const dbg = path.join(chatgptDshStoreDir(), 'debug.log');
|
|
1949
|
+
await fsp2.appendFile(dbg, new Date().toISOString() + ' specs rows=[' + rows.map(r2 => r2.id + ':' + r2.kind).join(',') + ']\n').catch(() => {});
|
|
1950
|
+
} catch {}
|
|
1945
1951
|
return { ok: true, value: { rows: rows.map(rowSpec), refreshMs } };
|
|
1946
1952
|
}
|
|
1953
|
+
if (endpoint === 'client-log') {
|
|
1954
|
+
try {
|
|
1955
|
+
const fsp2 = await import('node:fs/promises');
|
|
1956
|
+
const line = payload && typeof payload.line === 'string' ? payload.line : '';
|
|
1957
|
+
fsMod.mkdirSync(chatgptDshStoreDir(), { recursive: true });
|
|
1958
|
+
const dbg = path.join(chatgptDshStoreDir(), 'debug.log');
|
|
1959
|
+
await fsp2.appendFile(dbg, new Date().toISOString() + ' client: ' + line + '\n').catch(() => {});
|
|
1960
|
+
} catch {}
|
|
1961
|
+
return { ok: true, value: { logged: true } };
|
|
1962
|
+
}
|
|
1947
1963
|
if (endpoint === 'fetch-all') {
|
|
1948
1964
|
const overrides = {};
|
|
1949
1965
|
const overrideErrors = {};
|