cc-claw 0.3.1 → 0.3.2

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.
@@ -185,7 +185,7 @@ server.tool(
185
185
  `Task: ${agent.task ?? "none"}`,
186
186
  `Role: ${agent.role}`,
187
187
  `Tokens: ${agent.tokenInput} in / ${agent.tokenOutput} out`,
188
- agent.resultSummary ? `Result: ${agent.resultSummary.slice(0, 500)}` : null
188
+ agent.resultSummary ? `Result: ${agent.resultSummary.slice(0, 5e3)}` : null
189
189
  ].filter(Boolean).join("\n")
190
190
  }]
191
191
  };
package/dist/cli.js CHANGED
@@ -48,7 +48,7 @@ var VERSION;
48
48
  var init_version = __esm({
49
49
  "src/version.ts"() {
50
50
  "use strict";
51
- VERSION = true ? "0.3.1" : (() => {
51
+ VERSION = true ? "0.3.2" : (() => {
52
52
  try {
53
53
  return JSON.parse(readFileSync(join2(process.cwd(), "package.json"), "utf-8")).version ?? "unknown";
54
54
  } catch {
@@ -6130,61 +6130,38 @@ var init_cron = __esm({
6130
6130
 
6131
6131
  // src/agents/runners/wrap-backend.ts
6132
6132
  import { join as join8 } from "path";
6133
- import { writeFileSync as writeFileSync4, unlinkSync as unlinkSync2, mkdirSync as mkdirSync4 } from "fs";
6134
6133
  function buildMcpCommands(backendId) {
6135
6134
  const exe = backendId;
6136
6135
  return {
6137
6136
  add: (server) => {
6138
6137
  const cmd = [exe, "mcp", "add"];
6139
- if (backendId === "codex") {
6140
- if (server.env && Object.keys(server.env).length > 0 && server.command) {
6141
- const wrapperPath = writeEnvWrapper(server);
6142
- cmd.push(server.name, "--", "sh", wrapperPath);
6143
- return cmd;
6144
- }
6145
- cmd.push(server.name);
6146
- if (server.transport === "stdio" && server.command) {
6147
- cmd.push("--", server.command, ...server.args ?? []);
6148
- }
6149
- return cmd;
6138
+ if (backendId === "gemini") {
6139
+ cmd.push("-s", "user");
6150
6140
  }
6151
- if (server.env) {
6141
+ if (backendId !== "codex" && server.env) {
6152
6142
  for (const [k, v] of Object.entries(server.env)) {
6153
6143
  cmd.push("-e", `${k}=${v}`);
6154
6144
  }
6155
6145
  }
6156
6146
  cmd.push(server.name);
6157
6147
  if (server.transport === "stdio" && server.command) {
6158
- if (backendId === "claude") {
6159
- cmd.push("--", server.command, ...server.args ?? []);
6160
- } else {
6148
+ if (backendId === "gemini") {
6161
6149
  cmd.push(server.command, ...server.args ?? []);
6150
+ } else {
6151
+ cmd.push("--", server.command, ...server.args ?? []);
6162
6152
  }
6163
6153
  }
6164
6154
  return cmd;
6165
6155
  },
6166
6156
  remove: (name) => {
6167
- try {
6168
- unlinkSync2(join8(CC_CLAW_HOME, "mcp-configs", `wrapper-${name}.sh`));
6169
- } catch {
6157
+ if (backendId === "gemini") {
6158
+ return [exe, "mcp", "remove", "-s", "user", name];
6170
6159
  }
6171
6160
  return [exe, "mcp", "remove", name];
6172
6161
  },
6173
6162
  list: () => [exe, "mcp", "list"]
6174
6163
  };
6175
6164
  }
6176
- function writeEnvWrapper(server) {
6177
- const dir = join8(CC_CLAW_HOME, "mcp-configs");
6178
- mkdirSync4(dir, { recursive: true, mode: 448 });
6179
- const lines = ["#!/bin/sh"];
6180
- for (const [k, v] of Object.entries(server.env ?? {})) {
6181
- lines.push(`export ${k}='${v.replace(/'/g, "'\\''")}'`);
6182
- }
6183
- lines.push(`exec ${server.command} ${(server.args ?? []).map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ")}`);
6184
- const path = join8(dir, `wrapper-${server.name}.sh`);
6185
- writeFileSync4(path, lines.join("\n") + "\n", { mode: 448 });
6186
- return path;
6187
- }
6188
6165
  function wrapBackendAdapter(adapter) {
6189
6166
  const caps = BACKEND_CAPABILITIES[adapter.id] ?? {};
6190
6167
  const mcpCmds = buildMcpCommands(adapter.id);
@@ -6219,11 +6196,23 @@ function wrapBackendAdapter(adapter) {
6219
6196
  getMcpListCommand: () => mcpCmds.list(),
6220
6197
  prepareMcpInjection(server) {
6221
6198
  const method = caps.mcpInjection ?? "add-remove";
6222
- if (method === "config-file") {
6223
- const configPath = writeMcpConfigFile(server);
6224
- return ["--mcp-config", configPath];
6199
+ if (method !== "config-file") return [];
6200
+ if (adapter.id === "codex") {
6201
+ const safeName = server.name.replace(/[^a-zA-Z0-9_-]/g, "_");
6202
+ const args = [];
6203
+ args.push("-c", `mcp_servers.${safeName}.command="${server.command}"`);
6204
+ if (server.args?.length) {
6205
+ args.push("-c", `mcp_servers.${safeName}.args=${JSON.stringify(server.args)}`);
6206
+ }
6207
+ if (server.env) {
6208
+ for (const [k, v] of Object.entries(server.env)) {
6209
+ args.push("-c", `mcp_servers.${safeName}.env.${k}="${v}"`);
6210
+ }
6211
+ }
6212
+ return args;
6225
6213
  }
6226
- return [];
6214
+ const configPath = writeMcpConfigFile(server);
6215
+ return ["--mcp-config", configPath];
6227
6216
  },
6228
6217
  getSkillPath: () => join8(SKILLS_PATH, `agent-${adapter.id}.md`)
6229
6218
  };
@@ -6260,14 +6249,14 @@ var init_wrap_backend = __esm({
6260
6249
  supportsPermissionModes: true,
6261
6250
  maxConcurrentSessions: 4,
6262
6251
  specialties: ["code-generation", "refactoring"],
6263
- mcpInjection: "add-remove"
6252
+ mcpInjection: "config-file"
6264
6253
  }
6265
6254
  };
6266
6255
  }
6267
6256
  });
6268
6257
 
6269
6258
  // src/agents/runners/config-loader.ts
6270
- import { readFileSync as readFileSync6, readdirSync as readdirSync4, existsSync as existsSync9, mkdirSync as mkdirSync5, watchFile, unwatchFile } from "fs";
6259
+ import { readFileSync as readFileSync6, readdirSync as readdirSync4, existsSync as existsSync9, mkdirSync as mkdirSync4, watchFile, unwatchFile } from "fs";
6271
6260
  import { join as join9 } from "path";
6272
6261
  import { execFileSync } from "child_process";
6273
6262
  function resolveExecutable(config2) {
@@ -6418,7 +6407,7 @@ function loadRunnerConfig(filePath) {
6418
6407
  }
6419
6408
  function loadAllRunnerConfigs() {
6420
6409
  if (!existsSync9(RUNNERS_PATH)) {
6421
- mkdirSync5(RUNNERS_PATH, { recursive: true });
6410
+ mkdirSync4(RUNNERS_PATH, { recursive: true });
6422
6411
  return [];
6423
6412
  }
6424
6413
  const files = readdirSync4(RUNNERS_PATH).filter((f) => f.endsWith(".json"));
@@ -7300,7 +7289,7 @@ var init_install = __esm({
7300
7289
  });
7301
7290
 
7302
7291
  // src/bootstrap/profile.ts
7303
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, existsSync as existsSync11 } from "fs";
7292
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync4, existsSync as existsSync11 } from "fs";
7304
7293
  import { join as join12 } from "path";
7305
7294
  function hasActiveProfile(chatId) {
7306
7295
  return activeProfiles.has(chatId);
@@ -7404,7 +7393,7 @@ async function finalizeProfile(chatId, state, channel) {
7404
7393
  "<!-- Add any additional preferences below this line -->",
7405
7394
  ""
7406
7395
  ].join("\n");
7407
- writeFileSync5(USER_PATH3, content, "utf-8");
7396
+ writeFileSync4(USER_PATH3, content, "utf-8");
7408
7397
  activeProfiles.delete(chatId);
7409
7398
  log(`[profile] User profile saved for chat ${chatId}`);
7410
7399
  await channel.sendText(
@@ -7437,7 +7426,7 @@ function appendToUserProfile(key, value) {
7437
7426
  const updated = content.trimEnd() + `
7438
7427
  ${line}
7439
7428
  `;
7440
- writeFileSync5(USER_PATH3, updated, "utf-8");
7429
+ writeFileSync4(USER_PATH3, updated, "utf-8");
7441
7430
  log(`[profile] Appended preference: ${key}=${value}`);
7442
7431
  }
7443
7432
  var USER_PATH3, activeProfiles;
@@ -10777,7 +10766,7 @@ __export(ai_skill_exports, {
10777
10766
  generateAiSkill: () => generateAiSkill,
10778
10767
  installAiSkill: () => installAiSkill
10779
10768
  });
10780
- import { existsSync as existsSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6 } from "fs";
10769
+ import { existsSync as existsSync14, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5 } from "fs";
10781
10770
  import { join as join15 } from "path";
10782
10771
  import { homedir as homedir3 } from "os";
10783
10772
  function generateAiSkill() {
@@ -11009,8 +10998,8 @@ function installAiSkill() {
11009
10998
  const skillDir = join15(dir, "cc-claw-cli");
11010
10999
  const skillPath = join15(skillDir, "SKILL.md");
11011
11000
  try {
11012
- mkdirSync6(skillDir, { recursive: true });
11013
- writeFileSync6(skillPath, skill, "utf-8");
11001
+ mkdirSync5(skillDir, { recursive: true });
11002
+ writeFileSync5(skillPath, skill, "utf-8");
11014
11003
  installed.push(skillPath);
11015
11004
  } catch {
11016
11005
  failed.push(skillPath);
@@ -11039,7 +11028,7 @@ var index_exports = {};
11039
11028
  __export(index_exports, {
11040
11029
  main: () => main
11041
11030
  });
11042
- import { mkdirSync as mkdirSync7, existsSync as existsSync15, renameSync, statSync as statSync3 } from "fs";
11031
+ import { mkdirSync as mkdirSync6, existsSync as existsSync15, renameSync, statSync as statSync3 } from "fs";
11043
11032
  import { join as join16 } from "path";
11044
11033
  import dotenv from "dotenv";
11045
11034
  function migrateLayout() {
@@ -11137,11 +11126,11 @@ async function main() {
11137
11126
  bootstrapSkills().catch((err) => error("[cc-claw] Skill bootstrap failed:", err));
11138
11127
  try {
11139
11128
  const { generateAiSkill: generateAiSkill2 } = await Promise.resolve().then(() => (init_ai_skill(), ai_skill_exports));
11140
- const { writeFileSync: writeFileSync9, mkdirSync: mkdirSync11 } = await import("fs");
11129
+ const { writeFileSync: writeFileSync8, mkdirSync: mkdirSync10 } = await import("fs");
11141
11130
  const { join: join19 } = await import("path");
11142
11131
  const skillDir = join19(SKILLS_PATH, "cc-claw-cli");
11143
- mkdirSync11(skillDir, { recursive: true });
11144
- writeFileSync9(join19(skillDir, "SKILL.md"), generateAiSkill2(), "utf-8");
11132
+ mkdirSync10(skillDir, { recursive: true });
11133
+ writeFileSync8(join19(skillDir, "SKILL.md"), generateAiSkill2(), "utf-8");
11145
11134
  log("[cc-claw] AI skill updated");
11146
11135
  } catch {
11147
11136
  }
@@ -11197,7 +11186,7 @@ var init_index = __esm({
11197
11186
  init_bootstrap2();
11198
11187
  init_health2();
11199
11188
  for (const dir of [CC_CLAW_HOME, DATA_PATH, LOGS_PATH, SKILLS_PATH, RUNNERS_PATH, AGENTS_PATH]) {
11200
- if (!existsSync15(dir)) mkdirSync7(dir, { recursive: true });
11189
+ if (!existsSync15(dir)) mkdirSync6(dir, { recursive: true });
11201
11190
  }
11202
11191
  migrateLayout();
11203
11192
  if (existsSync15(ENV_PATH)) {
@@ -11221,7 +11210,7 @@ __export(service_exports, {
11221
11210
  serviceStatus: () => serviceStatus,
11222
11211
  uninstallService: () => uninstallService
11223
11212
  });
11224
- import { existsSync as existsSync16, mkdirSync as mkdirSync8, writeFileSync as writeFileSync7, unlinkSync as unlinkSync3 } from "fs";
11213
+ import { existsSync as existsSync16, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6, unlinkSync as unlinkSync2 } from "fs";
11225
11214
  import { execFileSync as execFileSync2, execSync as execSync5 } from "child_process";
11226
11215
  import { homedir as homedir4, platform } from "os";
11227
11216
  import { join as join17, dirname as dirname4 } from "path";
@@ -11299,15 +11288,15 @@ function generatePlist() {
11299
11288
  }
11300
11289
  function installMacOS() {
11301
11290
  const agentsDir = dirname4(PLIST_PATH);
11302
- if (!existsSync16(agentsDir)) mkdirSync8(agentsDir, { recursive: true });
11303
- if (!existsSync16(LOGS_PATH)) mkdirSync8(LOGS_PATH, { recursive: true });
11291
+ if (!existsSync16(agentsDir)) mkdirSync7(agentsDir, { recursive: true });
11292
+ if (!existsSync16(LOGS_PATH)) mkdirSync7(LOGS_PATH, { recursive: true });
11304
11293
  if (existsSync16(PLIST_PATH)) {
11305
11294
  try {
11306
11295
  execFileSync2("launchctl", ["unload", PLIST_PATH]);
11307
11296
  } catch {
11308
11297
  }
11309
11298
  }
11310
- writeFileSync7(PLIST_PATH, generatePlist());
11299
+ writeFileSync6(PLIST_PATH, generatePlist());
11311
11300
  console.log(` Installed: ${PLIST_PATH}`);
11312
11301
  execFileSync2("launchctl", ["load", PLIST_PATH]);
11313
11302
  console.log(" Service loaded and starting.");
@@ -11321,7 +11310,7 @@ function uninstallMacOS() {
11321
11310
  execFileSync2("launchctl", ["unload", PLIST_PATH]);
11322
11311
  } catch {
11323
11312
  }
11324
- unlinkSync3(PLIST_PATH);
11313
+ unlinkSync2(PLIST_PATH);
11325
11314
  console.log(" Service uninstalled.");
11326
11315
  }
11327
11316
  function statusMacOS() {
@@ -11364,9 +11353,9 @@ WantedBy=default.target
11364
11353
  `;
11365
11354
  }
11366
11355
  function installLinux() {
11367
- if (!existsSync16(SYSTEMD_DIR)) mkdirSync8(SYSTEMD_DIR, { recursive: true });
11368
- if (!existsSync16(LOGS_PATH)) mkdirSync8(LOGS_PATH, { recursive: true });
11369
- writeFileSync7(UNIT_PATH, generateUnit());
11356
+ if (!existsSync16(SYSTEMD_DIR)) mkdirSync7(SYSTEMD_DIR, { recursive: true });
11357
+ if (!existsSync16(LOGS_PATH)) mkdirSync7(LOGS_PATH, { recursive: true });
11358
+ writeFileSync6(UNIT_PATH, generateUnit());
11370
11359
  console.log(` Installed: ${UNIT_PATH}`);
11371
11360
  execFileSync2("systemctl", ["--user", "daemon-reload"]);
11372
11361
  execFileSync2("systemctl", ["--user", "enable", "cc-claw"]);
@@ -11386,7 +11375,7 @@ function uninstallLinux() {
11386
11375
  execFileSync2("systemctl", ["--user", "disable", "cc-claw"]);
11387
11376
  } catch {
11388
11377
  }
11389
- unlinkSync3(UNIT_PATH);
11378
+ unlinkSync2(UNIT_PATH);
11390
11379
  execFileSync2("systemctl", ["--user", "daemon-reload"]);
11391
11380
  console.log(" Service uninstalled.");
11392
11381
  }
@@ -12765,7 +12754,7 @@ __export(db_exports, {
12765
12754
  dbPath: () => dbPath,
12766
12755
  dbStats: () => dbStats
12767
12756
  });
12768
- import { existsSync as existsSync26, statSync as statSync6, copyFileSync, mkdirSync as mkdirSync9 } from "fs";
12757
+ import { existsSync as existsSync26, statSync as statSync6, copyFileSync, mkdirSync as mkdirSync8 } from "fs";
12769
12758
  import { dirname as dirname5 } from "path";
12770
12759
  async function dbStats(globalOpts) {
12771
12760
  if (!existsSync26(DB_PATH)) {
@@ -12816,7 +12805,7 @@ async function dbBackup(globalOpts, destPath) {
12816
12805
  }
12817
12806
  const dest = destPath ?? `${DB_PATH}.backup-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
12818
12807
  try {
12819
- mkdirSync9(dirname5(dest), { recursive: true });
12808
+ mkdirSync8(dirname5(dest), { recursive: true });
12820
12809
  copyFileSync(DB_PATH, dest);
12821
12810
  const walPath = DB_PATH + "-wal";
12822
12811
  if (existsSync26(walPath)) copyFileSync(walPath, dest + "-wal");
@@ -14212,7 +14201,7 @@ var init_completion = __esm({
14212
14201
 
14213
14202
  // src/setup.ts
14214
14203
  var setup_exports = {};
14215
- import { existsSync as existsSync37, writeFileSync as writeFileSync8, readFileSync as readFileSync16, copyFileSync as copyFileSync2, mkdirSync as mkdirSync10, statSync as statSync7 } from "fs";
14204
+ import { existsSync as existsSync37, writeFileSync as writeFileSync7, readFileSync as readFileSync16, copyFileSync as copyFileSync2, mkdirSync as mkdirSync9, statSync as statSync7 } from "fs";
14216
14205
  import { execFileSync as execFileSync4 } from "child_process";
14217
14206
  import { createInterface as createInterface5 } from "readline";
14218
14207
  import { join as join18 } from "path";
@@ -14289,7 +14278,7 @@ async function setup() {
14289
14278
  }
14290
14279
  console.log("");
14291
14280
  for (const dir of [CC_CLAW_HOME, DATA_PATH, LOGS_PATH, SKILLS_PATH, RUNNERS_PATH, AGENTS_PATH]) {
14292
- if (!existsSync37(dir)) mkdirSync10(dir, { recursive: true });
14281
+ if (!existsSync37(dir)) mkdirSync9(dir, { recursive: true });
14293
14282
  }
14294
14283
  const env = {};
14295
14284
  const envSource = existsSync37(ENV_PATH) ? ENV_PATH : existsSync37(".env") ? ".env" : null;
@@ -14497,7 +14486,7 @@ async function setup() {
14497
14486
  envLines.push("", "# Video Analysis", `GEMINI_API_KEY=${env.GEMINI_API_KEY}`);
14498
14487
  }
14499
14488
  const envContent = envLines.join("\n") + "\n";
14500
- writeFileSync8(ENV_PATH, envContent, { mode: 384 });
14489
+ writeFileSync7(ENV_PATH, envContent, { mode: 384 });
14501
14490
  console.log(green(` Config saved to ${ENV_PATH} (permissions: owner-only)`));
14502
14491
  header(6, TOTAL_STEPS, "Run on Startup (Daemon)");
14503
14492
  console.log(" CC-Claw can run automatically in the background, starting");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-claw",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "CC-Claw: Personal AI assistant on Telegram — multi-backend (Claude, Gemini, Codex), sub-agent orchestration, MCP management",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",