agen-vektor 0.3.24 → 0.3.25

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/tools/e2b.js +42 -7
  2. package/package.json +1 -1
package/dist/tools/e2b.js CHANGED
@@ -8,7 +8,7 @@ const GW_BASE = free_tier_1.FREE_GATEWAY_URL.replace(/\/v1$/, '');
8
8
  const POLL_INTERVAL_MS = Math.max(10, Number(process.env.VECTOR_E2B_POLL_MS) || 3_000);
9
9
  const POLL_MAX_MS = 320_000; // > E2B_MAX_TIMEOUT_MS worker (300s) + margin
10
10
  const OUT_CAP = 20_000;
11
- async function postRun(command, timeoutMs) {
11
+ async function postRun(command, timeoutMs, proxy) {
12
12
  const controller = new AbortController();
13
13
  const timer = setTimeout(() => controller.abort(), 30_000);
14
14
  try {
@@ -16,7 +16,7 @@ async function postRun(command, timeoutMs) {
16
16
  method: 'POST',
17
17
  signal: controller.signal,
18
18
  headers: { 'Content-Type': 'application/json', 'User-Agent': 'VectorHead-AI-Agent/0.1' },
19
- body: JSON.stringify({ command, timeout_ms: timeoutMs }),
19
+ body: JSON.stringify({ command, timeout_ms: timeoutMs, proxy }),
20
20
  });
21
21
  const data = (await res.json().catch(() => null));
22
22
  return { res, data };
@@ -25,6 +25,15 @@ async function postRun(command, timeoutMs) {
25
25
  clearTimeout(timer);
26
26
  }
27
27
  }
28
+ /** Daftar proxy Webshare ter-mask (tanpa kredensial) via gateway relay. */
29
+ async function fetchWebshareProxies() {
30
+ const res = await fetch(GW_BASE + '/v1/webshare/proxies', {
31
+ headers: { 'User-Agent': 'VectorHead-AI-Agent/0.1' },
32
+ signal: AbortSignal.timeout(30_000),
33
+ });
34
+ const data = (await res.json().catch(() => null));
35
+ return { count: data?.count || 0, proxies: data?.proxies || [], error: res.ok ? undefined : data?.error || 'HTTP ' + res.status };
36
+ }
28
37
  async function fetchStatus(id) {
29
38
  const controller = new AbortController();
30
39
  const timer = setTimeout(() => controller.abort(), 20_000);
@@ -74,6 +83,7 @@ function createE2bTools() {
74
83
  properties: {
75
84
  command: { type: 'string', description: 'The shell command to run in the sandbox (bash -lc; use && to chain)' },
76
85
  timeout_ms: { type: 'number', description: 'Timeout in ms (default 120000, max 300000)' },
86
+ proxy: { type: 'boolean', description: 'Route the command through a rotating Webshare proxy (curl/wget automatically proxied — different exit IP, anti rate-limit). Requires the gateway to have a Webshare key.' },
77
87
  },
78
88
  required: ['command'],
79
89
  },
@@ -83,8 +93,9 @@ function createE2bTools() {
83
93
  if (!command)
84
94
  return { output: 'ERROR: provide a "command"' };
85
95
  const timeoutMs = Math.min(300_000, Math.max(5_000, Number(args.timeout_ms) || 120_000));
86
- ctx.onActivity?.('e2b', `sandbox: ${command.slice(0, 80)}`);
87
- const { res, data } = await postRun(command, timeoutMs);
96
+ const useProxy = args.proxy === true;
97
+ ctx.onActivity?.('e2b', `sandbox${useProxy ? '+proxy' : ''}: ${command.slice(0, 80)}`);
98
+ const { res, data } = await postRun(command, timeoutMs, useProxy);
88
99
  if (!res.ok || !data || !data.id) {
89
100
  const why = data?.error ? ` — ${(0, credentials_1.redact)(data.error)}` : '';
90
101
  return { output: `ERROR: e2b relay HTTP ${res.status}${why}`, summary: 'e2b relay error' };
@@ -166,6 +177,7 @@ function createE2bTools() {
166
177
  action: { type: 'string', enum: ['create', 'close'], description: 'create = new persistent sandbox; close = kill it' },
167
178
  id: { type: 'string', description: 'Session id (required for close)' },
168
179
  ttl_s: { type: 'number', description: 'Session lifetime in seconds for create (default 1800, max 3600)' },
180
+ proxy: { type: 'boolean', description: 'create only: install a rotating Webshare proxy in the sandbox (~/.curlrc + profile.d) so curl/wget in every exec uses a rotating exit IP' },
169
181
  },
170
182
  required: ['action'],
171
183
  },
@@ -174,11 +186,12 @@ function createE2bTools() {
174
186
  const action = String(args.action || '');
175
187
  if (action === 'create') {
176
188
  const ttl = Math.min(3600, Math.max(120, Number(args.ttl_s) || 1800));
177
- ctx.onActivity?.('e2b', `cloud session create (${ttl}s)`);
189
+ const useProxy = args.proxy === true;
190
+ ctx.onActivity?.('e2b', `cloud session create (${ttl}s${useProxy ? '+proxy' : ''})`);
178
191
  const res = await fetch(GW_BASE + '/v1/e2b/session', {
179
192
  method: 'POST',
180
193
  headers: { 'Content-Type': 'application/json', 'User-Agent': 'VectorHead-AI-Agent/0.1' },
181
- body: JSON.stringify({ ttl_s: ttl }),
194
+ body: JSON.stringify({ ttl_s: ttl, proxy: useProxy }),
182
195
  signal: AbortSignal.timeout(60_000),
183
196
  });
184
197
  const data = (await res.json().catch(() => null));
@@ -187,7 +200,7 @@ function createE2bTools() {
187
200
  return { output: `ERROR: e2b session HTTP ${res.status}${why}`, summary: 'e2b session error' };
188
201
  }
189
202
  return {
190
- output: `session created: ${data.id} (ttl ${data.ttl}s)\nNext: e2b_upload files → e2b_exec commands (poll jobId) → e2b_download artifacts → e2b_cloud close.\nSession id: ${data.id}`,
203
+ output: `session created: ${data.id} (ttl ${data.ttl}s${data.proxy ? `, proxy ON via ${data.proxyCountry || '?'} — curl/wget otomatis lewat IP rotasi` : ''})\nNext: e2b_upload files → e2b_exec commands (poll jobId) → e2b_download artifacts → e2b_cloud close.\nSession id: ${data.id}`,
191
204
  summary: `e2b session ${data.id}`,
192
205
  data,
193
206
  };
@@ -300,6 +313,28 @@ function createE2bTools() {
300
313
  return { output: `TIMEOUT menunggu job ${jobId}. Log terakhir:\n${last.slice(0, 4000)}`, summary: 'e2b exec polling timeout', data: { jobId } };
301
314
  },
302
315
  },
316
+ {
317
+ definition: {
318
+ name: 'webshare_proxies',
319
+ description: 'List the rotating proxies available to the agent (Webshare via gateway relay). Use to check availability/countries before e2b_run/e2b_cloud with proxy:true — the gateway injects the credentials automatically (never exposed). Kredensial asli di-mask; rotasi dipilih acak oleh gateway.',
320
+ parameters: { type: 'object', properties: {} },
321
+ },
322
+ async execute(_args, ctx) {
323
+ ctx.onActivity?.('e2b', 'webshare: list proxies');
324
+ const r = await fetchWebshareProxies();
325
+ if (r.error)
326
+ return { output: `ERROR: webshare relay — ${(0, credentials_1.redact)(r.error)}`, summary: 'webshare relay error' };
327
+ if (!r.proxies.length)
328
+ return { output: 'tidak ada proxy tersedia di akun Webshare (0 proxy).', summary: 'webshare: 0 proxy' };
329
+ const lines = r.proxies.map((p) => `${p.proxy_address}:${p.port} [${p.country_code}] ${p.valid ? 'valid' : 'INVALID'}`);
330
+ return {
331
+ output: `${r.count} proxy (kredensial otomatis di-inject gateway saat proxy:true):
332
+ ${lines.join('\n')}`,
333
+ summary: `webshare: ${r.count} proxy`,
334
+ data: { count: r.count },
335
+ };
336
+ },
337
+ },
303
338
  {
304
339
  definition: {
305
340
  name: 'e2b_download',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agen-vektor",
3
- "version": "0.3.24",
3
+ "version": "0.3.25",
4
4
  "description": "VectorHead (agen-vektor) — AI Coding Agent CLI/TUI for Linux & Termux. Multi-provider, tool calling, session, permission system.",
5
5
  "type": "commonjs",
6
6
  "bin": {