garrytan/gstack · error · Error

Cannot save domain-skill: no top-level URL on active tab. Ca

Error message

Cannot save domain-skill: no top-level URL on active tab.
Cause: tab is empty or on chrome:// page.
Action: navigate to the target site first with $B goto <url>.

What it means

Error "Cannot save domain-skill: no top-level URL on active tab. Cause: tab is empty or on chrome:// page. Action: navigate to the target site first with $B goto <url>." thrown in garrytan/gstack.

Source

Thrown at browse/src/domain-skills.ts:100

  h = h.replace(/^https?:\/\//, '');
  // strip path/query
  h = h.split('/')[0]!.split('?')[0]!.split('#')[0]!;
  // strip port
  h = h.split(':')[0]!;
  // strip www. prefix
  h = h.replace(/^www\./, '');
  return h;
}

/**
 * Derive hostname from the active tab's top-level origin.
 * Closes the confused-deputy bug (Codex T3): agent cannot supply a wrong
 * hostname even if it tried — host is read from the page state we control.
 */
export async function deriveHostFromActiveTab(page: Page): Promise<string> {
  const url = page.url();
  if (!url || url === 'about:blank' || url.startsWith('chrome://')) {
    throw new Error(
      'Cannot save domain-skill: no top-level URL on active tab.\n' +
        'Cause: tab is empty or on chrome:// page.\n' +
        'Action: navigate to the target site first with $B goto <url>.'
    );
  }
  return normalizeHost(url);
}

// ─── File I/O (T5: append-only + flock-free atomic appends) ────

async function ensureDir(filePath: string): Promise<void> {
  await fs.mkdir(path.dirname(filePath), { recursive: true });
}

/**
 * Append a JSONL row atomically. POSIX guarantees atomicity for writes <
 * PIPE_BUF (typically 4KB) when O_APPEND is set. Each row is single-line JSON
 * well under that bound. fsync ensures durability before return.

View on GitHub (pinned to 94993f7401)

When it happens

Trigger: Thrown at browse/src/domain-skills.ts:100 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12). Data as JSON: /api/errors/0e2ff64b8fd98889. Report an issue: GitHub.