@lornatang/dsh-caveman 0.1.4 → 0.1.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/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/compression.js +14 -5
- package/lib/native.js +24 -4
- package/package.json +1 -1
- package/scripts/learn-checksums.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.5 - 2026-11-19
|
|
4
|
+
|
|
5
|
+
- Cache the verified local runtime identity for one second per endpoint, so a tool call performs one health check instead of two while a runtime restart still invalidates sessions.
|
|
6
|
+
- Skip the second read-and-hash of a read tool input when the runtime response carries no ccr:// recovery context.
|
|
7
|
+
- Cache per-session surface manifests by content generation and node count, so unchanged surfaces are not re-hashed on every agent step.
|
|
8
|
+
- Keep the verified analyzer binaries attached to this release under the new version.
|
|
9
|
+
|
|
3
10
|
## 0.1.4 - 2026-11-19
|
|
4
11
|
|
|
5
12
|
- Restore the POSIX native-socket retry: a socket the runtime has not created yet is retried instead of disabling the call, while a replaced or foreign-owned path is still refused before any request is sent.
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ git clone https://github.com/Lornatang/dsh-caveman.git
|
|
|
43
43
|
cd dsh-caveman
|
|
44
44
|
npm ci
|
|
45
45
|
npm pack
|
|
46
|
-
dsh plugin --profile <name> add ./lornatang-dsh-caveman-0.1.
|
|
46
|
+
dsh plugin --profile <name> add ./lornatang-dsh-caveman-0.1.5.tgz
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
The `add` command composes the bundle into the profile. Its patches insert the `caveman` row, three Cavecrew presets, and their delegation tools. Restart DSH after `add` or `remove` so the profile reloads its composition.
|
package/README.zh.md
CHANGED
|
@@ -43,7 +43,7 @@ git clone https://github.com/Lornatang/dsh-caveman.git
|
|
|
43
43
|
cd dsh-caveman
|
|
44
44
|
npm ci
|
|
45
45
|
npm pack
|
|
46
|
-
dsh plugin --profile <name> add ./lornatang-dsh-caveman-0.1.
|
|
46
|
+
dsh plugin --profile <name> add ./lornatang-dsh-caveman-0.1.5.tgz
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
`add` 命令把 bundle 组合进 profile。patch 会插入 `caveman` 行、三个 Cavecrew 预设及其委派工具。`add` 或 `remove` 后重启 DSH,使 profile 重新加载配置。
|
package/lib/compression.js
CHANGED
|
@@ -151,14 +151,23 @@ export function resolveOriginalResult(session, event) {
|
|
|
151
151
|
cache.set(item, current);
|
|
152
152
|
return current;
|
|
153
153
|
}
|
|
154
|
+
const manifests = new WeakMap();
|
|
154
155
|
function manifestFor(session) {
|
|
155
|
-
|
|
156
|
+
const generation = session.surface.contentGeneration;
|
|
157
|
+
const count = session.surface.nodes.length;
|
|
158
|
+
const cached = manifests.get(session);
|
|
159
|
+
if (cached && cached.generation === generation && cached.count === count)
|
|
160
|
+
return cached.value;
|
|
161
|
+
const entries = session.surface.nodes.map(seq => {
|
|
156
162
|
let event = session.eventAt(seq);
|
|
157
163
|
if (event.type === 'tool/result')
|
|
158
164
|
event = resolveOriginalResult(session, event);
|
|
159
165
|
const data = event.type === 'user/message' ? event.data : 'message' in event.data ? event.data.message : event.data;
|
|
160
166
|
return { id: `seq-${event.seq}`, sha256: createHash('sha256').update(JSON.stringify(data)).digest('hex') };
|
|
161
167
|
});
|
|
168
|
+
const value = { entries, bytes: Buffer.byteLength(JSON.stringify(entries), 'utf8') };
|
|
169
|
+
manifests.set(session, { generation, count, value });
|
|
170
|
+
return value;
|
|
162
171
|
}
|
|
163
172
|
function surfaceMatchesManifest(session, manifest) {
|
|
164
173
|
if (session.surface.nodes.length !== manifest.length)
|
|
@@ -372,7 +381,7 @@ export function registerCompression(ctx, endpoint, automatic) {
|
|
|
372
381
|
}
|
|
373
382
|
const manifest = manifestFor(session);
|
|
374
383
|
const maxSegments = capabilities.limits.max_segments ?? 256;
|
|
375
|
-
const byteBudget = Math.max(0, capabilities.limits.request_bytes -
|
|
384
|
+
const byteBudget = Math.max(0, capabilities.limits.request_bytes - manifest.bytes - 16_384);
|
|
376
385
|
const prepared = eligible.map(candidate => {
|
|
377
386
|
const sourceId = `seq-${resolveOriginalResult(session, candidate.event).seq}`;
|
|
378
387
|
const segments = candidate.blocks.map(block => ({
|
|
@@ -385,7 +394,7 @@ export function registerCompression(ctx, endpoint, automatic) {
|
|
|
385
394
|
try {
|
|
386
395
|
for (const group of batches) {
|
|
387
396
|
signal.throwIfAborted();
|
|
388
|
-
if (!surfaceMatchesManifest(session, manifest)) {
|
|
397
|
+
if (!surfaceMatchesManifest(session, manifest.entries)) {
|
|
389
398
|
restore(session);
|
|
390
399
|
return decision;
|
|
391
400
|
}
|
|
@@ -394,13 +403,13 @@ export function registerCompression(ctx, endpoint, automatic) {
|
|
|
394
403
|
continue;
|
|
395
404
|
const segments = candidates.flatMap(candidate => candidate.segments);
|
|
396
405
|
const optimization = await runtime.optimize({
|
|
397
|
-
scope, binding, adapter: ADAPTER, manifest,
|
|
406
|
+
scope, binding, adapter: ADAPTER, manifest: manifest.entries,
|
|
398
407
|
candidates: segments,
|
|
399
408
|
model: { provider: modelSelection.provider, id: modelSelection.model, protocol: 'dsh' },
|
|
400
409
|
recoveryOverheadText: JSON.stringify(published), signal,
|
|
401
410
|
});
|
|
402
411
|
signal.throwIfAborted();
|
|
403
|
-
if (!surfaceMatchesManifest(session, manifest) || ctx.tools.get(tool.name, agent, toolSet) !== tool) {
|
|
412
|
+
if (!surfaceMatchesManifest(session, manifest.entries) || ctx.tools.get(tool.name, agent, toolSet) !== tool) {
|
|
404
413
|
restore(session);
|
|
405
414
|
return decision;
|
|
406
415
|
}
|
package/lib/native.js
CHANGED
|
@@ -204,15 +204,32 @@ async function inputState(ctx, cwd, input, signal) {
|
|
|
204
204
|
return undefined;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
+
const RUNTIME_VERIFICATION_TTL_MS = 1_000;
|
|
208
|
+
const verifiedInstances = new Map();
|
|
207
209
|
async function runtimeInstance(endpoint, home, signal) {
|
|
208
|
-
|
|
210
|
+
signal?.throwIfAborted();
|
|
211
|
+
const key = `${endpoint}\u0000${home}`;
|
|
212
|
+
const cached = verifiedInstances.get(key);
|
|
213
|
+
if (cached && cached.expires > Date.now())
|
|
214
|
+
return cached.token;
|
|
215
|
+
if (!await verifiedRuntime(endpoint, process.env, signal)) {
|
|
216
|
+
verifiedInstances.delete(key);
|
|
209
217
|
return undefined;
|
|
218
|
+
}
|
|
210
219
|
try {
|
|
211
220
|
const port = Number(new URL(endpoint).port || 80);
|
|
212
221
|
const token = JSON.parse(readFileSync(join(home, 'run', `${port}.json`), 'utf8')).instance_token;
|
|
213
|
-
|
|
222
|
+
if (typeof token !== 'string' || !token) {
|
|
223
|
+
verifiedInstances.delete(key);
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
if (verifiedInstances.size >= 32)
|
|
227
|
+
verifiedInstances.delete(verifiedInstances.keys().next().value);
|
|
228
|
+
verifiedInstances.set(key, { token, expires: Date.now() + RUNTIME_VERIFICATION_TTL_MS });
|
|
229
|
+
return token;
|
|
214
230
|
}
|
|
215
231
|
catch {
|
|
232
|
+
verifiedInstances.delete(key);
|
|
216
233
|
return undefined;
|
|
217
234
|
}
|
|
218
235
|
}
|
|
@@ -346,16 +363,19 @@ export function registerNative(ctx, endpoint, policy) {
|
|
|
346
363
|
const before = await nativeCall(home, { ...base, event: { type: 'tool.before', timestamp_ms: Date.now() },
|
|
347
364
|
tool: { name: exec.name, input: exec.arguments, ...(beforeState ? { input_state: beforeState } : {}) } }, exec.signal);
|
|
348
365
|
const result = await next();
|
|
366
|
+
const recoveryContext = before?.context?.includes('ccr://') ?? false;
|
|
349
367
|
let afterState;
|
|
350
368
|
if (!exec.signal.aborted && await runtimeInstance(endpoint, home, exec.signal) === state.instance) {
|
|
351
|
-
|
|
369
|
+
// The comparison only gates a ccr:// reminder, so skip the second full
|
|
370
|
+
// read-and-hash when the before response carries no recovery context.
|
|
371
|
+
afterState = exec.name === 'read' && recoveryContext ? await inputState(ctx, state.session.cwd, exec.arguments, exec.signal) : undefined;
|
|
352
372
|
const textOnly = result.content.every(block => block.type === 'text') && result.content.reduce((sum, block) => sum + (block.type === 'text' ? Buffer.byteLength(block.text, 'utf8') : 0), 0) <= 1_500_000;
|
|
353
373
|
const content = textOnly ? result.content.map(block => block.type === 'text' ? block.text : '').join('\n') : '';
|
|
354
374
|
await nativeCall(home, { ...base, event: { type: result.isError ? 'tool.failure' : 'tool.after', timestamp_ms: Date.now() },
|
|
355
375
|
tool: { name: exec.name, input: exec.arguments, ...(afterState ? { input_state: afterState } : {}), ...(content ? { output: Buffer.from(content).toString('base64') } : {}) } }, exec.signal);
|
|
356
376
|
}
|
|
357
377
|
const canRecover = exec.toolSet && ctx.tools.get('mcp__caveman__caveman_retrieve', exec.agent, exec.toolSet);
|
|
358
|
-
if (!policy.core || state.specialized || !before?.context || (
|
|
378
|
+
if (!policy.core || state.specialized || !before?.context || (recoveryContext && (!canRecover || !beforeState || beforeState !== afterState)) || exec.signal.aborted)
|
|
359
379
|
return result;
|
|
360
380
|
const reminder = createUserMessage({ source: { kind: 'dsh-caveman-native', form: 'notice' }, content: [{ type: 'text', text: before.context }] });
|
|
361
381
|
return { ...result, additionalContexts: [...result.additionalContexts ?? [], reminder] };
|
package/package.json
CHANGED