@exreve/exk 1.0.19 → 1.0.21
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.
- package/dist/agentSession.js +10 -28
- package/dist/index.js +0 -93
- package/dist/ttc-cli.tar.gz +0 -0
- package/package.json +1 -1
package/dist/agentSession.js
CHANGED
|
@@ -134,11 +134,10 @@ function loadAiConfig() {
|
|
|
134
134
|
const apiKey = typeof config.authToken === 'string' ? config.authToken.trim() : '';
|
|
135
135
|
const baseUrl = typeof config.baseUrl === 'string' ? config.baseUrl.trim() : '';
|
|
136
136
|
const model = typeof config.model === 'string' && config.model.trim() ? config.model.trim() : DEFAULT_AI_MODEL;
|
|
137
|
-
|
|
138
|
-
return { apiKey, baseUrl, model, proxy };
|
|
137
|
+
return { apiKey, baseUrl, model };
|
|
139
138
|
}
|
|
140
139
|
catch {
|
|
141
|
-
return { apiKey: '', baseUrl: '', model: DEFAULT_AI_MODEL
|
|
140
|
+
return { apiKey: '', baseUrl: '', model: DEFAULT_AI_MODEL };
|
|
142
141
|
}
|
|
143
142
|
}
|
|
144
143
|
/** Create (or reuse) an empty directory to use as CLAUDE_CONFIG_DIR.
|
|
@@ -152,17 +151,6 @@ function getEmptyConfigDir() {
|
|
|
152
151
|
}
|
|
153
152
|
return configDir;
|
|
154
153
|
}
|
|
155
|
-
const PROXY_CONFIG_PATH = path.join(os.homedir(), '.talk-to-code', 'proxy.json');
|
|
156
|
-
/** Read proxy toggle state from disk (synchronous) */
|
|
157
|
-
function readProxyToggle() {
|
|
158
|
-
try {
|
|
159
|
-
const data = readFileSync(PROXY_CONFIG_PATH, 'utf-8');
|
|
160
|
-
return JSON.parse(data);
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
return { enabled: false };
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
154
|
/** Env for the Claude Code child: copy of host env with host ANTHROPIC_* stripped, then inject from ai-config only.
|
|
167
155
|
* If a local model is provided, override baseUrl to point to the anthropic-proxy adapter. */
|
|
168
156
|
function envForClaudeCodeChild(localModel) {
|
|
@@ -172,29 +160,23 @@ function envForClaudeCodeChild(localModel) {
|
|
|
172
160
|
delete env.ANTHROPIC_BASE_URL;
|
|
173
161
|
delete env.ANTHROPIC_AUTH_TOKEN;
|
|
174
162
|
// Inject from our ai-config.json only
|
|
175
|
-
const { apiKey, baseUrl
|
|
163
|
+
const { apiKey, baseUrl } = loadAiConfig();
|
|
176
164
|
if (apiKey)
|
|
177
165
|
env.ANTHROPIC_API_KEY = apiKey;
|
|
178
166
|
if (baseUrl)
|
|
179
167
|
env.ANTHROPIC_BASE_URL = baseUrl;
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
// Clear any inherited proxy env
|
|
188
|
-
delete env.HTTPS_PROXY;
|
|
189
|
-
delete env.HTTP_PROXY;
|
|
190
|
-
delete env.https_proxy;
|
|
191
|
-
delete env.http_proxy;
|
|
192
|
-
}
|
|
168
|
+
// Clear any inherited proxy env
|
|
169
|
+
delete env.HTTPS_PROXY;
|
|
170
|
+
delete env.HTTP_PROXY;
|
|
171
|
+
delete env.https_proxy;
|
|
172
|
+
delete env.http_proxy;
|
|
193
173
|
// Prevent ~/.claude/settings.json env section from overriding our base URL.
|
|
194
174
|
// This redirects the Claude config dir to an empty dir so that
|
|
195
175
|
// ~/.claude/settings.json (which may have ANTHROPIC_BASE_URL set to z.ai)
|
|
196
176
|
// is never read during the CLI process initialization.
|
|
197
177
|
env.CLAUDE_CONFIG_DIR = getEmptyConfigDir();
|
|
178
|
+
// Allow Claude to run as root (e.g. inside Docker containers)
|
|
179
|
+
env.IS_SANDBOX = '1';
|
|
198
180
|
return env;
|
|
199
181
|
}
|
|
200
182
|
/** Get env overrides for a local model (adapter proxy URL + dummy key). Returns null if not a local model. */
|
package/dist/index.js
CHANGED
|
@@ -66,33 +66,6 @@ async function fetchAiConfig(authToken) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
const AI_CONFIG_FILE = path.join(CONFIG_DIR, 'ai-config.json');
|
|
69
|
-
const PROXY_CONFIG_FILE = path.join(CONFIG_DIR, 'proxy.json');
|
|
70
|
-
/** Read proxy toggle state from disk */
|
|
71
|
-
async function readProxyConfig() {
|
|
72
|
-
try {
|
|
73
|
-
const raw = await fs.readFile(PROXY_CONFIG_FILE, 'utf-8');
|
|
74
|
-
return JSON.parse(raw);
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
return { enabled: false };
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/** Write proxy toggle state to disk */
|
|
81
|
-
async function writeProxyConfig(cfg) {
|
|
82
|
-
await fs.mkdir(CONFIG_DIR, { recursive: true });
|
|
83
|
-
await fs.writeFile(PROXY_CONFIG_FILE, JSON.stringify(cfg, null, 2));
|
|
84
|
-
}
|
|
85
|
-
/** Get the proxy URL from ai-config.json (saved from backend) */
|
|
86
|
-
function getProxyUrl() {
|
|
87
|
-
try {
|
|
88
|
-
const raw = fsSync.readFileSync(AI_CONFIG_FILE, 'utf-8');
|
|
89
|
-
const j = JSON.parse(raw);
|
|
90
|
-
return typeof j.proxy === 'string' ? j.proxy.trim() : '';
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
return '';
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
69
|
/** True if ai-config.json has a model API key (not read from host ANTHROPIC_* env). */
|
|
97
70
|
function hasAiCredentials() {
|
|
98
71
|
try {
|
|
@@ -1823,39 +1796,6 @@ async function runDaemon(foreground = false, email) {
|
|
|
1823
1796
|
});
|
|
1824
1797
|
});
|
|
1825
1798
|
// Cloudflared handlers
|
|
1826
|
-
// Proxy toggle handler
|
|
1827
|
-
socket.on('proxy:toggle:request', async (data, callback) => {
|
|
1828
|
-
try {
|
|
1829
|
-
const { enable } = data;
|
|
1830
|
-
const proxyUrl = getProxyUrl();
|
|
1831
|
-
if (enable && !proxyUrl) {
|
|
1832
|
-
callback?.({ success: false, enabled: false });
|
|
1833
|
-
return;
|
|
1834
|
-
}
|
|
1835
|
-
await writeProxyConfig({ enabled: enable });
|
|
1836
|
-
if (foreground) {
|
|
1837
|
-
console.log(`[CLI] Proxy ${enable ? 'enabled' : 'disabled'}${proxyUrl ? `: ${proxyUrl}` : ''}`);
|
|
1838
|
-
}
|
|
1839
|
-
else {
|
|
1840
|
-
console.log(`Proxy ${enable ? 'enabled' : 'disabled'}`);
|
|
1841
|
-
}
|
|
1842
|
-
callback?.({ success: true, enabled: enable, proxyUrl: enable ? proxyUrl : undefined });
|
|
1843
|
-
}
|
|
1844
|
-
catch (error) {
|
|
1845
|
-
callback?.({ success: false, enabled: false });
|
|
1846
|
-
}
|
|
1847
|
-
});
|
|
1848
|
-
// Proxy status handler
|
|
1849
|
-
socket.on('proxy:status:request', async (_data, callback) => {
|
|
1850
|
-
try {
|
|
1851
|
-
const proxyConfig = await readProxyConfig();
|
|
1852
|
-
const proxyUrl = getProxyUrl();
|
|
1853
|
-
callback?.({ enabled: proxyConfig.enabled, proxyUrl: proxyConfig.enabled ? proxyUrl : undefined });
|
|
1854
|
-
}
|
|
1855
|
-
catch {
|
|
1856
|
-
callback?.({ enabled: false });
|
|
1857
|
-
}
|
|
1858
|
-
});
|
|
1859
1799
|
socket.on('cloudflared:check:request', async () => {
|
|
1860
1800
|
try {
|
|
1861
1801
|
let installed = false;
|
|
@@ -2839,37 +2779,4 @@ program
|
|
|
2839
2779
|
process.exit(1);
|
|
2840
2780
|
});
|
|
2841
2781
|
});
|
|
2842
|
-
// Enable proxy command
|
|
2843
|
-
program
|
|
2844
|
-
.command('enable')
|
|
2845
|
-
.description('Enable a feature (e.g. proxy)')
|
|
2846
|
-
.argument('<feature>', 'Feature to enable (proxy)')
|
|
2847
|
-
.action(async (feature) => {
|
|
2848
|
-
if (feature !== 'proxy') {
|
|
2849
|
-
console.error(`Unknown feature: ${feature}. Available: proxy`);
|
|
2850
|
-
process.exit(1);
|
|
2851
|
-
}
|
|
2852
|
-
const proxyUrl = getProxyUrl();
|
|
2853
|
-
if (!proxyUrl) {
|
|
2854
|
-
console.log('No proxy URL configured. Run "exk daemon" first to sync config from server.');
|
|
2855
|
-
process.exit(1);
|
|
2856
|
-
}
|
|
2857
|
-
await writeProxyConfig({ enabled: true });
|
|
2858
|
-
console.log(`Proxy enabled: ${proxyUrl}`);
|
|
2859
|
-
process.exit(0);
|
|
2860
|
-
});
|
|
2861
|
-
// Disable proxy command
|
|
2862
|
-
program
|
|
2863
|
-
.command('disable')
|
|
2864
|
-
.description('Disable a feature (e.g. proxy)')
|
|
2865
|
-
.argument('<feature>', 'Feature to disable (proxy)')
|
|
2866
|
-
.action(async (feature) => {
|
|
2867
|
-
if (feature !== 'proxy') {
|
|
2868
|
-
console.error(`Unknown feature: ${feature}. Available: proxy`);
|
|
2869
|
-
process.exit(1);
|
|
2870
|
-
}
|
|
2871
|
-
await writeProxyConfig({ enabled: false });
|
|
2872
|
-
console.log('Proxy disabled');
|
|
2873
|
-
process.exit(0);
|
|
2874
|
-
});
|
|
2875
2782
|
program.parse();
|
package/dist/ttc-cli.tar.gz
CHANGED
|
Binary file
|