Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@
},
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.2.74"
},
"patchedDependencies": {
"telegraf@4.16.3": "patches/telegraf@4.16.3.patch"
}
}
15 changes: 15 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ if (!process.env.CLAUDE_API_KEY && !process.env.CLAUDE_CODE_OAUTH_TOKEN) {
}
}

// Strip Claude Code's nested-session markers from process.env.
// When Archon is launched from inside a Claude Code terminal session, the parent
// exports CLAUDECODE and several CLAUDE_CODE_* markers. The embedded CLI spawned
// by the Claude Agent SDK refuses to launch if it sees any of them (nested-session
// guard). SUBPROCESS_ENV_ALLOWLIST already excludes these, but the SDK leaks
// process.env into the subprocess anyway, so we delete at the process level.
// Auth/config vars (OAUTH_TOKEN, USE_BEDROCK, USE_VERTEX) are kept — only the
// nested-session markers below are removed.
delete process.env.CLAUDECODE;
delete process.env.CLAUDE_CODE_ENTRYPOINT;
delete process.env.CLAUDE_CODE_EXECPATH;
delete process.env.CLAUDE_CODE_HIDE_ACCOUNT_INFO;
delete process.env.CLAUDE_CODE_NO_FLICKER;
delete process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;

// DATABASE_URL is no longer required - SQLite will be used as default

// Import commands after dotenv is loaded
Expand Down
15 changes: 15 additions & 0 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ if (
process.env.CLAUDE_USE_GLOBAL_AUTH = 'true';
}

// Strip Claude Code's nested-session markers from process.env.
// When Archon is launched from inside a Claude Code terminal session, the parent
// exports CLAUDECODE and several CLAUDE_CODE_* markers. The embedded CLI spawned
// by the Claude Agent SDK refuses to launch if it sees any of them (nested-session
// guard). SUBPROCESS_ENV_ALLOWLIST already excludes these, but the SDK leaks
// process.env into the subprocess anyway, so we delete at the process level.
// Auth/config vars (OAUTH_TOKEN, USE_BEDROCK, USE_VERTEX) are kept — only the
// nested-session markers below are removed.
delete process.env.CLAUDECODE;
delete process.env.CLAUDE_CODE_ENTRYPOINT;
delete process.env.CLAUDE_CODE_EXECPATH;
delete process.env.CLAUDE_CODE_HIDE_ACCOUNT_INFO;
delete process.env.CLAUDE_CODE_NO_FLICKER;
delete process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;

import { OpenAPIHono } from '@hono/zod-openapi';
import { validationErrorHook } from './routes/openapi-defaults';
import { TelegramAdapter, GitHubAdapter, DiscordAdapter, SlackAdapter } from '@archon/adapters';
Expand Down
18 changes: 18 additions & 0 deletions patches/telegraf@4.16.3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/lib/core/network/client.js b/lib/core/network/client.js
index 25fbbbb47c7f88e83ae26f629e5ae1a0c141725c..7ee7bc4fc5e5d8fdb2f6307ecfdf0e3b932d1943 100644
--- a/lib/core/network/client.js
+++ b/lib/core/network/client.js
@@ -245,7 +245,12 @@ async function answerToWebhook(response, payload, options) {
return true;
}
function redactToken(error) {
- error.message = error.message.replace(/\/(bot|user)(\d+):[^/]+\//, '/$1$2:[REDACTED]/');
+ // Bun frozen Error.message workaround: assignment may throw TypeError in Bun
+ // runtimes where error.message is non-writable. Fall back to re-throwing the
+ // original error rather than killing the polling loop.
+ try {
+ error.message = error.message.replace(/\/(bot|user)(\d+):[^/]+\//, '/$1$2:[REDACTED]/');
+ } catch (_) { /* message is read-only; re-throw original */ }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve token redaction on readonly message errors

Catching and ignoring failures in redactToken means Bun readonly-message errors are rethrown with the original unredacted text, which can include /bot<id>:<token>/ and leak the Telegram bot token into logs. In this exact Bun 1.3+ path, the new behavior fixes retries but drops the security guarantee this function exists to provide; please keep retry behavior while still throwing a redacted error payload.

Useful? React with 👍 / 👎.

throw error;
}
class ApiClient {