create-deepagent-server 0.2.0 → 1.0.1

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.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/package.json +1 -1
  3. package/src/args.js +7 -7
  4. package/src/cli.js +8 -11
  5. package/src/dependencies.js +3 -3
  6. package/src/registry.js +5 -5
  7. package/src/scaffold.js +30 -15
  8. package/src/setup.js +2 -2
  9. package/src/version.js +1 -1
  10. package/src/versions.js +8 -8
  11. package/templates/deepagent/js/src/agents/prompts/loader.js +2 -2
  12. package/templates/deepagent/js/src/agents/prompts/supervisor.js +3 -3
  13. package/templates/deepagent/js/src/api/middleware/auth.js +2 -2
  14. package/templates/deepagent/js/src/config/agent.js +2 -2
  15. package/templates/deepagent/js/src/config/env.js +2 -2
  16. package/templates/deepagent/js/src/middleware/approval.js +6 -6
  17. package/templates/deepagent/js/src/middleware/index.js +3 -3
  18. package/templates/deepagent/js/src/middleware/security.js +2 -2
  19. package/templates/deepagent/js/src/model/config.js +4 -4
  20. package/templates/deepagent/js/src/model/index.js +1 -1
  21. package/templates/deepagent/js/src/model/presets.js +2 -2
  22. package/templates/deepagent/js/src/sandbox/opensandbox.js +3 -3
  23. package/templates/deepagent/js/src/skills/index.js +1 -1
  24. package/templates/deepagent/js/src/storage/logger/index.js +2 -2
  25. package/templates/deepagent/js/src/tools/database/query.js +4 -4
  26. package/templates/deepagent/shared/README.md +1 -1
  27. package/templates/deepagent/ts/scripts/copy-assets.ts +6 -6
  28. package/templates/deepagent/ts/src/agents/prompts/loader.ts +2 -2
  29. package/templates/deepagent/ts/src/agents/prompts/supervisor.ts +3 -3
  30. package/templates/deepagent/ts/src/api/middleware/auth.ts +2 -2
  31. package/templates/deepagent/ts/src/config/agent.ts +2 -2
  32. package/templates/deepagent/ts/src/config/env.ts +2 -2
  33. package/templates/deepagent/ts/src/middleware/approval.ts +6 -6
  34. package/templates/deepagent/ts/src/middleware/index.ts +3 -3
  35. package/templates/deepagent/ts/src/middleware/security.ts +2 -2
  36. package/templates/deepagent/ts/src/model/config.ts +4 -4
  37. package/templates/deepagent/ts/src/model/index.ts +2 -2
  38. package/templates/deepagent/ts/src/model/presets.ts +3 -3
  39. package/templates/deepagent/ts/src/sandbox/opensandbox.ts +3 -3
  40. package/templates/deepagent/ts/src/skills/index.ts +1 -1
  41. package/templates/deepagent/ts/src/storage/logger/index.ts +2 -2
  42. package/templates/deepagent/ts/src/tools/database/query.ts +4 -4
package/README.md CHANGED
@@ -101,6 +101,7 @@ my-agent/
101
101
  ├── scripts/ # 交互终端 + 预检脚本
102
102
  ├── deployment/ # Dockerfile + docker-compose
103
103
  ├── .editorconfig
104
+ ├── .env # 已生成,填入 MODEL_API_KEY
104
105
  ├── .env.example
105
106
  ├── package.json
106
107
  └── tsconfig.json # 仅 TypeScript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-deepagent-server",
3
- "version": "0.2.0",
3
+ "version": "1.0.1",
4
4
  "description": "快速创建生产可用的 Deep Agents(deepagents + LangGraph)项目,支持 JavaScript/TypeScript,仅使用 ESM。",
5
5
  "type": "module",
6
6
  "bin": {
package/src/args.js CHANGED
@@ -5,10 +5,10 @@ export class UsageError extends Error {
5
5
  }
6
6
  }
7
7
 
8
- export const TEMPLATES = ["deepagent"];
9
- export const PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
8
+ export const templates = ["deepagent"];
9
+ export const package_managers = ["npm", "pnpm", "yarn", "bun"];
10
10
 
11
- export const HELP_TEXT = `create-deepagent-server —— 快速创建 Deep Agents 项目
11
+ export const help_text = `create-deepagent-server —— 快速创建 Deep Agents 项目
12
12
 
13
13
  用法:
14
14
  create-deepagent-server [项目名] [选项]
@@ -115,15 +115,15 @@ export const parseArgs = (argv) => {
115
115
  i = parsed.index;
116
116
 
117
117
  if (flag === "-t" || flag === "--template") {
118
- if (!TEMPLATES.includes(parsed.value)) {
119
- throw new UsageError(`未知模板 "${parsed.value}"。可用模板:${TEMPLATES.join("、")}。`);
118
+ if (!templates.includes(parsed.value)) {
119
+ throw new UsageError(`未知模板 "${parsed.value}"。可用模板:${templates.join("、")}。`);
120
120
  }
121
121
  options.template = parsed.value;
122
122
  provided.add("template");
123
123
  } else {
124
- if (!PACKAGE_MANAGERS.includes(parsed.value)) {
124
+ if (!package_managers.includes(parsed.value)) {
125
125
  throw new UsageError(
126
- `未知包管理器 "${parsed.value}"。可选值:${PACKAGE_MANAGERS.join("、")}。`,
126
+ `未知包管理器 "${parsed.value}"。可选值:${package_managers.join("、")}。`,
127
127
  );
128
128
  }
129
129
  options.pm = parsed.value;
package/src/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
 
3
- import { HELP_TEXT, PACKAGE_MANAGERS, UsageError, parseArgs } from "./args.js";
3
+ import { help_text, package_managers, UsageError, parseArgs } from "./args.js";
4
4
  import { packagesFor } from "./dependencies.js";
5
5
  import { createPrompter, isInteractive } from "./prompts.js";
6
6
  import { bundledVersions, resolveVersions } from "./registry.js";
@@ -13,7 +13,7 @@ import {
13
13
  runScriptText,
14
14
  } from "./setup.js";
15
15
  import { banner, blank, bold, dim, green, info, step, success, warn } from "./ui.js";
16
- import { VERSION } from "./version.js";
16
+ import { version } from "./version.js";
17
17
 
18
18
  export const toPackageName = (input) => {
19
19
  const name = String(input)
@@ -58,10 +58,7 @@ const printNextSteps = ({ targetDir, cwd, packageManager, installed, language })
58
58
  console.log(` ${installCommandText(packageManager)}`);
59
59
  }
60
60
 
61
- const copyEnvCommand =
62
- process.platform === "win32" ? "copy .env.example .env" : "cp .env.example .env";
63
-
64
- console.log(` ${copyEnvCommand} ${dim("# 填入 MODEL_API_KEY")}`);
61
+ console.log(` ${dim("# 编辑 .env,填入 MODEL_API_KEY")}`);
65
62
  console.log(` ${runScriptText(packageManager, "check")} ${dim("# 可选:环境预检")}`);
66
63
  console.log(
67
64
  ` ${runScriptText(packageManager, "dev")} ${dim("# http://localhost:3000/health")}`,
@@ -108,12 +105,12 @@ export const main = async (argv = process.argv.slice(2)) => {
108
105
  const { options, positionals } = parseArgs(argv);
109
106
 
110
107
  if (options.help) {
111
- console.log(HELP_TEXT);
108
+ console.log(help_text);
112
109
  return 0;
113
110
  }
114
111
 
115
112
  if (options.version) {
116
- console.log(VERSION);
113
+ console.log(version);
117
114
  return 0;
118
115
  }
119
116
 
@@ -122,7 +119,7 @@ export const main = async (argv = process.argv.slice(2)) => {
122
119
  const prompter = interactive ? createPrompter() : null;
123
120
 
124
121
  try {
125
- banner("create-deepagent-server", VERSION);
122
+ banner("create-deepagent-server", version);
126
123
 
127
124
  let projectArgument = positionals[0];
128
125
 
@@ -180,13 +177,13 @@ export const main = async (argv = process.argv.slice(2)) => {
180
177
  (interactive
181
178
  ? await prompter.select(
182
179
  "包管理器",
183
- PACKAGE_MANAGERS.map((name) => ({
180
+ package_managers.map((name) => ({
184
181
  label: name,
185
182
  value: name,
186
183
  hint: name === detected ? "已检测" : undefined,
187
184
  })),
188
185
  {
189
- defaultIndex: Math.max(0, PACKAGE_MANAGERS.indexOf(detected)),
186
+ defaultIndex: Math.max(0, package_managers.indexOf(detected)),
190
187
  },
191
188
  )
192
189
  : detected);
@@ -2,7 +2,7 @@
2
2
  * 每个生成项目都会安装的依赖。
3
3
  * 版本在生成项目时从 npm 解析,保证模板始终使用当前发布版本。
4
4
  */
5
- export const RUNTIME_PACKAGES = [
5
+ export const runtime_packages = [
6
6
  "@alibaba-group/opensandbox",
7
7
  "@langchain/core",
8
8
  "@langchain/langgraph",
@@ -21,7 +21,7 @@ export const RUNTIME_PACKAGES = [
21
21
  "zod",
22
22
  ];
23
23
 
24
- export const TYPESCRIPT_PACKAGES = [
24
+ export const typescript_packages = [
25
25
  "typescript",
26
26
  "tsx",
27
27
  "@types/node",
@@ -30,5 +30,5 @@ export const TYPESCRIPT_PACKAGES = [
30
30
  ];
31
31
 
32
32
  export const packagesFor = (language) => {
33
- return language === "ts" ? [...RUNTIME_PACKAGES, ...TYPESCRIPT_PACKAGES] : RUNTIME_PACKAGES;
33
+ return language === "ts" ? [...runtime_packages, ...typescript_packages] : runtime_packages;
34
34
  };
package/src/registry.js CHANGED
@@ -1,6 +1,6 @@
1
- import { FALLBACK_VERSIONS } from "./versions.js";
1
+ import { fallback_versions } from "./versions.js";
2
2
 
3
- const REGISTRY = (
3
+ const registry = (
4
4
  process.env.DEEPAGENT_CLI_REGISTRY ||
5
5
  process.env.npm_config_registry ||
6
6
  "https://registry.npmjs.org"
@@ -12,7 +12,7 @@ const encodePackageName = (name) => {
12
12
  };
13
13
 
14
14
  const fetchLatestVersion = async (name, timeoutMs) => {
15
- const response = await fetch(`${REGISTRY}/${encodePackageName(name)}/latest`, {
15
+ const response = await fetch(`${registry}/${encodePackageName(name)}/latest`, {
16
16
  headers: { accept: "application/json" },
17
17
  signal: AbortSignal.timeout(timeoutMs),
18
18
  });
@@ -39,7 +39,7 @@ export const resolveVersions = async (packages, { timeoutMs = 5000 } = {}) => {
39
39
  const version = await fetchLatestVersion(name, timeoutMs).catch(() => undefined);
40
40
  if (version !== undefined) return { name, version, isFallback: false };
41
41
 
42
- const fallback = FALLBACK_VERSIONS[name];
42
+ const fallback = fallback_versions[name];
43
43
  if (!fallback) {
44
44
  throw new Error(`无法解析 ${name} 的版本,且没有内置回退版本。`);
45
45
  }
@@ -57,7 +57,7 @@ export const resolveVersions = async (packages, { timeoutMs = 5000 } = {}) => {
57
57
  export const bundledVersions = (packages) => {
58
58
  return Object.fromEntries(
59
59
  packages.map((name) => {
60
- const version = FALLBACK_VERSIONS[name];
60
+ const version = fallback_versions[name];
61
61
  if (!version) {
62
62
  throw new Error(`没有为 ${name} 内置回退版本。`);
63
63
  }
package/src/scaffold.js CHANGED
@@ -2,21 +2,21 @@ import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
 
5
- import { RUNTIME_PACKAGES, TYPESCRIPT_PACKAGES } from "./dependencies.js";
5
+ import { runtime_packages, typescript_packages } from "./dependencies.js";
6
6
 
7
- const HERE = path.dirname(fileURLToPath(import.meta.url));
8
- const TEMPLATES_DIR = path.join(HERE, "..", "templates");
7
+ const here = path.dirname(fileURLToPath(import.meta.url));
8
+ const templates_dir = path.join(here, "..", "templates");
9
9
 
10
- export const TEMPLATES = ["deepagent"];
10
+ export const templates = ["deepagent"];
11
11
 
12
- const TEMPLATE_FILENAMES = new Map([
12
+ const template_filenames = new Map([
13
13
  ["_gitignore", ".gitignore"],
14
14
  ["_env.example", ".env.example"],
15
15
  ["_editorconfig", ".editorconfig"],
16
16
  ]);
17
17
 
18
18
  const mapTemplateFilename = (name) => {
19
- return TEMPLATE_FILENAMES.get(name) ?? name;
19
+ return template_filenames.get(name) ?? name;
20
20
  };
21
21
 
22
22
  const walk = async (directory, prefix = "") => {
@@ -56,7 +56,7 @@ export const ensureEmptyTarget = async (targetDir, { force = false } = {}) => {
56
56
  };
57
57
 
58
58
  const assertVersions = (versions, language) => {
59
- const required = [...RUNTIME_PACKAGES, ...(language === "ts" ? TYPESCRIPT_PACKAGES : [])];
59
+ const required = [...runtime_packages, ...(language === "ts" ? typescript_packages : [])];
60
60
  const missing = required.filter((name) => !versions?.[name]);
61
61
 
62
62
  if (missing.length > 0) {
@@ -64,7 +64,7 @@ const assertVersions = (versions, language) => {
64
64
  }
65
65
  };
66
66
 
67
- const TYPESCRIPT_SCRIPTS = {
67
+ const typescript_scripts = {
68
68
  dev: "tsx watch src/index.ts",
69
69
  build: "tsc -p tsconfig.json && tsx scripts/copy-assets.ts",
70
70
  start: "node dist/index.js",
@@ -74,7 +74,7 @@ const TYPESCRIPT_SCRIPTS = {
74
74
  test: 'node --import tsx --test "tests/**/*.test.ts"',
75
75
  };
76
76
 
77
- const JAVASCRIPT_SCRIPTS = {
77
+ const javascript_scripts = {
78
78
  dev: "node --watch src/index.js",
79
79
  start: "node src/index.js",
80
80
  agent: "node scripts/dev.js",
@@ -84,16 +84,16 @@ const JAVASCRIPT_SCRIPTS = {
84
84
 
85
85
  export const buildPackageJson = ({ packageName, language, versions }) => {
86
86
  const dependencies = Object.fromEntries(
87
- RUNTIME_PACKAGES.map((name) => [name, `^${versions[name]}`]),
87
+ runtime_packages.map((name) => [name, `^${versions[name]}`]),
88
88
  );
89
89
 
90
90
  const typescriptDependencies = Object.fromEntries(
91
- TYPESCRIPT_PACKAGES.map((name) => [name, `^${versions[name]}`]),
91
+ typescript_packages.map((name) => [name, `^${versions[name]}`]),
92
92
  );
93
93
 
94
94
  const devDependencies = language === "ts" ? typescriptDependencies : {};
95
95
 
96
- const scripts = language === "ts" ? TYPESCRIPT_SCRIPTS : JAVASCRIPT_SCRIPTS;
96
+ const scripts = language === "ts" ? typescript_scripts : javascript_scripts;
97
97
 
98
98
  const manifest = {
99
99
  name: packageName,
@@ -122,8 +122,8 @@ export const scaffold = async ({
122
122
  versions,
123
123
  force = false,
124
124
  }) => {
125
- if (!TEMPLATES.includes(template)) {
126
- throw new Error(`未知模板 "${template}"。可用模板:${TEMPLATES.join("、")}。`);
125
+ if (!templates.includes(template)) {
126
+ throw new Error(`未知模板 "${template}"。可用模板:${templates.join("、")}。`);
127
127
  }
128
128
 
129
129
  if (language !== "js" && language !== "ts") {
@@ -138,7 +138,7 @@ export const scaffold = async ({
138
138
  await ensureEmptyTarget(targetDir, { force });
139
139
 
140
140
  // 先写入共享文件,再用语言专属文件覆盖同名文件。
141
- const templateRoot = path.join(TEMPLATES_DIR, template);
141
+ const templateRoot = path.join(templates_dir, template);
142
142
 
143
143
  const entries = await Promise.all(
144
144
  [path.join(templateRoot, "shared"), path.join(templateRoot, language)].map(async (directory) =>
@@ -174,6 +174,21 @@ export const scaffold = async ({
174
174
  );
175
175
  writtenFiles.push("package.json");
176
176
 
177
+ // 默认生成可直接编辑的 .env;写入已有目录(--force)时不覆盖用户配置。
178
+ const envCreated = await fs
179
+ .copyFile(
180
+ path.join(targetDir, ".env.example"),
181
+ path.join(targetDir, ".env"),
182
+ fs.constants.COPYFILE_EXCL,
183
+ )
184
+ .then(() => true)
185
+ .catch((error) => {
186
+ if (error?.code === "EEXIST") return false;
187
+ throw error;
188
+ });
189
+
190
+ if (envCreated) writtenFiles.push(".env");
191
+
177
192
  return {
178
193
  targetDir,
179
194
  files: writtenFiles.sort(),
package/src/setup.js CHANGED
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
2
2
  import { existsSync } from "node:fs";
3
3
  import path from "node:path";
4
4
 
5
- const LOCKFILES = [
5
+ const lockfiles = [
6
6
  ["pnpm-lock.yaml", "pnpm"],
7
7
  ["yarn.lock", "yarn"],
8
8
  ["bun.lockb", "bun"],
@@ -18,7 +18,7 @@ export const detectPackageManager = ({ cwd = process.cwd(), env = process.env }
18
18
  if (userAgent.startsWith(`${packageManager}/`)) return packageManager;
19
19
  }
20
20
 
21
- for (const [lockfile, packageManager] of LOCKFILES) {
21
+ for (const [lockfile, packageManager] of lockfiles) {
22
22
  if (existsSync(path.join(cwd, lockfile))) return packageManager;
23
23
  }
24
24
 
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.2.0";
1
+ export const version = "1.0.1";
package/src/versions.js CHANGED
@@ -4,24 +4,24 @@
4
4
  * 正常生成项目时会在运行时从 registry 解析 `latest`;这里的值仅作回退,
5
5
  * 随 CLI 发版一起更新。
6
6
  */
7
- export const FALLBACK_VERSIONS = {
7
+ export const fallback_versions = {
8
8
  "@alibaba-group/opensandbox": "1.2.1",
9
- "@langchain/core": "1.4.0",
10
- "@langchain/langgraph": "1.7.3",
11
- "@langchain/langgraph-checkpoint": "1.2.2",
12
- "@langchain/langgraph-checkpoint-postgres": "1.1.2",
9
+ "@langchain/core": "1.4.1",
10
+ "@langchain/langgraph": "1.7.5",
11
+ "@langchain/langgraph-checkpoint": "1.2.3",
12
+ "@langchain/langgraph-checkpoint-postgres": "1.1.4",
13
13
  "@langchain/mcp-adapters": "2.0.3",
14
14
  "@langchain/openai": "1.8.4",
15
- deepagents: "1.16.4",
15
+ deepagents: "1.17.0",
16
16
  dotenv: "18.0.10",
17
17
  express: "5.3.0",
18
18
  ioredis: "6.0.0",
19
- langchain: "1.6.5",
19
+ langchain: "1.6.6",
20
20
  pg: "8.23.1",
21
21
  pino: "10.4.0",
22
22
  "pino-pretty": "13.2.0",
23
23
  zod: "4.6.7",
24
- typescript: "5.9.3",
24
+ typescript: "7.0.2",
25
25
  tsx: "4.23.15",
26
26
  "@types/node": "26.6.6",
27
27
  "@types/express": "5.0.6",
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
3
 
4
- const VALID_NAME = /^[a-z0-9][a-z0-9/_-]*$/i;
4
+ const valid_name = /^[a-z0-9][a-z0-9/_-]*$/i;
5
5
  const cache = new Map();
6
6
 
7
7
  /**
@@ -10,7 +10,7 @@ const cache = new Map();
10
10
  * 相对路径保持一致。
11
11
  */
12
12
  export const loadPrompt = (name) => {
13
- if (!VALID_NAME.test(name) || name.includes("..")) {
13
+ if (!valid_name.test(name) || name.includes("..")) {
14
14
  throw new Error(`非法的提示词名称:${name}`);
15
15
  }
16
16
 
@@ -1,7 +1,7 @@
1
1
  import { loadPrompt, renderPrompt } from "./loader.js";
2
2
 
3
- const NO_APPROVAL_POLICY = "工具调用无需人工审批,直接执行。";
4
- const APPROVAL_POLICY =
3
+ const no_approval_policy = "工具调用无需人工审批,直接执行。";
4
+ const approval_policy =
5
5
  "有副作用的工具调用会暂停以等待人工审批。请说明为什么需要该工具,然后等待决定。";
6
6
 
7
7
  /**
@@ -11,7 +11,7 @@ const APPROVAL_POLICY =
11
11
  export const buildSupervisorPrompt = ({ name, subagents, approvalMode }) => {
12
12
  const team = subagents.map((agent) => `- **${agent.name}** — ${agent.description}`).join("\n");
13
13
 
14
- const approvalPolicy = approvalMode === "none" ? NO_APPROVAL_POLICY : APPROVAL_POLICY;
14
+ const approvalPolicy = approvalMode === "none" ? no_approval_policy : approval_policy;
15
15
 
16
16
  return renderPrompt(loadPrompt("supervisor"), {
17
17
  agentName: name,
@@ -2,7 +2,7 @@ import { timingSafeEqual } from "node:crypto";
2
2
 
3
3
  import { UnauthorizedError } from "../../utils/errors.js";
4
4
 
5
- const BEARER_PREFIX = "Bearer ";
5
+ const bearer_prefix = "Bearer ";
6
6
 
7
7
  const safeEqual = (provided, expected) => {
8
8
  const actual = Buffer.from(provided);
@@ -24,7 +24,7 @@ export const createAuthMiddleware = (apiKey) => {
24
24
 
25
25
  return (req, _res, next) => {
26
26
  const header = req.header("authorization") ?? "";
27
- const token = header.startsWith(BEARER_PREFIX) ? header.slice(BEARER_PREFIX.length).trim() : "";
27
+ const token = header.startsWith(bearer_prefix) ? header.slice(bearer_prefix.length).trim() : "";
28
28
 
29
29
  if (!token || !safeEqual(token, apiKey)) {
30
30
  next(new UnauthorizedError());
@@ -1,10 +1,10 @@
1
- export const DEFAULT_AGENT_DESCRIPTION =
1
+ export const default_agent_description =
2
2
  "负责规划任务、把工作分派给专职子 Agent,并维护工作区文件的主 Agent。";
3
3
 
4
4
  export const resolveAgentConfig = (env) => {
5
5
  return {
6
6
  name: env.AGENT_NAME,
7
- description: DEFAULT_AGENT_DESCRIPTION,
7
+ description: default_agent_description,
8
8
  recursionLimit: env.AGENT_RECURSION_LIMIT,
9
9
  approvals: env.APPROVAL_MODE,
10
10
  enableShell: env.ENABLE_SHELL,
@@ -2,7 +2,7 @@ import "../schemas/locale.js";
2
2
 
3
3
  import { z } from "zod";
4
4
 
5
- import { MODEL_PROVIDERS } from "../model/index.js";
5
+ import { model_providers } from "../model/index.js";
6
6
  import { ConfigurationError } from "../utils/errors.js";
7
7
 
8
8
  const booleanFlag = z
@@ -25,7 +25,7 @@ export const envSchema = z.object({
25
25
  LOG_LEVEL: z.enum(["fatal", "error", "warn", "info", "debug", "trace", "silent"]).default("info"),
26
26
 
27
27
  // 模型统一通过 OpenAI 兼容协议接入,服务商预设见 src/model/presets。
28
- MODEL_PROVIDER: z.enum(MODEL_PROVIDERS).default("minimax"),
28
+ MODEL_PROVIDER: z.enum(model_providers).default("minimax"),
29
29
  MODEL_NAME: optionalString,
30
30
  MODEL_BASE_URL: optionalString,
31
31
  MODEL_API_KEY: optionalString,
@@ -2,7 +2,7 @@
2
2
  * 会修改状态或操作基础设施的工具。它们会通过 `interruptOn` 暂停,
3
3
  * 等待人工批准后再执行。
4
4
  */
5
- export const SENSITIVE_TOOLS = [
5
+ export const sensitive_tools = [
6
6
  "write_file",
7
7
  "edit_file",
8
8
  "delete",
@@ -12,8 +12,8 @@ export const SENSITIVE_TOOLS = [
12
12
  ];
13
13
 
14
14
  /** 模板已知的全部工具名称。 */
15
- export const KNOWN_TOOLS = [
16
- ...SENSITIVE_TOOLS,
15
+ export const known_tools = [
16
+ ...sensitive_tools,
17
17
  "read_file",
18
18
  "read_workspace_file",
19
19
  "list_workspace_files",
@@ -34,14 +34,14 @@ export const KNOWN_TOOLS = [
34
34
  export const createApprovalPolicy = (mode) => {
35
35
  if (mode === "none") return {};
36
36
 
37
- const tools = mode === "all" ? [...KNOWN_TOOLS] : [...SENSITIVE_TOOLS];
37
+ const tools = mode === "all" ? [...known_tools] : [...sensitive_tools];
38
38
 
39
39
  return Object.fromEntries(tools.map((tool) => [tool, true]));
40
40
  };
41
41
 
42
42
  export const requiresApproval = (mode, toolName) => {
43
43
  if (mode === "none") return false;
44
- if (mode === "all") return KNOWN_TOOLS.includes(toolName);
44
+ if (mode === "all") return known_tools.includes(toolName);
45
45
 
46
- return SENSITIVE_TOOLS.includes(toolName);
46
+ return sensitive_tools.includes(toolName);
47
47
  };
@@ -1,9 +1,9 @@
1
1
  export {
2
2
  createApprovalPolicy,
3
- KNOWN_TOOLS,
3
+ known_tools,
4
4
  requiresApproval,
5
- SENSITIVE_TOOLS,
5
+ sensitive_tools,
6
6
  } from "./approval.js";
7
7
  export { createContextMiddleware, runtimeContextSchema } from "./context.js";
8
8
  export { createLoggingMiddleware } from "./logging.js";
9
- export { createSecurityMiddleware, DANGEROUS_PATTERNS, findSecurityViolation } from "./security.js";
9
+ export { createSecurityMiddleware, dangerous_patterns, findSecurityViolation } from "./security.js";
@@ -5,7 +5,7 @@ import { createMiddleware } from "langchain";
5
5
  * 针对破坏性 shell/SQL 载荷的启发式规则。这是纵深防御,不是沙箱:
6
6
  * 请以最小权限运行 Agent。
7
7
  */
8
- export const DANGEROUS_PATTERNS = [
8
+ export const dangerous_patterns = [
9
9
  {
10
10
  pattern: /\brm\s+-(?:[a-z]*r[a-z]*f|[a-z]*f[a-z]*r)\s+\/(?:\s|$)/i,
11
11
  reason: "递归删除根目录",
@@ -24,7 +24,7 @@ export const DANGEROUS_PATTERNS = [
24
24
  ];
25
25
 
26
26
  export const findSecurityViolation = (value) => {
27
- for (const { pattern, reason } of DANGEROUS_PATTERNS) {
27
+ for (const { pattern, reason } of dangerous_patterns) {
28
28
  if (pattern.test(value)) return reason;
29
29
  }
30
30
 
@@ -1,15 +1,15 @@
1
1
  import { ConfigurationError } from "../utils/errors.js";
2
- import { OPENAI_COMPATIBLE_PRESETS } from "./presets.js";
2
+ import { openai_compatible_presets } from "./presets.js";
3
3
 
4
4
  /** 未配置时的生成上限;MiniMax M3 最高支持 128K(含思考 token)。 */
5
- export const DEFAULT_MAX_COMPLETION_TOKENS = 32_768;
5
+ export const default_max_completion_tokens = 32_768;
6
6
 
7
7
  /**
8
8
  * 把环境变量解析成模型配置。
9
9
  * `MODEL_BASE_URL` 优先于预设地址,用于自建网关、代理或私有化部署。
10
10
  */
11
11
  export const resolveModelConfig = (env) => {
12
- const preset = OPENAI_COMPATIBLE_PRESETS[env.MODEL_PROVIDER];
12
+ const preset = openai_compatible_presets[env.MODEL_PROVIDER];
13
13
  const baseUrl = env.MODEL_BASE_URL ?? preset.baseUrl;
14
14
  const name = env.MODEL_NAME ?? preset.defaultModel;
15
15
 
@@ -33,6 +33,6 @@ export const resolveModelConfig = (env) => {
33
33
  apiKey: env.MODEL_API_KEY ?? "",
34
34
  temperature: env.MODEL_TEMPERATURE,
35
35
  maxCompletionTokens:
36
- env.MODEL_MAX_COMPLETION_TOKENS ?? env.MODEL_MAX_TOKENS ?? DEFAULT_MAX_COMPLETION_TOKENS,
36
+ env.MODEL_MAX_COMPLETION_TOKENS ?? env.MODEL_MAX_TOKENS ?? default_max_completion_tokens,
37
37
  };
38
38
  };
@@ -6,4 +6,4 @@
6
6
  */
7
7
  export { resolveModelConfig } from "./config.js";
8
8
  export { createChatModel } from "./openai-compatible.js";
9
- export { MODEL_PROVIDERS, OPENAI_COMPATIBLE_PRESETS } from "./presets.js";
9
+ export { model_providers, openai_compatible_presets } from "./presets.js";
@@ -5,7 +5,7 @@
5
5
  * 因此这里只维护各家的接口地址与默认模型。只要服务实现了同一套协议,
6
6
  * 增加一个预设就能接入,不需要引入新的 SDK。
7
7
  */
8
- export const MODEL_PROVIDERS = [
8
+ export const model_providers = [
9
9
  "openai",
10
10
  "deepseek",
11
11
  "moonshot",
@@ -18,7 +18,7 @@ export const MODEL_PROVIDERS = [
18
18
  "custom",
19
19
  ];
20
20
 
21
- export const OPENAI_COMPATIBLE_PRESETS = {
21
+ export const openai_compatible_presets = {
22
22
  openai: {
23
23
  label: "OpenAI",
24
24
  baseUrl: "https://api.openai.com/v1",
@@ -3,7 +3,7 @@ import { BaseSandbox } from "deepagents";
3
3
 
4
4
  import { errorMessage } from "../utils/helpers.js";
5
5
 
6
- const MAX_OUTPUT_CHARS = 100_000;
6
+ const max_output_chars = 100_000;
7
7
 
8
8
  const parentDirectory = (filePath) => {
9
9
  const index = filePath.lastIndexOf("/");
@@ -39,11 +39,11 @@ const formatExecution = (execution) => {
39
39
  const stdout = execution.logs.stdout.map((message) => message.text);
40
40
  const stderr = execution.logs.stderr.map((message) => `[stderr] ${message.text}`);
41
41
  const output = [...stdout, ...stderr].join("\n");
42
- const truncated = output.length > MAX_OUTPUT_CHARS;
42
+ const truncated = output.length > max_output_chars;
43
43
  const exitCode = execution.exitCode ?? execution.error?.exitCode ?? (execution.error ? 1 : 0);
44
44
 
45
45
  return {
46
- output: truncated ? `${output.slice(0, MAX_OUTPUT_CHARS)}\n… 输出已截断` : output,
46
+ output: truncated ? `${output.slice(0, max_output_chars)}\n… 输出已截断` : output,
47
47
  exitCode,
48
48
  truncated,
49
49
  };
@@ -3,7 +3,7 @@ import { discoverSkills } from "./loader.js";
3
3
  export { discoverSkills, parseSkillFrontmatter } from "./loader.js";
4
4
 
5
5
  /** Deep Agents skills 中间件扫描的虚拟后端路径。 */
6
- export const DEFAULT_SKILL_SOURCES = ["/skills/"];
6
+ export const default_skill_sources = ["/skills/"];
7
7
 
8
8
  /** 从磁盘发现技能(用于启动校验和 `scripts/check`)。 */
9
9
  export const loadSkills = async ({ rootDir }) => {
@@ -1,7 +1,7 @@
1
1
  import pino from "pino";
2
2
 
3
3
  /** `LOG_PRETTY=true` 时使用的 pino-pretty 传输配置。 */
4
- const PRETTY_TRANSPORT = {
4
+ const pretty_transport = {
5
5
  transport: {
6
6
  target: "pino-pretty",
7
7
  options: {
@@ -16,6 +16,6 @@ export const createLogger = (config) => {
16
16
  return pino({
17
17
  level: config.logging.level,
18
18
  base: { service: "deepagent", env: config.env.NODE_ENV },
19
- ...(config.logging.pretty ? PRETTY_TRANSPORT : {}),
19
+ ...(config.logging.pretty ? pretty_transport : {}),
20
20
  });
21
21
  };
@@ -3,8 +3,8 @@ import { z } from "zod";
3
3
 
4
4
  import { getPool } from "../../storage/database/client.js";
5
5
 
6
- const READ_ONLY_START = /^\s*(?:select|with)\b/i;
7
- const FORBIDDEN_KEYWORDS =
6
+ const read_only_start = /^\s*(?:select|with)\b/i;
7
+ const forbidden_keywords =
8
8
  /\b(insert|update|delete|drop|alter|truncate|create|grant|revoke|copy|vacuum|reindex|call|do)\b/i;
9
9
 
10
10
  /**
@@ -14,13 +14,13 @@ const FORBIDDEN_KEYWORDS =
14
14
  export const assertReadOnlyQuery = (sql) => {
15
15
  const statement = sql.trim().replace(/;\s*$/, "");
16
16
 
17
- if (!READ_ONLY_START.test(statement)) {
17
+ if (!read_only_start.test(statement)) {
18
18
  throw new Error("只允许 SELECT 和 WITH 查询。");
19
19
  }
20
20
  if (statement.includes(";")) {
21
21
  throw new Error("只允许单条 SQL 语句。");
22
22
  }
23
- if (FORBIDDEN_KEYWORDS.test(statement)) {
23
+ if (forbidden_keywords.test(statement)) {
24
24
  throw new Error("查询包含写入或 DDL 关键字,已拒绝执行。");
25
25
  }
26
26
  };
@@ -12,7 +12,7 @@
12
12
  ## 快速开始
13
13
 
14
14
  ```bash
15
- cp .env.example .env # 填入 MODEL_API_KEY(示例默认 MiniMax M3)
15
+ # .env 已自动生成,填入 MODEL_API_KEY 即可(示例默认 MiniMax M3)
16
16
  npm run check # 可选:启动前环境检查
17
17
  npm run dev # http://localhost:3000/health
18
18
  ```
@@ -6,10 +6,10 @@ import { fileURLToPath } from "node:url";
6
6
  * `tsc` 只输出 JavaScript。提示词 Markdown 和 SQL 迁移文件需要复制到编译产物
7
7
  * 旁边,保证从 `dist/` 运行时仍能按相对路径找到它们。
8
8
  */
9
- const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
10
- const SOURCE = path.join(ROOT, "src");
11
- const TARGET = path.join(ROOT, "dist");
12
- const ASSET_EXTENSIONS = new Set([".md", ".sql"]);
9
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
10
+ const source_root = path.join(root, "src");
11
+ const target_root = path.join(root, "dist");
12
+ const asset_extensions = new Set([".md", ".sql"]);
13
13
 
14
14
  const copyAssets = async (sourceDir: string, targetDir: string): Promise<number> => {
15
15
  const entries = await readdir(sourceDir, { withFileTypes: true });
@@ -23,7 +23,7 @@ const copyAssets = async (sourceDir: string, targetDir: string): Promise<number>
23
23
 
24
24
  if (entry.isDirectory()) {
25
25
  copied += await copyAssets(source, target);
26
- } else if (entry.isFile() && ASSET_EXTENSIONS.has(path.extname(entry.name))) {
26
+ } else if (entry.isFile() && asset_extensions.has(path.extname(entry.name))) {
27
27
  await copyFile(source, target);
28
28
  copied += 1;
29
29
  }
@@ -32,6 +32,6 @@ const copyAssets = async (sourceDir: string, targetDir: string): Promise<number>
32
32
  return copied;
33
33
  };
34
34
 
35
- const copied = await copyAssets(SOURCE, TARGET);
35
+ const copied = await copyAssets(source_root, target_root);
36
36
 
37
37
  console.log(`已将 ${copied} 个资源文件复制到 dist/。`);
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
3
 
4
- const VALID_NAME = /^[a-z0-9][a-z0-9/_-]*$/i;
4
+ const valid_name = /^[a-z0-9][a-z0-9/_-]*$/i;
5
5
  const cache = new Map<string, string>();
6
6
 
7
7
  /**
@@ -10,7 +10,7 @@ const cache = new Map<string, string>();
10
10
  * 相对路径保持一致。
11
11
  */
12
12
  export const loadPrompt = (name: string): string => {
13
- if (!VALID_NAME.test(name) || name.includes("..")) {
13
+ if (!valid_name.test(name) || name.includes("..")) {
14
14
  throw new Error(`非法的提示词名称:${name}`);
15
15
  }
16
16
 
@@ -8,8 +8,8 @@ export interface SupervisorPromptOptions {
8
8
  approvalMode: AgentConfig["approvals"];
9
9
  }
10
10
 
11
- const NO_APPROVAL_POLICY = "工具调用无需人工审批,直接执行。";
12
- const APPROVAL_POLICY =
11
+ const no_approval_policy = "工具调用无需人工审批,直接执行。";
12
+ const approval_policy =
13
13
  "有副作用的工具调用会暂停以等待人工审批。请说明为什么需要该工具,然后等待决定。";
14
14
 
15
15
  /**
@@ -23,7 +23,7 @@ export const buildSupervisorPrompt = ({
23
23
  }: SupervisorPromptOptions): string => {
24
24
  const team = subagents.map((agent) => `- **${agent.name}** — ${agent.description}`).join("\n");
25
25
 
26
- const approvalPolicy = approvalMode === "none" ? NO_APPROVAL_POLICY : APPROVAL_POLICY;
26
+ const approvalPolicy = approvalMode === "none" ? no_approval_policy : approval_policy;
27
27
 
28
28
  return renderPrompt(loadPrompt("supervisor"), {
29
29
  agentName: name,
@@ -4,7 +4,7 @@ import type { RequestHandler } from "express";
4
4
 
5
5
  import { UnauthorizedError } from "../../utils/errors.js";
6
6
 
7
- const BEARER_PREFIX = "Bearer ";
7
+ const bearer_prefix = "Bearer ";
8
8
 
9
9
  const safeEqual = (provided: string, expected: string): boolean => {
10
10
  const actual = Buffer.from(provided);
@@ -26,7 +26,7 @@ export const createAuthMiddleware = (apiKey?: string): RequestHandler => {
26
26
 
27
27
  return (req, _res, next) => {
28
28
  const header = req.header("authorization") ?? "";
29
- const token = header.startsWith(BEARER_PREFIX) ? header.slice(BEARER_PREFIX.length).trim() : "";
29
+ const token = header.startsWith(bearer_prefix) ? header.slice(bearer_prefix.length).trim() : "";
30
30
 
31
31
  if (!token || !safeEqual(token, apiKey)) {
32
32
  next(new UnauthorizedError());
@@ -21,13 +21,13 @@ export interface AgentConfig {
21
21
  systemPromptAppendix?: string;
22
22
  }
23
23
 
24
- export const DEFAULT_AGENT_DESCRIPTION =
24
+ export const default_agent_description =
25
25
  "负责规划任务、把工作分派给专职子 Agent,并维护工作区文件的主 Agent。";
26
26
 
27
27
  export const resolveAgentConfig = (env: Env): AgentConfig => {
28
28
  return {
29
29
  name: env.AGENT_NAME,
30
- description: DEFAULT_AGENT_DESCRIPTION,
30
+ description: default_agent_description,
31
31
  recursionLimit: env.AGENT_RECURSION_LIMIT,
32
32
  approvals: env.APPROVAL_MODE,
33
33
  enableShell: env.ENABLE_SHELL,
@@ -2,7 +2,7 @@ import "../schemas/locale.js";
2
2
 
3
3
  import { z } from "zod";
4
4
 
5
- import { MODEL_PROVIDERS } from "../model/index.js";
5
+ import { model_providers } from "../model/index.js";
6
6
  import { ConfigurationError } from "../utils/errors.js";
7
7
 
8
8
  const booleanFlag = z
@@ -25,7 +25,7 @@ export const envSchema = z.object({
25
25
  LOG_LEVEL: z.enum(["fatal", "error", "warn", "info", "debug", "trace", "silent"]).default("info"),
26
26
 
27
27
  // 模型统一通过 OpenAI 兼容协议接入,服务商预设见 src/model/presets。
28
- MODEL_PROVIDER: z.enum(MODEL_PROVIDERS).default("minimax"),
28
+ MODEL_PROVIDER: z.enum(model_providers).default("minimax"),
29
29
  MODEL_NAME: optionalString,
30
30
  MODEL_BASE_URL: optionalString,
31
31
  MODEL_API_KEY: optionalString,
@@ -4,7 +4,7 @@ import type { ApprovalMode } from "../config/index.js";
4
4
  * 会修改状态或操作基础设施的工具。它们会通过 `interruptOn` 暂停,
5
5
  * 等待人工批准后再执行。
6
6
  */
7
- export const SENSITIVE_TOOLS = [
7
+ export const sensitive_tools = [
8
8
  "write_file",
9
9
  "edit_file",
10
10
  "delete",
@@ -14,8 +14,8 @@ export const SENSITIVE_TOOLS = [
14
14
  ] as const;
15
15
 
16
16
  /** 模板已知的全部工具名称。 */
17
- export const KNOWN_TOOLS = [
18
- ...SENSITIVE_TOOLS,
17
+ export const known_tools = [
18
+ ...sensitive_tools,
19
19
  "read_file",
20
20
  "read_workspace_file",
21
21
  "list_workspace_files",
@@ -36,14 +36,14 @@ export const KNOWN_TOOLS = [
36
36
  export const createApprovalPolicy = (mode: ApprovalMode): Record<string, boolean> => {
37
37
  if (mode === "none") return {};
38
38
 
39
- const tools = mode === "all" ? [...KNOWN_TOOLS] : [...SENSITIVE_TOOLS];
39
+ const tools = mode === "all" ? [...known_tools] : [...sensitive_tools];
40
40
 
41
41
  return Object.fromEntries(tools.map((tool) => [tool, true]));
42
42
  };
43
43
 
44
44
  export const requiresApproval = (mode: ApprovalMode, toolName: string): boolean => {
45
45
  if (mode === "none") return false;
46
- if (mode === "all") return (KNOWN_TOOLS as readonly string[]).includes(toolName);
46
+ if (mode === "all") return (known_tools as readonly string[]).includes(toolName);
47
47
 
48
- return (SENSITIVE_TOOLS as readonly string[]).includes(toolName);
48
+ return (sensitive_tools as readonly string[]).includes(toolName);
49
49
  };
@@ -1,9 +1,9 @@
1
1
  export {
2
2
  createApprovalPolicy,
3
- KNOWN_TOOLS,
3
+ known_tools,
4
4
  requiresApproval,
5
- SENSITIVE_TOOLS,
5
+ sensitive_tools,
6
6
  } from "./approval.js";
7
7
  export { createContextMiddleware, runtimeContextSchema, type RuntimeContext } from "./context.js";
8
8
  export { createLoggingMiddleware } from "./logging.js";
9
- export { createSecurityMiddleware, DANGEROUS_PATTERNS, findSecurityViolation } from "./security.js";
9
+ export { createSecurityMiddleware, dangerous_patterns, findSecurityViolation } from "./security.js";
@@ -5,7 +5,7 @@ import { createMiddleware } from "langchain";
5
5
  * 针对破坏性 shell/SQL 载荷的启发式规则。这是纵深防御,不是沙箱:
6
6
  * 请以最小权限运行 Agent。
7
7
  */
8
- export const DANGEROUS_PATTERNS: ReadonlyArray<{
8
+ export const dangerous_patterns: ReadonlyArray<{
9
9
  pattern: RegExp;
10
10
  reason: string;
11
11
  }> = [
@@ -27,7 +27,7 @@ export const DANGEROUS_PATTERNS: ReadonlyArray<{
27
27
  ];
28
28
 
29
29
  export const findSecurityViolation = (value: string): string | null => {
30
- for (const { pattern, reason } of DANGEROUS_PATTERNS) {
30
+ for (const { pattern, reason } of dangerous_patterns) {
31
31
  if (pattern.test(value)) return reason;
32
32
  }
33
33
 
@@ -1,9 +1,9 @@
1
1
  import type { Env } from "../config/index.js";
2
2
  import { ConfigurationError } from "../utils/errors.js";
3
- import { OPENAI_COMPATIBLE_PRESETS, type ModelProvider } from "./presets.js";
3
+ import { openai_compatible_presets, type ModelProvider } from "./presets.js";
4
4
 
5
5
  /** 未配置时的生成上限;MiniMax M3 最高支持 128K(含思考 token)。 */
6
- export const DEFAULT_MAX_COMPLETION_TOKENS = 32_768;
6
+ export const default_max_completion_tokens = 32_768;
7
7
 
8
8
  /** 构建聊天模型所需的全部参数,集中在一处解析。 */
9
9
  export interface ModelConfig {
@@ -27,7 +27,7 @@ export interface ModelConfig {
27
27
  * `MODEL_BASE_URL` 优先于预设地址,用于自建网关、代理或私有化部署。
28
28
  */
29
29
  export const resolveModelConfig = (env: Env): ModelConfig => {
30
- const preset = OPENAI_COMPATIBLE_PRESETS[env.MODEL_PROVIDER];
30
+ const preset = openai_compatible_presets[env.MODEL_PROVIDER];
31
31
  const baseUrl = env.MODEL_BASE_URL ?? preset.baseUrl;
32
32
  const name = env.MODEL_NAME ?? preset.defaultModel;
33
33
 
@@ -51,6 +51,6 @@ export const resolveModelConfig = (env: Env): ModelConfig => {
51
51
  apiKey: env.MODEL_API_KEY ?? "",
52
52
  temperature: env.MODEL_TEMPERATURE,
53
53
  maxCompletionTokens:
54
- env.MODEL_MAX_COMPLETION_TOKENS ?? env.MODEL_MAX_TOKENS ?? DEFAULT_MAX_COMPLETION_TOKENS,
54
+ env.MODEL_MAX_COMPLETION_TOKENS ?? env.MODEL_MAX_TOKENS ?? default_max_completion_tokens,
55
55
  };
56
56
  };
@@ -7,8 +7,8 @@
7
7
  export { resolveModelConfig, type ModelConfig } from "./config.js";
8
8
  export { createChatModel } from "./openai-compatible.js";
9
9
  export {
10
- MODEL_PROVIDERS,
11
- OPENAI_COMPATIBLE_PRESETS,
10
+ model_providers,
11
+ openai_compatible_presets,
12
12
  type ModelPreset,
13
13
  type ModelProvider,
14
14
  } from "./presets.js";
@@ -5,7 +5,7 @@
5
5
  * 因此这里只维护各家的接口地址与默认模型。只要服务实现了同一套协议,
6
6
  * 增加一个预设就能接入,不需要引入新的 SDK。
7
7
  */
8
- export const MODEL_PROVIDERS = [
8
+ export const model_providers = [
9
9
  "openai",
10
10
  "deepseek",
11
11
  "moonshot",
@@ -18,7 +18,7 @@ export const MODEL_PROVIDERS = [
18
18
  "custom",
19
19
  ] as const;
20
20
 
21
- export type ModelProvider = (typeof MODEL_PROVIDERS)[number];
21
+ export type ModelProvider = (typeof model_providers)[number];
22
22
 
23
23
  export interface ModelPreset {
24
24
  /** 展示用名称,出现在日志与文档中。 */
@@ -29,7 +29,7 @@ export interface ModelPreset {
29
29
  defaultModel?: string;
30
30
  }
31
31
 
32
- export const OPENAI_COMPATIBLE_PRESETS: Record<ModelProvider, ModelPreset> = {
32
+ export const openai_compatible_presets: Record<ModelProvider, ModelPreset> = {
33
33
  openai: {
34
34
  label: "OpenAI",
35
35
  baseUrl: "https://api.openai.com/v1",
@@ -15,7 +15,7 @@ import {
15
15
  import { errorMessage } from "../utils/helpers.js";
16
16
  import type { SandboxConfig } from "./config.js";
17
17
 
18
- const MAX_OUTPUT_CHARS = 100_000;
18
+ const max_output_chars = 100_000;
19
19
 
20
20
  export interface OpenSandboxBackendOptions {
21
21
  sandbox: Sandbox;
@@ -58,11 +58,11 @@ const formatExecution = (execution: CommandExecution): ExecuteResponse => {
58
58
  const stdout = execution.logs.stdout.map((message) => message.text);
59
59
  const stderr = execution.logs.stderr.map((message) => `[stderr] ${message.text}`);
60
60
  const output = [...stdout, ...stderr].join("\n");
61
- const truncated = output.length > MAX_OUTPUT_CHARS;
61
+ const truncated = output.length > max_output_chars;
62
62
  const exitCode = execution.exitCode ?? execution.error?.exitCode ?? (execution.error ? 1 : 0);
63
63
 
64
64
  return {
65
- output: truncated ? `${output.slice(0, MAX_OUTPUT_CHARS)}\n… 输出已截断` : output,
65
+ output: truncated ? `${output.slice(0, max_output_chars)}\n… 输出已截断` : output,
66
66
  exitCode,
67
67
  truncated,
68
68
  };
@@ -4,7 +4,7 @@ export type { SkillMetadata } from "./loader.js";
4
4
  export { discoverSkills, parseSkillFrontmatter } from "./loader.js";
5
5
 
6
6
  /** Deep Agents skills 中间件扫描的虚拟后端路径。 */
7
- export const DEFAULT_SKILL_SOURCES = ["/skills/"] as const;
7
+ export const default_skill_sources = ["/skills/"] as const;
8
8
 
9
9
  export interface LoadSkillsOptions {
10
10
  rootDir: string;
@@ -5,7 +5,7 @@ import type { AppConfig } from "../../config/index.js";
5
5
  export type { Logger };
6
6
 
7
7
  /** `LOG_PRETTY=true` 时使用的 pino-pretty 传输配置。 */
8
- const PRETTY_TRANSPORT = {
8
+ const pretty_transport = {
9
9
  transport: {
10
10
  target: "pino-pretty",
11
11
  options: {
@@ -20,6 +20,6 @@ export const createLogger = (config: Pick<AppConfig, "env" | "logging">): Logger
20
20
  return pino({
21
21
  level: config.logging.level,
22
22
  base: { service: "deepagent", env: config.env.NODE_ENV },
23
- ...(config.logging.pretty ? PRETTY_TRANSPORT : {}),
23
+ ...(config.logging.pretty ? pretty_transport : {}),
24
24
  });
25
25
  };
@@ -3,8 +3,8 @@ import { z } from "zod";
3
3
 
4
4
  import { getPool } from "../../storage/database/client.js";
5
5
 
6
- const READ_ONLY_START = /^\s*(?:select|with)\b/i;
7
- const FORBIDDEN_KEYWORDS =
6
+ const read_only_start = /^\s*(?:select|with)\b/i;
7
+ const forbidden_keywords =
8
8
  /\b(insert|update|delete|drop|alter|truncate|create|grant|revoke|copy|vacuum|reindex|call|do)\b/i;
9
9
 
10
10
  /**
@@ -14,13 +14,13 @@ const FORBIDDEN_KEYWORDS =
14
14
  export const assertReadOnlyQuery = (sql: string): void => {
15
15
  const statement = sql.trim().replace(/;\s*$/, "");
16
16
 
17
- if (!READ_ONLY_START.test(statement)) {
17
+ if (!read_only_start.test(statement)) {
18
18
  throw new Error("只允许 SELECT 和 WITH 查询。");
19
19
  }
20
20
  if (statement.includes(";")) {
21
21
  throw new Error("只允许单条 SQL 语句。");
22
22
  }
23
- if (FORBIDDEN_KEYWORDS.test(statement)) {
23
+ if (forbidden_keywords.test(statement)) {
24
24
  throw new Error("查询包含写入或 DDL 关键字,已拒绝执行。");
25
25
  }
26
26
  };