ampcode-connector 0.1.10 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ampcode-connector",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Proxy AmpCode through local OAuth subscriptions (Claude Code, Codex, Gemini CLI, Antigravity)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -42,13 +42,15 @@
42
42
  "devDependencies": {
43
43
  "@biomejs/biome": "^2.4.2",
44
44
  "@google/genai": "^1.42.0",
45
- "@types/bun": "^1.3.9"
45
+ "@types/bun": "^1.3.9",
46
+ "@types/turndown": "^5.0.6"
46
47
  },
47
48
  "peerDependencies": {
48
49
  "typescript": "^5.9.3"
49
50
  },
50
51
  "dependencies": {
51
- "@kreuzberg/html-to-markdown": "^2.25.1",
52
- "exa-js": "^2.4.0"
52
+ "exa-js": "^2.4.0",
53
+ "turndown": "^7.2.2",
54
+ "turndown-plugin-gfm": "^1.0.2"
53
55
  }
54
56
  }
@@ -7,6 +7,7 @@ import type { LogLevel } from "../utils/logger.ts";
7
7
  import { logger } from "../utils/logger.ts";
8
8
 
9
9
  export interface ProxyConfig {
10
+ hostname: string;
10
11
  port: number;
11
12
  ampUpstreamUrl: string;
12
13
  ampApiKey?: string;
@@ -20,6 +21,7 @@ export interface ProxyConfig {
20
21
  }
21
22
 
22
23
  const DEFAULTS: ProxyConfig = {
24
+ hostname: "localhost",
23
25
  port: 8765,
24
26
  ampUpstreamUrl: DEFAULT_AMP_UPSTREAM_URL,
25
27
  logLevel: "info",
@@ -44,6 +46,7 @@ export async function loadConfig(): Promise<ProxyConfig> {
44
46
  }
45
47
 
46
48
  return {
49
+ hostname: asString(file?.hostname) ?? process.env.HOST ?? DEFAULTS.hostname,
47
50
  port,
48
51
  ampUpstreamUrl: asString(file?.ampUpstreamUrl) ?? DEFAULTS.ampUpstreamUrl,
49
52
  ampApiKey: apiKey,
package/src/index.ts CHANGED
@@ -59,7 +59,7 @@ function banner(config: ProxyConfig): void {
59
59
 
60
60
  line();
61
61
  line(` ${s.bold}ampcode-connector${s.reset}`);
62
- line(` ${s.dim}http://localhost:${config.port}${s.reset}`);
62
+ line(` ${s.dim}http://${config.hostname}:${config.port}${s.reset}`);
63
63
  line();
64
64
 
65
65
  for (const p of providers) {
@@ -17,7 +17,7 @@ import { type ParsedBody, parseBody } from "./body.ts";
17
17
  export function startServer(config: ProxyConfig): ReturnType<typeof Bun.serve> {
18
18
  const server = Bun.serve({
19
19
  port: config.port,
20
- hostname: "localhost",
20
+ hostname: config.hostname,
21
21
  idleTimeout: 255, // seconds — LLM streaming responses can take minutes
22
22
 
23
23
  async fetch(req) {
@@ -38,7 +38,7 @@ export function startServer(config: ProxyConfig): ReturnType<typeof Bun.serve> {
38
38
  });
39
39
 
40
40
  affinity.startCleanup();
41
- logger.info(`ampcode-connector listening on http://localhost:${config.port}`);
41
+ logger.info(`ampcode-connector listening on http://${config.hostname}:${config.port}`);
42
42
 
43
43
  const shutdown = () => {
44
44
  logger.info("Shutting down...");
@@ -1,6 +1,7 @@
1
1
  /** Local handler for extractWebPageContent — fetches a URL, converts to Markdown, ranks by objective. */
2
2
 
3
- import { convert, JsPreprocessingPreset } from "@kreuzberg/html-to-markdown";
3
+ import TurndownService from "turndown";
4
+ import { gfm } from "turndown-plugin-gfm";
4
5
  import { logger } from "../utils/logger.ts";
5
6
 
6
7
  interface WebReadParams {
@@ -55,10 +56,9 @@ const CLIPPING = {
55
56
  EXCERPT_SEP_BYTES: 2, // "\n\n" separator
56
57
  } as const;
57
58
 
58
- const HTML_OPTIONS = {
59
- skipImages: true,
60
- preprocessing: { enabled: true, preset: JsPreprocessingPreset.Aggressive },
61
- };
59
+ const turndown = new TurndownService({ headingStyle: "atx", codeBlockStyle: "fenced" });
60
+ turndown.use(gfm);
61
+ turndown.remove(["script", "style", "img"]);
62
62
 
63
63
  // biome-ignore format: compact
64
64
  const STOP_WORDS = new Set(
@@ -141,7 +141,7 @@ function fetchError(message: string): FetchErr {
141
141
 
142
142
  function convertToMarkdown(raw: string, contentType: string): string {
143
143
  if (contentType.includes("text/html") || contentType.includes("application/xhtml")) {
144
- return convert(raw, HTML_OPTIONS);
144
+ return turndown.turndown(raw);
145
145
  }
146
146
 
147
147
  if (contentType.includes("application/json")) {
@@ -0,0 +1,8 @@
1
+ declare module "turndown-plugin-gfm" {
2
+ import type TurndownService from "turndown";
3
+ export function gfm(service: TurndownService): void;
4
+ export function tables(service: TurndownService): void;
5
+ export function strikethrough(service: TurndownService): void;
6
+ export function taskListItems(service: TurndownService): void;
7
+ export function highlightedCodeBlock(service: TurndownService): void;
8
+ }