@nhtio/adk 0.1.0-master-74266e68 → 0.1.0-master-642a4223
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/CHANGELOG.md +43 -0
- package/batteries/artifacts/ecmascript.cjs +1 -1
- package/batteries/artifacts/ecmascript.mjs +1 -1
- package/batteries/artifacts/toon.cjs +1 -1
- package/batteries/artifacts/toon.mjs +1 -1
- package/batteries/artifacts/xml.cjs +1 -1
- package/batteries/artifacts/xml.mjs +1 -1
- package/batteries/artifacts/yaml.cjs +1 -1
- package/batteries/artifacts/yaml.mjs +1 -1
- package/batteries/artifacts.cjs +4 -4
- package/batteries/artifacts.mjs +4 -4
- package/batteries/llm/gemini_generate_content/adapter.cjs +1 -1
- package/batteries/llm/gemini_generate_content/adapter.mjs +1 -1
- package/batteries/llm/gemini_generate_content.cjs +1 -1
- package/batteries/llm/gemini_generate_content.mjs +1 -1
- package/batteries/media/lint.cjs +35 -25
- package/batteries/media/lint.cjs.map +1 -1
- package/batteries/media/lint.mjs +35 -25
- package/batteries/media/lint.mjs.map +1 -1
- package/batteries/orchestration.cjs +1 -1
- package/batteries/orchestration.mjs +1 -1
- package/batteries/sandbox/lint.cjs +272 -0
- package/batteries/sandbox/lint.cjs.map +1 -0
- package/batteries/sandbox/lint.d.ts +103 -0
- package/batteries/sandbox/lint.mjs +266 -0
- package/batteries/sandbox/lint.mjs.map +1 -0
- package/batteries/skills/lint.cjs +236 -0
- package/batteries/skills/lint.cjs.map +1 -0
- package/batteries/skills/lint.d.ts +99 -0
- package/batteries/skills/lint.mjs +229 -0
- package/batteries/skills/lint.mjs.map +1 -0
- package/batteries/skills.cjs +1 -1
- package/batteries/skills.mjs +1 -1
- package/batteries/tools/scrapper.cjs +1 -1
- package/batteries/tools/scrapper.mjs +1 -1
- package/batteries/tools/searxng.cjs +1 -1
- package/batteries/tools/searxng.mjs +1 -1
- package/batteries/tools.cjs +2 -2
- package/batteries/tools.mjs +2 -2
- package/batteries/vector/pinecone/index.d.ts +53 -1
- package/batteries/vector/pinecone.cjs +196 -25
- package/batteries/vector/pinecone.cjs.map +1 -1
- package/batteries/vector/pinecone.mjs +197 -26
- package/batteries/vector/pinecone.mjs.map +1 -1
- package/batteries.cjs +2 -2
- package/batteries.mjs +2 -2
- package/common-4_EYYb5H.mjs +245 -0
- package/common-4_EYYb5H.mjs.map +1 -0
- package/common-CKbae_Ra.cjs +291 -0
- package/common-CKbae_Ra.cjs.map +1 -0
- package/{ecmascript-ChvxTCXz.cjs → ecmascript-BDOWq4ka.cjs} +2 -2
- package/{ecmascript-ChvxTCXz.cjs.map → ecmascript-BDOWq4ka.cjs.map} +1 -1
- package/{ecmascript-bgwVyZG1.mjs → ecmascript-D1fxLTEc.mjs} +2 -2
- package/{ecmascript-bgwVyZG1.mjs.map → ecmascript-D1fxLTEc.mjs.map} +1 -1
- package/eslint/index.d.ts +16 -0
- package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs +1 -1
- package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs +1 -1
- package/eslint/rules/common.d.ts +76 -0
- package/eslint/rules/create_exception_args_array.cjs +285 -0
- package/eslint/rules/create_exception_args_array.cjs.map +1 -0
- package/eslint/rules/create_exception_args_array.d.ts +47 -0
- package/eslint/rules/create_exception_args_array.mjs +281 -0
- package/eslint/rules/create_exception_args_array.mjs.map +1 -0
- package/eslint/rules/index.d.ts +16 -0
- package/eslint/rules/no_model_in_tool_handler.cjs +1 -1
- package/eslint/rules/no_model_in_tool_handler.mjs +1 -1
- package/eslint/rules/require_string_empty_disposition.cjs +1 -1
- package/eslint/rules/require_string_empty_disposition.mjs +1 -1
- package/eslint/rules/require_validator_any_required.cjs +1 -1
- package/eslint/rules/require_validator_any_required.mjs +1 -1
- package/eslint/rules/thought_payload_requires_replay_tag.cjs +1 -1
- package/eslint/rules/thought_payload_requires_replay_tag.mjs +1 -1
- package/eslint/rules/token_encoding_requires_context_window.cjs +1 -1
- package/eslint/rules/token_encoding_requires_context_window.mjs +1 -1
- package/eslint/rules/tool_name_provider_safe.cjs +93 -0
- package/eslint/rules/tool_name_provider_safe.cjs.map +1 -0
- package/eslint/rules/tool_name_provider_safe.d.ts +34 -0
- package/eslint/rules/tool_name_provider_safe.mjs +89 -0
- package/eslint/rules/tool_name_provider_safe.mjs.map +1 -0
- package/eslint/rules.cjs +7 -0
- package/eslint/rules.mjs +4 -1
- package/eslint.cjs +6 -2
- package/eslint.cjs.map +1 -1
- package/eslint.mjs +6 -2
- package/eslint.mjs.map +1 -1
- package/index.cjs +2 -2
- package/index.mjs +2 -2
- package/mcp/adk-docs-corpus.json +2 -2
- package/package.json +440 -420
- package/{scrapper-Boc6kq2v.cjs → scrapper-B6QvqNDb.cjs} +2 -2
- package/{scrapper-Boc6kq2v.cjs.map → scrapper-B6QvqNDb.cjs.map} +1 -1
- package/{scrapper-D2Gy9Jhv.mjs → scrapper-Bc7Hvj7l.mjs} +2 -2
- package/{scrapper-D2Gy9Jhv.mjs.map → scrapper-Bc7Hvj7l.mjs.map} +1 -1
- package/{searxng-DOy3eBDH.cjs → searxng-0NlNYaF-.cjs} +2 -2
- package/{searxng-DOy3eBDH.cjs.map → searxng-0NlNYaF-.cjs.map} +1 -1
- package/{searxng-cCb0lAcN.mjs → searxng-CrkaC5XW.mjs} +2 -2
- package/{searxng-cCb0lAcN.mjs.map → searxng-CrkaC5XW.mjs.map} +1 -1
- package/server.json +2 -2
- package/skills/adk-assembly/SKILL.md +2 -2
- package/{toon-BA9Q7NHG.mjs → toon-CMCyUK58.mjs} +2 -2
- package/{toon-BA9Q7NHG.mjs.map → toon-CMCyUK58.mjs.map} +1 -1
- package/{toon-C8IFssRi.cjs → toon-Dj6yuul2.cjs} +2 -2
- package/{toon-C8IFssRi.cjs.map → toon-Dj6yuul2.cjs.map} +1 -1
- package/{xml-B1JIGLpU.mjs → xml-BL9pwTUC.mjs} +2 -2
- package/{xml-B1JIGLpU.mjs.map → xml-BL9pwTUC.mjs.map} +1 -1
- package/{xml-Cu7ZvgBQ.cjs → xml-CgpPMbHL.cjs} +2 -2
- package/{xml-Cu7ZvgBQ.cjs.map → xml-CgpPMbHL.cjs.map} +1 -1
- package/{yaml-BlB29N68.cjs → yaml-C4JparX8.cjs} +2 -2
- package/{yaml-BlB29N68.cjs.map → yaml-C4JparX8.cjs.map} +1 -1
- package/{yaml-1mP4uxdf.mjs → yaml-DeMZW6va.mjs} +2 -2
- package/{yaml-1mP4uxdf.mjs.map → yaml-DeMZW6va.mjs.map} +1 -1
- package/common-BuVhq_3h.cjs +0 -147
- package/common-BuVhq_3h.cjs.map +0 -1
- package/common-CQVJccPS.mjs +0 -119
- package/common-CQVJccPS.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,10 +19,53 @@ upgrading.
|
|
|
19
19
|
|
|
20
20
|
### Fixed
|
|
21
21
|
|
|
22
|
+
- **`PineconeVectorStore.dropCollection` now deletes the namespace itself** (closes issue #51), reclaiming the namespace slot instead of leaving an empty namespace behind. The namespace deletion is conditional on the index being serverless — pod-based indexes keep the previous vectors-only drop, because `deleteNamespace` is unsupported there — and a strong-consistency settle timeout on serverless can no longer skip the reclaim, since the namespace is deleted before the settle. Namespace-absence is tolerated only for structured 404-style signals, so unrelated errors surface instead of being swallowed.
|
|
23
|
+
|
|
24
|
+
- **`@nhtio/adk/batteries/media/engines/execa_executor` — oversized escalation delays no longer busy-loop.** Deadline timers are capped at Node's maximum timer delay and re-armed against the monotonic deadline; `forceKillAfterDelay: Infinity` disables escalation.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
22
30
|
- **`@nhtio/adk/batteries/media/engines/execa_executor` — oversized escalation delays no longer busy-loop.** Deadline timers are capped at Node's maximum timer delay and re-armed against the monotonic deadline; `forceKillAfterDelay: Infinity` disables escalation.
|
|
23
31
|
|
|
24
32
|
### Added
|
|
25
33
|
|
|
34
|
+
- **Footgun lint rules and build guards (closes issue #29).** Eight new report-only ESLint rules plus
|
|
35
|
+
three internal build guards, covering the mistakes that compile cleanly and then fail at the wire,
|
|
36
|
+
at construction time, or silently at runtime:
|
|
37
|
+
- **Core plugin** (`@nhtio/adk/eslint`, namespace `adk`, `error` in `recommended`):
|
|
38
|
+
`adk/tool-name-provider-safe` (a string-literal `Tool` name outside
|
|
39
|
+
`/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/` — providers reject it at the wire, e.g. Gemini rejects a
|
|
40
|
+
leading digit or `-`; matched on this package's `Tool`, aliased or namespace-imported, never on
|
|
41
|
+
another library's identically-named class) and `adk/create-exception-args-array`
|
|
42
|
+
(`new E_X(<non-array>)` where `E_X` is a `const`/`let` `createException<[non-empty tuple]>` — in
|
|
43
|
+
the same file, through any spelling of the factory, or — under type-aware linting — an IMPORTED
|
|
44
|
+
exception class resolved by its constructor's args-tuple shape; the value is silently read as
|
|
45
|
+
`ExceptionOptions`, the payload is dropped and the message prints a literal `%s`).
|
|
46
|
+
- **New `@nhtio/adk/batteries/sandbox/lint`** (namespace `adk-sandbox`):
|
|
47
|
+
`no-network-disabled` (`warn` — `network: { disabled: true }` omits SRT's network
|
|
48
|
+
configuration, which means UNRESTRICTED network, not network-off; deny-all is `network: {}`),
|
|
49
|
+
`filesystem-read-default-allow` (`warn` — reads are deny-then-allow, so an `allowRead` list with
|
|
50
|
+
no broad `denyRead: ['/']` before it re-permits nothing and the whole host stays readable; a
|
|
51
|
+
`denyRead`-only policy is deliberately not reported) and `require-gate` (`error` —
|
|
52
|
+
`createRunShellCommandTool` / `createEvaluateJavascriptTool` throw
|
|
53
|
+
`E_SANDBOX_GATE_REQUIRED` at construction without a gate).
|
|
54
|
+
- **New `@nhtio/adk/batteries/skills/lint`** (namespace `adk-skills`): `require-gate` (`error` —
|
|
55
|
+
`createSkillManager` throws `E_INVALID_SKILLS_CONFIG` without one) and `no-unsafe-opt-in`
|
|
56
|
+
(`warn` — one finding per enabled `unsafe` control, naming the boundary it removes:
|
|
57
|
+
`isolatedToolsInProcess`, `scriptsPermissivePolicy`, `ungatedSkillTools`).
|
|
58
|
+
- **Build guards** (`tests/unit/build/*.node.spec.ts`): battery-module reachability (every
|
|
59
|
+
`src/batteries/**/*.ts` file must be `@module`-tagged or transitively imported by a tagged file;
|
|
60
|
+
the six current orphans — the standalone claude-code wrapper cluster and a deprecated
|
|
61
|
+
media/patch re-export shim — are an explicit commented allow-list, so any NEW orphan fails) and
|
|
62
|
+
the `@module` leaf-basename collision invariant (the 17 pre-existing duplicate leaves are
|
|
63
|
+
harmless under the tree-mirrored `dtsComplex` emit, so the guard instead asserts that no two
|
|
64
|
+
entries compute the same `types` output path, that the mirrored layout itself is still in place,
|
|
65
|
+
and that `getEntries` still rejects duplicate keys).
|
|
66
|
+
All rules are report-only (no autofix), conservative about spreads, non-literal arguments and
|
|
67
|
+
dynamic values, and documented in `docs/developer-tools/eslint-rules` (split into per-battery
|
|
68
|
+
sub-pages).
|
|
26
69
|
- **`@nhtio/adk/batteries/sandbox/node` — `srtBinarySandbox(enforcer, opts?)`, the concrete
|
|
27
70
|
`BinarySandbox` implementor for the SRT enforcer** (closes issue #37, closes issue #20). The sandbox
|
|
28
71
|
battery could refuse and narrate invocations, but there was no bundled way to actually wrap a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ecmascript = require("../../ecmascript-
|
|
2
|
+
const require_ecmascript = require("../../ecmascript-BDOWq4ka.cjs");
|
|
3
3
|
exports.E_TYPESCRIPT_PEER_MISSING = require_ecmascript.E_TYPESCRIPT_PEER_MISSING;
|
|
4
4
|
exports.SpooledEcmaScriptArtifact = require_ecmascript.SpooledEcmaScriptArtifact;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as E_TYPESCRIPT_PEER_MISSING, t as SpooledEcmaScriptArtifact } from "../../ecmascript-
|
|
1
|
+
import { n as E_TYPESCRIPT_PEER_MISSING, t as SpooledEcmaScriptArtifact } from "../../ecmascript-D1fxLTEc.mjs";
|
|
2
2
|
export { E_TYPESCRIPT_PEER_MISSING, SpooledEcmaScriptArtifact };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_toon = require("../../toon-
|
|
2
|
+
const require_toon = require("../../toon-Dj6yuul2.cjs");
|
|
3
3
|
exports.E_TOON_DECODE_FAILED = require_toon.E_TOON_DECODE_FAILED;
|
|
4
4
|
exports.E_TOON_PEER_MISSING = require_toon.E_TOON_PEER_MISSING;
|
|
5
5
|
exports.SpooledToonArtifact = require_toon.SpooledToonArtifact;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as E_TOON_PEER_MISSING, i as E_TOON_DECODE_FAILED, n as jsonToToonTool, r as toonToJsonTool, t as SpooledToonArtifact } from "../../toon-
|
|
1
|
+
import { a as E_TOON_PEER_MISSING, i as E_TOON_DECODE_FAILED, n as jsonToToonTool, r as toonToJsonTool, t as SpooledToonArtifact } from "../../toon-CMCyUK58.mjs";
|
|
2
2
|
export { E_TOON_DECODE_FAILED, E_TOON_PEER_MISSING, SpooledToonArtifact, jsonToToonTool, toonToJsonTool };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_xml = require("../../xml-
|
|
2
|
+
const require_xml = require("../../xml-CgpPMbHL.cjs");
|
|
3
3
|
exports.E_XML_PARSER_PEER_MISSING = require_xml.E_XML_PARSER_PEER_MISSING;
|
|
4
4
|
exports.E_XML_PARSE_FAILED = require_xml.E_XML_PARSE_FAILED;
|
|
5
5
|
exports.SpooledXmlArtifact = require_xml.SpooledXmlArtifact;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as E_XML_PARSE_FAILED, i as E_XML_PARSER_PEER_MISSING, n as jsonToXmlTool, r as xmlToJsonTool, t as SpooledXmlArtifact } from "../../xml-
|
|
1
|
+
import { a as E_XML_PARSE_FAILED, i as E_XML_PARSER_PEER_MISSING, n as jsonToXmlTool, r as xmlToJsonTool, t as SpooledXmlArtifact } from "../../xml-BL9pwTUC.mjs";
|
|
2
2
|
export { E_XML_PARSER_PEER_MISSING, E_XML_PARSE_FAILED, SpooledXmlArtifact, jsonToXmlTool, xmlToJsonTool };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_yaml = require("../../yaml-
|
|
2
|
+
const require_yaml = require("../../yaml-C4JparX8.cjs");
|
|
3
3
|
exports.E_YAML_PARSE_ERROR = require_yaml.E_YAML_PARSE_ERROR;
|
|
4
4
|
exports.E_YAML_PEER_MISSING = require_yaml.E_YAML_PEER_MISSING;
|
|
5
5
|
exports.SpooledYamlArtifact = require_yaml.SpooledYamlArtifact;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as E_YAML_PEER_MISSING, i as E_YAML_PARSE_ERROR, n as jsonToYamlTool, r as yamlToJsonTool, t as SpooledYamlArtifact } from "../../yaml-
|
|
1
|
+
import { a as E_YAML_PEER_MISSING, i as E_YAML_PARSE_ERROR, n as jsonToYamlTool, r as yamlToJsonTool, t as SpooledYamlArtifact } from "../../yaml-DeMZW6va.mjs";
|
|
2
2
|
export { E_YAML_PARSE_ERROR, E_YAML_PEER_MISSING, SpooledYamlArtifact, jsonToYamlTool, yamlToJsonTool };
|
package/batteries/artifacts.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_toon = require("../toon-
|
|
3
|
-
const require_yaml = require("../yaml-
|
|
4
|
-
const require_xml = require("../xml-
|
|
5
|
-
const require_ecmascript = require("../ecmascript-
|
|
2
|
+
const require_toon = require("../toon-Dj6yuul2.cjs");
|
|
3
|
+
const require_yaml = require("../yaml-C4JparX8.cjs");
|
|
4
|
+
const require_xml = require("../xml-CgpPMbHL.cjs");
|
|
5
|
+
const require_ecmascript = require("../ecmascript-BDOWq4ka.cjs");
|
|
6
6
|
//#region src/batteries/artifacts/index.ts
|
|
7
7
|
/**
|
|
8
8
|
* Registers the four artifact classes with the '@nhtio/encoder' decoder.
|
package/batteries/artifacts.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as E_TOON_PEER_MISSING, i as E_TOON_DECODE_FAILED, n as jsonToToonTool, r as toonToJsonTool, t as SpooledToonArtifact } from "../toon-
|
|
2
|
-
import { a as E_YAML_PEER_MISSING, i as E_YAML_PARSE_ERROR, n as jsonToYamlTool, r as yamlToJsonTool, t as SpooledYamlArtifact } from "../yaml-
|
|
3
|
-
import { a as E_XML_PARSE_FAILED, i as E_XML_PARSER_PEER_MISSING, n as jsonToXmlTool, r as xmlToJsonTool, t as SpooledXmlArtifact } from "../xml-
|
|
4
|
-
import { n as E_TYPESCRIPT_PEER_MISSING, t as SpooledEcmaScriptArtifact } from "../ecmascript-
|
|
1
|
+
import { a as E_TOON_PEER_MISSING, i as E_TOON_DECODE_FAILED, n as jsonToToonTool, r as toonToJsonTool, t as SpooledToonArtifact } from "../toon-CMCyUK58.mjs";
|
|
2
|
+
import { a as E_YAML_PEER_MISSING, i as E_YAML_PARSE_ERROR, n as jsonToYamlTool, r as yamlToJsonTool, t as SpooledYamlArtifact } from "../yaml-DeMZW6va.mjs";
|
|
3
|
+
import { a as E_XML_PARSE_FAILED, i as E_XML_PARSER_PEER_MISSING, n as jsonToXmlTool, r as xmlToJsonTool, t as SpooledXmlArtifact } from "../xml-BL9pwTUC.mjs";
|
|
4
|
+
import { n as E_TYPESCRIPT_PEER_MISSING, t as SpooledEcmaScriptArtifact } from "../ecmascript-D1fxLTEc.mjs";
|
|
5
5
|
//#region src/batteries/artifacts/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* Registers the four artifact classes with the '@nhtio/encoder' decoder.
|
|
@@ -10,8 +10,8 @@ const require_lib_utils_retry = require("../../../lib/utils/retry.cjs");
|
|
|
10
10
|
const require_tool_parsers = require("../../../tool_parsers-8_qO0a_F.cjs");
|
|
11
11
|
const require_helpers = require("../../../helpers-D6ebO8Vc.cjs");
|
|
12
12
|
const require_batteries_llm_gemini_generate_content_exceptions = require("./exceptions.cjs");
|
|
13
|
-
const require_batteries_llm_gemini_generate_content_validation = require("./validation.cjs");
|
|
14
13
|
const require_batteries_llm_gemini_generate_content_helpers = require("./helpers.cjs");
|
|
14
|
+
const require_batteries_llm_gemini_generate_content_validation = require("./validation.cjs");
|
|
15
15
|
let luxon = require("luxon");
|
|
16
16
|
let js_sha256 = require("js-sha256");
|
|
17
17
|
let uuid = require("uuid");
|
|
@@ -9,8 +9,8 @@ import { computeBackoff, linkAbortSignals, parseRetryAfter, sleepWithJitter } fr
|
|
|
9
9
|
import { O as resolveToolCallParser } from "../../../tool_parsers-DgZhgxV8.mjs";
|
|
10
10
|
import { A as renderMemories, E as normalizeToolName, F as renderThirdPartyPrivateRetrievables, I as renderThirdPartyPublicRetrievables, L as renderThought, M as renderRetrievableSafetyDirective, N as renderRetrievables, O as renderChatCompletionsSystemPrompt, P as renderStandingInstructions, R as renderTrustedContent, k as renderFirstPartyRetrievables, x as filterThoughts, y as descriptionToChatCompletionsJsonSchema, z as renderUntrustedContent } from "../../../helpers-C1T0DV8Q.mjs";
|
|
11
11
|
import { E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW, E_GEMINI_INVALID_TOOL_CALL_ARGS, E_GEMINI_MISSING_THOUGHT_SIGNATURE, E_GEMINI_REQUEST_FAILED, E_GEMINI_STREAM_ERROR, E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS } from "./exceptions.mjs";
|
|
12
|
-
import { validateOptions } from "./validation.mjs";
|
|
13
12
|
import { DEFAULT_GEMINI_BUCKET_ORDER, buildGeminiRequest, extractGeminiGeneration, mediaToGeminiInlineData, renderGeminiToolResult, toolsToGeminiTools } from "./helpers.mjs";
|
|
13
|
+
import { validateOptions } from "./validation.mjs";
|
|
14
14
|
import { DateTime } from "luxon";
|
|
15
15
|
import { sha256 } from "js-sha256";
|
|
16
16
|
import { v6 } from "uuid";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_helpers = require("../../helpers-D6ebO8Vc.cjs");
|
|
3
3
|
const require_batteries_llm_gemini_generate_content_exceptions = require("./gemini_generate_content/exceptions.cjs");
|
|
4
|
-
const require_batteries_llm_gemini_generate_content_validation = require("./gemini_generate_content/validation.cjs");
|
|
5
4
|
const require_batteries_llm_gemini_generate_content_helpers = require("./gemini_generate_content/helpers.cjs");
|
|
5
|
+
const require_batteries_llm_gemini_generate_content_validation = require("./gemini_generate_content/validation.cjs");
|
|
6
6
|
const require_batteries_llm_gemini_generate_content_adapter = require("./gemini_generate_content/adapter.cjs");
|
|
7
7
|
exports.DEFAULT_GEMINI_BUCKET_ORDER = require_batteries_llm_gemini_generate_content_helpers.DEFAULT_GEMINI_BUCKET_ORDER;
|
|
8
8
|
exports.E_GEMINI_INVALID_TOOL_CALL_ARGS = require_batteries_llm_gemini_generate_content_exceptions.E_GEMINI_INVALID_TOOL_CALL_ARGS;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as renderMemories, D as renderArtifactHandleBody, F as renderThirdPartyPrivateRetrievables, I as renderThirdPartyPublicRetrievables, L as renderThought, M as renderRetrievableSafetyDirective, N as renderRetrievables, O as renderChatCompletionsSystemPrompt, P as renderStandingInstructions, R as renderTrustedContent, _ as defaultRenderUntrustedContent, a as defaultRenderArtifactHandleBody, c as defaultRenderMemories, d as defaultRenderRetrievables, f as defaultRenderStandingInstructions, g as defaultRenderTrustedContent, h as defaultRenderThought, i as defaultFilterThoughts, j as renderRetrievableHandleBody, k as renderFirstPartyRetrievables, l as defaultRenderRetrievableHandleBody, m as defaultRenderThirdPartyPublicRetrievables, o as defaultRenderChatCompletionsSystemPrompt, p as defaultRenderThirdPartyPrivateRetrievables, r as defaultDescriptionToChatCompletionsJsonSchema, s as defaultRenderFirstPartyRetrievables, u as defaultRenderRetrievableSafetyDirective, x as filterThoughts, y as descriptionToChatCompletionsJsonSchema, z as renderUntrustedContent } from "../../helpers-C1T0DV8Q.mjs";
|
|
2
2
|
import { E_GEMINI_INVALID_TOOL_CALL_ARGS, E_GEMINI_MISSING_THOUGHT_SIGNATURE, E_GEMINI_REQUEST_FAILED, E_GEMINI_STREAM_ERROR, E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS } from "./gemini_generate_content/exceptions.mjs";
|
|
3
|
-
import { geminiGenerateContentOptionsSchema, validateOptions } from "./gemini_generate_content/validation.mjs";
|
|
4
3
|
import { DEFAULT_GEMINI_BUCKET_ORDER, buildGeminiRequest, defaultBuildGeminiRequest, defaultExtractGeminiGeneration, defaultMediaToGeminiInlineData, defaultRenderGeminiToolResult, defaultSanitizeGeminiSchema, defaultToolsToGeminiTools, extractGeminiGeneration, mediaToGeminiInlineData, renderGeminiToolResult, sanitizeGeminiSchema, toolsToGeminiTools } from "./gemini_generate_content/helpers.mjs";
|
|
4
|
+
import { geminiGenerateContentOptionsSchema, validateOptions } from "./gemini_generate_content/validation.mjs";
|
|
5
5
|
import { GeminiGenerateContentAdapter } from "./gemini_generate_content/adapter.mjs";
|
|
6
6
|
export { DEFAULT_GEMINI_BUCKET_ORDER, E_GEMINI_INVALID_TOOL_CALL_ARGS, E_GEMINI_MISSING_THOUGHT_SIGNATURE, E_GEMINI_REQUEST_FAILED, E_GEMINI_STREAM_ERROR, E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS, GeminiGenerateContentAdapter, buildGeminiRequest, defaultBuildGeminiRequest, defaultDescriptionToChatCompletionsJsonSchema, defaultExtractGeminiGeneration, defaultFilterThoughts, defaultMediaToGeminiInlineData, defaultRenderArtifactHandleBody, defaultRenderChatCompletionsSystemPrompt, defaultRenderFirstPartyRetrievables, defaultRenderGeminiToolResult, defaultRenderMemories, defaultRenderRetrievableHandleBody, defaultRenderRetrievableSafetyDirective, defaultRenderRetrievables, defaultRenderStandingInstructions, defaultRenderThirdPartyPrivateRetrievables, defaultRenderThirdPartyPublicRetrievables, defaultRenderThought, defaultRenderTrustedContent, defaultRenderUntrustedContent, defaultSanitizeGeminiSchema, defaultToolsToGeminiTools, descriptionToChatCompletionsJsonSchema, extractGeminiGeneration, filterThoughts, geminiGenerateContentOptionsSchema, mediaToGeminiInlineData, renderArtifactHandleBody, renderChatCompletionsSystemPrompt, renderFirstPartyRetrievables, renderGeminiToolResult, renderMemories, renderRetrievableHandleBody, renderRetrievableSafetyDirective, renderRetrievables, renderStandingInstructions, renderThirdPartyPrivateRetrievables, renderThirdPartyPublicRetrievables, renderThought, renderTrustedContent, renderUntrustedContent, sanitizeGeminiSchema, toolsToGeminiTools, validateOptions };
|
package/batteries/media/lint.cjs
CHANGED
|
@@ -2,6 +2,8 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
+
const require_common = require("../../common-CKbae_Ra.cjs");
|
|
6
|
+
require("../../eslint/rules.cjs");
|
|
5
7
|
let _typescript_eslint_utils = require("@typescript-eslint/utils");
|
|
6
8
|
let node_module = require("node:module");
|
|
7
9
|
//#region src/batteries/media/lint.ts
|
|
@@ -375,33 +377,41 @@ var noShadowedEngine = createRule({
|
|
|
375
377
|
},
|
|
376
378
|
defaultOptions: [],
|
|
377
379
|
create(context) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
380
|
+
let bindings = /* @__PURE__ */ new Map();
|
|
381
|
+
return {
|
|
382
|
+
Program(node) {
|
|
383
|
+
bindings = require_common.collectImportBindings(node);
|
|
384
|
+
},
|
|
385
|
+
CallExpression(node) {
|
|
386
|
+
const resolved = require_common.resolveCalleeName(bindings, node.callee);
|
|
387
|
+
if (!resolved || resolved.name !== "createMediaPipeline") return;
|
|
388
|
+
if (resolved.imported && !resolved.fromAdk) return;
|
|
389
|
+
const config = node.arguments[0];
|
|
390
|
+
if (!config || config.type !== "ObjectExpression") return;
|
|
391
|
+
const engines = propOf(config, "engines");
|
|
392
|
+
if (!engines || engines.type !== "ArrayExpression") return;
|
|
393
|
+
const summaries = engines.elements.map((el) => el ? summarize(el) : void 0);
|
|
394
|
+
for (let i = 1; i < summaries.length; i++) {
|
|
395
|
+
const later = summaries[i];
|
|
396
|
+
if (!later) continue;
|
|
397
|
+
for (let j = 0; j < i; j++) {
|
|
398
|
+
const earlier = summaries[j];
|
|
399
|
+
if (!earlier) continue;
|
|
400
|
+
if (shadows(earlier, later)) {
|
|
401
|
+
context.report({
|
|
402
|
+
node: engines.elements[i],
|
|
403
|
+
messageId: "shadowed",
|
|
404
|
+
data: {
|
|
405
|
+
earlier: earlier.label,
|
|
406
|
+
later: later.label
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
401
411
|
}
|
|
402
412
|
}
|
|
403
413
|
}
|
|
404
|
-
}
|
|
414
|
+
};
|
|
405
415
|
}
|
|
406
416
|
});
|
|
407
417
|
var CONTRACTS_SUBPATH = "@nhtio/adk/batteries/media/contracts";
|
|
@@ -540,7 +550,7 @@ var rules = {
|
|
|
540
550
|
var plugin = {
|
|
541
551
|
meta: {
|
|
542
552
|
name: "@nhtio/adk/batteries/media/lint",
|
|
543
|
-
version: "0.1.0-master-
|
|
553
|
+
version: "0.1.0-master-642a4223"
|
|
544
554
|
},
|
|
545
555
|
rules
|
|
546
556
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.cjs","names":[],"sources":["../../../src/batteries/media/lint.ts"],"sourcesContent":["/**\n * @module @nhtio/adk/batteries/media/lint\n *\n * ESLint rules for consumers of the media pipeline battery: machine-checkable enforcement of\n * the engine-composition contracts implementors are most likely to get wrong.\n *\n * @remarks\n * Battery-scoped rules ship with the battery, not with the core `@nhtio/adk/eslint` plugin —\n * they only matter to deployments that compose this battery, and they version with the\n * battery's own API. The rules are report-only (no autofix); carve out a deliberate exception\n * with an inline `// eslint-disable-next-line adk-media/{rule} -- {reason}` comment.\n *\n * `@typescript-eslint/utils` and `eslint` are OPTIONAL peer dependencies of `@nhtio/adk` —\n * installed only by consumers who lint with this plugin. The battery never imports this\n * module at runtime.\n *\n * @example Flat config\n * ```ts\n * import adkMedia from '@nhtio/adk/batteries/media/lint'\n *\n * export default [\n * { plugins: { 'adk-media': adkMedia.plugin }, rules: adkMedia.configs.recommended.rules },\n * ]\n * ```\n */\n\nimport { createRequire } from 'node:module'\nimport { ESLintUtils } from '@typescript-eslint/utils'\nimport type { TSESTree } from '@typescript-eslint/utils'\nimport type { FlatConfig } from '@typescript-eslint/utils/ts-eslint'\n\nconst createRule = ESLintUtils.RuleCreator(\n (name) => `https://adk.nht.io/batteries/media/lint#${name}`\n)\n\n// ── prefer-engine-resolver ───────────────────────────────────────────────────\n\nconst ENGINE_SUBPATH = /^@nhtio\\/adk\\/batteries\\/media\\/engines\\//\n\n/**\n * Flags a static value import of a bundled engine subpath. The documented canonical supply\n * form is the dynamic-import resolver, which keeps the engine wrapper module out of every\n * bundle that merely might use it. Type-only imports are fine.\n */\nconst preferEngineResolver = createRule({\n name: 'prefer-engine-resolver',\n meta: {\n type: 'suggestion',\n docs: {\n description:\n 'Supply bundled media engines as dynamic-import resolvers, not static imports — a static import puts the engine wrapper in every bundle, even when the engine is conditional.',\n },\n schema: [],\n messages: {\n preferResolver:\n \"Import bundled engines lazily: supply `() => import('{{source}}').then((m) => m.{{hint}}(…))` in the engines array instead of a static import. Static imports put the engine wrapper module in every bundle. Opt out with an eslint-disable-next-line adk-media/prefer-engine-resolver comment + reason.\",\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (typeof node.source.value !== 'string') return\n if (!ENGINE_SUBPATH.test(node.source.value)) return\n if (node.importKind === 'type') return\n const valueSpecifiers = node.specifiers.filter(\n (s) => !(s.type === 'ImportSpecifier' && s.importKind === 'type')\n )\n if (valueSpecifiers.length === 0) return\n const first = valueSpecifiers[0]\n const hint =\n first.type === 'ImportSpecifier' && first.imported.type === 'Identifier'\n ? first.imported.name\n : 'engineFactory'\n context.report({\n node,\n messageId: 'preferResolver',\n data: { source: node.source.value, hint },\n })\n },\n }\n },\n})\n\n// ── no-shadowed-engine ───────────────────────────────────────────────────────\n\n/** A statically-derived capability summary for one engines-array element. */\nexport interface EngineSummary {\n /** Display label for the diagnostic. */\n label: string\n /** Mutate groups: input patterns, ops, encodes. */\n mutates: Array<{ over: string[]; ops: string[]; encodes: string[] }>\n /** Convert groups: input patterns, target tokens. */\n converts: Array<{ from: string[]; to: string[] }>\n /** Edit groups: input patterns, ops. */\n edits: Array<{ over: string[]; ops: string[] }>\n}\n\nconst SHEET_OPS = [\n 'sheet.add_rows',\n 'sheet.add_columns',\n 'sheet.update_cells',\n 'sheet.delete_rows',\n 'sheet.delete_columns',\n 'sheet.rename_sheet',\n 'sheet.add_sheet',\n 'sheet.remove_sheet',\n 'sheet.reorder_sheets',\n 'sheet.transform_table',\n]\n\nconst SHEET_WRITE_TARGETS = [\n 'xlsx',\n 'xlsm',\n 'xlsb',\n 'xls',\n 'ods',\n 'fods',\n 'csv',\n 'txt',\n 'html',\n 'rtf',\n 'sylk',\n 'dif',\n 'dbf',\n 'numbers',\n 'json',\n]\n\nconst SHEET_READ_MIMES = [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel.sheet.macroEnabled.12',\n 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',\n 'application/vnd.ms-excel',\n 'application/vnd.oasis.opendocument.spreadsheet',\n 'application/vnd.oasis.opendocument.spreadsheet-flat-xml',\n 'text/csv',\n 'application/x-iwork-numbers-sffnumbers',\n 'application/x-sylk',\n 'application/x-dif',\n 'application/x-dbf',\n]\n\n/**\n * Known declarations of the bundled engine factories, for shadow analysis. An ESLint rule\n * cannot execute the factories it lints, so this table mirrors their declarations by hand —\n * and is pinned against the live factories by a drift test (`lint_drift.node.spec.ts`).\n * Exported for that test only.\n */\nexport const BUNDLED_SUMMARIES: Record<string, EngineSummary> = {\n dataEngine: {\n label: 'dataEngine',\n mutates: [],\n converts: [\n { from: ['application/x-adk-empty'], to: ['txt', 'md', 'json', 'yaml', 'csv', 'html'] },\n { from: ['application/json'], to: ['yaml', 'txt', 'csv'] },\n { from: ['application/yaml'], to: ['json'] },\n { from: ['text/csv'], to: ['json'] },\n ],\n edits: [],\n },\n exceljsEngine: {\n label: 'exceljsEngine',\n mutates: [],\n converts: [{ from: ['application/x-adk-empty'], to: ['xlsx'] }],\n edits: [\n {\n over: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],\n ops: SHEET_OPS,\n },\n ],\n },\n jimpEngine: {\n label: 'jimpEngine',\n mutates: [\n {\n over: ['image/png', 'image/jpeg', 'image/bmp', 'image/gif', 'image/tiff'],\n ops: ['resize', 'rotate', 'flip', 'strip_metadata'],\n encodes: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff'],\n },\n ],\n converts: [\n { from: ['application/x-adk-empty'], to: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff'] },\n ],\n edits: [],\n },\n sharpEngine: {\n label: 'sharpEngine',\n mutates: [\n {\n over: ['image/*'],\n ops: ['resize', 'rotate', 'flip', 'strip_metadata', 'annotate'],\n encodes: ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif', 'gif'],\n },\n ],\n converts: [\n {\n from: ['application/x-adk-empty'],\n to: ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif', 'gif'],\n },\n ],\n edits: [],\n },\n sheetjsEngine: {\n label: 'sheetjsEngine',\n mutates: [],\n converts: [\n { from: ['application/x-adk-empty'], to: SHEET_WRITE_TARGETS },\n { from: SHEET_READ_MIMES, to: SHEET_WRITE_TARGETS },\n ],\n edits: [{ over: SHEET_READ_MIMES, ops: SHEET_OPS }],\n },\n}\n\nconst literalStrings = (node: TSESTree.Node | undefined): string[] | undefined => {\n if (!node || node.type !== 'ArrayExpression') return undefined\n const out: string[] = []\n for (const el of node.elements) {\n if (!el || el.type !== 'Literal' || typeof el.value !== 'string') return undefined\n out.push(el.value)\n }\n return out\n}\n\nconst propOf = (obj: TSESTree.ObjectExpression, name: string): TSESTree.Node | undefined =>\n obj.properties.find(\n (p): p is TSESTree.Property =>\n p.type === 'Property' && !p.computed && p.key.type === 'Identifier' && p.key.name === name\n )?.value\n\n/** Find the bundled factory name referenced by an element (direct call or resolver arrow). */\nconst bundledFactoryName = (node: TSESTree.Node): string | undefined => {\n if (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name in BUNDLED_SUMMARIES\n ) {\n return node.callee.name\n }\n // Resolver forms: () => …; scan the body for m.jimpEngine(…) / jimpEngine(…).\n if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression') {\n let found: string | undefined\n const visit = (n: TSESTree.Node): void => {\n if (found) return\n if (n.type === 'CallExpression') {\n if (n.callee.type === 'Identifier' && n.callee.name in BUNDLED_SUMMARIES) {\n found = n.callee.name\n } else if (\n n.callee.type === 'MemberExpression' &&\n n.callee.property.type === 'Identifier' &&\n n.callee.property.name in BUNDLED_SUMMARIES\n ) {\n found = n.callee.property.name\n }\n }\n for (const key of Object.keys(n)) {\n if (key === 'parent') continue\n const value = (n as unknown as Record<string, unknown>)[key]\n const children = Array.isArray(value) ? value : [value]\n for (const child of children) {\n if (!child || typeof child !== 'object') continue\n const childNode = child as TSESTree.Node\n if (typeof childNode.type !== 'string') continue\n visit(childNode)\n }\n }\n }\n visit(node.body)\n return found\n }\n return undefined\n}\n\n/** Derive a capability summary from an element, or undefined when not statically known. */\nconst summarize = (node: TSESTree.Node): EngineSummary | undefined => {\n const factory = bundledFactoryName(node)\n if (factory) return BUNDLED_SUMMARIES[factory]\n if (node.type !== 'ObjectExpression') return undefined\n const idNode = propOf(node, 'id')\n const label =\n idNode?.type === 'Literal' && typeof idNode.value === 'string' ? idNode.value : 'engine'\n const summary: EngineSummary = { label, mutates: [], converts: [], edits: [] }\n const mutates = propOf(node, 'mutates')\n if (mutates) {\n if (mutates.type !== 'ArrayExpression') return undefined\n for (const el of mutates.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const over = literalStrings(propOf(el, 'over'))\n const ops = literalStrings(propOf(el, 'ops'))\n const encodes = literalStrings(propOf(el, 'encodes'))\n if (!over || !ops || !encodes) return undefined\n summary.mutates.push({ over, ops, encodes })\n }\n }\n const converts = propOf(node, 'converts')\n if (converts) {\n if (converts.type !== 'ArrayExpression') return undefined\n for (const el of converts.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const from = literalStrings(propOf(el, 'from'))\n const to = literalStrings(propOf(el, 'to'))\n if (!from || !to) return undefined\n summary.converts.push({ from, to })\n }\n }\n const edits = propOf(node, 'edits')\n if (edits) {\n if (edits.type !== 'ArrayExpression') return undefined\n for (const el of edits.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const over = literalStrings(propOf(el, 'over'))\n const ops = literalStrings(propOf(el, 'ops'))\n if (!over || !ops) return undefined\n summary.edits.push({ over, ops })\n }\n }\n if (summary.mutates.length + summary.converts.length + summary.edits.length === 0) {\n return undefined\n }\n return summary\n}\n\nconst patternCovers = (broad: string, narrow: string): boolean => {\n if (broad === narrow) return true\n if (broad.endsWith('/*')) return narrow.startsWith(broad.slice(0, -1))\n return false\n}\n\nconst patternsCover = (broad: string[], narrow: string[]): boolean =>\n narrow.every((n) => broad.some((b) => patternCovers(b, n)))\n\nconst subset = (sup: string[], sub: string[]): boolean => sub.every((s) => sup.includes(s))\n\n/** `true` when EVERY capability of `later` is subsumed by some capability of `earlier`. */\nconst shadows = (earlier: EngineSummary, later: EngineSummary): boolean => {\n if (later.mutates.length + later.converts.length + later.edits.length === 0) return false\n const mutatesCovered = later.mutates.every((lm) =>\n earlier.mutates.some(\n (em) =>\n patternsCover(em.over, lm.over) && subset(em.ops, lm.ops) && subset(em.encodes, lm.encodes)\n )\n )\n const convertsCovered = later.converts.every((lc) =>\n earlier.converts.some((ec) => patternsCover(ec.from, lc.from) && subset(ec.to, lc.to))\n )\n const editsCovered = later.edits.every((le) =>\n earlier.edits.some((ee) => patternsCover(ee.over, le.over) && subset(ee.ops, le.ops))\n )\n return mutatesCovered && convertsCovered && editsCovered\n}\n\n/**\n * Flags an engines-array element whose statically-known capabilities are entirely covered by\n * an EARLIER element — dispatch is first-capable-wins, so the later engine is dead code.\n */\nconst noShadowedEngine = createRule({\n name: 'no-shadowed-engine',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'An engine whose declared capabilities are a subset of an earlier engine in the array can never be selected — first-capable-wins dispatch makes it dead code. Reorder (narrow before broad) or remove it.',\n },\n schema: [],\n messages: {\n shadowed:\n 'Engine \"{{later}}\" can never be selected: \"{{earlier}}\" appears earlier in the array and declares a superset of its capabilities (dispatch is first-capable-wins). Put the narrower engine first, or remove it. Opt out with an eslint-disable-next-line adk-media/no-shadowed-engine comment + reason.',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n CallExpression(node: TSESTree.CallExpression) {\n if (node.callee.type !== 'Identifier' || node.callee.name !== 'createMediaPipeline') {\n return\n }\n const config = node.arguments[0]\n if (!config || config.type !== 'ObjectExpression') return\n const engines = propOf(config, 'engines')\n if (!engines || engines.type !== 'ArrayExpression') return\n const summaries = engines.elements.map((el) => (el ? summarize(el) : undefined))\n for (let i = 1; i < summaries.length; i++) {\n const later = summaries[i]\n if (!later) continue\n for (let j = 0; j < i; j++) {\n const earlier = summaries[j]\n if (!earlier) continue\n if (shadows(earlier, later)) {\n context.report({\n node: engines.elements[i]!,\n messageId: 'shadowed',\n data: { earlier: earlier.label, later: later.label },\n })\n break\n }\n }\n }\n },\n }\n },\n})\n\n// ── augment-contracts-module ─────────────────────────────────────────────────\n\nconst CONTRACTS_SUBPATH = '@nhtio/adk/batteries/media/contracts'\n\n/**\n * Flags a `ConvertOptions` declaration-merging block whose module specifier is not the\n * contracts subpath. Augmenting the barrel (or any other module) silently does nothing —\n * the keys never merge, and the typo costs hours.\n */\nconst augmentContractsModule = createRule({\n name: 'augment-contracts-module',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'ConvertOptions augmentation must target the contracts subpath — declaration merging against any other module specifier silently fails to merge.',\n },\n schema: [],\n messages: {\n wrongModule:\n 'This ConvertOptions augmentation targets \"{{actual}}\", so it will silently never merge. Declaration merging must target the module that declares the interface: declare module \\'{{expected}}\\'.',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n TSModuleDeclaration(node: TSESTree.TSModuleDeclaration) {\n if (node.global) return\n if (node.id.type !== 'Literal' || typeof node.id.value !== 'string') return\n const specifier = node.id.value\n if (specifier === CONTRACTS_SUBPATH || specifier.endsWith('/media/contracts')) return\n // Only flag specifiers that are plausibly aimed at this battery.\n if (!specifier.includes('media') && !specifier.includes('@nhtio/adk')) return\n const body = node.body\n if (!body || body.type !== 'TSModuleBlock') return\n const declaresConvertOptions = body.body.some(\n (stmt) => stmt.type === 'TSInterfaceDeclaration' && stmt.id.name === 'ConvertOptions'\n )\n if (!declaresConvertOptions) return\n context.report({\n node: node.id,\n messageId: 'wrongModule',\n data: { actual: specifier, expected: CONTRACTS_SUBPATH },\n })\n },\n }\n },\n})\n\n// ── require-engine-peers ─────────────────────────────────────────────────────\n\n/**\n * The optional peer dependencies each bundled engine subpath lazily imports at runtime.\n * Keyed by the engine's subpath suffix (after `engines/`). An engine with no external peer\n * (soffice, fs_workspace) is absent — there's nothing to install. Kept in lockstep with the\n * engines' actual `import(...)` calls by `engine_peers_drift.node.spec.ts`.\n */\nexport const ENGINE_PEERS: Record<string, readonly string[]> = {\n jimp: ['jimp'],\n sharp: ['sharp'],\n sheetjs: ['xlsx'],\n exceljs: ['exceljs'],\n data: ['js-yaml', 'papaparse'],\n tesseract_js: ['tesseract.js'],\n audio_decode: ['audio-decode'],\n transformers_asr: ['@huggingface/transformers'],\n execa_executor: ['execa'],\n}\n\n/** Map a bundled engine subpath to its peer list, or undefined when it isn't a known engine. */\nconst peersForSubpath = (source: string): readonly string[] | undefined => {\n const m = /^@nhtio\\/adk\\/batteries\\/media\\/engines\\/([a-z_]+)$/.exec(source)\n if (!m) return undefined\n return ENGINE_PEERS[m[1]]\n}\n\n/**\n * Flags an import of a bundled engine subpath whose optional peer dependency cannot be\n * resolved from the linting file — the \"I composed `sheetjsEngine()` but never installed\n * `xlsx`, and now my pipeline throws `E_INVALID_MEDIA_PIPELINE_CONFIG` at the first sheet\n * op\" footgun, caught at lint time instead of runtime. Resolution uses Node's resolver from\n * the file's own directory, so it honors the consumer's real `node_modules` layout.\n *\n * Reports once per missing peer per engine import (whether the import is a static value\n * import or a dynamic-import resolver — both reference the engine and both need the peer).\n */\n/**\n * The peer-resolution probe: returns `true` when `peer` resolves from `fromFile`. Defaults to\n * Node's resolver anchored at the linted file (so it sees the consumer's `node_modules`).\n * Exposed as a settable seam so the rule's spec can simulate installed/missing peers without\n * depending on the test runner's own `node_modules` layout — production never sets it.\n */\nexport type PeerResolver = (peer: string, fromFile: string) => boolean\n\nconst defaultPeerResolver: PeerResolver = (peer, fromFile) => {\n try {\n createRequire(fromFile).resolve(peer)\n return true\n } catch {\n return false\n }\n}\n\nlet activePeerResolver: PeerResolver = defaultPeerResolver\n\n/** Override the peer resolver (spec-only seam). Pass nothing to restore the Node default. */\nexport const setPeerResolverForTesting = (resolver?: PeerResolver): void => {\n activePeerResolver = resolver ?? defaultPeerResolver\n}\n\nconst requireEnginePeers = createRule<[{ ignore?: readonly string[] }], 'missingPeer'>({\n name: 'require-engine-peers',\n meta: {\n type: 'problem',\n docs: {\n description:\n \"A bundled media engine's optional peer dependency must be installed where it's composed — otherwise the pipeline throws at first use, not at construction.\",\n },\n schema: [\n {\n type: 'object',\n properties: {\n ignore: {\n type: 'array',\n items: { type: 'string' },\n description:\n 'Peer package names to skip (e.g. one resolved via a custom loader the linter cannot see).',\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n missingPeer:\n 'The \"{{engine}}\" media engine requires the optional peer \"{{peer}}\", which cannot be resolved from this file. Install it ({{install}}) or the pipeline will throw E_INVALID_MEDIA_PIPELINE_CONFIG the first time this engine runs. Opt out with an eslint-disable-next-line adk-media/require-engine-peers comment + reason.',\n },\n },\n defaultOptions: [{ ignore: [] }],\n create(context, [options]) {\n const ignore = new Set(options?.ignore ?? [])\n\n /** SheetJS ships only from its CDN tarball, so the install hint must not say the registry. */\n const installHint = (peer: string): string =>\n peer === 'xlsx'\n ? 'pnpm add xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz'\n : `pnpm add ${peer}`\n\n const checkSource = (source: string, reportNode: TSESTree.Node): void => {\n const peers = peersForSubpath(source)\n if (!peers) return\n const engine = source.slice(source.lastIndexOf('/') + 1)\n for (const peer of peers) {\n if (ignore.has(peer)) continue\n if (!activePeerResolver(peer, context.filename)) {\n context.report({\n node: reportNode,\n messageId: 'missingPeer',\n data: { engine, peer, install: installHint(peer) },\n })\n }\n }\n }\n\n return {\n // Static value/type import of an engine subpath.\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (typeof node.source.value === 'string') checkSource(node.source.value, node.source)\n },\n // The canonical resolver form: import('@nhtio/adk/batteries/media/engines/…').\n ImportExpression(node: TSESTree.ImportExpression) {\n if (node.source.type === 'Literal' && typeof node.source.value === 'string') {\n checkSource(node.source.value, node.source)\n }\n },\n }\n },\n})\n\n// ── plugin assembly ──────────────────────────────────────────────────────────\n\n/**\n * Map of rule id (without the `adk-media/` plugin prefix) to its rule object. Registered on\n * the plugin as `rules`, so configs reference them as `adk-media/{id}`.\n */\nexport const rules = {\n 'prefer-engine-resolver': preferEngineResolver,\n 'no-shadowed-engine': noShadowedEngine,\n 'augment-contracts-module': augmentContractsModule,\n 'require-engine-peers': requireEnginePeers,\n} satisfies FlatConfig.Plugin['rules']\n\n/**\n * The media battery's ESLint plugin object. Register under the `adk-media` namespace:\n * `plugins: { 'adk-media': plugin }`.\n */\nexport const plugin: FlatConfig.Plugin = {\n meta: { name: '@nhtio/adk/batteries/media/lint', version: __VERSION__ },\n rules,\n}\n\nconst recommendedRules: NonNullable<FlatConfig.Config['rules']> = Object.fromEntries(\n Object.keys(rules).map((id) => [`adk-media/${id}`, 'error'])\n)\n\n/**\n * Named config presets. `recommended` enables every rule at `error` and registers the plugin\n * under the `adk-media` namespace — spread it into a flat config to adopt the full set.\n */\nexport const configs = {\n recommended: {\n name: '@nhtio/adk/batteries/media/lint/recommended',\n plugins: { 'adk-media': plugin },\n rules: recommendedRules,\n } satisfies FlatConfig.Config,\n}\n\n/**\n * Default export bundles the plugin and its config presets, mirroring the shape ESLint flat\n * configs expect from a plugin module.\n */\nexport default { plugin, rules, configs }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAM,aAAa,yBAAA,YAAY,aAC5B,SAAS,2CAA2C,MACvD;AAIA,IAAM,iBAAiB;;;;;;AAOvB,IAAM,uBAAuB,WAAW;CACtC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,+KACJ;EACA,QAAQ,CAAC;EACT,UAAU,EACR,gBACE,2SACJ;CACF;CACA,gBAAgB,CAAC;CACjB,OAAO,SAAS;EACd,OAAO,EACL,kBAAkB,MAAkC;GAClD,IAAI,OAAO,KAAK,OAAO,UAAU,UAAU;GAC3C,IAAI,CAAC,eAAe,KAAK,KAAK,OAAO,KAAK,GAAG;GAC7C,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|
+
{"version":3,"file":"lint.cjs","names":[],"sources":["../../../src/batteries/media/lint.ts"],"sourcesContent":["/**\n * @module @nhtio/adk/batteries/media/lint\n *\n * ESLint rules for consumers of the media pipeline battery: machine-checkable enforcement of\n * the engine-composition contracts implementors are most likely to get wrong.\n *\n * @remarks\n * Battery-scoped rules ship with the battery, not with the core `@nhtio/adk/eslint` plugin —\n * they only matter to deployments that compose this battery, and they version with the\n * battery's own API. The rules are report-only (no autofix); carve out a deliberate exception\n * with an inline `// eslint-disable-next-line adk-media/{rule} -- {reason}` comment.\n *\n * `@typescript-eslint/utils` and `eslint` are OPTIONAL peer dependencies of `@nhtio/adk` —\n * installed only by consumers who lint with this plugin. The battery never imports this\n * module at runtime.\n *\n * @example Flat config\n * ```ts\n * import adkMedia from '@nhtio/adk/batteries/media/lint'\n *\n * export default [\n * { plugins: { 'adk-media': adkMedia.plugin }, rules: adkMedia.configs.recommended.rules },\n * ]\n * ```\n */\n\nimport { createRequire } from 'node:module'\nimport { ESLintUtils } from '@typescript-eslint/utils'\nimport { collectImportBindings, resolveCalleeName } from '../../eslint/rules'\nimport type { TSESTree } from '@typescript-eslint/utils'\nimport type { ImportBindings } from '../../eslint/rules'\nimport type { FlatConfig } from '@typescript-eslint/utils/ts-eslint'\n\nconst createRule = ESLintUtils.RuleCreator(\n (name) => `https://adk.nht.io/batteries/media/lint#${name}`\n)\n\n// ── prefer-engine-resolver ───────────────────────────────────────────────────\n\nconst ENGINE_SUBPATH = /^@nhtio\\/adk\\/batteries\\/media\\/engines\\//\n\n/**\n * Flags a static value import of a bundled engine subpath. The documented canonical supply\n * form is the dynamic-import resolver, which keeps the engine wrapper module out of every\n * bundle that merely might use it. Type-only imports are fine.\n */\nconst preferEngineResolver = createRule({\n name: 'prefer-engine-resolver',\n meta: {\n type: 'suggestion',\n docs: {\n description:\n 'Supply bundled media engines as dynamic-import resolvers, not static imports — a static import puts the engine wrapper in every bundle, even when the engine is conditional.',\n },\n schema: [],\n messages: {\n preferResolver:\n \"Import bundled engines lazily: supply `() => import('{{source}}').then((m) => m.{{hint}}(…))` in the engines array instead of a static import. Static imports put the engine wrapper module in every bundle. Opt out with an eslint-disable-next-line adk-media/prefer-engine-resolver comment + reason.\",\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (typeof node.source.value !== 'string') return\n if (!ENGINE_SUBPATH.test(node.source.value)) return\n if (node.importKind === 'type') return\n const valueSpecifiers = node.specifiers.filter(\n (s) => !(s.type === 'ImportSpecifier' && s.importKind === 'type')\n )\n if (valueSpecifiers.length === 0) return\n const first = valueSpecifiers[0]\n const hint =\n first.type === 'ImportSpecifier' && first.imported.type === 'Identifier'\n ? first.imported.name\n : 'engineFactory'\n context.report({\n node,\n messageId: 'preferResolver',\n data: { source: node.source.value, hint },\n })\n },\n }\n },\n})\n\n// ── no-shadowed-engine ───────────────────────────────────────────────────────\n\n/** A statically-derived capability summary for one engines-array element. */\nexport interface EngineSummary {\n /** Display label for the diagnostic. */\n label: string\n /** Mutate groups: input patterns, ops, encodes. */\n mutates: Array<{ over: string[]; ops: string[]; encodes: string[] }>\n /** Convert groups: input patterns, target tokens. */\n converts: Array<{ from: string[]; to: string[] }>\n /** Edit groups: input patterns, ops. */\n edits: Array<{ over: string[]; ops: string[] }>\n}\n\nconst SHEET_OPS = [\n 'sheet.add_rows',\n 'sheet.add_columns',\n 'sheet.update_cells',\n 'sheet.delete_rows',\n 'sheet.delete_columns',\n 'sheet.rename_sheet',\n 'sheet.add_sheet',\n 'sheet.remove_sheet',\n 'sheet.reorder_sheets',\n 'sheet.transform_table',\n]\n\nconst SHEET_WRITE_TARGETS = [\n 'xlsx',\n 'xlsm',\n 'xlsb',\n 'xls',\n 'ods',\n 'fods',\n 'csv',\n 'txt',\n 'html',\n 'rtf',\n 'sylk',\n 'dif',\n 'dbf',\n 'numbers',\n 'json',\n]\n\nconst SHEET_READ_MIMES = [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel.sheet.macroEnabled.12',\n 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',\n 'application/vnd.ms-excel',\n 'application/vnd.oasis.opendocument.spreadsheet',\n 'application/vnd.oasis.opendocument.spreadsheet-flat-xml',\n 'text/csv',\n 'application/x-iwork-numbers-sffnumbers',\n 'application/x-sylk',\n 'application/x-dif',\n 'application/x-dbf',\n]\n\n/**\n * Known declarations of the bundled engine factories, for shadow analysis. An ESLint rule\n * cannot execute the factories it lints, so this table mirrors their declarations by hand —\n * and is pinned against the live factories by a drift test (`lint_drift.node.spec.ts`).\n * Exported for that test only.\n */\nexport const BUNDLED_SUMMARIES: Record<string, EngineSummary> = {\n dataEngine: {\n label: 'dataEngine',\n mutates: [],\n converts: [\n { from: ['application/x-adk-empty'], to: ['txt', 'md', 'json', 'yaml', 'csv', 'html'] },\n { from: ['application/json'], to: ['yaml', 'txt', 'csv'] },\n { from: ['application/yaml'], to: ['json'] },\n { from: ['text/csv'], to: ['json'] },\n ],\n edits: [],\n },\n exceljsEngine: {\n label: 'exceljsEngine',\n mutates: [],\n converts: [{ from: ['application/x-adk-empty'], to: ['xlsx'] }],\n edits: [\n {\n over: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],\n ops: SHEET_OPS,\n },\n ],\n },\n jimpEngine: {\n label: 'jimpEngine',\n mutates: [\n {\n over: ['image/png', 'image/jpeg', 'image/bmp', 'image/gif', 'image/tiff'],\n ops: ['resize', 'rotate', 'flip', 'strip_metadata'],\n encodes: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff'],\n },\n ],\n converts: [\n { from: ['application/x-adk-empty'], to: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff'] },\n ],\n edits: [],\n },\n sharpEngine: {\n label: 'sharpEngine',\n mutates: [\n {\n over: ['image/*'],\n ops: ['resize', 'rotate', 'flip', 'strip_metadata', 'annotate'],\n encodes: ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif', 'gif'],\n },\n ],\n converts: [\n {\n from: ['application/x-adk-empty'],\n to: ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif', 'gif'],\n },\n ],\n edits: [],\n },\n sheetjsEngine: {\n label: 'sheetjsEngine',\n mutates: [],\n converts: [\n { from: ['application/x-adk-empty'], to: SHEET_WRITE_TARGETS },\n { from: SHEET_READ_MIMES, to: SHEET_WRITE_TARGETS },\n ],\n edits: [{ over: SHEET_READ_MIMES, ops: SHEET_OPS }],\n },\n}\n\nconst literalStrings = (node: TSESTree.Node | undefined): string[] | undefined => {\n if (!node || node.type !== 'ArrayExpression') return undefined\n const out: string[] = []\n for (const el of node.elements) {\n if (!el || el.type !== 'Literal' || typeof el.value !== 'string') return undefined\n out.push(el.value)\n }\n return out\n}\n\nconst propOf = (obj: TSESTree.ObjectExpression, name: string): TSESTree.Node | undefined =>\n obj.properties.find(\n (p): p is TSESTree.Property =>\n p.type === 'Property' && !p.computed && p.key.type === 'Identifier' && p.key.name === name\n )?.value\n\n/** Find the bundled factory name referenced by an element (direct call or resolver arrow). */\nconst bundledFactoryName = (node: TSESTree.Node): string | undefined => {\n if (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name in BUNDLED_SUMMARIES\n ) {\n return node.callee.name\n }\n // Resolver forms: () => …; scan the body for m.jimpEngine(…) / jimpEngine(…).\n if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression') {\n let found: string | undefined\n const visit = (n: TSESTree.Node): void => {\n if (found) return\n if (n.type === 'CallExpression') {\n if (n.callee.type === 'Identifier' && n.callee.name in BUNDLED_SUMMARIES) {\n found = n.callee.name\n } else if (\n n.callee.type === 'MemberExpression' &&\n n.callee.property.type === 'Identifier' &&\n n.callee.property.name in BUNDLED_SUMMARIES\n ) {\n found = n.callee.property.name\n }\n }\n for (const key of Object.keys(n)) {\n if (key === 'parent') continue\n const value = (n as unknown as Record<string, unknown>)[key]\n const children = Array.isArray(value) ? value : [value]\n for (const child of children) {\n if (!child || typeof child !== 'object') continue\n const childNode = child as TSESTree.Node\n if (typeof childNode.type !== 'string') continue\n visit(childNode)\n }\n }\n }\n visit(node.body)\n return found\n }\n return undefined\n}\n\n/** Derive a capability summary from an element, or undefined when not statically known. */\nconst summarize = (node: TSESTree.Node): EngineSummary | undefined => {\n const factory = bundledFactoryName(node)\n if (factory) return BUNDLED_SUMMARIES[factory]\n if (node.type !== 'ObjectExpression') return undefined\n const idNode = propOf(node, 'id')\n const label =\n idNode?.type === 'Literal' && typeof idNode.value === 'string' ? idNode.value : 'engine'\n const summary: EngineSummary = { label, mutates: [], converts: [], edits: [] }\n const mutates = propOf(node, 'mutates')\n if (mutates) {\n if (mutates.type !== 'ArrayExpression') return undefined\n for (const el of mutates.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const over = literalStrings(propOf(el, 'over'))\n const ops = literalStrings(propOf(el, 'ops'))\n const encodes = literalStrings(propOf(el, 'encodes'))\n if (!over || !ops || !encodes) return undefined\n summary.mutates.push({ over, ops, encodes })\n }\n }\n const converts = propOf(node, 'converts')\n if (converts) {\n if (converts.type !== 'ArrayExpression') return undefined\n for (const el of converts.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const from = literalStrings(propOf(el, 'from'))\n const to = literalStrings(propOf(el, 'to'))\n if (!from || !to) return undefined\n summary.converts.push({ from, to })\n }\n }\n const edits = propOf(node, 'edits')\n if (edits) {\n if (edits.type !== 'ArrayExpression') return undefined\n for (const el of edits.elements) {\n if (!el || el.type !== 'ObjectExpression') return undefined\n const over = literalStrings(propOf(el, 'over'))\n const ops = literalStrings(propOf(el, 'ops'))\n if (!over || !ops) return undefined\n summary.edits.push({ over, ops })\n }\n }\n if (summary.mutates.length + summary.converts.length + summary.edits.length === 0) {\n return undefined\n }\n return summary\n}\n\nconst patternCovers = (broad: string, narrow: string): boolean => {\n if (broad === narrow) return true\n if (broad.endsWith('/*')) return narrow.startsWith(broad.slice(0, -1))\n return false\n}\n\nconst patternsCover = (broad: string[], narrow: string[]): boolean =>\n narrow.every((n) => broad.some((b) => patternCovers(b, n)))\n\nconst subset = (sup: string[], sub: string[]): boolean => sub.every((s) => sup.includes(s))\n\n/** `true` when EVERY capability of `later` is subsumed by some capability of `earlier`. */\nconst shadows = (earlier: EngineSummary, later: EngineSummary): boolean => {\n if (later.mutates.length + later.converts.length + later.edits.length === 0) return false\n const mutatesCovered = later.mutates.every((lm) =>\n earlier.mutates.some(\n (em) =>\n patternsCover(em.over, lm.over) && subset(em.ops, lm.ops) && subset(em.encodes, lm.encodes)\n )\n )\n const convertsCovered = later.converts.every((lc) =>\n earlier.converts.some((ec) => patternsCover(ec.from, lc.from) && subset(ec.to, lc.to))\n )\n const editsCovered = later.edits.every((le) =>\n earlier.edits.some((ee) => patternsCover(ee.over, le.over) && subset(ee.ops, le.ops))\n )\n return mutatesCovered && convertsCovered && editsCovered\n}\n\n/**\n * Flags an engines-array element whose statically-known capabilities are entirely covered by\n * an EARLIER element — dispatch is first-capable-wins, so the later engine is dead code.\n */\nconst noShadowedEngine = createRule({\n name: 'no-shadowed-engine',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'An engine whose declared capabilities are a subset of an earlier engine in the array can never be selected — first-capable-wins dispatch makes it dead code. Reorder (narrow before broad) or remove it.',\n },\n schema: [],\n messages: {\n shadowed:\n 'Engine \"{{later}}\" can never be selected: \"{{earlier}}\" appears earlier in the array and declares a superset of its capabilities (dispatch is first-capable-wins). Put the narrower engine first, or remove it. Opt out with an eslint-disable-next-line adk-media/no-shadowed-engine comment + reason.',\n },\n },\n defaultOptions: [],\n create(context) {\n let bindings: ImportBindings = new Map()\n return {\n Program(node: TSESTree.Program): void {\n bindings = collectImportBindings(node)\n },\n CallExpression(node: TSESTree.CallExpression) {\n const resolved = resolveCalleeName(bindings, node.callee)\n // The same binding policy as the other name-matched factories: an aliased or\n // namespace-spelled callee still names the `createMediaPipeline` export, and so does a\n // never-imported name (a snippet or a re-export shim); a same-named import from a foreign\n // module does not.\n if (!resolved || resolved.name !== 'createMediaPipeline') return\n if (resolved.imported && !resolved.fromAdk) return\n const config = node.arguments[0]\n if (!config || config.type !== 'ObjectExpression') return\n const engines = propOf(config, 'engines')\n if (!engines || engines.type !== 'ArrayExpression') return\n const summaries = engines.elements.map((el) => (el ? summarize(el) : undefined))\n for (let i = 1; i < summaries.length; i++) {\n const later = summaries[i]\n if (!later) continue\n for (let j = 0; j < i; j++) {\n const earlier = summaries[j]\n if (!earlier) continue\n if (shadows(earlier, later)) {\n context.report({\n node: engines.elements[i]!,\n messageId: 'shadowed',\n data: { earlier: earlier.label, later: later.label },\n })\n break\n }\n }\n }\n },\n }\n },\n})\n\n// ── augment-contracts-module ─────────────────────────────────────────────────\n\nconst CONTRACTS_SUBPATH = '@nhtio/adk/batteries/media/contracts'\n\n/**\n * Flags a `ConvertOptions` declaration-merging block whose module specifier is not the\n * contracts subpath. Augmenting the barrel (or any other module) silently does nothing —\n * the keys never merge, and the typo costs hours.\n */\nconst augmentContractsModule = createRule({\n name: 'augment-contracts-module',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'ConvertOptions augmentation must target the contracts subpath — declaration merging against any other module specifier silently fails to merge.',\n },\n schema: [],\n messages: {\n wrongModule:\n 'This ConvertOptions augmentation targets \"{{actual}}\", so it will silently never merge. Declaration merging must target the module that declares the interface: declare module \\'{{expected}}\\'.',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n TSModuleDeclaration(node: TSESTree.TSModuleDeclaration) {\n if (node.global) return\n if (node.id.type !== 'Literal' || typeof node.id.value !== 'string') return\n const specifier = node.id.value\n if (specifier === CONTRACTS_SUBPATH || specifier.endsWith('/media/contracts')) return\n // Only flag specifiers that are plausibly aimed at this battery.\n if (!specifier.includes('media') && !specifier.includes('@nhtio/adk')) return\n const body = node.body\n if (!body || body.type !== 'TSModuleBlock') return\n const declaresConvertOptions = body.body.some(\n (stmt) => stmt.type === 'TSInterfaceDeclaration' && stmt.id.name === 'ConvertOptions'\n )\n if (!declaresConvertOptions) return\n context.report({\n node: node.id,\n messageId: 'wrongModule',\n data: { actual: specifier, expected: CONTRACTS_SUBPATH },\n })\n },\n }\n },\n})\n\n// ── require-engine-peers ─────────────────────────────────────────────────────\n\n/**\n * The optional peer dependencies each bundled engine subpath lazily imports at runtime.\n * Keyed by the engine's subpath suffix (after `engines/`). An engine with no external peer\n * (soffice, fs_workspace) is absent — there's nothing to install. Kept in lockstep with the\n * engines' actual `import(...)` calls by `engine_peers_drift.node.spec.ts`.\n */\nexport const ENGINE_PEERS: Record<string, readonly string[]> = {\n jimp: ['jimp'],\n sharp: ['sharp'],\n sheetjs: ['xlsx'],\n exceljs: ['exceljs'],\n data: ['js-yaml', 'papaparse'],\n tesseract_js: ['tesseract.js'],\n audio_decode: ['audio-decode'],\n transformers_asr: ['@huggingface/transformers'],\n execa_executor: ['execa'],\n}\n\n/** Map a bundled engine subpath to its peer list, or undefined when it isn't a known engine. */\nconst peersForSubpath = (source: string): readonly string[] | undefined => {\n const m = /^@nhtio\\/adk\\/batteries\\/media\\/engines\\/([a-z_]+)$/.exec(source)\n if (!m) return undefined\n return ENGINE_PEERS[m[1]]\n}\n\n/**\n * Flags an import of a bundled engine subpath whose optional peer dependency cannot be\n * resolved from the linting file — the \"I composed `sheetjsEngine()` but never installed\n * `xlsx`, and now my pipeline throws `E_INVALID_MEDIA_PIPELINE_CONFIG` at the first sheet\n * op\" footgun, caught at lint time instead of runtime. Resolution uses Node's resolver from\n * the file's own directory, so it honors the consumer's real `node_modules` layout.\n *\n * Reports once per missing peer per engine import (whether the import is a static value\n * import or a dynamic-import resolver — both reference the engine and both need the peer).\n */\n/**\n * The peer-resolution probe: returns `true` when `peer` resolves from `fromFile`. Defaults to\n * Node's resolver anchored at the linted file (so it sees the consumer's `node_modules`).\n * Exposed as a settable seam so the rule's spec can simulate installed/missing peers without\n * depending on the test runner's own `node_modules` layout — production never sets it.\n */\nexport type PeerResolver = (peer: string, fromFile: string) => boolean\n\nconst defaultPeerResolver: PeerResolver = (peer, fromFile) => {\n try {\n createRequire(fromFile).resolve(peer)\n return true\n } catch {\n return false\n }\n}\n\nlet activePeerResolver: PeerResolver = defaultPeerResolver\n\n/** Override the peer resolver (spec-only seam). Pass nothing to restore the Node default. */\nexport const setPeerResolverForTesting = (resolver?: PeerResolver): void => {\n activePeerResolver = resolver ?? defaultPeerResolver\n}\n\nconst requireEnginePeers = createRule<[{ ignore?: readonly string[] }], 'missingPeer'>({\n name: 'require-engine-peers',\n meta: {\n type: 'problem',\n docs: {\n description:\n \"A bundled media engine's optional peer dependency must be installed where it's composed — otherwise the pipeline throws at first use, not at construction.\",\n },\n schema: [\n {\n type: 'object',\n properties: {\n ignore: {\n type: 'array',\n items: { type: 'string' },\n description:\n 'Peer package names to skip (e.g. one resolved via a custom loader the linter cannot see).',\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n missingPeer:\n 'The \"{{engine}}\" media engine requires the optional peer \"{{peer}}\", which cannot be resolved from this file. Install it ({{install}}) or the pipeline will throw E_INVALID_MEDIA_PIPELINE_CONFIG the first time this engine runs. Opt out with an eslint-disable-next-line adk-media/require-engine-peers comment + reason.',\n },\n },\n defaultOptions: [{ ignore: [] }],\n create(context, [options]) {\n const ignore = new Set(options?.ignore ?? [])\n\n /** SheetJS ships only from its CDN tarball, so the install hint must not say the registry. */\n const installHint = (peer: string): string =>\n peer === 'xlsx'\n ? 'pnpm add xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz'\n : `pnpm add ${peer}`\n\n const checkSource = (source: string, reportNode: TSESTree.Node): void => {\n const peers = peersForSubpath(source)\n if (!peers) return\n const engine = source.slice(source.lastIndexOf('/') + 1)\n for (const peer of peers) {\n if (ignore.has(peer)) continue\n if (!activePeerResolver(peer, context.filename)) {\n context.report({\n node: reportNode,\n messageId: 'missingPeer',\n data: { engine, peer, install: installHint(peer) },\n })\n }\n }\n }\n\n return {\n // Static value/type import of an engine subpath.\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (typeof node.source.value === 'string') checkSource(node.source.value, node.source)\n },\n // The canonical resolver form: import('@nhtio/adk/batteries/media/engines/…').\n ImportExpression(node: TSESTree.ImportExpression) {\n if (node.source.type === 'Literal' && typeof node.source.value === 'string') {\n checkSource(node.source.value, node.source)\n }\n },\n }\n },\n})\n\n// ── plugin assembly ──────────────────────────────────────────────────────────\n\n/**\n * Map of rule id (without the `adk-media/` plugin prefix) to its rule object. Registered on\n * the plugin as `rules`, so configs reference them as `adk-media/{id}`.\n */\nexport const rules = {\n 'prefer-engine-resolver': preferEngineResolver,\n 'no-shadowed-engine': noShadowedEngine,\n 'augment-contracts-module': augmentContractsModule,\n 'require-engine-peers': requireEnginePeers,\n} satisfies FlatConfig.Plugin['rules']\n\n/**\n * The media battery's ESLint plugin object. Register under the `adk-media` namespace:\n * `plugins: { 'adk-media': plugin }`.\n */\nexport const plugin: FlatConfig.Plugin = {\n meta: { name: '@nhtio/adk/batteries/media/lint', version: __VERSION__ },\n rules,\n}\n\nconst recommendedRules: NonNullable<FlatConfig.Config['rules']> = Object.fromEntries(\n Object.keys(rules).map((id) => [`adk-media/${id}`, 'error'])\n)\n\n/**\n * Named config presets. `recommended` enables every rule at `error` and registers the plugin\n * under the `adk-media` namespace — spread it into a flat config to adopt the full set.\n */\nexport const configs = {\n recommended: {\n name: '@nhtio/adk/batteries/media/lint/recommended',\n plugins: { 'adk-media': plugin },\n rules: recommendedRules,\n } satisfies FlatConfig.Config,\n}\n\n/**\n * Default export bundles the plugin and its config presets, mirroring the shape ESLint flat\n * configs expect from a plugin module.\n */\nexport default { plugin, rules, configs }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAM,aAAa,yBAAA,YAAY,aAC5B,SAAS,2CAA2C,MACvD;AAIA,IAAM,iBAAiB;;;;;;AAOvB,IAAM,uBAAuB,WAAW;CACtC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,a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OAAO,OAAO,KAAK,MAAM;IAE9C;GACF;EACF;CACF,CAY0B;AAC1B;;;;;AAMA,IAAa,SAA4B;CACvC,MAAM;EAAE,MAAM;EAAmC,SAAA;CAAqB;CACtE;AACF;AAEA,IAAM,mBAA4D,OAAO,YACvE,OAAO,KAAK,KAAK,EAAE,KAAK,OAAO,CAAC,aAAa,MAAM,OAAO,CAAC,CAC7D;;;;;AAMA,IAAa,UAAU,EACrB,aAAa;CACX,MAAM;CACN,SAAS,EAAE,aAAa,OAAO;CAC/B,OAAO;AACT,EACF;;;;;AAMA,IAAA,eAAe;CAAE;CAAQ;CAAO;AAAQ"}
|
package/batteries/media/lint.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { a as resolveCalleeName, t as collectImportBindings } from "../../common-4_EYYb5H.mjs";
|
|
2
|
+
import "../../eslint/rules.mjs";
|
|
1
3
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
4
|
import { createRequire } from "node:module";
|
|
3
5
|
//#region src/batteries/media/lint.ts
|
|
@@ -371,33 +373,41 @@ var noShadowedEngine = createRule({
|
|
|
371
373
|
},
|
|
372
374
|
defaultOptions: [],
|
|
373
375
|
create(context) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
376
|
+
let bindings = /* @__PURE__ */ new Map();
|
|
377
|
+
return {
|
|
378
|
+
Program(node) {
|
|
379
|
+
bindings = collectImportBindings(node);
|
|
380
|
+
},
|
|
381
|
+
CallExpression(node) {
|
|
382
|
+
const resolved = resolveCalleeName(bindings, node.callee);
|
|
383
|
+
if (!resolved || resolved.name !== "createMediaPipeline") return;
|
|
384
|
+
if (resolved.imported && !resolved.fromAdk) return;
|
|
385
|
+
const config = node.arguments[0];
|
|
386
|
+
if (!config || config.type !== "ObjectExpression") return;
|
|
387
|
+
const engines = propOf(config, "engines");
|
|
388
|
+
if (!engines || engines.type !== "ArrayExpression") return;
|
|
389
|
+
const summaries = engines.elements.map((el) => el ? summarize(el) : void 0);
|
|
390
|
+
for (let i = 1; i < summaries.length; i++) {
|
|
391
|
+
const later = summaries[i];
|
|
392
|
+
if (!later) continue;
|
|
393
|
+
for (let j = 0; j < i; j++) {
|
|
394
|
+
const earlier = summaries[j];
|
|
395
|
+
if (!earlier) continue;
|
|
396
|
+
if (shadows(earlier, later)) {
|
|
397
|
+
context.report({
|
|
398
|
+
node: engines.elements[i],
|
|
399
|
+
messageId: "shadowed",
|
|
400
|
+
data: {
|
|
401
|
+
earlier: earlier.label,
|
|
402
|
+
later: later.label
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
397
407
|
}
|
|
398
408
|
}
|
|
399
409
|
}
|
|
400
|
-
}
|
|
410
|
+
};
|
|
401
411
|
}
|
|
402
412
|
});
|
|
403
413
|
var CONTRACTS_SUBPATH = "@nhtio/adk/batteries/media/contracts";
|
|
@@ -536,7 +546,7 @@ var rules = {
|
|
|
536
546
|
var plugin = {
|
|
537
547
|
meta: {
|
|
538
548
|
name: "@nhtio/adk/batteries/media/lint",
|
|
539
|
-
version: "0.1.0-master-
|
|
549
|
+
version: "0.1.0-master-642a4223"
|
|
540
550
|
},
|
|
541
551
|
rules
|
|
542
552
|
};
|