@lornatang/dsh-caveman 0.1.7 → 0.1.10
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 +16 -0
- package/LICENSE +202 -202
- package/LICENSE-MIT +21 -21
- package/NOTICE +51 -51
- package/README.md +5 -3
- package/README.zh.md +5 -3
- package/cordis.patch.yml +3 -3
- package/examples/caveman-anthropic.patch.yml +14 -14
- package/examples/caveman-auto.patch.yml +15 -15
- package/lib/cavecrew.js +53 -26
- package/lib/compression.js +8 -14
- package/lib/native.js +33 -41
- package/lib/runtime.js +14 -7
- package/lib/types/native.d.ts +2 -2
- package/lib/types/runtime.d.ts +6 -0
- package/package.json +5 -4
- package/presets/cavecrew.patch.yml +54 -54
- package/scripts/benchmark.mjs +79 -79
- package/scripts/caveman-cli.mjs +30 -30
- package/scripts/learn-binary.mjs +82 -82
- package/scripts/learn-checksums.json +7 -7
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# Merge this provider into the existing llm-pi-ai providers map.
|
|
2
|
-
# Replace the model id with one available to the Anthropic credential.
|
|
3
|
-
- id: llm-pi-ai
|
|
4
|
-
config:
|
|
5
|
-
providers:
|
|
6
|
-
caveman-anthropic:
|
|
7
|
-
displayName: Caveman Anthropic
|
|
8
|
-
api: anthropic-messages
|
|
9
|
-
baseURL: 'http://127.0.0.1:8787'
|
|
10
|
-
apiKeyEnv: ANTHROPIC_API_KEY
|
|
11
|
-
cacheRetention: short
|
|
12
|
-
models:
|
|
13
|
-
- id: claude-sonnet-4-5
|
|
14
|
-
name: Claude Sonnet 4.5
|
|
1
|
+
# Merge this provider into the existing llm-pi-ai providers map.
|
|
2
|
+
# Replace the model id with one available to the Anthropic credential.
|
|
3
|
+
- id: llm-pi-ai
|
|
4
|
+
config:
|
|
5
|
+
providers:
|
|
6
|
+
caveman-anthropic:
|
|
7
|
+
displayName: Caveman Anthropic
|
|
8
|
+
api: anthropic-messages
|
|
9
|
+
baseURL: 'http://127.0.0.1:8787'
|
|
10
|
+
apiKeyEnv: ANTHROPIC_API_KEY
|
|
11
|
+
cacheRetention: short
|
|
12
|
+
models:
|
|
13
|
+
- id: claude-sonnet-4-5
|
|
14
|
+
name: Claude Sonnet 4.5
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# Example only: merge this provider with the existing llm-pi-ai providers.
|
|
2
|
-
# Replacing the providers map would remove the other configured routes.
|
|
3
|
-
- id: llm-pi-ai
|
|
4
|
-
config:
|
|
5
|
-
providers:
|
|
6
|
-
caveman-auto:
|
|
7
|
-
displayName: Caveman Auto
|
|
8
|
-
api: openai-completions
|
|
9
|
-
baseURL: 'http://127.0.0.1:8787/v1'
|
|
10
|
-
apiKeyEnv: OPENAI_API_KEY
|
|
11
|
-
headers:
|
|
12
|
-
x-cave-agent: dsh
|
|
13
|
-
models:
|
|
14
|
-
- id: caveman-auto
|
|
15
|
-
name: Caveman Auto
|
|
1
|
+
# Example only: merge this provider with the existing llm-pi-ai providers.
|
|
2
|
+
# Replacing the providers map would remove the other configured routes.
|
|
3
|
+
- id: llm-pi-ai
|
|
4
|
+
config:
|
|
5
|
+
providers:
|
|
6
|
+
caveman-auto:
|
|
7
|
+
displayName: Caveman Auto
|
|
8
|
+
api: openai-completions
|
|
9
|
+
baseURL: 'http://127.0.0.1:8787/v1'
|
|
10
|
+
apiKeyEnv: OPENAI_API_KEY
|
|
11
|
+
headers:
|
|
12
|
+
x-cave-agent: dsh
|
|
13
|
+
models:
|
|
14
|
+
- id: caveman-auto
|
|
15
|
+
name: Caveman Auto
|
package/lib/cavecrew.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { normalize } from 'node:path';
|
|
3
2
|
import z from '@deepseek-ai/schemastery';
|
|
4
3
|
import { registerCavecrewGit } from './cavecrew-git.js';
|
|
5
4
|
export const name = 'cavecrew';
|
|
@@ -7,6 +6,57 @@ export const inject = ['tools', 'systemPrompt', 'llm'];
|
|
|
7
6
|
export const Config = z.object({
|
|
8
7
|
role: z.union([z.const('investigator'), z.const('builder'), z.const('reviewer')]).required(),
|
|
9
8
|
});
|
|
9
|
+
function limitBuilderEdits(ctx) {
|
|
10
|
+
const byAgent = new WeakMap();
|
|
11
|
+
const active = new WeakMap();
|
|
12
|
+
ctx.on('tools/execute', async (exec, next) => {
|
|
13
|
+
if (exec.name !== 'edit' || !exec.agent)
|
|
14
|
+
return next();
|
|
15
|
+
const targets = byAgent.get(exec.agent) ?? new Map();
|
|
16
|
+
byAgent.set(exec.agent, targets);
|
|
17
|
+
const attempt = { targets };
|
|
18
|
+
active.set(exec, attempt);
|
|
19
|
+
try {
|
|
20
|
+
return await next();
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
active.delete(exec);
|
|
24
|
+
const reservation = attempt.reservation;
|
|
25
|
+
if (reservation) {
|
|
26
|
+
reservation.state.pending -= 1;
|
|
27
|
+
if (!reservation.state.committed && reservation.state.pending === 0)
|
|
28
|
+
targets.delete(reservation.key);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
// The filesystem tool supplies the resolved target that it will actually edit.
|
|
33
|
+
ctx.on('fs/edit-intent', async (target, actor, next) => {
|
|
34
|
+
const attempt = actor ? active.get(actor) : undefined;
|
|
35
|
+
if (!attempt)
|
|
36
|
+
return next();
|
|
37
|
+
const key = target.targetKey;
|
|
38
|
+
if (attempt.reservation) {
|
|
39
|
+
if (attempt.reservation.key !== key)
|
|
40
|
+
throw new Error('Cavecrew edit cannot change its resolved target.');
|
|
41
|
+
return next();
|
|
42
|
+
}
|
|
43
|
+
let state = attempt.targets.get(key);
|
|
44
|
+
if (!state) {
|
|
45
|
+
if (attempt.targets.size >= 2)
|
|
46
|
+
throw new Error('Cavecrew builder is limited to two file paths.');
|
|
47
|
+
state = { pending: 0, committed: false };
|
|
48
|
+
attempt.targets.set(key, state);
|
|
49
|
+
}
|
|
50
|
+
state.pending += 1;
|
|
51
|
+
attempt.reservation = { key, state };
|
|
52
|
+
return next();
|
|
53
|
+
}, { prepend: true });
|
|
54
|
+
ctx.on('fs/observed', (target, observation, actor) => {
|
|
55
|
+
const reservation = actor ? active.get(actor)?.reservation : undefined;
|
|
56
|
+
if (reservation?.key === target.targetKey && observation.kind === 'present')
|
|
57
|
+
reservation.state.committed = true;
|
|
58
|
+
}, { prepend: true });
|
|
59
|
+
}
|
|
10
60
|
/** Install one original Cavecrew persona and keep its agent's tools bounded. */
|
|
11
61
|
export async function apply(ctx, config) {
|
|
12
62
|
const original = await readFile(new URL(`../vendor/caveman/agents/cavecrew-${config.role}.md`, import.meta.url), 'utf8');
|
|
@@ -32,11 +82,6 @@ export async function apply(ctx, config) {
|
|
|
32
82
|
});
|
|
33
83
|
}
|
|
34
84
|
const permitted = new Set(allowed);
|
|
35
|
-
const edited = new WeakMap();
|
|
36
|
-
const editKey = (value) => {
|
|
37
|
-
const normalized = normalize(value);
|
|
38
|
-
return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
|
|
39
|
-
};
|
|
40
85
|
ctx.tools.guard(exec => {
|
|
41
86
|
if (!permitted.has(exec.name))
|
|
42
87
|
return `Cavecrew ${config.role} does not permit ${exec.name}.`;
|
|
@@ -46,28 +91,10 @@ export async function apply(ctx, config) {
|
|
|
46
91
|
!('file_path' in exec.arguments) || typeof exec.arguments.file_path !== 'string' || !exec.arguments.file_path.trim()) {
|
|
47
92
|
return 'Cavecrew builder requires an existing file path.';
|
|
48
93
|
}
|
|
49
|
-
const path = editKey(exec.arguments.file_path);
|
|
50
|
-
const paths = edited.get(exec.agent) ?? new Set();
|
|
51
|
-
if (!paths.has(path)) {
|
|
52
|
-
if (paths.size >= 2)
|
|
53
|
-
return 'Cavecrew builder is limited to two file paths.';
|
|
54
|
-
paths.add(path);
|
|
55
|
-
edited.set(exec.agent, paths);
|
|
56
|
-
}
|
|
57
94
|
return undefined;
|
|
58
95
|
});
|
|
59
|
-
if (config.role === 'builder')
|
|
60
|
-
|
|
61
|
-
ctx.on('tools/execute', async (exec, next) => {
|
|
62
|
-
const result = await next();
|
|
63
|
-
if (exec.name !== 'edit' || !exec.agent || !result.isError ||
|
|
64
|
-
typeof exec.arguments !== 'object' || exec.arguments === null ||
|
|
65
|
-
!('file_path' in exec.arguments) || typeof exec.arguments.file_path !== 'string')
|
|
66
|
-
return result;
|
|
67
|
-
edited.get(exec.agent)?.delete(editKey(exec.arguments.file_path));
|
|
68
|
-
return result;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
96
|
+
if (config.role === 'builder')
|
|
97
|
+
limitBuilderEdits(ctx);
|
|
71
98
|
ctx.on('agent/created', async ({ agent }) => {
|
|
72
99
|
const available = allowed.filter(tool => ctx.tools.get(tool, agent) !== undefined);
|
|
73
100
|
agent.ctx.tools.restrict({ allow: available });
|
package/lib/compression.js
CHANGED
|
@@ -104,24 +104,18 @@ function fallbackPage(history, session, args) {
|
|
|
104
104
|
const offset = args.offset ?? 0;
|
|
105
105
|
if (offset > bytes.length)
|
|
106
106
|
throw new Error('Recovery offset exceeds the original length');
|
|
107
|
-
|
|
108
|
-
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
109
|
-
let page;
|
|
110
|
-
for (let attempt = 0; attempt < 4 && end >= offset; attempt++, end--) {
|
|
111
|
-
try {
|
|
112
|
-
page = decoder.decode(bytes.subarray(offset, end));
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
catch { }
|
|
116
|
-
}
|
|
117
|
-
if (page === undefined)
|
|
107
|
+
if (offset < bytes.length && (bytes[offset] & 0xc0) === 0x80)
|
|
118
108
|
throw new Error('Recovery offset is not a UTF-8 boundary');
|
|
119
|
-
|
|
109
|
+
let end = Math.min(offset + (args.limit ?? 262144), bytes.length);
|
|
110
|
+
// A continuation byte at the end means the page would split a code point.
|
|
111
|
+
while (end < bytes.length && (bytes[end] & 0xc0) === 0x80)
|
|
112
|
+
end--;
|
|
113
|
+
const page = bytes.toString('utf8', offset, end);
|
|
120
114
|
return JSON.stringify({
|
|
121
115
|
schema_version: 1, handle: args.handle, source_id: original.sourceId, text: page,
|
|
122
116
|
original_sha256: createHash('sha256').update(bytes).digest('hex'), total_bytes: bytes.length,
|
|
123
|
-
complete: offset === 0 &&
|
|
124
|
-
next_offset:
|
|
117
|
+
complete: offset === 0 && end === bytes.length, kind: 'original_page', offset,
|
|
118
|
+
next_offset: end === bytes.length ? null : end,
|
|
125
119
|
});
|
|
126
120
|
}
|
|
127
121
|
const resultOrigins = new WeakMap();
|
package/lib/native.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { constants
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
3
|
import { lstat, open, realpath, stat } from 'node:fs/promises';
|
|
4
4
|
import { connect } from 'node:net';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
|
-
import { join, resolve
|
|
6
|
+
import { join, resolve } from 'node:path';
|
|
7
7
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
8
8
|
import { isDeepStrictEqual } from 'node:util';
|
|
9
9
|
import { createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
10
10
|
import { cavemanSessionId } from './attribution.js';
|
|
11
|
-
import {
|
|
11
|
+
import { verifiedRuntimeInstance } from './runtime.js';
|
|
12
12
|
import { isManagedTool } from './compression.js';
|
|
13
13
|
const profiles = new Set(['record-only', 'core', 'core-lean-build', 'ledger', 'ccr-masking', 'cache-aware', 'full-safe', 'full-max']);
|
|
14
14
|
const stopwords = new Set(['about', 'after', 'again', 'agent', 'before', 'build', 'change', 'code', 'could', 'create', 'does', 'from', 'have', 'help', 'implement', 'into', 'make', 'please', 'project', 'repository', 'should', 'spec', 'task', 'that', 'their', 'then', 'there', 'these', 'they', 'this', 'through', 'user', 'want', 'what', 'when', 'where', 'which', 'with', 'would', 'your']);
|
|
@@ -49,14 +49,11 @@ export function nativePrompt(prompt) {
|
|
|
49
49
|
const bytes = Buffer.from(prompt, 'utf8');
|
|
50
50
|
return { prompt: { bytes: bytes.length, sha256: `sha256:${createHash('sha256').update(bytes).digest('hex')}` }, task_profile: { type, terms: [...seen], continuation } };
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
52
|
+
/** Return the supported local socket endpoint, if available on this platform. */
|
|
53
53
|
export function nativeSocketPath(home, platform = process.platform) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
for (const char of win32.resolve(home))
|
|
58
|
-
folded += String.fromCodePoint(char.toLowerCase().codePointAt(0));
|
|
59
|
-
return `\\\\.\\pipe\\caveman-native-${createHash('sha256').update(folded).digest('hex').slice(0, 16)}`;
|
|
54
|
+
// The current Windows runtime has no pipe peer proof, and its HTTP health
|
|
55
|
+
// check only verifies the HTTP listener. Keep native events local to DSH.
|
|
56
|
+
return platform === 'win32' ? undefined : join(home, 'run', 'native.sock');
|
|
60
57
|
}
|
|
61
58
|
function validResponse(value) {
|
|
62
59
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
@@ -78,8 +75,6 @@ function validResponse(value) {
|
|
|
78
75
|
}
|
|
79
76
|
/** Refuse a replaced socket path before sending prompt terms or tool data over it. */
|
|
80
77
|
async function socketTrust(path) {
|
|
81
|
-
if (process.platform === 'win32')
|
|
82
|
-
return 'trusted';
|
|
83
78
|
try {
|
|
84
79
|
const info = await lstat(path);
|
|
85
80
|
if (!info.isSocket())
|
|
@@ -98,7 +93,7 @@ export async function nativeCall(home, request, signal) {
|
|
|
98
93
|
if (signal?.aborted)
|
|
99
94
|
return undefined;
|
|
100
95
|
const socketPath = nativeSocketPath(home);
|
|
101
|
-
if (await socketTrust(socketPath) === 'untrusted')
|
|
96
|
+
if (!socketPath || await socketTrust(socketPath) === 'untrusted')
|
|
102
97
|
return undefined;
|
|
103
98
|
const payload = Buffer.from(JSON.stringify(request) + '\n');
|
|
104
99
|
if (payload.length > 2 * 1024 * 1024)
|
|
@@ -207,39 +202,29 @@ async function inputState(ctx, cwd, input, signal) {
|
|
|
207
202
|
const RUNTIME_VERIFICATION_TTL_MS = 1_000;
|
|
208
203
|
const verifiedInstances = new Map();
|
|
209
204
|
async function runtimeInstance(endpoint, home, signal) {
|
|
210
|
-
signal?.throwIfAborted();
|
|
211
205
|
const key = `${endpoint}\u0000${home}`;
|
|
212
206
|
const cached = verifiedInstances.get(key);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (!await verifiedRuntime(endpoint, process.env, signal)) {
|
|
207
|
+
const instance = await verifiedRuntimeInstance(endpoint, home, signal, cached && cached.expires > Date.now() ? cached.instance : undefined);
|
|
208
|
+
if (!instance) {
|
|
216
209
|
verifiedInstances.delete(key);
|
|
217
210
|
return undefined;
|
|
218
211
|
}
|
|
219
|
-
|
|
220
|
-
const port = Number(new URL(endpoint).port || 80);
|
|
221
|
-
const token = JSON.parse(readFileSync(join(home, 'run', `${port}.json`), 'utf8')).instance_token;
|
|
222
|
-
if (typeof token !== 'string' || !token) {
|
|
223
|
-
verifiedInstances.delete(key);
|
|
224
|
-
return undefined;
|
|
225
|
-
}
|
|
212
|
+
if (instance !== cached?.instance) {
|
|
226
213
|
if (verifiedInstances.size >= 32)
|
|
227
214
|
verifiedInstances.delete(verifiedInstances.keys().next().value);
|
|
228
|
-
verifiedInstances.set(key, {
|
|
229
|
-
return token;
|
|
230
|
-
}
|
|
231
|
-
catch {
|
|
232
|
-
verifiedInstances.delete(key);
|
|
233
|
-
return undefined;
|
|
215
|
+
verifiedInstances.set(key, { instance, expires: Date.now() + RUNTIME_VERIFICATION_TTL_MS });
|
|
234
216
|
}
|
|
217
|
+
return instance.token;
|
|
235
218
|
}
|
|
236
219
|
/** Add dynamic native task context when the verified local runtime is running. */
|
|
237
220
|
export function registerNative(ctx, endpoint, policy) {
|
|
221
|
+
const home = process.env.CAVEMAN_HOME ?? join(homedir(), '.caveman');
|
|
222
|
+
if (!nativeSocketPath(home))
|
|
223
|
+
return;
|
|
238
224
|
const sessions = new WeakMap();
|
|
239
225
|
const owners = new WeakMap();
|
|
240
226
|
const selections = new WeakMap();
|
|
241
227
|
const pending = new Set();
|
|
242
|
-
const home = process.env.CAVEMAN_HOME ?? join(homedir(), '.caveman');
|
|
243
228
|
ctx.on('system-prompt/assemble', async (_assembly, context, next) => {
|
|
244
229
|
const result = await next();
|
|
245
230
|
if (context.agent && context.toolSet)
|
|
@@ -363,19 +348,26 @@ export function registerNative(ctx, endpoint, policy) {
|
|
|
363
348
|
const before = await nativeCall(home, { ...base, event: { type: 'tool.before', timestamp_ms: Date.now() },
|
|
364
349
|
tool: { name: exec.name, input: exec.arguments, ...(beforeState ? { input_state: beforeState } : {}) } }, exec.signal);
|
|
365
350
|
const result = await next();
|
|
351
|
+
if (exec.signal.aborted)
|
|
352
|
+
return result;
|
|
366
353
|
const recoveryContext = before?.context?.includes('ccr://') ?? false;
|
|
367
354
|
let afterState;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
355
|
+
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;
|
|
356
|
+
const content = textOnly ? result.content.map(block => block.type === 'text' ? block.text : '').join('\n') : '';
|
|
357
|
+
// A first read needs a fingerprint for future reuse. Only attach it
|
|
358
|
+
// when the same file state brackets a successful, recordable result.
|
|
359
|
+
if (beforeState && content && !result.isError) {
|
|
360
|
+
const observed = await inputState(ctx, state.session.cwd, exec.arguments, exec.signal);
|
|
361
|
+
if (observed === beforeState)
|
|
362
|
+
afterState = observed;
|
|
376
363
|
}
|
|
377
|
-
|
|
378
|
-
|
|
364
|
+
if (exec.signal.aborted || await runtimeInstance(endpoint, home, exec.signal) !== state.instance)
|
|
365
|
+
return result;
|
|
366
|
+
await nativeCall(home, { ...base, event: { type: result.isError ? 'tool.failure' : 'tool.after', timestamp_ms: Date.now() },
|
|
367
|
+
tool: { name: exec.name, input: exec.arguments, ...(afterState ? { input_state: afterState } : {}), ...(content ? { output: Buffer.from(content).toString('base64') } : {}) } }, exec.signal);
|
|
368
|
+
if (!policy.core || state.specialized || !before?.context || exec.signal.aborted)
|
|
369
|
+
return result;
|
|
370
|
+
if (recoveryContext && (!afterState || !exec.toolSet || !ctx.tools.get('mcp__caveman__caveman_retrieve', exec.agent, exec.toolSet)))
|
|
379
371
|
return result;
|
|
380
372
|
const reminder = createUserMessage({ source: { kind: 'dsh-caveman-native', form: 'notice' }, content: [{ type: 'text', text: before.context }] });
|
|
381
373
|
return { ...result, additionalContexts: [...result.additionalContexts ?? [], reminder] };
|
package/lib/runtime.js
CHANGED
|
@@ -162,30 +162,37 @@ async function directLocalFetch(input, init) {
|
|
|
162
162
|
}
|
|
163
163
|
/** Verify that the loopback listener matches the runtime's private run-state record. */
|
|
164
164
|
export async function verifiedRuntime(endpoint, env = process.env, signal) {
|
|
165
|
+
return Boolean(await verifiedRuntimeInstance(endpoint, env.CAVEMAN_HOME ?? join(homedir(), '.caveman'), signal));
|
|
166
|
+
}
|
|
167
|
+
/** Reuse a recent health check only while the private run-state record is unchanged. */
|
|
168
|
+
export async function verifiedRuntimeInstance(endpoint, home, signal, cached) {
|
|
165
169
|
signal?.throwIfAborted();
|
|
166
170
|
const url = localOrigin(endpoint);
|
|
167
171
|
if (!url)
|
|
168
|
-
return
|
|
172
|
+
return undefined;
|
|
169
173
|
const port = Number(url.port || 80);
|
|
170
174
|
try {
|
|
171
|
-
const
|
|
172
|
-
const
|
|
175
|
+
const runPath = join(home, 'run', `${port}.json`);
|
|
176
|
+
const record = readFileSync(runPath, 'utf8');
|
|
177
|
+
if (record === cached?.record)
|
|
178
|
+
return cached;
|
|
179
|
+
const state = JSON.parse(record);
|
|
173
180
|
if (!state || typeof state !== 'object' || Array.isArray(state))
|
|
174
|
-
return
|
|
181
|
+
return undefined;
|
|
175
182
|
const run = state;
|
|
176
183
|
if (run.schema !== 'caveman.proxy.run.v1' || (run.owner !== 'start' && run.owner !== 'wrap') ||
|
|
177
184
|
typeof run.pid !== 'number' || run.port !== port || typeof run.instance_token !== 'string' || !run.instance_token)
|
|
178
|
-
return
|
|
185
|
+
return undefined;
|
|
179
186
|
const timeout = AbortSignal.timeout(750);
|
|
180
187
|
const combined = signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
181
188
|
const health = await directLocalFetch(`${url.origin}/health/live`, { signal: combined });
|
|
182
189
|
const matches = health.ok && health.headers.get('x-caveman-instance') === run.instance_token;
|
|
183
190
|
await health.body?.cancel();
|
|
184
|
-
return matches;
|
|
191
|
+
return matches && readFileSync(runPath, 'utf8') === record ? { record, token: run.instance_token } : undefined;
|
|
185
192
|
}
|
|
186
193
|
catch {
|
|
187
194
|
signal?.throwIfAborted();
|
|
188
|
-
return
|
|
195
|
+
return undefined;
|
|
189
196
|
}
|
|
190
197
|
}
|
|
191
198
|
/** Guard every automatic middleware call against a different or replaced listener. */
|
package/lib/types/native.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare function nativePrompt(prompt: string): {
|
|
|
31
31
|
continuation: boolean;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
/**
|
|
35
|
-
export declare function nativeSocketPath(home: string, platform?: NodeJS.Platform): string;
|
|
34
|
+
/** Return the supported local socket endpoint, if available on this platform. */
|
|
35
|
+
export declare function nativeSocketPath(home: string, platform?: NodeJS.Platform): string | undefined;
|
|
36
36
|
export declare function nativeCall(home: string, request: object, signal?: AbortSignal): Promise<NativeResponse | undefined>;
|
|
37
37
|
/** Add dynamic native task context when the verified local runtime is running. */
|
|
38
38
|
export declare function registerNative(ctx: Context, endpoint: string, policy: {
|
package/lib/types/runtime.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ export declare function runtimeSettings(env?: NodeJS.ProcessEnv): {
|
|
|
18
18
|
export declare function moduleEnabled(kind: Module, env?: NodeJS.ProcessEnv): boolean;
|
|
19
19
|
/** Verify that the loopback listener matches the runtime's private run-state record. */
|
|
20
20
|
export declare function verifiedRuntime(endpoint: string, env?: NodeJS.ProcessEnv, signal?: AbortSignal): Promise<boolean>;
|
|
21
|
+
export interface VerifiedRuntimeInstance {
|
|
22
|
+
readonly record: string;
|
|
23
|
+
readonly token: string;
|
|
24
|
+
}
|
|
25
|
+
/** Reuse a recent health check only while the private run-state record is unchanged. */
|
|
26
|
+
export declare function verifiedRuntimeInstance(endpoint: string, home: string, signal?: AbortSignal, cached?: VerifiedRuntimeInstance): Promise<VerifiedRuntimeInstance | undefined>;
|
|
21
27
|
/** Guard every automatic middleware call against a different or replaced listener. */
|
|
22
28
|
export declare function guardedRuntimeFetch(endpoint: string, env?: NodeJS.ProcessEnv): typeof fetch;
|
|
23
29
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lornatang/dsh-caveman",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Caveman integration for DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -120,11 +120,12 @@
|
|
|
120
120
|
},
|
|
121
121
|
"repository": {
|
|
122
122
|
"type": "git",
|
|
123
|
-
"url": "git+https://github.com/Lornatang/dsh-
|
|
123
|
+
"url": "git+https://github.com/Lornatang/dsh-plugin.git",
|
|
124
|
+
"directory": "packages/workflow/dsh-caveman"
|
|
124
125
|
},
|
|
125
|
-
"homepage": "https://github.com/Lornatang/dsh-caveman#readme",
|
|
126
|
+
"homepage": "https://github.com/Lornatang/dsh-plugin/tree/main/packages/workflow/dsh-caveman#readme",
|
|
126
127
|
"bugs": {
|
|
127
|
-
"url": "https://github.com/Lornatang/dsh-
|
|
128
|
+
"url": "https://github.com/Lornatang/dsh-plugin/issues"
|
|
128
129
|
},
|
|
129
130
|
"publishConfig": {
|
|
130
131
|
"access": "public",
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
# Cavecrew agent presets and their in-process delegation tools. The read-only
|
|
2
|
-
# roles use a read-only Git tool instead of a shell.
|
|
3
|
-
- insert:
|
|
4
|
-
- id: preset-cavecrew-investigator
|
|
5
|
-
name: '@deepseek-ai/dsh-agent-preset'
|
|
6
|
-
config:
|
|
7
|
-
id: cavecrew-investigator
|
|
8
|
-
name: Cavecrew Investigator
|
|
9
|
-
plugins:
|
|
10
|
-
- id: cavecrew
|
|
11
|
-
name: '@lornatang/dsh-caveman/cavecrew'
|
|
12
|
-
config: { role: investigator }
|
|
13
|
-
- id: tool-fs
|
|
14
|
-
name: '@deepseek-ai/dsh-tool-fs'
|
|
15
|
-
config: { readImage: false, write: false, edit: false, applyPatch: false }
|
|
16
|
-
- id: tool-fs-search
|
|
17
|
-
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
18
|
-
config: { sampleOverCapGlobResults: false }
|
|
19
|
-
- id: preset-cavecrew-builder
|
|
20
|
-
name: '@deepseek-ai/dsh-agent-preset'
|
|
21
|
-
config:
|
|
22
|
-
id: cavecrew-builder
|
|
23
|
-
name: Cavecrew Builder
|
|
24
|
-
plugins:
|
|
25
|
-
- id: cavecrew
|
|
26
|
-
name: '@lornatang/dsh-caveman/cavecrew'
|
|
27
|
-
config: { role: builder }
|
|
28
|
-
- id: tool-fs
|
|
29
|
-
name: '@deepseek-ai/dsh-tool-fs'
|
|
30
|
-
config: { readImage: false, write: false, applyPatch: false }
|
|
31
|
-
- id: preset-cavecrew-reviewer
|
|
32
|
-
name: '@deepseek-ai/dsh-agent-preset'
|
|
33
|
-
config:
|
|
34
|
-
id: cavecrew-reviewer
|
|
35
|
-
name: Cavecrew Reviewer
|
|
36
|
-
plugins:
|
|
37
|
-
- id: cavecrew
|
|
38
|
-
name: '@lornatang/dsh-caveman/cavecrew'
|
|
39
|
-
config: { role: reviewer }
|
|
40
|
-
- id: tool-fs
|
|
41
|
-
name: '@deepseek-ai/dsh-tool-fs'
|
|
42
|
-
config: { readImage: false, write: false, edit: false, applyPatch: false }
|
|
43
|
-
- id: tool-fs-search
|
|
44
|
-
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
45
|
-
config: { sampleOverCapGlobResults: false }
|
|
46
|
-
- id: tool-cavecrew-investigator
|
|
47
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
48
|
-
config: { provider: spawn, toolName: cavecrew-investigator, agentPreset: cavecrew-investigator }
|
|
49
|
-
- id: tool-cavecrew-builder
|
|
50
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
51
|
-
config: { provider: spawn, toolName: cavecrew-builder, agentPreset: cavecrew-builder }
|
|
52
|
-
- id: tool-cavecrew-reviewer
|
|
53
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
54
|
-
config: { provider: spawn, toolName: cavecrew-reviewer, agentPreset: cavecrew-reviewer }
|
|
1
|
+
# Cavecrew agent presets and their in-process delegation tools. The read-only
|
|
2
|
+
# roles use a read-only Git tool instead of a shell.
|
|
3
|
+
- insert:
|
|
4
|
+
- id: preset-cavecrew-investigator
|
|
5
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
6
|
+
config:
|
|
7
|
+
id: cavecrew-investigator
|
|
8
|
+
name: Cavecrew Investigator
|
|
9
|
+
plugins:
|
|
10
|
+
- id: cavecrew
|
|
11
|
+
name: '@lornatang/dsh-caveman/cavecrew'
|
|
12
|
+
config: { role: investigator }
|
|
13
|
+
- id: tool-fs
|
|
14
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
15
|
+
config: { readImage: false, write: false, edit: false, applyPatch: false }
|
|
16
|
+
- id: tool-fs-search
|
|
17
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
18
|
+
config: { sampleOverCapGlobResults: false }
|
|
19
|
+
- id: preset-cavecrew-builder
|
|
20
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
21
|
+
config:
|
|
22
|
+
id: cavecrew-builder
|
|
23
|
+
name: Cavecrew Builder
|
|
24
|
+
plugins:
|
|
25
|
+
- id: cavecrew
|
|
26
|
+
name: '@lornatang/dsh-caveman/cavecrew'
|
|
27
|
+
config: { role: builder }
|
|
28
|
+
- id: tool-fs
|
|
29
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
30
|
+
config: { readImage: false, write: false, applyPatch: false }
|
|
31
|
+
- id: preset-cavecrew-reviewer
|
|
32
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
33
|
+
config:
|
|
34
|
+
id: cavecrew-reviewer
|
|
35
|
+
name: Cavecrew Reviewer
|
|
36
|
+
plugins:
|
|
37
|
+
- id: cavecrew
|
|
38
|
+
name: '@lornatang/dsh-caveman/cavecrew'
|
|
39
|
+
config: { role: reviewer }
|
|
40
|
+
- id: tool-fs
|
|
41
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
42
|
+
config: { readImage: false, write: false, edit: false, applyPatch: false }
|
|
43
|
+
- id: tool-fs-search
|
|
44
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
45
|
+
config: { sampleOverCapGlobResults: false }
|
|
46
|
+
- id: tool-cavecrew-investigator
|
|
47
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
48
|
+
config: { provider: spawn, toolName: cavecrew-investigator, agentPreset: cavecrew-investigator }
|
|
49
|
+
- id: tool-cavecrew-builder
|
|
50
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
51
|
+
config: { provider: spawn, toolName: cavecrew-builder, agentPreset: cavecrew-builder }
|
|
52
|
+
- id: tool-cavecrew-reviewer
|
|
53
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
54
|
+
config: { provider: spawn, toolName: cavecrew-reviewer, agentPreset: cavecrew-reviewer }
|