llm-mock-server 1.0.5 → 1.0.6

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.
@@ -37,7 +37,7 @@ jobs:
37
37
  run: npm run docs
38
38
 
39
39
  - name: Upload pages artifact
40
- uses: actions/upload-pages-artifact@v3
40
+ uses: actions/upload-pages-artifact@v4
41
41
  with:
42
42
  path: docs/api
43
43
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # llm-mock-server
1
+ # llm-mock-server [![npm version](https://img.shields.io/npm/v/llm-mock-server)](https://www.npmjs.com/package/llm-mock-server) ![npm downloads](https://img.shields.io/npm/d18m/llm-mock-server)
2
2
 
3
3
  A mock LLM server for testing. It handles OpenAI `/chat/completions`, Anthropic `/messages`, and OpenAI `/responses` API formats, with both streaming (SSE) and non-streaming responses. Point any client at it and get instant, deterministic replies. Used by [xcode-copilot-server](https://github.com/theblixguy/xcode-copilot-server) and [copilot-sdk-proxy](https://github.com/theblixguy/copilot-sdk-proxy) for their integration tests.
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-mock-server",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A standalone mock LLM server for deterministic testing: OpenAI, Anthropic, and Responses API formats",
5
5
  "type": "module",
6
6
  "engines": {
@@ -15,6 +15,9 @@
15
15
  },
16
16
  "./package.json": "./package.json"
17
17
  },
18
+ "imports": {
19
+ "#/*": "./src/*"
20
+ },
18
21
  "bin": {
19
22
  "llm-mock-server": "./dist/cli/cli.js"
20
23
  },
@@ -43,21 +46,21 @@
43
46
  "license": "MIT",
44
47
  "dependencies": {
45
48
  "commander": "14.0.3",
46
- "fastify": "5.8.2",
49
+ "fastify": "5.8.4",
47
50
  "json5": "2.2.3",
48
- "llm-schemas": "1.0.1",
51
+ "llm-schemas": "1.0.2",
49
52
  "picocolors": "1.1.1",
50
53
  "zod": "4.3.6"
51
54
  },
52
55
  "devDependencies": {
53
56
  "@types/node": "25.5.0",
54
- "@vitest/coverage-v8": "4.1.0",
55
- "oxfmt": "0.40.0",
56
- "oxlint": "1.55.0",
57
+ "@vitest/coverage-v8": "4.1.2",
58
+ "oxfmt": "0.42.0",
59
+ "oxlint": "1.57.0",
57
60
  "tsx": "4.21.0",
58
- "typedoc": "0.28.17",
61
+ "typedoc": "0.28.18",
59
62
  "typedoc-theme-oxide": "0.2.5",
60
- "typescript": "5.9.3",
61
- "vitest": "4.1.0"
63
+ "typescript": "6.0.2",
64
+ "vitest": "4.1.2"
62
65
  }
63
66
  }
package/src/cli/cli.ts CHANGED
@@ -4,8 +4,8 @@ import { watch } from "node:fs";
4
4
  import { createRequire } from "node:module";
5
5
  import { Command } from "commander";
6
6
  import pc from "picocolors";
7
- import { MockServer } from "../mock-server.js";
8
- import { Logger } from "../logger.js";
7
+ import { MockServer } from "#/mock-server.js";
8
+ import { Logger } from "#/logger.js";
9
9
  import {
10
10
  parsePort,
11
11
  parseHost,
@@ -1,6 +1,6 @@
1
1
  import { isIP } from "node:net";
2
2
  import { lookup } from "node:dns/promises";
3
- import { LEVEL_PRIORITY, type LogLevel } from "../logger.js";
3
+ import { LEVEL_PRIORITY, type LogLevel } from "#/logger.js";
4
4
 
5
5
  const VALID_LOG_LEVELS: string[] = Object.keys(LEVEL_PRIORITY);
6
6
 
@@ -1,5 +1,5 @@
1
- import type { Format } from "../types.js";
2
- import { isStreaming } from "../request-helpers.js";
1
+ import type { Format } from "#/formats/types.js";
2
+ import { isStreaming } from "#/formats/request-helpers.js";
3
3
  import { parseRequest } from "./parse.js";
4
4
  import { serialize, serializeComplete, serializeError } from "./serialize.js";
5
5
 
@@ -1,5 +1,8 @@
1
- import type { MockRequest, Message, ToolDef } from "../../types/request.js";
2
- import { buildMockRequest, type RequestMeta } from "../request-helpers.js";
1
+ import type { MockRequest, Message, ToolDef } from "#/types/request.js";
2
+ import {
3
+ buildMockRequest,
4
+ type RequestMeta,
5
+ } from "#/formats/request-helpers.js";
3
6
  import { AnthropicRequestSchema, type AnthropicRequest } from "./schema.js";
4
7
 
5
8
  function extractSystem(system: AnthropicRequest["system"]): Message[] {
@@ -1,5 +1,5 @@
1
- import type { ReplyObject, ReplyOptions } from "../../types/reply.js";
2
- import type { SSEChunk } from "../types.js";
1
+ import type { ReplyObject, ReplyOptions } from "#/types/reply.js";
2
+ import type { SSEChunk } from "#/formats/types.js";
3
3
  import {
4
4
  splitText,
5
5
  genId,
@@ -7,7 +7,7 @@ import {
7
7
  shouldEmitText,
8
8
  finishReason,
9
9
  DEFAULT_USAGE,
10
- } from "../serialize-helpers.js";
10
+ } from "#/formats/serialize-helpers.js";
11
11
 
12
12
  function buildUsage(usage: { input: number; output: number }) {
13
13
  return { input_tokens: usage.input, output_tokens: usage.output };
@@ -1,5 +1,5 @@
1
- import type { Format } from "../../types.js";
2
- import { isStreaming } from "../../request-helpers.js";
1
+ import type { Format } from "#/formats/types.js";
2
+ import { isStreaming } from "#/formats/request-helpers.js";
3
3
  import { parseRequest } from "./parse.js";
4
4
  import { serialize, serializeComplete, serializeError } from "./serialize.js";
5
5
 
@@ -1,5 +1,8 @@
1
- import type { MockRequest, Message, ToolDef } from "../../../types/request.js";
2
- import { buildMockRequest, type RequestMeta } from "../../request-helpers.js";
1
+ import type { MockRequest, Message, ToolDef } from "#/types/request.js";
2
+ import {
3
+ buildMockRequest,
4
+ type RequestMeta,
5
+ } from "#/formats/request-helpers.js";
3
6
  import { OpenAIRequestSchema, type OpenAIRequest } from "./schema.js";
4
7
 
5
8
  function extractContent(
@@ -1,5 +1,5 @@
1
- import type { ReplyObject, ReplyOptions } from "../../../types/reply.js";
2
- import type { SSEChunk } from "../../types.js";
1
+ import type { ReplyObject, ReplyOptions } from "#/types/reply.js";
2
+ import type { SSEChunk } from "#/formats/types.js";
3
3
  import {
4
4
  splitText,
5
5
  genId,
@@ -7,7 +7,7 @@ import {
7
7
  finishReason,
8
8
  MS_PER_SECOND,
9
9
  DEFAULT_USAGE,
10
- } from "../../serialize-helpers.js";
10
+ } from "#/formats/serialize-helpers.js";
11
11
 
12
12
  function buildUsage(usage: { input: number; output: number }) {
13
13
  return {
@@ -1,5 +1,5 @@
1
- import type { Format } from "../../types.js";
2
- import { isStreaming } from "../../request-helpers.js";
1
+ import type { Format } from "#/formats/types.js";
2
+ import { isStreaming } from "#/formats/request-helpers.js";
3
3
  import { parseRequest } from "./parse.js";
4
4
  import { serialize, serializeComplete, serializeError } from "./serialize.js";
5
5
 
@@ -1,5 +1,8 @@
1
- import type { MockRequest, Message, ToolDef } from "../../../types/request.js";
2
- import { buildMockRequest, type RequestMeta } from "../../request-helpers.js";
1
+ import type { MockRequest, Message, ToolDef } from "#/types/request.js";
2
+ import {
3
+ buildMockRequest,
4
+ type RequestMeta,
5
+ } from "#/formats/request-helpers.js";
3
6
  import {
4
7
  ResponsesRequestSchema,
5
8
  FunctionToolSchema,
@@ -1,9 +1,5 @@
1
- import type {
2
- ReplyObject,
3
- ReplyOptions,
4
- ToolCall,
5
- } from "../../../types/reply.js";
6
- import type { SSEChunk } from "../../types.js";
1
+ import type { ReplyObject, ReplyOptions, ToolCall } from "#/types/reply.js";
2
+ import type { SSEChunk } from "#/formats/types.js";
7
3
  import {
8
4
  splitText,
9
5
  genId,
@@ -11,7 +7,7 @@ import {
11
7
  shouldEmitText,
12
8
  MS_PER_SECOND,
13
9
  DEFAULT_USAGE,
14
- } from "../../serialize-helpers.js";
10
+ } from "#/formats/serialize-helpers.js";
15
11
 
16
12
  function buildUsage(usage: { input: number; output: number }) {
17
13
  return {
@@ -3,7 +3,7 @@ import type {
3
3
  Message,
4
4
  MockRequest,
5
5
  ToolDef,
6
- } from "../types/request.js";
6
+ } from "#/types/request.js";
7
7
 
8
8
  function asRecord(body: unknown): Record<string, unknown> {
9
9
  if (typeof body === "object" && body !== null)
@@ -1,4 +1,4 @@
1
- import type { ReplyObject } from "../types/reply.js";
1
+ import type { ReplyObject } from "#/types/reply.js";
2
2
 
3
3
  export const MS_PER_SECOND = 1000;
4
4
  export const DEFAULT_USAGE = { input: 10, output: 5 } as const;
@@ -1,5 +1,5 @@
1
- import type { FormatName, MockRequest } from "../types/request.js";
2
- import type { ReplyObject, ReplyOptions } from "../types/reply.js";
1
+ import type { FormatName, MockRequest } from "#/types/request.js";
2
+ import type { ReplyObject, ReplyOptions } from "#/types/reply.js";
3
3
  import type { RequestMeta } from "./request-helpers.js";
4
4
 
5
5
  export interface SSEChunk {
@@ -5,7 +5,7 @@ import {
5
5
  parseChunkSize,
6
6
  parseLogLevel,
7
7
  parseLatency,
8
- } from "../src/cli/validators.js";
8
+ } from "#/cli/validators.js";
9
9
 
10
10
  describe("parsePort", () => {
11
11
  it("parses a valid port", () => {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, beforeEach } from "vitest";
2
- import { RequestHistory, type RecordedRequest } from "../src/history.js";
2
+ import { RequestHistory, type RecordedRequest } from "#/history.js";
3
3
  import { makeReq } from "./helpers/make-req.js";
4
4
 
5
5
  describe("RequestHistory", () => {
@@ -1,9 +1,9 @@
1
1
  import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
2
  import { writeFile, mkdir, rm } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { RuleEngine } from "../src/rule-engine.js";
5
- import { loadRulesFromPath } from "../src/loader.js";
6
- import type { MockRequest } from "../src/types.js";
4
+ import { RuleEngine } from "#/rule-engine.js";
5
+ import { loadRulesFromPath } from "#/loader.js";
6
+ import type { MockRequest } from "#/types.js";
7
7
  import { makeReq } from "./helpers/make-req.js";
8
8
 
9
9
  const tmpDir = join(import.meta.dirname, ".tmp-loader-test");
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, vi, afterEach } from "vitest";
2
- import { Logger, LEVEL_PRIORITY } from "../src/logger.js";
3
- import type { LogLevel } from "../src/logger.js";
2
+ import { Logger, LEVEL_PRIORITY } from "#/logger.js";
3
+ import type { LogLevel } from "#/logger.js";
4
4
 
5
5
  afterEach(() => {
6
6
  vi.restoreAllMocks();
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
- import { createMock, MockServer } from "../src/index.js";
2
+ import { createMock, MockServer } from "#/index.js";
3
3
 
4
4
  interface OpenAIResponse {
5
5
  choices: {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, beforeEach } from "vitest";
2
- import { RuleEngine } from "../src/rule-engine.js";
2
+ import { RuleEngine } from "#/rule-engine.js";
3
3
  import { makeReq } from "./helpers/make-req.js";
4
4
 
5
5
  describe("RuleEngine", () => {
package/tsconfig.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2024",
3
+ "target": "ES2025",
4
4
  "module": "NodeNext",
5
5
  "moduleResolution": "NodeNext",
6
- "lib": ["ES2024"],
6
+ "lib": ["ES2025"],
7
7
  "outDir": "./dist",
8
8
  "rootDir": "./src",
9
9
  "declaration": true,
10
10
  "declarationMap": true,
11
11
  "sourceMap": true,
12
- "strict": true,
13
- "esModuleInterop": true,
14
12
  "skipLibCheck": true,
15
13
  "forceConsistentCasingInFileNames": true,
16
14
  "verbatimModuleSyntax": true,