@copilotkit/aimock 1.43.0 → 1.45.0
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-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +46 -0
- package/README.md +14 -2
- package/dist/agui-handler.d.ts.map +1 -1
- package/dist/aimock-cli.cjs +31 -5
- package/dist/aimock-cli.cjs.map +1 -1
- package/dist/aimock-cli.d.cts.map +1 -1
- package/dist/aimock-cli.d.ts.map +1 -1
- package/dist/aimock-cli.js +31 -5
- package/dist/aimock-cli.js.map +1 -1
- package/dist/bedrock-converse.cjs +344 -43
- package/dist/bedrock-converse.cjs.map +1 -1
- package/dist/bedrock-converse.d.cts.map +1 -1
- package/dist/bedrock-converse.d.ts.map +1 -1
- package/dist/bedrock-converse.js +345 -44
- package/dist/bedrock-converse.js.map +1 -1
- package/dist/bedrock.cjs +195 -42
- package/dist/bedrock.cjs.map +1 -1
- package/dist/bedrock.d.cts.map +1 -1
- package/dist/bedrock.d.ts.map +1 -1
- package/dist/bedrock.js +196 -43
- package/dist/bedrock.js.map +1 -1
- package/dist/chaos.cjs +9 -5
- package/dist/chaos.cjs.map +1 -1
- package/dist/chaos.d.cts.map +1 -1
- package/dist/chaos.d.ts.map +1 -1
- package/dist/chaos.js +10 -7
- package/dist/chaos.js.map +1 -1
- package/dist/cli.cjs +238 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +242 -13
- package/dist/cli.js.map +1 -1
- package/dist/cohere.cjs +159 -72
- package/dist/cohere.cjs.map +1 -1
- package/dist/cohere.d.cts.map +1 -1
- package/dist/cohere.d.ts.map +1 -1
- package/dist/cohere.js +160 -73
- package/dist/cohere.js.map +1 -1
- package/dist/config-loader.cjs +63 -5
- package/dist/config-loader.cjs.map +1 -1
- package/dist/config-loader.d.cts +37 -4
- package/dist/config-loader.d.cts.map +1 -1
- package/dist/config-loader.d.ts +37 -4
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/config-loader.js +63 -5
- package/dist/config-loader.js.map +1 -1
- package/dist/constants.cjs +8 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +6 -2
- package/dist/constants.d.ts +6 -2
- package/dist/constants.js +8 -1
- package/dist/constants.js.map +1 -1
- package/dist/echo-text.cjs +65 -0
- package/dist/echo-text.cjs.map +1 -0
- package/dist/echo-text.d.cts +22 -0
- package/dist/echo-text.d.cts.map +1 -0
- package/dist/echo-text.d.ts +22 -0
- package/dist/echo-text.d.ts.map +1 -0
- package/dist/echo-text.js +65 -0
- package/dist/echo-text.js.map +1 -0
- package/dist/embeddings.cjs +18 -1
- package/dist/embeddings.cjs.map +1 -1
- package/dist/embeddings.d.cts +1 -1
- package/dist/embeddings.d.cts.map +1 -1
- package/dist/embeddings.d.ts +1 -1
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/embeddings.js +18 -1
- package/dist/embeddings.js.map +1 -1
- package/dist/fakes-plugin.cjs +131 -0
- package/dist/fakes-plugin.cjs.map +1 -0
- package/dist/fakes-plugin.d.cts +23 -0
- package/dist/fakes-plugin.d.cts.map +1 -0
- package/dist/fakes-plugin.d.ts +23 -0
- package/dist/fakes-plugin.d.ts.map +1 -0
- package/dist/fakes-plugin.js +127 -0
- package/dist/fakes-plugin.js.map +1 -0
- package/dist/files.cjs +9 -11
- package/dist/files.cjs.map +1 -1
- package/dist/files.d.cts.map +1 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +10 -13
- package/dist/files.js.map +1 -1
- package/dist/fine-tuning.cjs +1 -19
- package/dist/fine-tuning.cjs.map +1 -1
- package/dist/fine-tuning.d.cts.map +1 -1
- package/dist/fine-tuning.d.ts.map +1 -1
- package/dist/fine-tuning.js +2 -20
- package/dist/fine-tuning.js.map +1 -1
- package/dist/fixture-loader-services.cjs +116 -0
- package/dist/fixture-loader-services.cjs.map +1 -0
- package/dist/fixture-loader-services.d.cts +48 -0
- package/dist/fixture-loader-services.d.cts.map +1 -0
- package/dist/fixture-loader-services.d.ts +48 -0
- package/dist/fixture-loader-services.d.ts.map +1 -0
- package/dist/fixture-loader-services.js +114 -0
- package/dist/fixture-loader-services.js.map +1 -0
- package/dist/fixture-loader.cjs +552 -29
- package/dist/fixture-loader.cjs.map +1 -1
- package/dist/fixture-loader.d.cts +140 -2
- package/dist/fixture-loader.d.cts.map +1 -1
- package/dist/fixture-loader.d.ts +140 -2
- package/dist/fixture-loader.d.ts.map +1 -1
- package/dist/fixture-loader.js +542 -31
- package/dist/fixture-loader.js.map +1 -1
- package/dist/gemini-embeddings.cjs +42 -2
- package/dist/gemini-embeddings.cjs.map +1 -1
- package/dist/gemini-embeddings.js +43 -3
- package/dist/gemini-embeddings.js.map +1 -1
- package/dist/gemini-interactions.cjs +288 -52
- package/dist/gemini-interactions.cjs.map +1 -1
- package/dist/gemini-interactions.d.cts.map +1 -1
- package/dist/gemini-interactions.d.ts.map +1 -1
- package/dist/gemini-interactions.js +289 -53
- package/dist/gemini-interactions.js.map +1 -1
- package/dist/gemini.cjs +234 -38
- package/dist/gemini.cjs.map +1 -1
- package/dist/gemini.d.cts.map +1 -1
- package/dist/gemini.d.ts.map +1 -1
- package/dist/gemini.js +235 -39
- package/dist/gemini.js.map +1 -1
- package/dist/helpers.cjs +1157 -12
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +85 -4
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.ts +85 -4
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +1113 -14
- package/dist/helpers.js.map +1 -1
- package/dist/images.cjs +3 -2
- package/dist/images.cjs.map +1 -1
- package/dist/images.js +3 -2
- package/dist/images.js.map +1 -1
- package/dist/index.cjs +39 -1
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +11 -4
- package/dist/jest.cjs +43 -14
- package/dist/jest.cjs.map +1 -1
- package/dist/jest.d.cts +47 -5
- package/dist/jest.d.cts.map +1 -1
- package/dist/jest.d.ts +47 -5
- package/dist/jest.d.ts.map +1 -1
- package/dist/jest.js +45 -16
- package/dist/jest.js.map +1 -1
- package/dist/journal.cjs +155 -13
- package/dist/journal.cjs.map +1 -1
- package/dist/journal.d.cts +54 -4
- package/dist/journal.d.cts.map +1 -1
- package/dist/journal.d.ts +54 -4
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +155 -13
- package/dist/journal.js.map +1 -1
- package/dist/live-sanitize.cjs +4 -32
- package/dist/live-sanitize.cjs.map +1 -1
- package/dist/live-sanitize.js +4 -32
- package/dist/live-sanitize.js.map +1 -1
- package/dist/llmock.cjs +204 -39
- package/dist/llmock.cjs.map +1 -1
- package/dist/llmock.d.cts +51 -1
- package/dist/llmock.d.cts.map +1 -1
- package/dist/llmock.d.ts +51 -1
- package/dist/llmock.d.ts.map +1 -1
- package/dist/llmock.js +206 -41
- package/dist/llmock.js.map +1 -1
- package/dist/mcp-fakes-mount.cjs +217 -0
- package/dist/mcp-fakes-mount.cjs.map +1 -0
- package/dist/mcp-fakes-mount.js +211 -0
- package/dist/mcp-fakes-mount.js.map +1 -0
- package/dist/mcp-fakes-report.cjs +111 -0
- package/dist/mcp-fakes-report.cjs.map +1 -0
- package/dist/mcp-fakes-report.d.cts +40 -0
- package/dist/mcp-fakes-report.d.cts.map +1 -0
- package/dist/mcp-fakes-report.d.ts +40 -0
- package/dist/mcp-fakes-report.d.ts.map +1 -0
- package/dist/mcp-fakes-report.js +107 -0
- package/dist/mcp-fakes-report.js.map +1 -0
- package/dist/mcp-fakes.cjs +1942 -0
- package/dist/mcp-fakes.cjs.map +1 -0
- package/dist/mcp-fakes.d.cts +504 -0
- package/dist/mcp-fakes.d.cts.map +1 -0
- package/dist/mcp-fakes.d.ts +504 -0
- package/dist/mcp-fakes.d.ts.map +1 -0
- package/dist/mcp-fakes.js +1937 -0
- package/dist/mcp-fakes.js.map +1 -0
- package/dist/mcp-handler.cjs +534 -27
- package/dist/mcp-handler.cjs.map +1 -1
- package/dist/mcp-handler.d.cts +49 -0
- package/dist/mcp-handler.d.cts.map +1 -0
- package/dist/mcp-handler.d.ts +49 -0
- package/dist/mcp-handler.d.ts.map +1 -0
- package/dist/mcp-handler.js +530 -28
- package/dist/mcp-handler.js.map +1 -1
- package/dist/mcp-mock.cjs +326 -47
- package/dist/mcp-mock.cjs.map +1 -1
- package/dist/mcp-mock.d.cts +97 -1
- package/dist/mcp-mock.d.cts.map +1 -1
- package/dist/mcp-mock.d.ts +97 -1
- package/dist/mcp-mock.d.ts.map +1 -1
- package/dist/mcp-mock.js +327 -48
- package/dist/mcp-mock.js.map +1 -1
- package/dist/mcp-recorder.cjs +1224 -0
- package/dist/mcp-recorder.cjs.map +1 -0
- package/dist/mcp-recorder.d.cts +108 -0
- package/dist/mcp-recorder.d.cts.map +1 -0
- package/dist/mcp-recorder.d.ts +108 -0
- package/dist/mcp-recorder.d.ts.map +1 -0
- package/dist/mcp-recorder.js +1215 -0
- package/dist/mcp-recorder.js.map +1 -0
- package/dist/mcp-stub.cjs +5 -1
- package/dist/mcp-stub.d.cts +3 -1
- package/dist/mcp-stub.d.ts +3 -1
- package/dist/mcp-stub.js +3 -1
- package/dist/mcp-types.d.cts +6 -0
- package/dist/mcp-types.d.ts +6 -0
- package/dist/message-text.cjs +192 -0
- package/dist/message-text.cjs.map +1 -0
- package/dist/message-text.d.cts +31 -0
- package/dist/message-text.d.cts.map +1 -0
- package/dist/message-text.d.ts +31 -0
- package/dist/message-text.d.ts.map +1 -0
- package/dist/message-text.js +184 -0
- package/dist/message-text.js.map +1 -0
- package/dist/messages.cjs +400 -56
- package/dist/messages.cjs.map +1 -1
- package/dist/messages.d.cts.map +1 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +401 -58
- package/dist/messages.js.map +1 -1
- package/dist/metrics.cjs +46 -66
- package/dist/metrics.cjs.map +1 -1
- package/dist/metrics.d.cts +14 -6
- package/dist/metrics.d.cts.map +1 -1
- package/dist/metrics.d.ts +14 -6
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +32 -40
- package/dist/metrics.js.map +1 -1
- package/dist/misbehavior.cjs +1523 -0
- package/dist/misbehavior.cjs.map +1 -0
- package/dist/misbehavior.d.cts +43 -0
- package/dist/misbehavior.d.cts.map +1 -0
- package/dist/misbehavior.d.ts +43 -0
- package/dist/misbehavior.d.ts.map +1 -0
- package/dist/misbehavior.js +1511 -0
- package/dist/misbehavior.js.map +1 -0
- package/dist/ollama.cjs +315 -113
- package/dist/ollama.cjs.map +1 -1
- package/dist/ollama.d.cts.map +1 -1
- package/dist/ollama.d.ts.map +1 -1
- package/dist/ollama.js +316 -114
- package/dist/ollama.js.map +1 -1
- package/dist/openapi.cjs +3405 -0
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +30 -0
- package/dist/openapi.d.cts.map +1 -0
- package/dist/openapi.d.ts +30 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +3404 -0
- package/dist/openapi.js.map +1 -0
- package/dist/openrouter-video.cjs +4 -4
- package/dist/openrouter-video.cjs.map +1 -1
- package/dist/openrouter-video.d.cts.map +1 -1
- package/dist/openrouter-video.d.ts.map +1 -1
- package/dist/openrouter-video.js +4 -4
- package/dist/openrouter-video.js.map +1 -1
- package/dist/record-sanitize.cjs +231 -0
- package/dist/record-sanitize.cjs.map +1 -0
- package/dist/record-sanitize.js +224 -0
- package/dist/record-sanitize.js.map +1 -0
- package/dist/recorder.cjs +115 -6
- package/dist/recorder.cjs.map +1 -1
- package/dist/recorder.d.cts +2 -1
- package/dist/recorder.d.cts.map +1 -1
- package/dist/recorder.d.ts +2 -1
- package/dist/recorder.d.ts.map +1 -1
- package/dist/recorder.js +116 -8
- package/dist/recorder.js.map +1 -1
- package/dist/responses.cjs +701 -166
- package/dist/responses.cjs.map +1 -1
- package/dist/responses.d.cts +5 -13
- package/dist/responses.d.cts.map +1 -1
- package/dist/responses.d.ts +5 -13
- package/dist/responses.d.ts.map +1 -1
- package/dist/responses.js +699 -169
- package/dist/responses.js.map +1 -1
- package/dist/route-registry.cjs +951 -0
- package/dist/route-registry.cjs.map +1 -0
- package/dist/route-registry.d.cts +33 -0
- package/dist/route-registry.d.cts.map +1 -0
- package/dist/route-registry.d.ts +33 -0
- package/dist/route-registry.d.ts.map +1 -0
- package/dist/route-registry.js +866 -0
- package/dist/route-registry.js.map +1 -0
- package/dist/router.cjs +24 -2
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +25 -4
- package/dist/router.js.map +1 -1
- package/dist/server.cjs +1159 -264
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +4 -1
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +4 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1067 -172
- package/dist/server.js.map +1 -1
- package/dist/speech.cjs +4 -2
- package/dist/speech.cjs.map +1 -1
- package/dist/speech.js +4 -2
- package/dist/speech.js.map +1 -1
- package/dist/stream-collapse.cjs +236 -34
- package/dist/stream-collapse.cjs.map +1 -1
- package/dist/stream-collapse.d.cts +39 -4
- package/dist/stream-collapse.d.cts.map +1 -1
- package/dist/stream-collapse.d.ts +39 -4
- package/dist/stream-collapse.d.ts.map +1 -1
- package/dist/stream-collapse.js +235 -35
- package/dist/stream-collapse.js.map +1 -1
- package/dist/suite.cjs +1 -1
- package/dist/suite.js +1 -1
- package/dist/transcription.cjs +2 -2
- package/dist/transcription.cjs.map +1 -1
- package/dist/transcription.d.cts.map +1 -1
- package/dist/transcription.d.ts.map +1 -1
- package/dist/transcription.js +2 -2
- package/dist/transcription.js.map +1 -1
- package/dist/types.cjs +18 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +516 -5
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +516 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/validate-cli.cjs +123 -33
- package/dist/validate-cli.cjs.map +1 -1
- package/dist/validate-cli.js +125 -35
- package/dist/validate-cli.js.map +1 -1
- package/dist/vector-stores.cjs +1180 -0
- package/dist/vector-stores.cjs.map +1 -0
- package/dist/vector-stores.d.cts +106 -0
- package/dist/vector-stores.d.cts.map +1 -0
- package/dist/vector-stores.d.ts +106 -0
- package/dist/vector-stores.d.ts.map +1 -0
- package/dist/vector-stores.js +1164 -0
- package/dist/vector-stores.js.map +1 -0
- package/dist/vector-types.d.cts.map +1 -1
- package/dist/version.cjs +45 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.js +44 -0
- package/dist/version.js.map +1 -0
- package/dist/video.cjs +19 -0
- package/dist/video.cjs.map +1 -1
- package/dist/video.d.cts.map +1 -1
- package/dist/video.d.ts.map +1 -1
- package/dist/video.js +19 -0
- package/dist/video.js.map +1 -1
- package/dist/vitest.cjs +77 -16
- package/dist/vitest.cjs.map +1 -1
- package/dist/vitest.d.cts +38 -5
- package/dist/vitest.d.cts.map +1 -1
- package/dist/vitest.d.ts +38 -5
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +78 -17
- package/dist/vitest.js.map +1 -1
- package/dist/watcher.cjs +6 -2
- package/dist/watcher.cjs.map +1 -1
- package/dist/watcher.js +6 -2
- package/dist/watcher.js.map +1 -1
- package/dist/ws-gemini-live.cjs +210 -101
- package/dist/ws-gemini-live.cjs.map +1 -1
- package/dist/ws-gemini-live.d.cts +9 -3
- package/dist/ws-gemini-live.d.cts.map +1 -1
- package/dist/ws-gemini-live.d.ts +9 -3
- package/dist/ws-gemini-live.d.ts.map +1 -1
- package/dist/ws-gemini-live.js +211 -102
- package/dist/ws-gemini-live.js.map +1 -1
- package/dist/ws-realtime.cjs +175 -62
- package/dist/ws-realtime.cjs.map +1 -1
- package/dist/ws-realtime.d.cts +8 -3
- package/dist/ws-realtime.d.cts.map +1 -1
- package/dist/ws-realtime.d.ts +8 -3
- package/dist/ws-realtime.d.ts.map +1 -1
- package/dist/ws-realtime.js +176 -63
- package/dist/ws-realtime.js.map +1 -1
- package/dist/ws-responses.cjs +121 -16
- package/dist/ws-responses.cjs.map +1 -1
- package/dist/ws-responses.d.cts +8 -12
- package/dist/ws-responses.d.cts.map +1 -1
- package/dist/ws-responses.d.ts +8 -12
- package/dist/ws-responses.d.ts.map +1 -1
- package/dist/ws-responses.js +123 -18
- package/dist/ws-responses.js.map +1 -1
- package/package.json +13 -2
- package/skills/write-fixtures/SKILL.md +179 -21
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"source": {
|
|
10
10
|
"source": "npm",
|
|
11
11
|
"package": "@copilotkit/aimock",
|
|
12
|
-
"version": "^1.
|
|
12
|
+
"version": "^1.45.0"
|
|
13
13
|
},
|
|
14
14
|
"description": "Fixture authoring skill for @copilotkit/aimock — LLM, multimedia (image/TTS/transcription/video), MCP, A2A, AG-UI, vector, embeddings, structured output, sequential responses, streaming physics, record/replay, agent loop patterns, and debugging"
|
|
15
15
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @copilotkit/aimock
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [1.45.0] - 2026-10-10
|
|
6
|
+
|
|
7
|
+
Every fixture, config and request that 1.44.0 accepted behaves the same by default. New behavior that would change those inputs is opt-in.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Record live MCP servers into `mcpFakes` files and replay them offline: `--mcp-record <mount>=<url>` and `--mcp-proxy-only <mount>=<url>` (`llmock` bin and Docker image), `llm.record.mcp` with the opt-in `llm.enableMcpRecording: true` for `aimock --config` (without the opt-in, `llm.record.mcp` is ignored with a warning, as 1.44.0 ignored it), and `MCPMock.enableRecording()` / `disableRecording()` (#509).
|
|
12
|
+
- Recordings never contain headers and redact known secrets (`AIMOCK_RECORD_SECRET_VALUES`, `AIMOCK_MCP_UPSTREAM_AUTH`); a file is not written while a secret remains (#509).
|
|
13
|
+
- Recorded MCP fakes replay list order, progress and log notifications, and call timing (scaled by `--replay-speed`). The recorded `mcpFakes` keys (`list`, `recorded`, `timing`, `notifications`, `durationMs`) need 1.45.0 or later (#509).
|
|
14
|
+
- Per-test MCP fake report at `GET /__aimock/mcp/fakes/report` (#509).
|
|
15
|
+
- Vitest and Jest: `fakesFor()` and `fakesReport()` on a new `AimockFakesHandle` returned by `useAimock()`, and opt-in `useAimock({ fakesReport: "warn" | "fail" })` (default `"off"`); Jest option `testIdRoot`. New exports `assertFakesReport`, `AimockFakesReportError` and `AimockTestIdCollisionError` (#509).
|
|
16
|
+
- aimock-pytest 0.7.0: `fakes_for`, `fakes_report` and `assert_fakes_report` (#509), and `AIMockServer` opt-ins `enable_misbehavior` and `responses_tools` (#508, #511).
|
|
17
|
+
- Workflow-target examples: a Mastra Workflow and a LangGraph JS graph call MCP fakes with no LLM (`examples/mcp-workflow-targets`), plus record and report proofs (#509).
|
|
18
|
+
- Model misbehavior faults (invalid tool arguments, schema violations, unknown tools, duplicate IDs, length stops, empty responses, refusals, content filtering, reasoning-only) across provider wires, with seeded rates, `/__aimock/misbehavior` runtime controls, journal evidence and the `aimock_misbehavior_total` metric. Off unless enabled with `enableMisbehavior: true` (programmatic, including `useAimock`), `llmock --misbehavior` / `aimock validate --misbehavior`, or `aimock --misbehavior`, or the config opt-in `llm.enableMisbehavior: true` (an `llm.misbehavior` key alone never enables it, as in 1.44.0). Invalid misbehavior settings throw the new `MisbehaviorConfigError` (#508).
|
|
19
|
+
- Namespaced function calls and custom tool calls on the OpenAI Responses API, over HTTP, SSE and WebSocket, plus `match.toolNamespace` (#511). Like the fixture fields below, `match.toolNamespace` applies only with `responsesTools: "extended"`; in the default mode it is ignored, as in 1.44.0.
|
|
20
|
+
- Responses namespaced and custom tool calls: with `responsesTools: "extended"` (CLI `--responses-tools extended`, also on `aimock validate`; config `llm.responsesTools`), tools inside `namespace` tools, `custom` tools and `additional_tools` / `tool_search_output` tools are visible to `toolName`, `toolNamespace` and predicates, custom tool rounds count for `hasToolResult`, `toolCallId` and `turnIndex`, and fixtures can answer with namespaced calls and `customToolCalls` / `responsesBlocks`. The default `"legacy"` keeps 1.44.0 behavior. New types: `CustomToolCallMessage`, `ResponsesToolsMode` (#511).
|
|
21
|
+
- Record mode keeps Responses namespaces and custom tool calls (`customToolCalls`, `responsesBlocks`, `CollapseResult.customToolCalls`) in streamed recordings when `responsesTools: "extended"` is set (#513).
|
|
22
|
+
- Strict tool arguments: with `strictToolArguments` (CLI `--strict-tool-arguments`, config `llm.strictToolArguments`), malformed tool-call argument strings are sent unchanged on string wires and return an explicit error on object wires. The default keeps 1.44.0 behavior (#501).
|
|
23
|
+
- Vertex and Bedrock modeled-contract comparisons for the misbehavior faults in the daily drift checks (#508).
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- MCP recording checks its config at start, redacts credentials in errors, fails loudly when the upstream dies mid-body (502 or a terminated stream, logged and journaled), and defaults `aimock --config` with record mounts to `logLevel: "warn"` (#517).
|
|
28
|
+
- Kept 1.44.0 default behavior for strict tool arguments, model misbehavior, Responses namespaced and custom tools, `llm.record.mcp`, fixture identity and the exported stream helpers, and made each new behavior opt-in (#518).
|
|
29
|
+
- Kept the published types compatible with 1.44.0: `AimockHandle`, `Mountable` and `McpFakeAddOrigin` keep their 1.44.0 shape, and every entry point type-checks with `skipLibCheck: false` (#517).
|
|
30
|
+
- Align Cohere streaming length-stop faults with captured provider framing (#508).
|
|
31
|
+
- Retain drift evidence across retries and for oversized records (#510, #512).
|
|
32
|
+
- Classify `claude-haiku-5-5` in the drift model registry (#515).
|
|
33
|
+
- Docs: dark-site font smoothing, consistent homepage comparison headings, the test-suite highlight, and the copy-button fallback (#504, #506, #514).
|
|
34
|
+
- Invalid opt-in values never stop startup: an invalid `responsesTools` warns once and runs `"legacy"`, and a non-boolean `llm.strictToolArguments`, `llm.enableMisbehavior` or `llm.enableMcpRecording` warns once and stays off (#518).
|
|
35
|
+
|
|
36
|
+
## [1.44.0] - 2026-10-07
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- Script MCP tool answers and errors per scenario, including aimock-pytest 0.6.0 support.
|
|
41
|
+
- Mock OpenAI Vector Stores, file batches and deterministic search (#497).
|
|
42
|
+
- Discover supported HTTP routes through the OpenAPI 3.1 catalog (#451).
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- Reject malformed requests and fixtures with clear validation errors (#474).
|
|
47
|
+
- Correct video status, browser PUT access, model classification and comparison docs.
|
|
48
|
+
|
|
3
49
|
## [1.43.0] - 2026-09-22
|
|
4
50
|
|
|
5
51
|
> **BREAKING** — `aimock -h` is `--help`, not `--host`: `aimock -h 0.0.0.0` exits 1 with `Error: Unexpected argument '0.0.0.0'. This command does not take positional arguments`. Migration: `--host <string>` (long form only). The `llmock` bin (the Docker ENTRYPOINT) keeps `-h, --host` (#453).
|
package/README.md
CHANGED
|
@@ -74,10 +74,15 @@ Run them all on one port with `npx @copilotkit/aimock --config aimock.json`, or
|
|
|
74
74
|
- **[Multi-turn Conversations](https://aimock.copilotkit.dev/multi-turn)** — Record and replay multi-turn traces with tool rounds; match distinct turns via `turnIndex`, `hasToolResult`, `toolCallId`, `toolResultContains` (gate on the tool-result payload), `sequenceIndex`, `systemMessage` (gate on host-supplied agent context), or custom predicates
|
|
75
75
|
- **[11 providers across 22 API surfaces](https://aimock.copilotkit.dev/docs)** — OpenAI Chat, OpenAI Responses, OpenAI Realtime (GA; an `OpenAI-Beta: realtime=v1` request gets the real sunset rejection), GPT-Live, Claude, Gemini REST, Gemini embedContent, Gemini Live, Gemini Interactions, Azure, Bedrock, Vertex AI, Ollama (chat + embeddings), Cohere (chat + embed), OpenRouter (chat + router failover), BytePlus Ark (OpenAI-compatible chat + images under `/api/v3`), ElevenLabs TTS and Voice Design — full streaming support
|
|
76
76
|
- **Multimedia APIs** — [image generation](https://aimock.copilotkit.dev/images) (`gpt-image-1` default, Imagen; `/v1/images/variations` replays OpenAI's removal 404), [image editing](https://aimock.copilotkit.dev/images) (/v1/images/edits), [text-to-speech](https://aimock.copilotkit.dev/speech) (OpenAI + ElevenLabs TTS and Voice Design), [audio transcription](https://aimock.copilotkit.dev/transcription), [audio translation](https://aimock.copilotkit.dev/transcription) (/v1/audio/translations), [video generation](https://aimock.copilotkit.dev/video), [OpenRouter video generation](https://aimock.copilotkit.dev/openrouter-video) (/api/v1/videos with async job lifecycle), [Google Veo video generation](https://aimock.copilotkit.dev/veo-video) (:predictLongRunning + /v1beta/operations async lifecycle), [Grok Imagine video generation](https://aimock.copilotkit.dev/grok-video) (/v1/videos/generations with async job lifecycle), [BytePlus Ark video generation](https://aimock.copilotkit.dev/byteplus-video) (Seedance, /api/v3/contents/generations/tasks with async task lifecycle), [fal.ai](https://aimock.copilotkit.dev/fal-ai) (image / video / audio with queue lifecycle)
|
|
77
|
-
- **OpenAI platform APIs** — [Files](https://aimock.copilotkit.dev/files) (byte-exact uploads, purpose validation), [fine-tuning jobs](https://aimock.copilotkit.dev/fine-tuning) (deterministic lifecycle, events, cursor pages) and Batches (`/v1/batches` create/list/retrieve/cancel with deterministic poll progression and real output files)
|
|
77
|
+
- **OpenAI platform APIs** — [Files](https://aimock.copilotkit.dev/files) (byte-exact uploads, purpose validation), [Vector Stores](https://aimock.copilotkit.dev/vector-stores) (CRUD, file attach with deterministic poll progression, file batches, deterministic direct search; hosted `file_search` execution is not supported), [fine-tuning jobs](https://aimock.copilotkit.dev/fine-tuning) (deterministic lifecycle, events, cursor pages) and Batches (`/v1/batches` create/list/retrieve/cancel with deterministic poll progression and real output files)
|
|
78
78
|
- **[MCP](https://aimock.copilotkit.dev/mcp-mock) / [A2A](https://aimock.copilotkit.dev/a2a-mock) / [AG-UI](https://aimock.copilotkit.dev/agui-mock) / [Vector](https://aimock.copilotkit.dev/vector-mock)** — Mock every protocol your AI agents use
|
|
79
|
+
- **[MCP Scenario Fakes](https://aimock.copilotkit.dev/mcp-mock#scenario-fakes)** — An `mcpFakes` block in a fixture file scripts each test's MCP tool answers next to its LLM turns: ordered answers, exact or any-argument matching, scripted tool errors, and a closed-world mode that fails on any undeclared tool. Works with any MCP client over Streamable HTTP
|
|
80
|
+
- **[MCP Recording](https://aimock.copilotkit.dev/record-replay#mcp-recording)** — Record a live MCP server into `mcpFakes` files (`--mcp-record /mcp=<url>`, or `llm.record.mcp` with `llm.enableMcpRecording: true` in a config) and replay them offline, with the recorded tool list, progress notifications and timing; known secrets are redacted before anything is written
|
|
81
|
+
- **[MCP Fake Reports](https://aimock.copilotkit.dev/mcp-mock#fakes-report)** — `GET /__aimock/mcp/fakes/report` lists each test's served, unused and failed fakes; with `useAimock({ fakesReport: "fail" })` a swallowed fake error or an unused fake fails the test, and `fakesFor()` gives the MCP URL and headers for the current test. Works for agents, workflows and pipelines alike
|
|
79
82
|
- **[Chaos Testing](https://aimock.copilotkit.dev/chaos-testing)** — 500 errors, malformed JSON, mid-stream disconnects and 429 rate limits (`--chaos-ratelimit`, with `Retry-After`) at any probability, plus a fixed pre-handling delay (`--chaos-latency <ms>`); read, set and clear the rates at runtime via `GET` / `POST` / `DELETE /__aimock/chaos`, scoped to the caller's `X-Test-Id` so one test cannot destabilise the suite running beside it
|
|
83
|
+
- **[Model Misbehavior](https://aimock.copilotkit.dev/model-misbehavior)** — Test invalid tool arguments, schema violations, unknown tools, duplicate IDs, length stops, empty responses, refusals, content filtering, and reasoning-only responses. Supported wires include OpenAI Chat, Responses, Realtime GA, Anthropic, Bedrock InvokeModel and Converse, Gemini generateContent (including the Vertex wrapper), Gemini Live, Gemini Interactions, Cohere, and Ollama chat. Fault and mode support varies by wire. Azure and OpenRouter use the Chat wire. Seeded rates, per-test limits, and journal evidence apply across supported wires. See the reference for the support matrix, SDK behavior, and modeled contracts whose native occurrence remains unverified.
|
|
80
84
|
- **Request journal** — `GET /__aimock/journal` returns every recorded request, filterable by `path`, `method`, `status`, `service`, `testId` and `requestId` with `limit` / `offset` paging and an `X-Total-Count` header carrying the pre-pagination total
|
|
85
|
+
- **HTTP route catalog** — `GET /__aimock/openapi.json` returns OpenAPI 3.1; `GET /__aimock/routes` returns `{ count, routes }`. For programmatic inspection, import `buildOpenApiDocument`, `CATALOG_ROUTES` and `ROUTE_DEFINITIONS` (with `CatalogRoute`/`RouteDefinition` types) from `@copilotkit/aimock`. The catalog describes HTTP operations; streaming responses include media and framing metadata, not a complete-stream JSON body.
|
|
81
86
|
- **Request IDs** — every response carries `X-Request-Id`, echoing the caller's header or minting one; the journal stores it on each entry and `GET /__aimock/journal?requestId=<id>` returns that request. A minted id is never forwarded upstream in record/proxy mode
|
|
82
87
|
- **Per-Request Strict Mode** — `X-AIMock-Strict` header overrides the server-level `--strict` flag per request (`true`/`1` = strict, `false`/`0` = lenient)
|
|
83
88
|
- **Context-Based Fixture Routing** — `X-AIMock-Context` header scopes fixtures per integration; fixtures with `match.context` only match requests carrying that context, fixtures without it remain shared
|
|
@@ -90,10 +95,13 @@ Run them all on one port with `npx @copilotkit/aimock --config aimock.json`, or
|
|
|
90
95
|
- **[Vitest & Jest Plugins](https://aimock.copilotkit.dev/test-plugins)** — Zero-config `useAimock()` with auto lifecycle and env patching
|
|
91
96
|
- **[Response Overrides](https://aimock.copilotkit.dev/fixtures)** — Control `id`, `model`, `usage`, `finishReason` in fixture responses
|
|
92
97
|
- **[Ordered Blocks](https://aimock.copilotkit.dev/fixtures#ordered-blocks)** — A `blocks` array streams text and tool calls in any order (tool-first or interleaved); blocks-only fixtures are first-class, and the recorder captures order from genuinely tool-first/interleaved streams
|
|
98
|
+
- **[Namespaced and Custom Tool Calls](https://aimock.copilotkit.dev/responses-api#namespaced-and-custom-tool-calls)** — Responses API fixtures can return namespaced function calls and custom tool calls (`custom_tool_call`) over HTTP streaming, non-streaming and WebSocket, and can match on `toolNamespace`. This lets you script OpenAI Codex CLI's namespaced MCP and sub-agent tools and its freeform `apply_patch` tool (with the `responsesTools: "extended"` server option)
|
|
93
99
|
- **[Streaming Usage Chunks](https://aimock.copilotkit.dev/streaming-physics)** — `stream_options.include_usage` support emits a final chunk with token counts, matching OpenAI's streaming usage protocol
|
|
94
100
|
- **[Rate Limiting Headers](https://aimock.copilotkit.dev/chaos-testing)** — `x-ratelimit-*` headers on every response and `Retry-After` on 429 errors for testing retry/backoff logic
|
|
95
101
|
- **Zero dependencies** — Everything from Node.js builtins
|
|
96
102
|
|
|
103
|
+
Model misbehavior requires aimock 1.45.0 or later. Older versions silently ignore the fixture's `misbehavior` field and serve its original response. Invalid configurations now fail during fixture loading or programmatic addition. See the [model misbehavior reference](https://aimock.copilotkit.dev/model-misbehavior) for supported parameters and compatibility details.
|
|
104
|
+
|
|
97
105
|
## GitHub Action
|
|
98
106
|
|
|
99
107
|
```yaml
|
|
@@ -157,6 +165,8 @@ Against the server's `--validate-on-load` it is stricter in one direction and we
|
|
|
157
165
|
|
|
158
166
|
Anything the filesystem or a fixture entry can throw is contained in the report instead of crashing the run: a malformed entry, an unreadable file or directory, a stat failure, or a symlink cycle each becomes a per-file `[error]` line and exits 1. One stat failure is deliberately silent: a directory entry that vanishes between the `readdir` and the `stat` (`ENOENT` — a dangling symlink, or a file deleted mid-walk) is skipped without a finding, exactly as the server's loader skips it; every other stat failure is surfaced. A directory argument that walks cleanly but holds no `*.json` files is likewise a per-path `[error]` and exits 1. A crash inside the validator itself is contained too: a per-file one becomes a file-level `[error]` naming no entry, and one in the combined pass becomes a run-level `[error]` printed after the per-file output.
|
|
159
167
|
|
|
168
|
+
A file may also hold an [`mcpFakes`](https://aimock.copilotkit.dev/mcp-mock#scenario-fakes) key. `validate` checks its blocks by the server's load rules (a bad block is an error that names its rule, such as `[mcp-fakes/bad-block:a]`; an `args` entry after an `anyArgs` entry is a warning) and checks entry ids across all files. Mount conflicts depend on the running server and are not checked. A file with only `mcpFakes` is validated, not skipped, and a run of fakes-only files does not fail the zero-fixture rule. The `OK` line counts blocks: `account/read-only.json: OK (0 fixture(s), 1 mcpFakes block(s))`.
|
|
169
|
+
|
|
160
170
|
Errors go to stderr while `OK` and summary lines go to stdout; warnings follow the exit they produce — stdout by default, stderr under `--strict`. Every file gets exactly one stdout line — including a file that failed fatally, and a file the walk skipped (`<file>: skipped (...)`) — so a reader tallying stdout never loses a file. `OK` is withheld in one case: on a run that failed because it loaded no fixtures at all, the file that loaded none reads `<file>: 0 fixture(s), loaded nothing — see the run-level error`. With `--json`, stdout carries the report alone and the one-line failure reason goes to stderr; a usage error is reported the same way, as a document with `files: []` and the reason in `run.errors`. Exit codes: `0` clean; `1` everything else — validation errors, a malformed fixture entry, unreadable/unparseable files, a NAMED path of the wrong shape (a walked one is skipped instead), a remote `http(s)://` path, a stat failure or symlink cycle while walking a directory, a `*.json` path that is not a regular file, a directory holding no `*.json` files, no fixtures loaded at all, `--strict` warnings, or a usage error (no paths given, or an unknown option). There is no exit code 2; every other CLI in this package reports a usage error as 1 too.
|
|
161
171
|
|
|
162
172
|
`--json` emits one document on stdout, and only that document — a usage error included. Validating a directory holding a file with invalid JSON and a file with one bad entry and a duplicate `userMessage`:
|
|
@@ -198,6 +208,7 @@ Errors go to stderr while `OK` and summary lines go to stdout; warnings follow t
|
|
|
198
208
|
],
|
|
199
209
|
"run": {
|
|
200
210
|
"fixtures": 2,
|
|
211
|
+
"mcpFakeBlocks": 0,
|
|
201
212
|
"errors": []
|
|
202
213
|
}
|
|
203
214
|
}
|
|
@@ -212,12 +223,13 @@ A usage error carries the reason in `run.errors` (`aimock validate --json`, exit
|
|
|
212
223
|
"files": [],
|
|
213
224
|
"run": {
|
|
214
225
|
"fixtures": 0,
|
|
226
|
+
"mcpFakeBlocks": 0,
|
|
215
227
|
"errors": ["no fixture paths given."]
|
|
216
228
|
}
|
|
217
229
|
}
|
|
218
230
|
```
|
|
219
231
|
|
|
220
|
-
`failed` is the boolean the exit code follows, and `strict` echoes the flag it was computed under. `files` has one entry per path the run touched, in argv/walk order: `mention` is which load of that path this is (1-based, always present); `fixtures` is how many entries converted; `skipped` (present only when set) is why a walked non-fixture file was passed over; `fatal` (present only when set) is the reason the file produced no report at all, and that same reason also appears in `errors`, so a tally of `files[].errors` matches the error count on the file's stdout line; and `errors`/`warnings` hold findings. A finding always has `message`; `index` is the entry it belongs to and is **absent** on a file-level finding; `detail` carries the raw thrown text when `message` is a rephrasing of it. `run` covers the combined pass: `fixtures` is the total fixture count across every file, and `errors` holds run-level strings such as `"Cross-file validation failed: ..."`, the `"No fixtures loaded from any input — the server aborts startup on this under --validate-on-load/--strict"` line, or the reason a usage error failed.
|
|
232
|
+
`failed` is the boolean the exit code follows, and `strict` echoes the flag it was computed under. `files` has one entry per path the run touched, in argv/walk order: `mention` is which load of that path this is (1-based, always present); `fixtures` is how many entries converted; `skipped` (present only when set) is why a walked non-fixture file was passed over; `fatal` (present only when set) is the reason the file produced no report at all, and that same reason also appears in `errors`, so a tally of `files[].errors` matches the error count on the file's stdout line; and `errors`/`warnings` hold findings; a file with an `mcpFakes` key also has `mcpFakeBlocks`, the number of blocks it adds. A finding always has `message`; `index` is the entry it belongs to and is **absent** on a file-level finding; `detail` carries the raw thrown text when `message` is a rephrasing of it. `run` covers the combined pass: `fixtures` is the total fixture count across every file, `mcpFakeBlocks` (always present, `0` when no file has `mcpFakes`) is the total number of `mcpFakes` blocks, and `errors` holds run-level strings such as `"Cross-file validation failed: ..."`, the `"No fixtures loaded from any input — the server aborts startup on this under --validate-on-load/--strict"` line, or the reason a usage error failed.
|
|
221
233
|
|
|
222
234
|
### Remote fixture URLs
|
|
223
235
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agui-handler.d.ts","names":[],"sources":["../src/agui-handler.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAsDA;AAgCA;;AAAkD,iBAhClC,sBAAA,CAgCkC,KAAA,EAhCJ,iBAgCI,CAAA,EAAA,MAAA;;;AAUlD;AAA8B,iBAVd,0BAAA,CAUc,KAAA,EAVoB,iBAUpB,CAAA,E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6EoD,EAAA,EAAA,EAAA,IAAA,CAAA,EA5E7D,aA4E6D,CAAA,EA3EnE,SA2EmE,EAAA;;;AAiBtE;;AAAsE,iBAlEtD,kBAAA,CAkEsD,SAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,KAAA,EAAA,OAAA,EAAA,EAAA,IAAA,CAAA,EA9D7D,aA8D6D,CAAA,EA7DnE,SA6DmE,EAAA;;;AAiBtE;;AAES,iBA9DO,kBAAA,CA8DP,KAAA,EAAA,MAAA,EAAA,IAkBmC,CAlBnC,EA5DA,aA4DA,GAAA;YACN,CAAA,EAAA,MAAA;EAAS,YAAA,CAAA,EAAA,MAAA;EAiBI,eAAA,CAAA,EAAA,MAAA;CAA4B,CAAA,EAzEzC,SAyEyC,EAAA;;;;;AA0BtB,iBAhFN,aAAA,CAgF0B,KAAA,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAhF4B,aAgF5B,CAAA,EAhF4C,SAgF5C,EAAA;;;;;AAGkB,iBAlE5C,gBAAA,CAkE4C,IAAA,EAAA,MAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,CAAA,EAlEU,aAkEV,CAAA,EAlE0B,SAkE1B,EAAA;;;;;iBAjD5C,mBAAA,uBAEP;;IACN;;;;;iBAiBa,4BAAA,UACL,qFAGF,gBACN;;;;;;iBAqBmB,oBAAA,MACf,MAAA,CAAK,wBACF;;WAC4B;WAAsB;IACzD"}
|
package/dist/aimock-cli.cjs
CHANGED
|
@@ -17,6 +17,11 @@ Options:
|
|
|
17
17
|
-c, --config <path> Path to aimock config JSON file (required)
|
|
18
18
|
-p, --port <number> Port override (default: from config or 0)
|
|
19
19
|
--host <string> Host override (default: from config or 127.0.0.1)
|
|
20
|
+
--misbehavior Enable model misbehavior (same as llm.enableMisbehavior: true)
|
|
21
|
+
--strict-tool-arguments Reject fixture tool calls with invalid JSON arguments
|
|
22
|
+
instead of serving {} (same as llm.strictToolArguments: true)
|
|
23
|
+
--responses-tools <mode> OpenAI Responses tool handling: legacy (default) or
|
|
24
|
+
extended (overrides llm.responsesTools)
|
|
20
25
|
-h, --help Show this help message
|
|
21
26
|
|
|
22
27
|
Subcommands:
|
|
@@ -66,6 +71,15 @@ function runAimockCli(deps = {}) {
|
|
|
66
71
|
short: "p"
|
|
67
72
|
},
|
|
68
73
|
host: { type: "string" },
|
|
74
|
+
misbehavior: {
|
|
75
|
+
type: "boolean",
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
"strict-tool-arguments": {
|
|
79
|
+
type: "boolean",
|
|
80
|
+
default: false
|
|
81
|
+
},
|
|
82
|
+
"responses-tools": { type: "string" },
|
|
69
83
|
help: {
|
|
70
84
|
type: "boolean",
|
|
71
85
|
short: "h",
|
|
@@ -92,7 +106,8 @@ function runAimockCli(deps = {}) {
|
|
|
92
106
|
const blank = [
|
|
93
107
|
["config", values.config],
|
|
94
108
|
["port", values.port],
|
|
95
|
-
["host", values.host]
|
|
109
|
+
["host", values.host],
|
|
110
|
+
["responses-tools", values["responses-tools"]]
|
|
96
111
|
].find(([, value]) => value !== void 0 && value.trim() === "");
|
|
97
112
|
if (blank !== void 0) {
|
|
98
113
|
logError(`Error: --${blank[0]} requires a non-empty value.\n\n${HELP}`);
|
|
@@ -115,11 +130,22 @@ function runAimockCli(deps = {}) {
|
|
|
115
130
|
return;
|
|
116
131
|
}
|
|
117
132
|
const host = values.host;
|
|
133
|
+
const responsesToolsFlag = values["responses-tools"];
|
|
134
|
+
if (responsesToolsFlag !== void 0 && responsesToolsFlag !== "legacy" && responsesToolsFlag !== "extended") {
|
|
135
|
+
logError(`Error: invalid --responses-tools "${responsesToolsFlag}" (expected "legacy" or "extended").\n\n${HELP}`);
|
|
136
|
+
exit(1);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const responsesTools = responsesToolsFlag;
|
|
140
|
+
const overrides = {
|
|
141
|
+
port,
|
|
142
|
+
host,
|
|
143
|
+
...values.misbehavior ? { enableMisbehavior: true } : {},
|
|
144
|
+
...values["strict-tool-arguments"] ? { strictToolArguments: true } : {},
|
|
145
|
+
...responsesTools !== void 0 ? { responsesTools } : {}
|
|
146
|
+
};
|
|
118
147
|
async function main() {
|
|
119
|
-
const { llmock, url } = await startFromConfigFn(config,
|
|
120
|
-
port,
|
|
121
|
-
host
|
|
122
|
-
});
|
|
148
|
+
const { llmock, url } = await startFromConfigFn(config, overrides);
|
|
123
149
|
function shutdown() {
|
|
124
150
|
log("Shutting down...");
|
|
125
151
|
process.removeListener("SIGINT", shutdown);
|
package/dist/aimock-cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aimock-cli.cjs","names":["loadConfig","startFromConfig"],"sources":["../src/aimock-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { resolve, basename } from \"node:path\";\nimport { loadConfig, startFromConfig } from \"./config-loader.js\";\nimport { runConvertCli, type ConvertCliDeps } from \"./convert.js\";\nimport { runValidateCli } from \"./validate-cli.js\";\n\nconst HELP = `\nUsage: aimock [options]\n aimock convert <format> <input> [output]\n aimock validate [--strict] [--json] [--] <path> [more paths ...]\n\nOptions:\n -c, --config <path> Path to aimock config JSON file (required)\n -p, --port <number> Port override (default: from config or 0)\n --host <string> Host override (default: from config or 127.0.0.1)\n -h, --help Show this help message\n\nSubcommands:\n convert Convert third-party mock configs to aimock format\n Run \"aimock convert --help\" for details\n validate Validate fixture files or directories offline\n Run \"aimock validate --help\" for details\n`.trim();\n\nexport interface AimockCliDeps {\n argv?: string[];\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n loadConfigFn?: typeof loadConfig;\n startFromConfigFn?: typeof startFromConfig;\n onReady?: (ctx: { shutdown: () => void }) => void;\n convertDeps?: Partial<ConvertCliDeps>;\n validateDeps?: {\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n };\n}\n\nexport function runAimockCli(deps: AimockCliDeps = {}): void {\n /* v8 ignore next 6 -- defaults used only when called from CLI entry point */\n const argv = deps.argv ?? process.argv.slice(2);\n const log = deps.log ?? console.log.bind(console);\n const logError = deps.logError ?? console.error.bind(console);\n const exit = deps.exit ?? process.exit.bind(process);\n const loadConfigFn = deps.loadConfigFn ?? loadConfig;\n const startFromConfigFn = deps.startFromConfigFn ?? startFromConfig;\n\n // Intercept \"convert\" subcommand before parseArgs (which uses strict mode)\n if (argv[0] === \"convert\") {\n runConvertCli({\n argv: argv.slice(1),\n log,\n logError,\n exit,\n ...deps.convertDeps,\n });\n return;\n }\n\n // Intercept \"validate\" the same way — it takes file paths, not --config.\n if (argv[0] === \"validate\") {\n runValidateCli({\n argv: argv.slice(1),\n log: deps.validateDeps?.log ?? log,\n logError: deps.validateDeps?.logError ?? logError,\n exit: deps.validateDeps?.exit ?? exit,\n });\n return;\n }\n\n // Short-flag rule for the `aimock` bin: a short flag means the same thing at\n // the top level and in every subcommand. `-h` is `--help` everywhere, which\n // is what `convert` (src/convert.ts) and `validate` (src/validate-cli.ts)\n // already did and what a reader typing `aimock -h` expects; the host\n // override is long-form `--host` only, and had no documented short use.\n // Short flags are per-bin: the separate `llmock` bin (src/cli.ts, the\n // Docker ENTRYPOINT) keeps its own documented set, where `-h` is `--host`\n // and `-c` is `--chunk-size`.\n let values;\n try {\n ({ values } = parseArgs({\n args: argv,\n options: {\n config: { type: \"string\", short: \"c\" },\n port: { type: \"string\", short: \"p\" },\n host: { type: \"string\" },\n help: { type: \"boolean\", short: \"h\", default: false },\n },\n strict: true,\n }));\n } catch (err) {\n /* v8 ignore next -- parseArgs always throws Error subclasses */\n const msg = err instanceof Error ? err.message : String(err);\n logError(`Error: ${msg}\\n\\n${HELP}`);\n exit(1);\n return;\n }\n\n if (values.help) {\n log(HELP);\n exit(0);\n return;\n }\n if (values.config === undefined) {\n logError(\"Error: --config is required.\\n\\n\" + HELP);\n exit(1);\n return;\n }\n // A value-taking option that was GIVEN an empty (or blank) value is a usage\n // error, not an absent option. Testing these for truthiness instead let\n // `--config \"\"` read as \"not given\", and let `--port \"\"` / `--host \"\"` be\n // dropped in silence — `--host \"\"` in particular reached the server as an\n // empty bind address, which listens on every interface rather than on the\n // documented 127.0.0.1 default.\n const blank = (\n [\n [\"config\", values.config],\n [\"port\", values.port],\n [\"host\", values.host],\n ] as const\n ).find(([, value]) => value !== undefined && value.trim() === \"\");\n if (blank !== undefined) {\n logError(`Error: --${blank[0]} requires a non-empty value.\\n\\n${HELP}`);\n exit(1);\n return;\n }\n\n const configPath = resolve(values.config);\n let config;\n try {\n config = loadConfigFn(configPath);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logError(`Failed to load config from ${configPath}: ${msg}`);\n exit(1);\n return;\n }\n\n const port = values.port === undefined ? undefined : Number(values.port);\n if (\n port !== undefined &&\n (Number.isNaN(port) || !Number.isInteger(port) || port < 0 || port > 65535)\n ) {\n logError(`Error: invalid port \"${values.port}\".\\n\\n${HELP}`);\n exit(1);\n return;\n }\n const host = values.host;\n\n async function main() {\n const { llmock, url } = await startFromConfigFn(config!, { port, host });\n\n function shutdown() {\n log(\"Shutting down...\");\n process.removeListener(\"SIGINT\", shutdown);\n process.removeListener(\"SIGTERM\", shutdown);\n llmock.stop().then(\n () => exit(0),\n (err) => {\n logError(`Shutdown error: ${err instanceof Error ? err.message : String(err)}`);\n exit(1);\n },\n );\n }\n // Register BEFORE announcing readiness — see the note in src/cli.ts. A supervisor\n // that reacts to the readiness line must never win a race against this listener.\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n log(`aimock server listening on ${url}`);\n\n if (deps.onReady) {\n deps.onReady({ shutdown });\n }\n }\n\n main().catch((err) => {\n logError(err instanceof Error ? err.message : String(err));\n exit(1);\n });\n}\n\n// Run when executed as a script (not when imported for testing).\n/* v8 ignore start -- entry-point guard, exercised by integration tests */\n// The basenames this module is ever argv[1] under: the `aimock` bin (the\n// package.json \"bin\" name), both build outputs — tsdown.config.ts builds\n// src/aimock-cli.ts in \"esm\" AND \"cjs\" format, which under `\"type\": \"module\"`\n// emits dist/aimock-cli.js and dist/aimock-cli.cjs — and the TypeScript\n// source, run through tsx. Omitting the .cjs made `node dist/aimock-cli.cjs`\n// print nothing and exit 0 despite its shebang and exec bit.\nconst ENTRY_BASENAMES = new Set([\"aimock\", \"aimock-cli.js\", \"aimock-cli.cjs\", \"aimock-cli.ts\"]);\nconst scriptName = process.argv[1] ?? \"\";\nif (ENTRY_BASENAMES.has(basename(scriptName))) {\n runAimockCli();\n}\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;AAOA,MAAM,OAAO;;;;;;;;;;;;;;;;EAgBX,MAAM;AAkBR,SAAgB,aAAa,OAAsB,EAAE,EAAQ;;CAE3D,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK,MAAM,EAAE;CAC/C,MAAM,MAAM,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ;CACjD,MAAM,WAAW,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ;CAC7D,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK,KAAK,QAAQ;CACpD,MAAM,eAAe,KAAK,gBAAgBA;CAC1C,MAAM,oBAAoB,KAAK,qBAAqBC;AAGpD,KAAI,KAAK,OAAO,WAAW;AACzB,gCAAc;GACZ,MAAM,KAAK,MAAM,EAAE;GACnB;GACA;GACA;GACA,GAAG,KAAK;GACT,CAAC;AACF;;AAIF,KAAI,KAAK,OAAO,YAAY;AAC1B,sCAAe;GACb,MAAM,KAAK,MAAM,EAAE;GACnB,KAAK,KAAK,cAAc,OAAO;GAC/B,UAAU,KAAK,cAAc,YAAY;GACzC,MAAM,KAAK,cAAc,QAAQ;GAClC,CAAC;AACF;;CAWF,IAAI;AACJ,KAAI;AACF,GAAC,CAAE,mCAAqB;GACtB,MAAM;GACN,SAAS;IACP,QAAQ;KAAE,MAAM;KAAU,OAAO;KAAK;IACtC,MAAM;K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AAI,mBAAmB;AACvB,WAAQ,eAAe,UAAU,SAAS;AAC1C,WAAQ,eAAe,WAAW,SAAS;AAC3C,UAAO,MAAM,CAAC,WACN,KAAK,EAAE,GACZ,QAAQ;AACP,aAAS,mBAAmB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAAG;AAC/E,SAAK,EAAE;KAEV;;AAIH,UAAQ,GAAG,UAAU,SAAS;AAC9B,UAAQ,GAAG,WAAW,SAAS;AAE/B,MAAI,8BAA8B,MAAM;AAExC,MAAI,KAAK,QACP,MAAK,QAAQ,EAAE,UAAU,CAAC;;AAI9B,OAAM,CAAC,OAAO,QAAQ;AACpB,WAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC;AAC1D,OAAK,EAAE;GACP;;;AAWJ,MAAM,kBAAkB,IAAI,IAAI;CAAC;CAAU;CAAiB;CAAkB;CAAgB,CAAC;AAC/F,MAAM,aAAa,QAAQ,KAAK,MAAM;AACtC,IAAI,gBAAgB,4BAAa,WAAW,CAAC,CAC3C,eAAc"}
|
|
1
|
+
{"version":3,"file":"aimock-cli.cjs","names":["loadConfig","startFromConfig"],"sources":["../src/aimock-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { resolve, basename } from \"node:path\";\nimport { loadConfig, startFromConfig, type StartFromConfigOverrides } from \"./config-loader.js\";\nimport { runConvertCli, type ConvertCliDeps } from \"./convert.js\";\nimport { runValidateCli } from \"./validate-cli.js\";\n\nconst HELP = `\nUsage: aimock [options]\n aimock convert <format> <input> [output]\n aimock validate [--strict] [--json] [--] <path> [more paths ...]\n\nOptions:\n -c, --config <path> Path to aimock config JSON file (required)\n -p, --port <number> Port override (default: from config or 0)\n --host <string> Host override (default: from config or 127.0.0.1)\n --misbehavior Enable model misbehavior (same as llm.enableMisbehavior: true)\n --strict-tool-arguments Reject fixture tool calls with invalid JSON arguments\n instead of serving {} (same as llm.strictToolArguments: true)\n --responses-tools <mode> OpenAI Responses tool handling: legacy (default) or\n extended (overrides llm.responsesTools)\n -h, --help Show this help message\n\nSubcommands:\n convert Convert third-party mock configs to aimock format\n Run \"aimock convert --help\" for details\n validate Validate fixture files or directories offline\n Run \"aimock validate --help\" for details\n`.trim();\n\nexport interface AimockCliDeps {\n argv?: string[];\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n loadConfigFn?: typeof loadConfig;\n startFromConfigFn?: typeof startFromConfig;\n onReady?: (ctx: { shutdown: () => void }) => void;\n convertDeps?: Partial<ConvertCliDeps>;\n validateDeps?: {\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n };\n}\n\nexport function runAimockCli(deps: AimockCliDeps = {}): void {\n /* v8 ignore next 6 -- defaults used only when called from CLI entry point */\n const argv = deps.argv ?? process.argv.slice(2);\n const log = deps.log ?? console.log.bind(console);\n const logError = deps.logError ?? console.error.bind(console);\n const exit = deps.exit ?? process.exit.bind(process);\n const loadConfigFn = deps.loadConfigFn ?? loadConfig;\n const startFromConfigFn = deps.startFromConfigFn ?? startFromConfig;\n\n // Intercept \"convert\" subcommand before parseArgs (which uses strict mode)\n if (argv[0] === \"convert\") {\n runConvertCli({\n argv: argv.slice(1),\n log,\n logError,\n exit,\n ...deps.convertDeps,\n });\n return;\n }\n\n // Intercept \"validate\" the same way — it takes file paths, not --config.\n if (argv[0] === \"validate\") {\n runValidateCli({\n argv: argv.slice(1),\n log: deps.validateDeps?.log ?? log,\n logError: deps.validateDeps?.logError ?? logError,\n exit: deps.validateDeps?.exit ?? exit,\n });\n return;\n }\n\n // Short-flag rule for the `aimock` bin: a short flag means the same thing at\n // the top level and in every subcommand. `-h` is `--help` everywhere, which\n // is what `convert` (src/convert.ts) and `validate` (src/validate-cli.ts)\n // already did and what a reader typing `aimock -h` expects; the host\n // override is long-form `--host` only, and had no documented short use.\n // Short flags are per-bin: the separate `llmock` bin (src/cli.ts, the\n // Docker ENTRYPOINT) keeps its own documented set, where `-h` is `--host`\n // and `-c` is `--chunk-size`.\n let values;\n try {\n ({ values } = parseArgs({\n args: argv,\n options: {\n config: { type: \"string\", short: \"c\" },\n port: { type: \"string\", short: \"p\" },\n host: { type: \"string\" },\n misbehavior: { type: \"boolean\", default: false },\n \"strict-tool-arguments\": { type: \"boolean\", default: false },\n \"responses-tools\": { type: \"string\" },\n help: { type: \"boolean\", short: \"h\", default: false },\n },\n strict: true,\n }));\n } catch (err) {\n /* v8 ignore next -- parseArgs always throws Error subclasses */\n const msg = err instanceof Error ? err.message : String(err);\n logError(`Error: ${msg}\\n\\n${HELP}`);\n exit(1);\n return;\n }\n\n if (values.help) {\n log(HELP);\n exit(0);\n return;\n }\n if (values.config === undefined) {\n logError(\"Error: --config is required.\\n\\n\" + HELP);\n exit(1);\n return;\n }\n // A value-taking option that was GIVEN an empty (or blank) value is a usage\n // error, not an absent option. Testing these for truthiness instead let\n // `--config \"\"` read as \"not given\", and let `--port \"\"` / `--host \"\"` be\n // dropped in silence — `--host \"\"` in particular reached the server as an\n // empty bind address, which listens on every interface rather than on the\n // documented 127.0.0.1 default.\n const blank = (\n [\n [\"config\", values.config],\n [\"port\", values.port],\n [\"host\", values.host],\n [\"responses-tools\", values[\"responses-tools\"]],\n ] as const\n ).find(([, value]) => value !== undefined && value.trim() === \"\");\n if (blank !== undefined) {\n logError(`Error: --${blank[0]} requires a non-empty value.\\n\\n${HELP}`);\n exit(1);\n return;\n }\n\n const configPath = resolve(values.config);\n let config;\n try {\n config = loadConfigFn(configPath);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logError(`Failed to load config from ${configPath}: ${msg}`);\n exit(1);\n return;\n }\n\n const port = values.port === undefined ? undefined : Number(values.port);\n if (\n port !== undefined &&\n (Number.isNaN(port) || !Number.isInteger(port) || port < 0 || port > 65535)\n ) {\n logError(`Error: invalid port \"${values.port}\".\\n\\n${HELP}`);\n exit(1);\n return;\n }\n const host = values.host;\n const responsesToolsFlag = values[\"responses-tools\"];\n if (\n responsesToolsFlag !== undefined &&\n responsesToolsFlag !== \"legacy\" &&\n responsesToolsFlag !== \"extended\"\n ) {\n logError(\n `Error: invalid --responses-tools \"${responsesToolsFlag}\" (expected \"legacy\" or \"extended\").\\n\\n${HELP}`,\n );\n exit(1);\n return;\n }\n // The boolean opt-ins override the config only when given, so an absent flag\n // leaves llm.enableMisbehavior / llm.strictToolArguments in charge.\n const responsesTools: StartFromConfigOverrides[\"responsesTools\"] = responsesToolsFlag;\n const overrides: StartFromConfigOverrides = {\n port,\n host,\n ...(values.misbehavior ? { enableMisbehavior: true } : {}),\n ...(values[\"strict-tool-arguments\"] ? { strictToolArguments: true } : {}),\n ...(responsesTools !== undefined ? { responsesTools } : {}),\n };\n\n async function main() {\n const { llmock, url } = await startFromConfigFn(config!, overrides);\n\n function shutdown() {\n log(\"Shutting down...\");\n process.removeListener(\"SIGINT\", shutdown);\n process.removeListener(\"SIGTERM\", shutdown);\n llmock.stop().then(\n () => exit(0),\n (err) => {\n logError(`Shutdown error: ${err instanceof Error ? err.message : String(err)}`);\n exit(1);\n },\n );\n }\n // Register BEFORE announcing readiness — see the note in src/cli.ts. A supervisor\n // that reacts to the readiness line must never win a race against this listener.\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n log(`aimock server listening on ${url}`);\n\n if (deps.onReady) {\n deps.onReady({ shutdown });\n }\n }\n\n main().catch((err) => {\n logError(err instanceof Error ? err.message : String(err));\n exit(1);\n });\n}\n\n// Run when executed as a script (not when imported for testing).\n/* v8 ignore start -- entry-point guard, exercised by integration tests */\n// The basenames this module is ever argv[1] under: the `aimock` bin (the\n// package.json \"bin\" name), both build outputs — tsdown.config.ts builds\n// src/aimock-cli.ts in \"esm\" AND \"cjs\" format, which under `\"type\": \"module\"`\n// emits dist/aimock-cli.js and dist/aimock-cli.cjs — and the TypeScript\n// source, run through tsx. Omitting the .cjs made `node dist/aimock-cli.cjs`\n// print nothing and exit 0 despite its shebang and exec bit.\nconst ENTRY_BASENAMES = new Set([\"aimock\", \"aimock-cli.js\", \"aimock-cli.cjs\", \"aimock-cli.ts\"]);\nconst scriptName = process.argv[1] ?? \"\";\nif (ENTRY_BASENAMES.has(basename(scriptName))) {\n runAimockCli();\n}\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;AAOA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;EAqBX,MAAM;AAkBR,SAAgB,aAAa,OAAsB,EAAE,EAAQ;;CAE3D,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK,MAAM,EAAE;CAC/C,MAAM,MAAM,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ;CACjD,MAAM,WAAW,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ;CAC7D,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK,KAAK,QAAQ;CACpD,MAAM,eAAe,KAAK,gBAAgBA;CAC1C,MAAM,oBAAoB,KAAK,qBAAqBC;AAGpD,KAAI,KAAK,OAAO,WAAW;AACzB,gCAAc;GACZ,MAAM,KAAK,MAAM,EAAE;GACnB;GACA;GACA;GACA,GAAG,KAAK;GACT,CAAC;AACF;;AAIF,KAAI,KAAK,OAAO,YAAY;AAC1B,sCAAe;GACb,MAAM,KAAK,MAAM,EAAE;GACnB,KAAK,KAAK,cAAc,OAAO;GAC/B,UAAU,KAAK,cAAc,YAAY;GACzC,MAAM,KAAK,cAAc,QAAQ;GAClC,CAAC;AACF;;CAWF,IAAI;AACJ,KAAI;AACF,GAAC,CAAE,mCAAqB;GACtB,MAAM;GACN,SAAS;IACP,QAAQ;KAAE,MAAM;KAAU,OAAO;KAAK;IACtC,MAAM;KAAE,MAAM;KAAU,OAAO;KAAK;IACpC,MAAM,EAAE,MAAM,UAAU;IACxB,aAAa;KAAE,MAAM;KAAW,SAAS;KAAO;IAChD,yBAAyB;KAAE,MAAM;KAAW,SAAS;KAAO;IAC5D,mBAAmB,EAAE,MAAM,UAAU;IACrC,MAAM;KAAE,MAAM;KAA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AAM,YAAsC;EAC1C;EACA;EACA,GAAI,OAAO,cAAc,EAAE,mBAAmB,MAAM,GAAG,EAAE;EACzD,GAAI,OAAO,2BAA2B,EAAE,qBAAqB,MAAM,GAAG,EAAE;EACxE,GAAI,mBAAmB,SAAY,EAAE,gBAAgB,GAAG,EAAE;EAC3D;CAED,eAAe,OAAO;EACpB,MAAM,EAAE,QAAQ,QAAQ,MAAM,kBAAkB,QAAS,UAAU;EAEnE,SAAS,WAAW;AAClB,OAAI,mBAAmB;AACvB,WAAQ,eAAe,UAAU,SAAS;AAC1C,WAAQ,eAAe,WAAW,SAAS;AAC3C,UAAO,MAAM,CAAC,WACN,KAAK,EAAE,GACZ,QAAQ;AACP,aAAS,mBAAmB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAAG;AAC/E,SAAK,EAAE;KAEV;;AAIH,UAAQ,GAAG,UAAU,SAAS;AAC9B,UAAQ,GAAG,WAAW,SAAS;AAE/B,MAAI,8BAA8B,MAAM;AAExC,MAAI,KAAK,QACP,MAAK,QAAQ,EAAE,UAAU,CAAC;;AAI9B,OAAM,CAAC,OAAO,QAAQ;AACpB,WAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC;AAC1D,OAAK,EAAE;GACP;;;AAWJ,MAAM,kBAAkB,IAAI,IAAI;CAAC;CAAU;CAAiB;CAAkB;CAAgB,CAAC;AAC/F,MAAM,aAAa,QAAQ,KAAK,MAAM;AACtC,IAAI,gBAAgB,4BAAa,WAAW,CAAC,CAC3C,eAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aimock-cli.d.cts","names":[],"sources":["../src/aimock-cli.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"aimock-cli.d.cts","names":[],"sources":["../src/aimock-cli.ts"],"sourcesContent":[],"mappings":";;;;UA8BiB,aAAA;EAAA,IAAA,CAAA,EAAA,MAAA,EAAA;EAAa,GAAA,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;UAKN,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;MACK,CAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,IAAA;cAEL,CAAA,EAAA,OAHA,UAGA;mBAAR,CAAA,EAAA,OAFa,eAEb;EAAO,OAAA,CAAA,EAAA,CAAA,GAAA,EAAA;IAQP,QAAA,EAAA,GAAY,GAAA,IAAA;;gBARZ,QAAQ;;;;;;;iBAQR,YAAA,QAAmB"}
|
package/dist/aimock-cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aimock-cli.d.ts","names":[],"sources":["../src/aimock-cli.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"aimock-cli.d.ts","names":[],"sources":["../src/aimock-cli.ts"],"sourcesContent":[],"mappings":";;;;UA8BiB,aAAA;EAAA,IAAA,CAAA,EAAA,MAAA,EAAA;EAAa,GAAA,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;UAKN,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;MACK,CAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,IAAA;cAEL,CAAA,EAAA,OAHA,UAGA;mBAAR,CAAA,EAAA,OAFa,eAEb;EAAO,OAAA,CAAA,EAAA,CAAA,GAAA,EAAA;IAQP,QAAA,EAAA,GAAY,GAAA,IAAA;;gBARZ,QAAQ;;;;;;;iBAQR,YAAA,QAAmB"}
|
package/dist/aimock-cli.js
CHANGED
|
@@ -15,6 +15,11 @@ Options:
|
|
|
15
15
|
-c, --config <path> Path to aimock config JSON file (required)
|
|
16
16
|
-p, --port <number> Port override (default: from config or 0)
|
|
17
17
|
--host <string> Host override (default: from config or 127.0.0.1)
|
|
18
|
+
--misbehavior Enable model misbehavior (same as llm.enableMisbehavior: true)
|
|
19
|
+
--strict-tool-arguments Reject fixture tool calls with invalid JSON arguments
|
|
20
|
+
instead of serving {} (same as llm.strictToolArguments: true)
|
|
21
|
+
--responses-tools <mode> OpenAI Responses tool handling: legacy (default) or
|
|
22
|
+
extended (overrides llm.responsesTools)
|
|
18
23
|
-h, --help Show this help message
|
|
19
24
|
|
|
20
25
|
Subcommands:
|
|
@@ -64,6 +69,15 @@ function runAimockCli(deps = {}) {
|
|
|
64
69
|
short: "p"
|
|
65
70
|
},
|
|
66
71
|
host: { type: "string" },
|
|
72
|
+
misbehavior: {
|
|
73
|
+
type: "boolean",
|
|
74
|
+
default: false
|
|
75
|
+
},
|
|
76
|
+
"strict-tool-arguments": {
|
|
77
|
+
type: "boolean",
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
"responses-tools": { type: "string" },
|
|
67
81
|
help: {
|
|
68
82
|
type: "boolean",
|
|
69
83
|
short: "h",
|
|
@@ -90,7 +104,8 @@ function runAimockCli(deps = {}) {
|
|
|
90
104
|
const blank = [
|
|
91
105
|
["config", values.config],
|
|
92
106
|
["port", values.port],
|
|
93
|
-
["host", values.host]
|
|
107
|
+
["host", values.host],
|
|
108
|
+
["responses-tools", values["responses-tools"]]
|
|
94
109
|
].find(([, value]) => value !== void 0 && value.trim() === "");
|
|
95
110
|
if (blank !== void 0) {
|
|
96
111
|
logError(`Error: --${blank[0]} requires a non-empty value.\n\n${HELP}`);
|
|
@@ -113,11 +128,22 @@ function runAimockCli(deps = {}) {
|
|
|
113
128
|
return;
|
|
114
129
|
}
|
|
115
130
|
const host = values.host;
|
|
131
|
+
const responsesToolsFlag = values["responses-tools"];
|
|
132
|
+
if (responsesToolsFlag !== void 0 && responsesToolsFlag !== "legacy" && responsesToolsFlag !== "extended") {
|
|
133
|
+
logError(`Error: invalid --responses-tools "${responsesToolsFlag}" (expected "legacy" or "extended").\n\n${HELP}`);
|
|
134
|
+
exit(1);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const responsesTools = responsesToolsFlag;
|
|
138
|
+
const overrides = {
|
|
139
|
+
port,
|
|
140
|
+
host,
|
|
141
|
+
...values.misbehavior ? { enableMisbehavior: true } : {},
|
|
142
|
+
...values["strict-tool-arguments"] ? { strictToolArguments: true } : {},
|
|
143
|
+
...responsesTools !== void 0 ? { responsesTools } : {}
|
|
144
|
+
};
|
|
116
145
|
async function main() {
|
|
117
|
-
const { llmock, url } = await startFromConfigFn(config,
|
|
118
|
-
port,
|
|
119
|
-
host
|
|
120
|
-
});
|
|
146
|
+
const { llmock, url } = await startFromConfigFn(config, overrides);
|
|
121
147
|
function shutdown() {
|
|
122
148
|
log("Shutting down...");
|
|
123
149
|
process.removeListener("SIGINT", shutdown);
|
package/dist/aimock-cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aimock-cli.js","names":[],"sources":["../src/aimock-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { resolve, basename } from \"node:path\";\nimport { loadConfig, startFromConfig } from \"./config-loader.js\";\nimport { runConvertCli, type ConvertCliDeps } from \"./convert.js\";\nimport { runValidateCli } from \"./validate-cli.js\";\n\nconst HELP = `\nUsage: aimock [options]\n aimock convert <format> <input> [output]\n aimock validate [--strict] [--json] [--] <path> [more paths ...]\n\nOptions:\n -c, --config <path> Path to aimock config JSON file (required)\n -p, --port <number> Port override (default: from config or 0)\n --host <string> Host override (default: from config or 127.0.0.1)\n -h, --help Show this help message\n\nSubcommands:\n convert Convert third-party mock configs to aimock format\n Run \"aimock convert --help\" for details\n validate Validate fixture files or directories offline\n Run \"aimock validate --help\" for details\n`.trim();\n\nexport interface AimockCliDeps {\n argv?: string[];\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n loadConfigFn?: typeof loadConfig;\n startFromConfigFn?: typeof startFromConfig;\n onReady?: (ctx: { shutdown: () => void }) => void;\n convertDeps?: Partial<ConvertCliDeps>;\n validateDeps?: {\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n };\n}\n\nexport function runAimockCli(deps: AimockCliDeps = {}): void {\n /* v8 ignore next 6 -- defaults used only when called from CLI entry point */\n const argv = deps.argv ?? process.argv.slice(2);\n const log = deps.log ?? console.log.bind(console);\n const logError = deps.logError ?? console.error.bind(console);\n const exit = deps.exit ?? process.exit.bind(process);\n const loadConfigFn = deps.loadConfigFn ?? loadConfig;\n const startFromConfigFn = deps.startFromConfigFn ?? startFromConfig;\n\n // Intercept \"convert\" subcommand before parseArgs (which uses strict mode)\n if (argv[0] === \"convert\") {\n runConvertCli({\n argv: argv.slice(1),\n log,\n logError,\n exit,\n ...deps.convertDeps,\n });\n return;\n }\n\n // Intercept \"validate\" the same way — it takes file paths, not --config.\n if (argv[0] === \"validate\") {\n runValidateCli({\n argv: argv.slice(1),\n log: deps.validateDeps?.log ?? log,\n logError: deps.validateDeps?.logError ?? logError,\n exit: deps.validateDeps?.exit ?? exit,\n });\n return;\n }\n\n // Short-flag rule for the `aimock` bin: a short flag means the same thing at\n // the top level and in every subcommand. `-h` is `--help` everywhere, which\n // is what `convert` (src/convert.ts) and `validate` (src/validate-cli.ts)\n // already did and what a reader typing `aimock -h` expects; the host\n // override is long-form `--host` only, and had no documented short use.\n // Short flags are per-bin: the separate `llmock` bin (src/cli.ts, the\n // Docker ENTRYPOINT) keeps its own documented set, where `-h` is `--host`\n // and `-c` is `--chunk-size`.\n let values;\n try {\n ({ values } = parseArgs({\n args: argv,\n options: {\n config: { type: \"string\", short: \"c\" },\n port: { type: \"string\", short: \"p\" },\n host: { type: \"string\" },\n help: { type: \"boolean\", short: \"h\", default: false },\n },\n strict: true,\n }));\n } catch (err) {\n /* v8 ignore next -- parseArgs always throws Error subclasses */\n const msg = err instanceof Error ? err.message : String(err);\n logError(`Error: ${msg}\\n\\n${HELP}`);\n exit(1);\n return;\n }\n\n if (values.help) {\n log(HELP);\n exit(0);\n return;\n }\n if (values.config === undefined) {\n logError(\"Error: --config is required.\\n\\n\" + HELP);\n exit(1);\n return;\n }\n // A value-taking option that was GIVEN an empty (or blank) value is a usage\n // error, not an absent option. Testing these for truthiness instead let\n // `--config \"\"` read as \"not given\", and let `--port \"\"` / `--host \"\"` be\n // dropped in silence — `--host \"\"` in particular reached the server as an\n // empty bind address, which listens on every interface rather than on the\n // documented 127.0.0.1 default.\n const blank = (\n [\n [\"config\", values.config],\n [\"port\", values.port],\n [\"host\", values.host],\n ] as const\n ).find(([, value]) => value !== undefined && value.trim() === \"\");\n if (blank !== undefined) {\n logError(`Error: --${blank[0]} requires a non-empty value.\\n\\n${HELP}`);\n exit(1);\n return;\n }\n\n const configPath = resolve(values.config);\n let config;\n try {\n config = loadConfigFn(configPath);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logError(`Failed to load config from ${configPath}: ${msg}`);\n exit(1);\n return;\n }\n\n const port = values.port === undefined ? undefined : Number(values.port);\n if (\n port !== undefined &&\n (Number.isNaN(port) || !Number.isInteger(port) || port < 0 || port > 65535)\n ) {\n logError(`Error: invalid port \"${values.port}\".\\n\\n${HELP}`);\n exit(1);\n return;\n }\n const host = values.host;\n\n async function main() {\n const { llmock, url } = await startFromConfigFn(config!, { port, host });\n\n function shutdown() {\n log(\"Shutting down...\");\n process.removeListener(\"SIGINT\", shutdown);\n process.removeListener(\"SIGTERM\", shutdown);\n llmock.stop().then(\n () => exit(0),\n (err) => {\n logError(`Shutdown error: ${err instanceof Error ? err.message : String(err)}`);\n exit(1);\n },\n );\n }\n // Register BEFORE announcing readiness — see the note in src/cli.ts. A supervisor\n // that reacts to the readiness line must never win a race against this listener.\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n log(`aimock server listening on ${url}`);\n\n if (deps.onReady) {\n deps.onReady({ shutdown });\n }\n }\n\n main().catch((err) => {\n logError(err instanceof Error ? err.message : String(err));\n exit(1);\n });\n}\n\n// Run when executed as a script (not when imported for testing).\n/* v8 ignore start -- entry-point guard, exercised by integration tests */\n// The basenames this module is ever argv[1] under: the `aimock` bin (the\n// package.json \"bin\" name), both build outputs — tsdown.config.ts builds\n// src/aimock-cli.ts in \"esm\" AND \"cjs\" format, which under `\"type\": \"module\"`\n// emits dist/aimock-cli.js and dist/aimock-cli.cjs — and the TypeScript\n// source, run through tsx. Omitting the .cjs made `node dist/aimock-cli.cjs`\n// print nothing and exit 0 despite its shebang and exec bit.\nconst ENTRY_BASENAMES = new Set([\"aimock\", \"aimock-cli.js\", \"aimock-cli.cjs\", \"aimock-cli.ts\"]);\nconst scriptName = process.argv[1] ?? \"\";\nif (ENTRY_BASENAMES.has(basename(scriptName))) {\n runAimockCli();\n}\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;AAOA,MAAM,OAAO;;;;;;;;;;;;;;;;EAgBX,MAAM;AAkBR,SAAgB,aAAa,OAAsB,EAAE,EAAQ;;CAE3D,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK,MAAM,EAAE;CAC/C,MAAM,MAAM,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ;CACjD,MAAM,WAAW,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ;CAC7D,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK,KAAK,QAAQ;CACpD,MAAM,eAAe,KAAK,gBAAgB;CAC1C,MAAM,oBAAoB,KAAK,qBAAqB;AAGpD,KAAI,KAAK,OAAO,WAAW;AACzB,gBAAc;GACZ,MAAM,KAAK,MAAM,EAAE;GACnB;GACA;GACA;GACA,GAAG,KAAK;GACT,CAAC;AACF;;AAIF,KAAI,KAAK,OAAO,YAAY;AAC1B,iBAAe;GACb,MAAM,KAAK,MAAM,EAAE;GACnB,KAAK,KAAK,cAAc,OAAO;GAC/B,UAAU,KAAK,cAAc,YAAY;GACzC,MAAM,KAAK,cAAc,QAAQ;GAClC,CAAC;AACF;;CAWF,IAAI;AACJ,KAAI;AACF,GAAC,CAAE,UAAW,UAAU;GACtB,MAAM;GACN,SAAS;IAC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B,QAAS;GAAE;GAAM;GAAM,CAAC;EAExE,SAAS,WAAW;AAClB,OAAI,mBAAmB;AACvB,WAAQ,eAAe,UAAU,SAAS;AAC1C,WAAQ,eAAe,WAAW,SAAS;AAC3C,UAAO,MAAM,CAAC,WACN,KAAK,EAAE,GACZ,QAAQ;AACP,aAAS,mBAAmB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAAG;AAC/E,SAAK,EAAE;KAEV;;AAIH,UAAQ,GAAG,UAAU,SAAS;AAC9B,UAAQ,GAAG,WAAW,SAAS;AAE/B,MAAI,8BAA8B,MAAM;AAExC,MAAI,KAAK,QACP,MAAK,QAAQ,EAAE,UAAU,CAAC;;AAI9B,OAAM,CAAC,OAAO,QAAQ;AACpB,WAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC;AAC1D,OAAK,EAAE;GACP;;;AAWJ,MAAM,kBAAkB,IAAI,IAAI;CAAC;CAAU;CAAiB;CAAkB;CAAgB,CAAC;AAC/F,MAAM,aAAa,QAAQ,KAAK,MAAM;AACtC,IAAI,gBAAgB,IAAI,SAAS,WAAW,CAAC,CAC3C,eAAc"}
|
|
1
|
+
{"version":3,"file":"aimock-cli.js","names":[],"sources":["../src/aimock-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { resolve, basename } from \"node:path\";\nimport { loadConfig, startFromConfig, type StartFromConfigOverrides } from \"./config-loader.js\";\nimport { runConvertCli, type ConvertCliDeps } from \"./convert.js\";\nimport { runValidateCli } from \"./validate-cli.js\";\n\nconst HELP = `\nUsage: aimock [options]\n aimock convert <format> <input> [output]\n aimock validate [--strict] [--json] [--] <path> [more paths ...]\n\nOptions:\n -c, --config <path> Path to aimock config JSON file (required)\n -p, --port <number> Port override (default: from config or 0)\n --host <string> Host override (default: from config or 127.0.0.1)\n --misbehavior Enable model misbehavior (same as llm.enableMisbehavior: true)\n --strict-tool-arguments Reject fixture tool calls with invalid JSON arguments\n instead of serving {} (same as llm.strictToolArguments: true)\n --responses-tools <mode> OpenAI Responses tool handling: legacy (default) or\n extended (overrides llm.responsesTools)\n -h, --help Show this help message\n\nSubcommands:\n convert Convert third-party mock configs to aimock format\n Run \"aimock convert --help\" for details\n validate Validate fixture files or directories offline\n Run \"aimock validate --help\" for details\n`.trim();\n\nexport interface AimockCliDeps {\n argv?: string[];\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n loadConfigFn?: typeof loadConfig;\n startFromConfigFn?: typeof startFromConfig;\n onReady?: (ctx: { shutdown: () => void }) => void;\n convertDeps?: Partial<ConvertCliDeps>;\n validateDeps?: {\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n };\n}\n\nexport function runAimockCli(deps: AimockCliDeps = {}): void {\n /* v8 ignore next 6 -- defaults used only when called from CLI entry point */\n const argv = deps.argv ?? process.argv.slice(2);\n const log = deps.log ?? console.log.bind(console);\n const logError = deps.logError ?? console.error.bind(console);\n const exit = deps.exit ?? process.exit.bind(process);\n const loadConfigFn = deps.loadConfigFn ?? loadConfig;\n const startFromConfigFn = deps.startFromConfigFn ?? startFromConfig;\n\n // Intercept \"convert\" subcommand before parseArgs (which uses strict mode)\n if (argv[0] === \"convert\") {\n runConvertCli({\n argv: argv.slice(1),\n log,\n logError,\n exit,\n ...deps.convertDeps,\n });\n return;\n }\n\n // Intercept \"validate\" the same way — it takes file paths, not --config.\n if (argv[0] === \"validate\") {\n runValidateCli({\n argv: argv.slice(1),\n log: deps.validateDeps?.log ?? log,\n logError: deps.validateDeps?.logError ?? logError,\n exit: deps.validateDeps?.exit ?? exit,\n });\n return;\n }\n\n // Short-flag rule for the `aimock` bin: a short flag means the same thing at\n // the top level and in every subcommand. `-h` is `--help` everywhere, which\n // is what `convert` (src/convert.ts) and `validate` (src/validate-cli.ts)\n // already did and what a reader typing `aimock -h` expects; the host\n // override is long-form `--host` only, and had no documented short use.\n // Short flags are per-bin: the separate `llmock` bin (src/cli.ts, the\n // Docker ENTRYPOINT) keeps its own documented set, where `-h` is `--host`\n // and `-c` is `--chunk-size`.\n let values;\n try {\n ({ values } = parseArgs({\n args: argv,\n options: {\n config: { type: \"string\", short: \"c\" },\n port: { type: \"string\", short: \"p\" },\n host: { type: \"string\" },\n misbehavior: { type: \"boolean\", default: false },\n \"strict-tool-arguments\": { type: \"boolean\", default: false },\n \"responses-tools\": { type: \"string\" },\n help: { type: \"boolean\", short: \"h\", default: false },\n },\n strict: true,\n }));\n } catch (err) {\n /* v8 ignore next -- parseArgs always throws Error subclasses */\n const msg = err instanceof Error ? err.message : String(err);\n logError(`Error: ${msg}\\n\\n${HELP}`);\n exit(1);\n return;\n }\n\n if (values.help) {\n log(HELP);\n exit(0);\n return;\n }\n if (values.config === undefined) {\n logError(\"Error: --config is required.\\n\\n\" + HELP);\n exit(1);\n return;\n }\n // A value-taking option that was GIVEN an empty (or blank) value is a usage\n // error, not an absent option. Testing these for truthiness instead let\n // `--config \"\"` read as \"not given\", and let `--port \"\"` / `--host \"\"` be\n // dropped in silence — `--host \"\"` in particular reached the server as an\n // empty bind address, which listens on every interface rather than on the\n // documented 127.0.0.1 default.\n const blank = (\n [\n [\"config\", values.config],\n [\"port\", values.port],\n [\"host\", values.host],\n [\"responses-tools\", values[\"responses-tools\"]],\n ] as const\n ).find(([, value]) => value !== undefined && value.trim() === \"\");\n if (blank !== undefined) {\n logError(`Error: --${blank[0]} requires a non-empty value.\\n\\n${HELP}`);\n exit(1);\n return;\n }\n\n const configPath = resolve(values.config);\n let config;\n try {\n config = loadConfigFn(configPath);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logError(`Failed to load config from ${configPath}: ${msg}`);\n exit(1);\n return;\n }\n\n const port = values.port === undefined ? undefined : Number(values.port);\n if (\n port !== undefined &&\n (Number.isNaN(port) || !Number.isInteger(port) || port < 0 || port > 65535)\n ) {\n logError(`Error: invalid port \"${values.port}\".\\n\\n${HELP}`);\n exit(1);\n return;\n }\n const host = values.host;\n const responsesToolsFlag = values[\"responses-tools\"];\n if (\n responsesToolsFlag !== undefined &&\n responsesToolsFlag !== \"legacy\" &&\n responsesToolsFlag !== \"extended\"\n ) {\n logError(\n `Error: invalid --responses-tools \"${responsesToolsFlag}\" (expected \"legacy\" or \"extended\").\\n\\n${HELP}`,\n );\n exit(1);\n return;\n }\n // The boolean opt-ins override the config only when given, so an absent flag\n // leaves llm.enableMisbehavior / llm.strictToolArguments in charge.\n const responsesTools: StartFromConfigOverrides[\"responsesTools\"] = responsesToolsFlag;\n const overrides: StartFromConfigOverrides = {\n port,\n host,\n ...(values.misbehavior ? { enableMisbehavior: true } : {}),\n ...(values[\"strict-tool-arguments\"] ? { strictToolArguments: true } : {}),\n ...(responsesTools !== undefined ? { responsesTools } : {}),\n };\n\n async function main() {\n const { llmock, url } = await startFromConfigFn(config!, overrides);\n\n function shutdown() {\n log(\"Shutting down...\");\n process.removeListener(\"SIGINT\", shutdown);\n process.removeListener(\"SIGTERM\", shutdown);\n llmock.stop().then(\n () => exit(0),\n (err) => {\n logError(`Shutdown error: ${err instanceof Error ? err.message : String(err)}`);\n exit(1);\n },\n );\n }\n // Register BEFORE announcing readiness — see the note in src/cli.ts. A supervisor\n // that reacts to the readiness line must never win a race against this listener.\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n log(`aimock server listening on ${url}`);\n\n if (deps.onReady) {\n deps.onReady({ shutdown });\n }\n }\n\n main().catch((err) => {\n logError(err instanceof Error ? err.message : String(err));\n exit(1);\n });\n}\n\n// Run when executed as a script (not when imported for testing).\n/* v8 ignore start -- entry-point guard, exercised by integration tests */\n// The basenames this module is ever argv[1] under: the `aimock` bin (the\n// package.json \"bin\" name), both build outputs — tsdown.config.ts builds\n// src/aimock-cli.ts in \"esm\" AND \"cjs\" format, which under `\"type\": \"module\"`\n// emits dist/aimock-cli.js and dist/aimock-cli.cjs — and the TypeScript\n// source, run through tsx. Omitting the .cjs made `node dist/aimock-cli.cjs`\n// print nothing and exit 0 despite its shebang and exec bit.\nconst ENTRY_BASENAMES = new Set([\"aimock\", \"aimock-cli.js\", \"aimock-cli.cjs\", \"aimock-cli.ts\"]);\nconst scriptName = process.argv[1] ?? \"\";\nif (ENTRY_BASENAMES.has(basename(scriptName))) {\n runAimockCli();\n}\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;AAOA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;EAqBX,MAAM;AAkBR,SAAgB,aAAa,OAAsB,EAAE,EAAQ;;CAE3D,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK,MAAM,EAAE;CAC/C,MAAM,MAAM,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ;CACjD,MAAM,WAAW,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ;CAC7D,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK,KAAK,QAAQ;CACpD,MAAM,eAAe,KAAK,gBAAgB;CAC1C,MAAM,oBAAoB,KAAK,qBAAqB;AAGpD,KAAI,KAAK,OAAO,WAAW;AACzB,gBAAc;GACZ,MAAM,KAAK,MAAM,EAAE;GACnB;GACA;GACA;GACA,GAAG,KAAK;GACT,CAAC;AACF;;AAIF,KAAI,KAAK,OAAO,YAAY;AAC1B,iBAAe;GACb,MAAM,KAAK,MAAM,EAAE;GACnB,KAAK,KAAK,cAAc,OAAO;GAC/B,UAAU,KAAK,cAAc,YAAY;GACzC,MAAM,KAAK,cAAc,QAAQ;GAClC,CAAC;AACF;;CAWF,IAAI;AACJ,KAAI;AACF,GAAC,CAAE,UAAW,UAAU;GACtB,MAAM;GACN,SAAS;IACP,QAAQ;KAAE,MAAM;KAAU,OAAO;KAAK;IACtC,MAAM;KAAE,MAAM;KAAU,OAAO;KAAK;IACpC,MAAM,EAAE,MAAM,UAAU;IACxB,aAAa;KAAE,MAAM;KAAW,SAAS;KAAO;IAChD,yBAAyB;KAAE,MAAM;KAAW,SAAS;KAAO;IAC5D,mBAAmB,EA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