llm-mock-server 1.0.0 → 1.0.2
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/.claude/skills/desloppify/SKILL.md +308 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/canonical_import_20260315_000801.json +242 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/canonical_import_20260315_000905.json +248 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/canonical_import_20260315_000917.json +248 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/canonical_import_20260315_000950.json +311 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/claude_launch_prompt.md +17 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/review_result.json +255 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/review_result.template.json +22 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/reviewer_instructions.md +20 -0
- package/.desloppify/external_review_sessions/ext_20260315_000339_a6cdc3e6/session.json +20 -0
- package/.desloppify/query.json +284 -0
- package/.desloppify/review_packet_blind.json +1303 -0
- package/.desloppify/review_packets/holistic_packet_20260315_000339.json +1471 -0
- package/.desloppify/state-typescript.json +5114 -0
- package/.desloppify/state-typescript.json.bak +5108 -0
- package/dist/cli-validators.d.ts +7 -0
- package/dist/cli-validators.d.ts.map +1 -0
- package/dist/cli-validators.js +51 -0
- package/dist/cli-validators.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +106 -0
- package/dist/cli.js.map +1 -0
- package/dist/formats/anthropic/index.d.ts +3 -0
- package/dist/formats/anthropic/index.d.ts.map +1 -0
- package/dist/formats/anthropic/index.js +13 -0
- package/dist/formats/anthropic/index.js.map +1 -0
- package/dist/formats/anthropic/parse.d.ts +4 -0
- package/dist/formats/anthropic/parse.d.ts.map +1 -0
- package/dist/formats/anthropic/parse.js +47 -0
- package/dist/formats/anthropic/parse.js.map +1 -0
- package/dist/formats/anthropic/schema.d.ts +75 -0
- package/dist/formats/anthropic/schema.d.ts.map +1 -0
- package/dist/formats/anthropic/schema.js +50 -0
- package/dist/formats/anthropic/schema.js.map +1 -0
- package/dist/formats/anthropic/serialize.d.ts +10 -0
- package/dist/formats/anthropic/serialize.d.ts.map +1 -0
- package/dist/formats/anthropic/serialize.js +73 -0
- package/dist/formats/anthropic/serialize.js.map +1 -0
- package/dist/formats/openai/index.d.ts +3 -0
- package/dist/formats/openai/index.d.ts.map +1 -0
- package/dist/formats/openai/index.js +13 -0
- package/dist/formats/openai/index.js.map +1 -0
- package/dist/formats/openai/parse.d.ts +4 -0
- package/dist/formats/openai/parse.d.ts.map +1 -0
- package/dist/formats/openai/parse.js +33 -0
- package/dist/formats/openai/parse.js.map +1 -0
- package/dist/formats/openai/schema.d.ts +93 -0
- package/dist/formats/openai/schema.d.ts.map +1 -0
- package/dist/formats/openai/schema.js +68 -0
- package/dist/formats/openai/schema.js.map +1 -0
- package/dist/formats/openai/serialize.d.ts +10 -0
- package/dist/formats/openai/serialize.d.ts.map +1 -0
- package/dist/formats/openai/serialize.js +70 -0
- package/dist/formats/openai/serialize.js.map +1 -0
- package/dist/formats/parse-helpers.d.ts +24 -0
- package/dist/formats/parse-helpers.d.ts.map +1 -0
- package/dist/formats/parse-helpers.js +52 -0
- package/dist/formats/parse-helpers.js.map +1 -0
- package/dist/formats/request-helpers.d.ts +13 -0
- package/dist/formats/request-helpers.d.ts.map +1 -0
- package/dist/formats/request-helpers.js +28 -0
- package/dist/formats/request-helpers.js.map +1 -0
- package/dist/formats/responses/index.d.ts +3 -0
- package/dist/formats/responses/index.d.ts.map +1 -0
- package/dist/formats/responses/index.js +13 -0
- package/dist/formats/responses/index.js.map +1 -0
- package/dist/formats/responses/parse.d.ts +4 -0
- package/dist/formats/responses/parse.d.ts.map +1 -0
- package/dist/formats/responses/parse.js +51 -0
- package/dist/formats/responses/parse.js.map +1 -0
- package/dist/formats/responses/schema.d.ts +103 -0
- package/dist/formats/responses/schema.d.ts.map +1 -0
- package/dist/formats/responses/schema.js +61 -0
- package/dist/formats/responses/schema.js.map +1 -0
- package/dist/formats/responses/serialize.d.ts +10 -0
- package/dist/formats/responses/serialize.d.ts.map +1 -0
- package/dist/formats/responses/serialize.js +108 -0
- package/dist/formats/responses/serialize.js.map +1 -0
- package/dist/formats/serialize-helpers.d.ts +14 -0
- package/dist/formats/serialize-helpers.d.ts.map +1 -0
- package/dist/formats/serialize-helpers.js +25 -0
- package/dist/formats/serialize-helpers.js.map +1 -0
- package/dist/formats/types.d.ts +20 -0
- package/dist/formats/types.d.ts.map +1 -0
- package/dist/formats/types.js +2 -0
- package/dist/formats/types.js.map +1 -0
- package/dist/history.d.ts +38 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +48 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +9 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +169 -0
- package/dist/loader.js.map +1 -0
- package/dist/logger.d.ts +21 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +42 -0
- package/dist/logger.js.map +1 -0
- package/dist/mock-server.d.ts +102 -0
- package/dist/mock-server.d.ts.map +1 -0
- package/dist/mock-server.js +195 -0
- package/dist/mock-server.js.map +1 -0
- package/dist/route-handler.d.ts +16 -0
- package/dist/route-handler.d.ts.map +1 -0
- package/dist/route-handler.js +75 -0
- package/dist/route-handler.js.map +1 -0
- package/dist/rule-engine.d.ts +24 -0
- package/dist/rule-engine.d.ts.map +1 -0
- package/dist/rule-engine.js +129 -0
- package/dist/rule-engine.js.map +1 -0
- package/dist/sse-writer.d.ts +5 -0
- package/dist/sse-writer.d.ts.map +1 -0
- package/dist/sse-writer.js +23 -0
- package/dist/sse-writer.js.map +1 -0
- package/{src/types/index.ts → dist/types/index.d.ts} +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/reply.d.ts +45 -0
- package/dist/types/reply.d.ts.map +1 -0
- package/dist/types/reply.js +2 -0
- package/dist/types/reply.js.map +1 -0
- package/dist/types/request.d.ts +39 -0
- package/dist/types/request.d.ts.map +1 -0
- package/dist/types/request.js +2 -0
- package/dist/types/request.js.map +1 -0
- package/dist/types/rule.d.ts +57 -0
- package/dist/types/rule.d.ts.map +1 -0
- package/dist/types/rule.js +2 -0
- package/dist/types/rule.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +2 -1
- package/scorecard.png +0 -0
- package/src/cli-validators.ts +3 -0
- package/src/cli.ts +6 -2
- package/src/formats/anthropic/index.ts +1 -1
- package/src/formats/anthropic/parse.ts +4 -4
- package/src/formats/anthropic/schema.ts +1 -68
- package/src/formats/anthropic/serialize.ts +9 -5
- package/src/formats/openai/index.ts +1 -1
- package/src/formats/openai/parse.ts +1 -1
- package/src/formats/openai/schema.ts +1 -69
- package/src/formats/openai/serialize.ts +15 -17
- package/src/formats/{parse-helpers.ts → request-helpers.ts} +2 -31
- package/src/formats/responses/index.ts +1 -1
- package/src/formats/responses/parse.ts +1 -1
- package/src/formats/responses/schema.ts +1 -72
- package/src/formats/responses/serialize.ts +9 -5
- package/src/formats/serialize-helpers.ts +30 -0
- package/src/formats/types.ts +3 -3
- package/src/loader.ts +7 -11
- package/src/logger.ts +19 -25
- package/src/mock-server.ts +10 -14
- package/src/route-handler.ts +1 -1
- package/src/rule-engine.ts +23 -1
- package/src/types/reply.ts +6 -10
- package/src/types/request.ts +7 -11
- package/src/types/rule.ts +3 -10
- package/src/types.ts +3 -5
- package/test/formats/anthropic.test.ts +4 -4
- package/test/formats/parse-helpers.test.ts +275 -0
- package/test/formats/responses.test.ts +4 -4
- package/test/helpers/make-req.ts +18 -0
- package/test/history.test.ts +348 -0
- package/test/loader.test.ts +11 -27
- package/test/logger.test.ts +294 -0
- package/test/mock-server.test.ts +1 -1
- package/test/rule-engine.test.ts +8 -22
- package/test/formats/anthropic-schema.test.ts +0 -192
- package/test/formats/openai-schema.test.ts +0 -105
- package/test/formats/responses-schema.test.ts +0 -114
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { OpenAIRequestSchema } from "../../src/formats/openai/schema.js";
|
|
3
|
-
|
|
4
|
-
describe("OpenAIRequestSchema", () => {
|
|
5
|
-
const validRequest = {
|
|
6
|
-
model: "gpt-5.4",
|
|
7
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
it("accepts a valid minimal request", () => {
|
|
11
|
-
expect(OpenAIRequestSchema.safeParse(validRequest).success).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("rejects missing model", () => {
|
|
15
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
16
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
17
|
-
}).success).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("rejects empty model string", () => {
|
|
21
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
22
|
-
model: "",
|
|
23
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
24
|
-
}).success).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("rejects empty messages array", () => {
|
|
28
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
29
|
-
model: "gpt-5.4",
|
|
30
|
-
messages: [],
|
|
31
|
-
}).success).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("rejects missing messages", () => {
|
|
35
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
36
|
-
model: "gpt-5.4",
|
|
37
|
-
}).success).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("accepts array content format in messages", () => {
|
|
41
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
42
|
-
model: "gpt-5.4",
|
|
43
|
-
messages: [{ role: "user", content: [{ type: "text", text: "Hello" }] }],
|
|
44
|
-
}).success).toBe(true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("accepts null content", () => {
|
|
48
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
49
|
-
model: "gpt-5.4",
|
|
50
|
-
messages: [{ role: "assistant", content: null }],
|
|
51
|
-
}).success).toBe(true);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("accepts optional fields", () => {
|
|
55
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
56
|
-
...validRequest,
|
|
57
|
-
temperature: 0.7,
|
|
58
|
-
top_p: 0.9,
|
|
59
|
-
max_tokens: 100,
|
|
60
|
-
presence_penalty: 0.5,
|
|
61
|
-
frequency_penalty: 0.5,
|
|
62
|
-
user: "test-user",
|
|
63
|
-
}).success).toBe(true);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("accepts tools array", () => {
|
|
67
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
68
|
-
...validRequest,
|
|
69
|
-
tools: [{
|
|
70
|
-
type: "function",
|
|
71
|
-
function: {
|
|
72
|
-
name: "get_weather",
|
|
73
|
-
description: "Get the weather",
|
|
74
|
-
parameters: { type: "object", properties: {} },
|
|
75
|
-
},
|
|
76
|
-
}],
|
|
77
|
-
}).success).toBe(true);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("accepts stream: true", () => {
|
|
81
|
-
const result = OpenAIRequestSchema.safeParse({ ...validRequest, stream: true });
|
|
82
|
-
expect(result.success).toBe(true);
|
|
83
|
-
if (result.success) expect(result.data.stream).toBe(true);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("accepts stream: false", () => {
|
|
87
|
-
const result = OpenAIRequestSchema.safeParse({ ...validRequest, stream: false });
|
|
88
|
-
expect(result.success).toBe(true);
|
|
89
|
-
if (result.success) expect(result.data.stream).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("accepts messages with tool_calls", () => {
|
|
93
|
-
expect(OpenAIRequestSchema.safeParse({
|
|
94
|
-
model: "gpt-5.4",
|
|
95
|
-
messages: [{
|
|
96
|
-
role: "assistant",
|
|
97
|
-
tool_calls: [{
|
|
98
|
-
id: "call_1",
|
|
99
|
-
type: "function",
|
|
100
|
-
function: { name: "search", arguments: "{}" },
|
|
101
|
-
}],
|
|
102
|
-
}],
|
|
103
|
-
}).success).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { ResponsesRequestSchema, FunctionToolSchema } from "../../src/formats/responses/schema.js";
|
|
3
|
-
|
|
4
|
-
describe("ResponsesRequestSchema", () => {
|
|
5
|
-
const validRequest = {
|
|
6
|
-
model: "codex-mini",
|
|
7
|
-
input: "Hello",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
it("accepts a valid minimal request with string input", () => {
|
|
11
|
-
expect(ResponsesRequestSchema.safeParse(validRequest).success).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("accepts array input with a user message", () => {
|
|
15
|
-
expect(ResponsesRequestSchema.safeParse({
|
|
16
|
-
model: "codex-mini",
|
|
17
|
-
input: [{ role: "user", content: "Hello" }],
|
|
18
|
-
}).success).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("accepts array input with function_call and function_call_output", () => {
|
|
22
|
-
expect(ResponsesRequestSchema.safeParse({
|
|
23
|
-
model: "codex-mini",
|
|
24
|
-
input: [
|
|
25
|
-
{ type: "function_call", call_id: "call_1", name: "search", arguments: "{}" },
|
|
26
|
-
{ type: "function_call_output", call_id: "call_1", output: "result" },
|
|
27
|
-
],
|
|
28
|
-
}).success).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("accepts missing model", () => {
|
|
32
|
-
expect(ResponsesRequestSchema.safeParse({ input: "Hello" }).success).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("rejects empty model string", () => {
|
|
36
|
-
expect(ResponsesRequestSchema.safeParse({ model: "", input: "Hello" }).success).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("accepts missing input", () => {
|
|
40
|
-
expect(ResponsesRequestSchema.safeParse({ model: "codex-mini" }).success).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("accepts stream: true", () => {
|
|
44
|
-
const result = ResponsesRequestSchema.safeParse({ ...validRequest, stream: true });
|
|
45
|
-
expect(result.success).toBe(true);
|
|
46
|
-
if (result.success) expect(result.data.stream).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("accepts stream: false", () => {
|
|
50
|
-
const result = ResponsesRequestSchema.safeParse({ ...validRequest, stream: false });
|
|
51
|
-
expect(result.success).toBe(true);
|
|
52
|
-
if (result.success) expect(result.data.stream).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("accepts optional fields", () => {
|
|
56
|
-
expect(ResponsesRequestSchema.safeParse({
|
|
57
|
-
...validRequest,
|
|
58
|
-
instructions: "Be helpful",
|
|
59
|
-
temperature: 0.5,
|
|
60
|
-
previous_response_id: "resp_abc",
|
|
61
|
-
}).success).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("accepts tools array with function tools", () => {
|
|
65
|
-
expect(ResponsesRequestSchema.safeParse({
|
|
66
|
-
...validRequest,
|
|
67
|
-
tools: [{
|
|
68
|
-
type: "function",
|
|
69
|
-
name: "search",
|
|
70
|
-
description: "Search the web",
|
|
71
|
-
parameters: { type: "object", properties: {} },
|
|
72
|
-
}],
|
|
73
|
-
}).success).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("accepts tools array with non-function tools", () => {
|
|
77
|
-
expect(ResponsesRequestSchema.safeParse({
|
|
78
|
-
...validRequest,
|
|
79
|
-
tools: [{ type: "web_search" }],
|
|
80
|
-
}).success).toBe(true);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("accepts message input with array content", () => {
|
|
84
|
-
expect(ResponsesRequestSchema.safeParse({
|
|
85
|
-
model: "codex-mini",
|
|
86
|
-
input: [{ role: "user", content: [{ type: "text", text: "Hello" }] }],
|
|
87
|
-
}).success).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe("FunctionToolSchema", () => {
|
|
92
|
-
it("accepts a valid function tool", () => {
|
|
93
|
-
const result = FunctionToolSchema.safeParse({
|
|
94
|
-
type: "function",
|
|
95
|
-
name: "search",
|
|
96
|
-
description: "Search the web",
|
|
97
|
-
parameters: { type: "object" },
|
|
98
|
-
});
|
|
99
|
-
expect(result.success).toBe(true);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("accepts a function tool without optional fields", () => {
|
|
103
|
-
const result = FunctionToolSchema.safeParse({ type: "function", name: "run" });
|
|
104
|
-
expect(result.success).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("rejects a non-function tool", () => {
|
|
108
|
-
expect(FunctionToolSchema.safeParse({ type: "web_search" }).success).toBe(false);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("rejects a tool missing name", () => {
|
|
112
|
-
expect(FunctionToolSchema.safeParse({ type: "function" }).success).toBe(false);
|
|
113
|
-
});
|
|
114
|
-
});
|