@ancha-labs/cli 0.1.0 → 0.1.1

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.
@@ -59,7 +59,7 @@ class AnchaAgent(BaseInstalledAgent):
59
59
  await environment.upload_dir(self.entry['source'], '/workspace')
60
60
  # Each attempt owns this bounded copy; database seeds may need to write locally.
61
61
  check(await environment.exec('chmod -R a+rwX /workspace', user='root'), 'Could not prepare writable agent workspace')
62
- result = await environment.service_exec('node /opt/ancha/companion.mjs connection', service='tools', timeout_sec=30)
62
+ result = await environment.service_exec('node /opt/ancha/companion.mjs connection', service='tools', timeout_sec=60)
63
63
  check(result, 'The mock tools did not start')
64
64
  connection = json.loads(result.stdout)
65
65
  manifest = connection.get('manifest')
@@ -150,7 +150,7 @@ class AnchaAgent(BaseInstalledAgent):
150
150
  # Save the private bounded log before stopping any process. In particular,
151
151
  # readiness failures and HTTP-task exceptions bypass the success-path read.
152
152
  try:
153
- log=await asyncio.shield(environment.exec('if [ -f /tmp/ancha-agent.log ]; then tail -c 65536 /tmp/ancha-agent.log; fi',user='65532',timeout_sec=10))
153
+ log=await asyncio.shield(environment.exec('if [ -f /tmp/ancha-agent.log ]; then tail -c 65536 /tmp/ancha-agent.log; fi',user='65532',timeout_sec=30))
154
154
  output=safe(log.stdout or '')[-65536:]
155
155
  previous=OUTPUTS.get(self.aid,{})
156
156
  OUTPUTS[self.aid]={**previous,'logs':output}
@@ -160,11 +160,11 @@ class AnchaAgent(BaseInstalledAgent):
160
160
  # Stop all descendants before freezing the tool world. This UID belongs
161
161
  # only to this attempt; Harbor still owns container/network teardown.
162
162
  try:
163
- await asyncio.shield(environment.exec('kill -KILL -1',user='65532',timeout_sec=10))
163
+ await asyncio.shield(environment.exec('kill -KILL -1',user='65532',timeout_sec=30))
164
164
  except BaseException:
165
165
  await asyncio.shield(environment.stop_service('main'))
166
166
  try:
167
- capture = await asyncio.shield(environment.service_exec('node /opt/ancha/companion.mjs capture',service='tools',timeout_sec=15))
167
+ capture = await asyncio.shield(environment.service_exec('node /opt/ancha/companion.mjs capture',service='tools',timeout_sec=60))
168
168
  check(capture,'Could not collect final tool state')
169
169
  CAPTURES[self.aid] = json.loads(capture.stdout)
170
170
  except BaseException as exc:
@@ -10,7 +10,11 @@ for (const [variable, path, headers] of calls) {
10
10
  const base = process.env[variable];
11
11
  if (!base) continue;
12
12
  const url = new URL(`${base.replace(/\/+$/, '')}/${path}`);
13
- if (!['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)) throw new Error('reference companions require a loopback twin URL');
13
+ // A twin URL is loopback (local server) or carries this environment's /e/<id>/ path (hosted server);
14
+ // a real API has neither, so the reference companion can never reach one.
15
+ const envId = process.env.ANCHA_ENV_ID;
16
+ const twin = ['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname) || (envId && url.pathname.includes(`/e/${envId}/`));
17
+ if (!twin) throw new Error('reference companions only call Ancha twins: a loopback URL or this environment\'s /e/<id>/ path');
14
18
  const response = await fetch(url, { headers, signal: AbortSignal.timeout(3000) });
15
19
  if (!response.ok) throw new Error(`${variable}: HTTP ${response.status}`);
16
20
  const body = await response.json();