@botlearn-course/daemon 0.0.23-beta.1 → 0.0.23-beta.3
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Materialize the Skills authorized for one turn into the runtime's skills directory.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* exposes them through its native
|
|
4
|
+
* DeepSeek TUI 0.8.39 discovers global Skills from
|
|
5
|
+
* `<runtime-home>/.deepseek/skills/<name>/SKILL.md` and exposes them through its native
|
|
6
|
+
* `load_skill` tool. That path does not involve MCP, which
|
|
6
7
|
* matters because `deepseek serve --http` — the mode the daemon runs — never loads an MCP
|
|
7
8
|
* config at all, so the previous relay could not reach the model.
|
|
8
9
|
*
|
|
@@ -13,8 +14,8 @@
|
|
|
13
14
|
* task's set) and ordinary conversation (global set only).
|
|
14
15
|
*/
|
|
15
16
|
import type { PreparedRuntimeSkillProvider, RuntimeSkillCatalogEntry } from "./runtime-skills.js";
|
|
16
|
-
/**
|
|
17
|
-
export declare const
|
|
17
|
+
/** Standard DeepSeek path created under the activation-scoped runtime home. */
|
|
18
|
+
export declare const RUNTIME_SKILLS_RELATIVE_PATH: string;
|
|
18
19
|
export declare class RuntimeSkillMaterializationError extends Error {
|
|
19
20
|
readonly code: string;
|
|
20
21
|
constructor(code: string, message: string);
|
|
@@ -34,7 +35,7 @@ export interface MaterializeCourseSkillsResult {
|
|
|
34
35
|
}
|
|
35
36
|
export interface MaterializeCourseSkillsOptions {
|
|
36
37
|
prepared: PreparedRuntimeSkillProvider;
|
|
37
|
-
/**
|
|
38
|
+
/** Activation-scoped runtime home; Skills use DeepSeek's standard global path below it. */
|
|
38
39
|
profileRoot: string;
|
|
39
40
|
/** Managed sessions hand the directory to a separate runtime UID via the group bit. */
|
|
40
41
|
managed: boolean;
|
|
@@ -46,7 +47,15 @@ export interface MaterializeCourseSkillsOptions {
|
|
|
46
47
|
export declare function skillDirectoryName(entry: RuntimeSkillCatalogEntry): string;
|
|
47
48
|
export declare function skillSetFingerprint(refs: readonly string[]): string;
|
|
48
49
|
/**
|
|
49
|
-
*
|
|
50
|
+
* Prepare the DeepSeek state directory before the server starts.
|
|
51
|
+
*
|
|
52
|
+
* DeepSeek creates its own task and automation subdirectories below `.deepseek`, so the
|
|
53
|
+
* runtime group needs write access there. The sticky bit prevents that separate UID from
|
|
54
|
+
* replacing the control-process-owned `skills` entry.
|
|
55
|
+
*/
|
|
56
|
+
export declare function prepareRuntimeSkillsHome(profileRoot: string, managed: boolean): string;
|
|
57
|
+
/**
|
|
58
|
+
* Rewrite `<profileRoot>/.deepseek/skills` so it contains exactly the authorized Skills.
|
|
50
59
|
*
|
|
51
60
|
* Throws on any failure. A partial or stale directory must never be handed to the model:
|
|
52
61
|
* silently continuing without a Skill is the failure mode this whole change exists to
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Materialize the Skills authorized for one turn into the runtime's skills directory.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* exposes them through its native
|
|
4
|
+
* DeepSeek TUI 0.8.39 discovers global Skills from
|
|
5
|
+
* `<runtime-home>/.deepseek/skills/<name>/SKILL.md` and exposes them through its native
|
|
6
|
+
* `load_skill` tool. That path does not involve MCP, which
|
|
6
7
|
* matters because `deepseek serve --http` — the mode the daemon runs — never loads an MCP
|
|
7
8
|
* config at all, so the previous relay could not reach the model.
|
|
8
9
|
*
|
|
@@ -14,12 +15,13 @@
|
|
|
14
15
|
*/
|
|
15
16
|
import { chmodSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
16
17
|
import path from "node:path";
|
|
17
|
-
/**
|
|
18
|
-
export const
|
|
18
|
+
/** Standard DeepSeek path created under the activation-scoped runtime home. */
|
|
19
|
+
export const RUNTIME_SKILLS_RELATIVE_PATH = path.join(".deepseek", "skills");
|
|
19
20
|
const DIR_MODE_MANAGED = 0o750;
|
|
20
21
|
const FILE_MODE_MANAGED = 0o640;
|
|
21
22
|
const DIR_MODE_PRIVATE = 0o700;
|
|
22
23
|
const FILE_MODE_PRIVATE = 0o600;
|
|
24
|
+
const DEEPSEEK_HOME_MODE_MANAGED = 0o1770;
|
|
23
25
|
export class RuntimeSkillMaterializationError extends Error {
|
|
24
26
|
code;
|
|
25
27
|
constructor(code, message) {
|
|
@@ -45,7 +47,21 @@ export function skillSetFingerprint(refs) {
|
|
|
45
47
|
return [...refs].sort().join(",");
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
50
|
+
* Prepare the DeepSeek state directory before the server starts.
|
|
51
|
+
*
|
|
52
|
+
* DeepSeek creates its own task and automation subdirectories below `.deepseek`, so the
|
|
53
|
+
* runtime group needs write access there. The sticky bit prevents that separate UID from
|
|
54
|
+
* replacing the control-process-owned `skills` entry.
|
|
55
|
+
*/
|
|
56
|
+
export function prepareRuntimeSkillsHome(profileRoot, managed) {
|
|
57
|
+
const deepseekHome = path.join(profileRoot, ".deepseek");
|
|
58
|
+
const mode = managed ? DEEPSEEK_HOME_MODE_MANAGED : DIR_MODE_PRIVATE;
|
|
59
|
+
mkdirSync(deepseekHome, { recursive: true, mode });
|
|
60
|
+
chmodSync(deepseekHome, mode);
|
|
61
|
+
return deepseekHome;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Rewrite `<profileRoot>/.deepseek/skills` so it contains exactly the authorized Skills.
|
|
49
65
|
*
|
|
50
66
|
* Throws on any failure. A partial or stale directory must never be handed to the model:
|
|
51
67
|
* silently continuing without a Skill is the failure mode this whole change exists to
|
|
@@ -53,9 +69,10 @@ export function skillSetFingerprint(refs) {
|
|
|
53
69
|
*/
|
|
54
70
|
export async function materializeCourseSkills(options) {
|
|
55
71
|
const { prepared, profileRoot, managed } = options;
|
|
56
|
-
const skillsDir = path.join(profileRoot,
|
|
72
|
+
const skillsDir = path.join(profileRoot, RUNTIME_SKILLS_RELATIVE_PATH);
|
|
57
73
|
const dirMode = managed ? DIR_MODE_MANAGED : DIR_MODE_PRIVATE;
|
|
58
74
|
const fileMode = managed ? FILE_MODE_MANAGED : FILE_MODE_PRIVATE;
|
|
75
|
+
prepareRuntimeSkillsHome(profileRoot, managed);
|
|
59
76
|
// Rebuild rather than merge: a Skill dropped from the authorized set must disappear.
|
|
60
77
|
rmSync(skillsDir, { recursive: true, force: true });
|
|
61
78
|
if (prepared.catalog.length === 0) {
|
|
@@ -120,14 +137,23 @@ function writeFile(destination, content, root, dirMode, fileMode) {
|
|
|
120
137
|
if (resolved !== resolvedRoot && !resolved.startsWith(`${resolvedRoot}${path.sep}`)) {
|
|
121
138
|
throw new RuntimeSkillMaterializationError("skill_package_path_escape", "Skill package file escapes its materialization directory");
|
|
122
139
|
}
|
|
123
|
-
|
|
140
|
+
const parent = path.dirname(resolved);
|
|
141
|
+
mkdirSync(parent, { recursive: true, mode: dirMode });
|
|
142
|
+
// The managed daemon uses a restrictive umask. chmod every package-created ancestor,
|
|
143
|
+
// not only the Skill root, so the separate runtime UID can traverse nested references.
|
|
144
|
+
let current = resolvedRoot;
|
|
145
|
+
const relativeParent = path.relative(resolvedRoot, parent);
|
|
146
|
+
for (const segment of relativeParent.split(path.sep).filter(Boolean)) {
|
|
147
|
+
current = path.join(current, segment);
|
|
148
|
+
chmodSync(current, dirMode);
|
|
149
|
+
}
|
|
124
150
|
writeFileSync(resolved, content, { mode: fileMode });
|
|
125
151
|
chmodSync(resolved, fileMode);
|
|
126
152
|
}
|
|
127
153
|
export function cleanupCourseSkills(profileRoot) {
|
|
128
154
|
if (!profileRoot)
|
|
129
155
|
return;
|
|
130
|
-
rmSync(path.join(profileRoot,
|
|
156
|
+
rmSync(path.join(profileRoot, RUNTIME_SKILLS_RELATIVE_PATH), {
|
|
131
157
|
recursive: true,
|
|
132
158
|
force: true,
|
|
133
159
|
});
|
|
@@ -3,7 +3,7 @@ import { chmodSync, existsSync, lstatSync, mkdirSync, realpathSync, rmSync, writ
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import net from "node:net";
|
|
5
5
|
import { MAX_PROGRESS_EVENTS_PER_ATTEMPT } from "../mcp/report-progress.js";
|
|
6
|
-
import { materializeCourseSkills,
|
|
6
|
+
import { materializeCourseSkills, prepareRuntimeSkillsHome, RUNTIME_SKILLS_RELATIVE_PATH, skillDirectoryName, } from "../runtime-skill-materialization.js";
|
|
7
7
|
import { startCourseSkillsMcpServer, } from "../mcp/course-skills-server.js";
|
|
8
8
|
import { sanitizeRuntimeFailureText } from "../redaction.js";
|
|
9
9
|
import { runtimeChildEnv, runtimeChildLaunch } from "../runtime-env.js";
|
|
@@ -229,7 +229,7 @@ export class DeepseekTuiAdapter {
|
|
|
229
229
|
countedInFlight = true;
|
|
230
230
|
// 每个 turn 都要重写 skills 目录,且必须在此处而不是 acquireHandle 内:
|
|
231
231
|
// acquireHandle 只在需要新建进程时执行,复用进程时不会走到,那样第二个 turn
|
|
232
|
-
//
|
|
232
|
+
// 会沿用上一轮的授权集。目录路径固定,复用进程的 HOME 仍指向同一 profile。
|
|
233
233
|
if (opts.skillProvider && handle.progressMcpConfig) {
|
|
234
234
|
const startedAt = Date.now();
|
|
235
235
|
try {
|
|
@@ -458,6 +458,9 @@ export class DeepseekTuiAdapter {
|
|
|
458
458
|
: {}),
|
|
459
459
|
})
|
|
460
460
|
: undefined;
|
|
461
|
+
if (opts.skillProvider && progressMcpConfig) {
|
|
462
|
+
prepareRuntimeSkillsHome(progressMcpConfig.dir, Boolean(this.managedActivationId(opts)));
|
|
463
|
+
}
|
|
461
464
|
visionConfigPath = createManagedVisionConfig(opts, progressMcpConfig);
|
|
462
465
|
}
|
|
463
466
|
catch (error) {
|
|
@@ -481,8 +484,8 @@ export class DeepseekTuiAdapter {
|
|
|
481
484
|
try {
|
|
482
485
|
child = this.spawnFn(launch.binary, launch.args, {
|
|
483
486
|
cwd: opts.cwd,
|
|
484
|
-
env: this.spawnEnv(opts, progressMcpConfig?.path, visionConfigPath, progressMcpConfig
|
|
485
|
-
? path.join(progressMcpConfig.dir,
|
|
487
|
+
env: this.spawnEnv(opts, progressMcpConfig?.path, visionConfigPath, progressMcpConfig && opts.skillProvider
|
|
488
|
+
? path.join(progressMcpConfig.dir, RUNTIME_SKILLS_RELATIVE_PATH)
|
|
486
489
|
: undefined),
|
|
487
490
|
...launch.identity,
|
|
488
491
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -556,10 +559,9 @@ export class DeepseekTuiAdapter {
|
|
|
556
559
|
if (progressMcpConfigPath)
|
|
557
560
|
env.DEEPSEEK_MCP_CONFIG = progressMcpConfigPath;
|
|
558
561
|
if (skillsDir) {
|
|
559
|
-
//
|
|
560
|
-
//
|
|
561
|
-
env.
|
|
562
|
-
env.CODEWHALE_SKILLS_DIR = skillsDir;
|
|
562
|
+
// 0.8.39 只扫描 HOME 下的标准 `.deepseek/skills`,不读取原先假定的
|
|
563
|
+
// DEEPSEEK_SKILLS_DIR。profile 同时隔离 Course Skill,避免写入学员工作区。
|
|
564
|
+
env.HOME = path.dirname(path.dirname(skillsDir));
|
|
563
565
|
}
|
|
564
566
|
if (visionConfigPath)
|
|
565
567
|
env.DEEPSEEK_CONFIG_PATH = visionConfigPath;
|
package/package.json
CHANGED