dsh-ustc-quota 2.0.4 → 2.0.5
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/client.js +1 -1
- package/index.js +15 -4
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -55,7 +55,7 @@ window.__ModuleLoader__.load({
|
|
|
55
55
|
return 0;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const CLIENT_VERSION = '2.0.
|
|
58
|
+
const CLIENT_VERSION = '2.0.5';
|
|
59
59
|
const UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
60
60
|
const CLIENT_VERSION_KEY = `${NS}:client-version`;
|
|
61
61
|
const CLIENT_RELOAD_KEY = `${NS}:client-reload`;
|
package/index.js
CHANGED
|
@@ -163,7 +163,7 @@ function rejectGuard(response, reason) {
|
|
|
163
163
|
const UPDATE_PATH = '/plugins/dsh-ustc-quota/update';
|
|
164
164
|
const UPDATE_APPLY_PATH = '/plugins/dsh-ustc-quota/update/apply';
|
|
165
165
|
const UPDATE_TOKEN_TTL_MS = 30 * 60 * 1000;
|
|
166
|
-
const PLUGIN_VERSION = '2.0.
|
|
166
|
+
const PLUGIN_VERSION = '2.0.5';
|
|
167
167
|
const KEY_INFO_PATH = 'key/info';
|
|
168
168
|
const USER_INFO_PATH = 'user/info';
|
|
169
169
|
const DISCOVERY_TTL_MS = 10_000;
|
|
@@ -203,6 +203,11 @@ export function apply(ctx, config) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
let lastPoolMove = null
|
|
206
|
+
const poolMoves = []
|
|
207
|
+
const noteMove = (record) => {
|
|
208
|
+
poolMoves.unshift(record)
|
|
209
|
+
while (poolMoves.length > 40) poolMoves.pop()
|
|
210
|
+
}
|
|
206
211
|
// Observation only: the waterfall hands us the frozen options and the next() chain, so we
|
|
207
212
|
// record and pass through. Rewriting here is impossible (the host's fallback keeps the
|
|
208
213
|
// original options), which is why selection happens through selectModel instead.
|
|
@@ -252,7 +257,8 @@ export function apply(ctx, config) {
|
|
|
252
257
|
...(decision.reasoningEffort === undefined ? {} : { reasoningEffort: decision.reasoningEffort }),
|
|
253
258
|
})
|
|
254
259
|
}
|
|
255
|
-
lastPoolMove = { sessionId, from: current.provider, to: decision.provider, reason: decision.reason, changed: decision.changed, step, at: Date.now() }
|
|
260
|
+
lastPoolMove = { sessionId, from: current.provider, to: decision.provider, reason: decision.reason, changed: decision.changed, delegated: depth > 0, depth, step, at: Date.now() }
|
|
261
|
+
noteMove(lastPoolMove)
|
|
256
262
|
}
|
|
257
263
|
} catch { /* never break a step */ }
|
|
258
264
|
return next()
|
|
@@ -314,7 +320,7 @@ export function apply(ctx, config) {
|
|
|
314
320
|
kind: 'exact',
|
|
315
321
|
path: '/plugins/dsh-ustc-quota/pool/last',
|
|
316
322
|
handler: guarded((request, response) => {
|
|
317
|
-
const body = JSON.stringify({ ok: true, last: lastCall, move: lastPoolMove })
|
|
323
|
+
const body = JSON.stringify({ ok: true, last: lastCall, move: lastPoolMove, moves: poolMoves.slice(0, 25) })
|
|
318
324
|
response.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
|
|
319
325
|
response.end(body)
|
|
320
326
|
}, ['GET']),
|
|
@@ -451,6 +457,11 @@ export function apply(ctx, config) {
|
|
|
451
457
|
if (!controller || typeof controller.create !== 'function' || typeof controller.prompt !== 'function') {
|
|
452
458
|
throw new Error('no-session-controller')
|
|
453
459
|
}
|
|
460
|
+
// Callers may supply their own probe prompt (base64, because HTTP headers are
|
|
461
|
+
// latin1): that is how a delegation can be triggered without driving the UI.
|
|
462
|
+
const probeText = typeof request.headers['x-probe-b64'] === 'string' && request.headers['x-probe-b64'] !== ''
|
|
463
|
+
? Buffer.from(request.headers['x-probe-b64'], 'base64').toString('utf8')
|
|
464
|
+
: '自动验收:请只回复 OK'
|
|
454
465
|
const created = await controller.create({})
|
|
455
466
|
const sessionId = created && created.sessionId ? created.sessionId : null
|
|
456
467
|
if (sessionId === null) throw new Error('create-returned-no-session')
|
|
@@ -459,7 +470,7 @@ export function apply(ctx, config) {
|
|
|
459
470
|
requestId: 'lb-probe-' + Date.now(),
|
|
460
471
|
sessionId,
|
|
461
472
|
mode: 'queue',
|
|
462
|
-
content: [{ type: 'text', text:
|
|
473
|
+
content: [{ type: 'text', text: probeText }],
|
|
463
474
|
}, new AbortController().signal)
|
|
464
475
|
result.accepted = accepted !== null && accepted !== undefined
|
|
465
476
|
result.ok = true
|