dsh-as-aistudio 0.5.12 → 0.5.13
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/CHANGELOG.md +2 -0
- package/package.json +1 -1
- package/src/client.js +2 -2
- package/src/components.js +1 -1
- package/src/vendor/host/dsh-rerun-turn.js +36 -6
- package/src/vendor/versions.json +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-as-aistudio",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"description": "Google-AI-Studio-style turn controls for DeepSeek Harness, in one install: edit a prompt and re-run it, re-run a reply in place, delete a turn from the model context, render sent prompts as Markdown, and trim idle session logs on boot. Self-contained: the plugin list shows this one row, and the five components (four actions + one maintenance) are vendored inside it - installing the studio installs nothing else.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/client.js
CHANGED
|
@@ -5530,7 +5530,7 @@ window.__ModuleLoader__.load({
|
|
|
5530
5530
|
const ROUTE_PREFIX = '/dsh-rerun-turn'
|
|
5531
5531
|
|
|
5532
5532
|
/** Keep in sync with package.json and lib/index.js. */
|
|
5533
|
-
const PLUGIN_VERSION = '0.2.
|
|
5533
|
+
const PLUGIN_VERSION = '0.2.11'
|
|
5534
5534
|
|
|
5535
5535
|
// --- copy -----------------------------------------------------------------
|
|
5536
5536
|
|
|
@@ -10168,7 +10168,7 @@ window.__ModuleLoader__.load({
|
|
|
10168
10168
|
const NS = 'dsh-as-aistudio'
|
|
10169
10169
|
|
|
10170
10170
|
/** Keep in sync with package.json and src/components.js. */
|
|
10171
|
-
const PLUGIN_VERSION = '0.5.
|
|
10171
|
+
const PLUGIN_VERSION = '0.5.13'
|
|
10172
10172
|
|
|
10173
10173
|
/** Presence marker the live verifier reads. */
|
|
10174
10174
|
const DEBUG_KEY = '__DSH_AS_AISTUDIO__'
|
package/src/components.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
export const STUDIO_ID = 'dsh-as-aistudio'
|
|
27
27
|
|
|
28
28
|
/** Keep in sync with package.json and src/client.js. */
|
|
29
|
-
export const STUDIO_VERSION = '0.5.
|
|
29
|
+
export const STUDIO_VERSION = '0.5.13'
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* The AI Studio action strip this studio composes, in the order the user meets
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// dsh-rerun-turn host half (dsh-rerun-turn.js), VENDORED by tools/vendor.mjs - DO NOT EDIT.
|
|
2
2
|
//
|
|
3
|
-
// Source: ../dsh-rerun-turn/lib/index.js (v0.2.
|
|
3
|
+
// Source: ../dsh-rerun-turn/lib/index.js (v0.2.11, sha256 e795e5c3eb214e8f)
|
|
4
4
|
// Regenerate with `npm run vendor`; test/sync.test.js fails when this is stale.
|
|
5
5
|
//
|
|
6
6
|
// src/shell.js imports the copy named after the component, which is why the
|
|
@@ -90,7 +90,7 @@ export const PLUGIN_ID = 'dsh-rerun-turn'
|
|
|
90
90
|
export const name = PLUGIN_ID
|
|
91
91
|
|
|
92
92
|
/** Keep in sync with package.json and lib/client.js. */
|
|
93
|
-
export const PLUGIN_VERSION = '0.2.
|
|
93
|
+
export const PLUGIN_VERSION = '0.2.11'
|
|
94
94
|
|
|
95
95
|
const ROUTE_PREFIX = '/dsh-rerun-turn'
|
|
96
96
|
// A session id is an OPAQUE string to DSH: the host's own schema is
|
|
@@ -1862,6 +1862,12 @@ function eventsFromLive(session) {
|
|
|
1862
1862
|
// Live-preferred read through the public query service; the live session's own
|
|
1863
1863
|
// snapshot is the fallback when the service is absent.
|
|
1864
1864
|
async function readEvents(ctx, sessionId) {
|
|
1865
|
+
// 打开着的会话先读它自己的内存快照:`snapshotEvents()` 是 O(1) 的引用,
|
|
1866
|
+
// 而 `readSession` 会把整份日志重新解码一遍(大会话实测几十秒)。
|
|
1867
|
+
// 面板可见时宿主一定持有这个 session,所以这是最常走的路径。
|
|
1868
|
+
const live = findLiveSession(ctx, sessionId)
|
|
1869
|
+
const fromLive = eventsFromLive(live)
|
|
1870
|
+
if (Array.isArray(fromLive) && fromLive.length > 0) return fromLive
|
|
1865
1871
|
const query = ctx.get('sessionQuery')
|
|
1866
1872
|
if (query && typeof query.readSession === 'function') {
|
|
1867
1873
|
try {
|
|
@@ -1871,7 +1877,6 @@ async function readEvents(ctx, sessionId) {
|
|
|
1871
1877
|
// fall through to the live snapshot
|
|
1872
1878
|
}
|
|
1873
1879
|
}
|
|
1874
|
-
const live = findLiveSession(ctx, sessionId)
|
|
1875
1880
|
return eventsFromLive(live) ?? null
|
|
1876
1881
|
}
|
|
1877
1882
|
|
|
@@ -2337,6 +2342,33 @@ function emptyState(config) {
|
|
|
2337
2342
|
}
|
|
2338
2343
|
}
|
|
2339
2344
|
|
|
2345
|
+
|
|
2346
|
+
// /state 的派生结果缓存:同一份事件流被反复请求时(轮询、行增长、多个标签页),
|
|
2347
|
+
// 只算一次。键是「事件数 + 最后 seq」——日志只追加,这两个数变了才重算。
|
|
2348
|
+
const STATE_CACHE_LIMIT = 8
|
|
2349
|
+
const stateCache = new Map()
|
|
2350
|
+
|
|
2351
|
+
/**
|
|
2352
|
+
* 取出(或计算)一份事件流的派生结果。
|
|
2353
|
+
*
|
|
2354
|
+
* @param {string} sessionId - 会话 id。
|
|
2355
|
+
* @param {object[]} events - 事件数组。
|
|
2356
|
+
* @returns {{ folded: object, ledger: object, replies: object[] }} 派生结果。
|
|
2357
|
+
*/
|
|
2358
|
+
function derivedOf(sessionId, events) {
|
|
2359
|
+
const lastSeq = events.length > 0 ? events[events.length - 1].seq : -1
|
|
2360
|
+
const signature = events.length + ':' + lastSeq
|
|
2361
|
+
const cached = stateCache.get(sessionId)
|
|
2362
|
+
if (cached !== undefined && cached.signature === signature) return cached.value
|
|
2363
|
+
const folded = foldSurface(events)
|
|
2364
|
+
const ledger = rerunLedger(events)
|
|
2365
|
+
const replies = rerunnableReplies(events, folded.nodes)
|
|
2366
|
+
const value = { folded, ledger, replies }
|
|
2367
|
+
stateCache.set(sessionId, { signature, value })
|
|
2368
|
+
if (stateCache.size > STATE_CACHE_LIMIT) stateCache.delete(stateCache.keys().next().value)
|
|
2369
|
+
return value
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2340
2372
|
async function stateOf(ctx, sessionId, config) {
|
|
2341
2373
|
const events = await readEvents(ctx, sessionId)
|
|
2342
2374
|
if (!events) {
|
|
@@ -2344,10 +2376,8 @@ async function stateOf(ctx, sessionId, config) {
|
|
|
2344
2376
|
noteRequest({ kind: 'state', sessionId, ok: true, code: 'session-empty' })
|
|
2345
2377
|
return emptyState(config)
|
|
2346
2378
|
}
|
|
2347
|
-
const folded =
|
|
2348
|
-
const ledger = rerunLedger(events)
|
|
2379
|
+
const { folded, ledger, replies } = derivedOf(sessionId, events)
|
|
2349
2380
|
const live = findLiveSession(ctx, sessionId)
|
|
2350
|
-
const replies = rerunnableReplies(events, folded.nodes)
|
|
2351
2381
|
const busy = isBusy(events)
|
|
2352
2382
|
const rerunning = locked(sessionId)
|
|
2353
2383
|
const current = progress.get(sessionId) || null
|