@clawos-dev/clawd 0.2.534 → 0.2.535

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 (2) hide show
  1. package/dist/cli.cjs +40 -9
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -54624,6 +54624,32 @@ function upsertEnvFileVar(file, key, value) {
54624
54624
  import_node_fs28.default.writeFileSync(file, `${out.join("\n")}
54625
54625
  `, { encoding: "utf8", mode: 384 });
54626
54626
  }
54627
+ function readEnvFileVar(file, key) {
54628
+ try {
54629
+ return parseEnvFile(import_node_fs28.default.readFileSync(file, "utf8"))[key];
54630
+ } catch {
54631
+ return void 0;
54632
+ }
54633
+ }
54634
+ function removeEnvFileVar(file, key) {
54635
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) throw new Error(`invalid env name: ${key}`);
54636
+ let lines;
54637
+ try {
54638
+ lines = import_node_fs28.default.readFileSync(file, "utf8").split("\n");
54639
+ } catch {
54640
+ return;
54641
+ }
54642
+ if (lines[lines.length - 1] === "") lines.pop();
54643
+ const re2 = new RegExp(`^\\s*(?:export\\s+)?${key}=`);
54644
+ const out = lines.filter((l2) => !re2.test(l2));
54645
+ if (out.length === lines.length) return;
54646
+ if (out.every((l2) => l2.trim() === "" || l2.trim().startsWith("#"))) {
54647
+ import_node_fs28.default.rmSync(file, { force: true });
54648
+ return;
54649
+ }
54650
+ import_node_fs28.default.writeFileSync(file, `${out.join("\n")}
54651
+ `, { encoding: "utf8", mode: 384 });
54652
+ }
54627
54653
  function readSecretTable(args) {
54628
54654
  return {
54629
54655
  ...args.bundleRoot ? readDir(args.bundleRoot, args.logger) : {},
@@ -59010,13 +59036,16 @@ async function storeGitCredential(exec, token) {
59010
59036
  return back?.token === token;
59011
59037
  }
59012
59038
  async function resolveGithubAuth(args) {
59013
- const fromGit = await readGitCredential(args.exec);
59014
- if (fromGit) return { token: fromGit.token, source: "git" };
59015
59039
  const fromFile = args.fileToken();
59016
- return fromFile ? { token: fromFile, source: "file" } : void 0;
59040
+ if (fromFile) return { token: fromFile, source: "file" };
59041
+ const fromGit = await readGitCredential(args.exec);
59042
+ return fromGit ? { token: fromGit.token, source: "git" } : void 0;
59017
59043
  }
59018
59044
  async function storeGithubAuth(args) {
59019
- if (await storeGitCredential(args.exec, args.token)) return { token: args.token, source: "git" };
59045
+ if (await storeGitCredential(args.exec, args.token)) {
59046
+ args.clearFileToken();
59047
+ return { token: args.token, source: "git" };
59048
+ }
59020
59049
  args.writeFileToken(args.token);
59021
59050
  return { token: args.token, source: "file" };
59022
59051
  }
@@ -70418,7 +70447,7 @@ function computeMethodAccess(args) {
70418
70447
  }
70419
70448
 
70420
70449
  // src/version.ts
70421
- var version = "0.2.534".length > 0 ? "0.2.534" : "dev";
70450
+ var version = "0.2.535".length > 0 ? "0.2.535" : "dev";
70422
70451
 
70423
70452
  // src/cli-probe/probe.ts
70424
70453
  var fs77 = __toESM(require("fs"), 1);
@@ -73214,15 +73243,17 @@ async function startDaemon(config) {
73214
73243
  const secretsBundleRoot = findSecretsBundleRoot(logger);
73215
73244
  const localSecretsDir = import_node_path79.default.join(config.dataDir, LOCAL_SECRETS_DIRNAME);
73216
73245
  const readSecrets = () => readSecretTable({ bundleRoot: secretsBundleRoot, overrideDir: localSecretsDir, logger });
73246
+ const githubTokenFile = import_node_path79.default.join(localSecretsDir, GITHUB_TOKEN_FILE);
73217
73247
  const githubIdentity = createGithubIdentity({
73218
- resolve: () => resolveGithubAuth({ exec: runCommand, fileToken: () => readSecrets()[GITHUB_TOKEN_VAR] }),
73248
+ resolve: () => resolveGithubAuth({ exec: runCommand, fileToken: () => readEnvFileVar(githubTokenFile, GITHUB_TOKEN_VAR) }),
73219
73249
  store: (token) => storeGithubAuth({
73220
73250
  exec: runCommand,
73221
73251
  token,
73222
73252
  writeFileToken: (t2) => {
73223
- upsertEnvFileVar(import_node_path79.default.join(localSecretsDir, GITHUB_TOKEN_FILE), GITHUB_TOKEN_VAR, t2);
73224
- logger.warn("github.identity.token-in-file", { reason: "git \u6CA1\u914D credential helper\uFF0Ctoken \u843D\u672C\u673A\u51ED\u636E\u8868", file: GITHUB_TOKEN_FILE });
73225
- }
73253
+ upsertEnvFileVar(githubTokenFile, GITHUB_TOKEN_VAR, t2);
73254
+ logger.warn("github.identity.token-in-file", { reason: "git \u4E0D\u6536\uFF08\u6CA1\u914D credential helper\uFF0C\u6216\u53EA\u6709 gh \u90A3\u4E2A\u53EA\u8BFB\u7684\uFF09\uFF0Ctoken \u843D\u672C\u673A\u51ED\u636E\u8868", file: GITHUB_TOKEN_FILE });
73255
+ },
73256
+ clearFileToken: () => removeEnvFileVar(githubTokenFile, GITHUB_TOKEN_VAR)
73226
73257
  }),
73227
73258
  api: (token) => createGithubApi({ token }),
73228
73259
  oauth: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.534",
3
+ "version": "0.2.535",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",