@nhtio/adk 1.20260912.0 → 1.20260921.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/CHANGELOG.md +74 -0
- package/artifact_methods-Cg0go7Q4.mjs +1 -0
- package/artifact_methods-SKgM322C.js +1 -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/dev-tools/forge.cjs +3 -3
- package/batteries/dev-tools/forge.mjs +3 -3
- package/batteries/dev-tools.cjs +2 -2
- package/batteries/dev-tools.mjs +2 -2
- package/batteries/encoding.cjs +7 -7
- package/batteries/encoding.mjs +7 -7
- package/batteries/generation/gemini/adapter.cjs +1 -1
- package/batteries/generation/gemini/adapter.mjs +1 -1
- package/batteries/generation/local_diffusion/adapter.cjs +2 -2
- package/batteries/generation/local_diffusion/adapter.mjs +2 -2
- package/batteries/generation/openai/adapter.cjs +1 -1
- package/batteries/generation/openai/adapter.mjs +1 -1
- package/batteries/isolation/browser.d.ts +1 -1
- package/batteries/isolation/child_process/transport.d.ts +2 -2
- package/batteries/isolation/child_process.cjs +4 -4
- package/batteries/isolation/child_process.cjs.map +1 -1
- package/batteries/isolation/child_process.mjs +4 -4
- package/batteries/isolation/child_process.mjs.map +1 -1
- package/batteries/isolation/codec.d.ts +2 -2
- package/batteries/isolation/crash_policy.d.ts +1 -1
- package/batteries/isolation/isolate_function.d.ts +2 -2
- package/batteries/isolation/protocol.d.ts +4 -4
- package/batteries/isolation/serve.d.ts +2 -2
- package/batteries/isolation/types.d.ts +4 -4
- package/batteries/isolation.cjs +1 -1
- package/batteries/isolation.mjs +1 -1
- package/batteries/llm/anthropic_messages/adapter.cjs +6 -6
- package/batteries/llm/anthropic_messages/adapter.cjs.map +1 -1
- package/batteries/llm/anthropic_messages/adapter.mjs +6 -6
- package/batteries/llm/anthropic_messages/adapter.mjs.map +1 -1
- package/batteries/llm/anthropic_messages/count_tokens.cjs +1 -1
- package/batteries/llm/anthropic_messages/count_tokens.mjs +1 -1
- package/batteries/llm/anthropic_messages/helpers.cjs +3 -3
- package/batteries/llm/anthropic_messages/helpers.mjs +3 -3
- package/batteries/llm/anthropic_messages/types.d.ts +2 -2
- package/batteries/llm/anthropic_messages/validation.cjs +3 -3
- package/batteries/llm/anthropic_messages/validation.cjs.map +1 -1
- package/batteries/llm/anthropic_messages/validation.mjs +3 -3
- package/batteries/llm/anthropic_messages/validation.mjs.map +1 -1
- package/batteries/llm/anthropic_messages.cjs +2 -2
- package/batteries/llm/anthropic_messages.mjs +2 -2
- package/batteries/llm/bedrock_converse/adapter.cjs +29 -7
- package/batteries/llm/bedrock_converse/adapter.cjs.map +1 -1
- package/batteries/llm/bedrock_converse/adapter.mjs +30 -8
- package/batteries/llm/bedrock_converse/adapter.mjs.map +1 -1
- package/batteries/llm/bedrock_converse/exceptions.cjs +3 -0
- package/batteries/llm/bedrock_converse/exceptions.cjs.map +1 -1
- package/batteries/llm/bedrock_converse/exceptions.d.ts +6 -0
- package/batteries/llm/bedrock_converse/exceptions.mjs +3 -1
- package/batteries/llm/bedrock_converse/exceptions.mjs.map +1 -1
- package/batteries/llm/bedrock_converse/helpers.cjs +1 -1
- package/batteries/llm/bedrock_converse/helpers.mjs +1 -1
- package/batteries/llm/bedrock_converse/types.d.ts +6 -2
- package/batteries/llm/bedrock_converse/validation.cjs +7 -1
- package/batteries/llm/bedrock_converse/validation.cjs.map +1 -1
- package/batteries/llm/bedrock_converse/validation.mjs +7 -1
- package/batteries/llm/bedrock_converse/validation.mjs.map +1 -1
- package/batteries/llm/bedrock_converse.cjs +2 -2
- package/batteries/llm/bedrock_converse.mjs +2 -2
- package/batteries/llm/claude_code_cli/adapter.cjs +6 -6
- package/batteries/llm/claude_code_cli/adapter.cjs.map +1 -1
- package/batteries/llm/claude_code_cli/adapter.mjs +6 -6
- package/batteries/llm/claude_code_cli/adapter.mjs.map +1 -1
- package/batteries/llm/claude_code_cli/helpers.cjs +3 -3
- package/batteries/llm/claude_code_cli/helpers.mjs +3 -3
- package/batteries/llm/claude_code_cli/types.d.ts +3 -2
- package/batteries/llm/claude_code_cli/validation.cjs +3 -3
- package/batteries/llm/claude_code_cli/validation.cjs.map +1 -1
- package/batteries/llm/claude_code_cli/validation.mjs +3 -3
- package/batteries/llm/claude_code_cli/validation.mjs.map +1 -1
- package/batteries/llm/claude_code_cli.cjs +1 -1
- package/batteries/llm/claude_code_cli.mjs +1 -1
- package/batteries/llm/gemini_generate_content/adapter.cjs +29 -7
- package/batteries/llm/gemini_generate_content/adapter.cjs.map +1 -1
- package/batteries/llm/gemini_generate_content/adapter.mjs +30 -8
- package/batteries/llm/gemini_generate_content/adapter.mjs.map +1 -1
- package/batteries/llm/gemini_generate_content/exceptions.cjs +3 -0
- package/batteries/llm/gemini_generate_content/exceptions.cjs.map +1 -1
- package/batteries/llm/gemini_generate_content/exceptions.d.ts +6 -0
- package/batteries/llm/gemini_generate_content/exceptions.mjs +3 -1
- package/batteries/llm/gemini_generate_content/exceptions.mjs.map +1 -1
- package/batteries/llm/gemini_generate_content/helpers.cjs +1 -1
- package/batteries/llm/gemini_generate_content/helpers.mjs +1 -1
- package/batteries/llm/gemini_generate_content/types.d.ts +7 -3
- package/batteries/llm/gemini_generate_content/validation.cjs +11 -2
- package/batteries/llm/gemini_generate_content/validation.cjs.map +1 -1
- package/batteries/llm/gemini_generate_content/validation.mjs +11 -2
- package/batteries/llm/gemini_generate_content/validation.mjs.map +1 -1
- package/batteries/llm/gemini_generate_content.cjs +1 -1
- package/batteries/llm/gemini_generate_content.mjs +1 -1
- package/batteries/llm/litert_lm/adapter.cjs +6 -6
- package/batteries/llm/litert_lm/adapter.cjs.map +1 -1
- package/batteries/llm/litert_lm/adapter.mjs +6 -6
- package/batteries/llm/litert_lm/adapter.mjs.map +1 -1
- package/batteries/llm/litert_lm/helpers.cjs +3 -3
- package/batteries/llm/litert_lm/helpers.mjs +3 -3
- package/batteries/llm/litert_lm/types.d.ts +2 -2
- package/batteries/llm/litert_lm/validation.cjs +3 -3
- package/batteries/llm/litert_lm/validation.cjs.map +1 -1
- package/batteries/llm/litert_lm/validation.mjs +3 -3
- package/batteries/llm/litert_lm/validation.mjs.map +1 -1
- package/batteries/llm/litert_lm.cjs +1 -1
- package/batteries/llm/litert_lm.mjs +1 -1
- package/batteries/llm/ollama/adapter.cjs +6 -6
- package/batteries/llm/ollama/adapter.cjs.map +1 -1
- package/batteries/llm/ollama/adapter.mjs +6 -6
- package/batteries/llm/ollama/adapter.mjs.map +1 -1
- package/batteries/llm/ollama/helpers.cjs +4 -4
- package/batteries/llm/ollama/helpers.mjs +4 -4
- package/batteries/llm/ollama/types.d.ts +2 -2
- package/batteries/llm/ollama/validation.cjs +3 -3
- package/batteries/llm/ollama/validation.cjs.map +1 -1
- package/batteries/llm/ollama/validation.mjs +3 -3
- package/batteries/llm/ollama/validation.mjs.map +1 -1
- package/batteries/llm/ollama.cjs +2 -2
- package/batteries/llm/ollama.mjs +2 -2
- package/batteries/llm/openai_chat_completions/adapter.cjs +6 -6
- package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -1
- package/batteries/llm/openai_chat_completions/adapter.mjs +6 -6
- package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -1
- package/batteries/llm/openai_chat_completions/helpers.cjs +4 -4
- package/batteries/llm/openai_chat_completions/helpers.mjs +4 -4
- package/batteries/llm/openai_chat_completions/types.d.ts +2 -2
- package/batteries/llm/openai_chat_completions/validation.cjs +3 -3
- package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -1
- package/batteries/llm/openai_chat_completions/validation.mjs +3 -3
- package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -1
- package/batteries/llm/openai_chat_completions.cjs +2 -2
- package/batteries/llm/openai_chat_completions.mjs +2 -2
- package/batteries/llm/openai_responses/adapter.cjs +6 -6
- package/batteries/llm/openai_responses/adapter.cjs.map +1 -1
- package/batteries/llm/openai_responses/adapter.mjs +6 -6
- package/batteries/llm/openai_responses/adapter.mjs.map +1 -1
- package/batteries/llm/openai_responses/helpers.cjs +3 -3
- package/batteries/llm/openai_responses/helpers.mjs +3 -3
- package/batteries/llm/openai_responses/types.d.ts +2 -2
- package/batteries/llm/openai_responses/validation.cjs +3 -3
- package/batteries/llm/openai_responses/validation.cjs.map +1 -1
- package/batteries/llm/openai_responses/validation.mjs +3 -3
- package/batteries/llm/openai_responses/validation.mjs.map +1 -1
- package/batteries/llm/openai_responses.cjs +2 -2
- package/batteries/llm/openai_responses.mjs +2 -2
- package/batteries/llm/transformers_js/adapter.cjs +6 -6
- package/batteries/llm/transformers_js/adapter.cjs.map +1 -1
- package/batteries/llm/transformers_js/adapter.mjs +6 -6
- package/batteries/llm/transformers_js/adapter.mjs.map +1 -1
- package/batteries/llm/transformers_js/helpers.cjs +3 -3
- package/batteries/llm/transformers_js/helpers.mjs +3 -3
- package/batteries/llm/transformers_js/types.d.ts +2 -2
- package/batteries/llm/transformers_js/validation.cjs +3 -3
- package/batteries/llm/transformers_js/validation.cjs.map +1 -1
- package/batteries/llm/transformers_js/validation.mjs +3 -3
- package/batteries/llm/transformers_js/validation.mjs.map +1 -1
- package/batteries/llm/transformers_js.cjs +1 -1
- package/batteries/llm/transformers_js.mjs +1 -1
- package/batteries/llm/webllm_chat_completions/adapter.cjs +6 -6
- package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -1
- package/batteries/llm/webllm_chat_completions/adapter.mjs +6 -6
- package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -1
- package/batteries/llm/webllm_chat_completions/helpers.cjs +1 -1
- package/batteries/llm/webllm_chat_completions/helpers.mjs +1 -1
- package/batteries/llm/webllm_chat_completions/validation.cjs +3 -3
- package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -1
- package/batteries/llm/webllm_chat_completions/validation.mjs +3 -3
- package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -1
- package/batteries/llm/webllm_chat_completions.cjs +2 -2
- package/batteries/llm/webllm_chat_completions.mjs +2 -2
- package/batteries/llm.cjs +2 -2
- package/batteries/llm.mjs +2 -2
- package/batteries/media/builder.d.ts +3 -0
- package/batteries/media/contracts.cjs.map +1 -1
- package/batteries/media/contracts.d.ts +40 -1
- package/batteries/media/contracts.mjs.map +1 -1
- package/batteries/media/engines/sharp.cjs +36 -2
- package/batteries/media/engines/sharp.cjs.map +1 -1
- package/batteries/media/engines/sharp.mjs +36 -2
- package/batteries/media/engines/sharp.mjs.map +1 -1
- package/batteries/media/forge.cjs +5 -5
- package/batteries/media/forge.mjs +5 -5
- package/batteries/media/index.d.ts +1 -1
- package/batteries/media/lint.cjs +3 -2
- package/batteries/media/lint.cjs.map +1 -1
- package/batteries/media/lint.mjs +3 -2
- package/batteries/media/lint.mjs.map +1 -1
- package/batteries/media.cjs +66 -2
- package/batteries/media.cjs.map +1 -1
- package/batteries/media.mjs +66 -2
- package/batteries/media.mjs.map +1 -1
- package/batteries/orchestration/conformance.cjs +123 -74
- package/batteries/orchestration/conformance.cjs.map +1 -1
- package/batteries/orchestration/conformance.d.ts +10 -8
- package/batteries/orchestration/conformance.mjs +54 -5
- package/batteries/orchestration/conformance.mjs.map +1 -1
- package/batteries/orchestration/dispatch_reasoner.cjs +4 -4
- package/batteries/orchestration/dispatch_reasoner.mjs +4 -4
- package/batteries/orchestration/executor.cjs +2 -2
- package/batteries/orchestration/executor.mjs +2 -2
- package/batteries/orchestration/forge.cjs +4 -4
- package/batteries/orchestration/forge.mjs +4 -4
- package/batteries/orchestration/validation.cjs +2 -2
- package/batteries/orchestration/validation.mjs +2 -2
- package/batteries/orchestration.cjs +4 -4
- package/batteries/orchestration.mjs +4 -4
- package/batteries/sandbox/contracts/policy_enforcer.d.ts +13 -1
- package/batteries/sandbox/js/compartment.d.ts +7 -2
- package/batteries/sandbox/js/exceptions.d.ts +4 -0
- package/batteries/sandbox/js/runner.d.ts +1 -1
- package/batteries/sandbox/js/service.d.ts +1 -1
- package/batteries/sandbox/js/ses_contracts.d.ts +4 -3
- package/batteries/sandbox/js.cjs +18 -9
- package/batteries/sandbox/js.cjs.map +1 -1
- package/batteries/sandbox/js.mjs +18 -10
- package/batteries/sandbox/js.mjs.map +1 -1
- package/batteries/sandbox/manager.d.ts +4 -3
- package/batteries/sandbox/node/srt_enforcer.d.ts +1 -1
- package/batteries/sandbox/node.cjs +36 -12
- package/batteries/sandbox/node.cjs.map +1 -1
- package/batteries/sandbox/node.mjs +36 -12
- package/batteries/sandbox/node.mjs.map +1 -1
- package/batteries/sandbox/tools.cjs +1 -1
- package/batteries/sandbox/tools.mjs +1 -1
- package/batteries/sandbox/types.d.ts +10 -1
- package/batteries/sandbox.cjs +28 -10
- package/batteries/sandbox.cjs.map +1 -1
- package/batteries/sandbox.mjs +29 -12
- package/batteries/sandbox.mjs.map +1 -1
- package/batteries/skills.cjs +8 -8
- package/batteries/skills.mjs +8 -8
- package/batteries/tools/_shared.cjs +1 -1
- package/batteries/tools/_shared.mjs +1 -1
- package/batteries/tools/color.cjs +2 -2
- package/batteries/tools/color.mjs +2 -2
- package/batteries/tools/comparison.cjs +2 -2
- package/batteries/tools/comparison.mjs +2 -2
- package/batteries/tools/data_structure.cjs +2 -2
- package/batteries/tools/data_structure.mjs +2 -2
- package/batteries/tools/datetime_extended.cjs +2 -2
- package/batteries/tools/datetime_extended.mjs +2 -2
- package/batteries/tools/datetime_math.cjs +2 -2
- package/batteries/tools/datetime_math.mjs +2 -2
- package/batteries/tools/encoding.cjs +2 -2
- package/batteries/tools/encoding.mjs +2 -2
- package/batteries/tools/formatting.cjs +2 -2
- package/batteries/tools/formatting.mjs +2 -2
- package/batteries/tools/geo_basics.cjs +2 -2
- package/batteries/tools/geo_basics.mjs +2 -2
- package/batteries/tools/math.cjs +2 -2
- package/batteries/tools/math.mjs +2 -2
- package/batteries/tools/memory.cjs +4 -4
- package/batteries/tools/memory.mjs +4 -4
- package/batteries/tools/parsing.cjs +3 -3
- package/batteries/tools/parsing.mjs +3 -3
- package/batteries/tools/retrievables.cjs +4 -4
- package/batteries/tools/retrievables.mjs +4 -4
- 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/standing_instructions.cjs +3 -3
- package/batteries/tools/standing_instructions.mjs +3 -3
- package/batteries/tools/statistics.cjs +3 -3
- package/batteries/tools/statistics.mjs +3 -3
- package/batteries/tools/string_processing.cjs +2 -2
- package/batteries/tools/string_processing.mjs +2 -2
- package/batteries/tools/structured_data.cjs +2 -2
- package/batteries/tools/structured_data.mjs +2 -2
- package/batteries/tools/text_analysis.cjs +3 -3
- package/batteries/tools/text_analysis.mjs +3 -3
- package/batteries/tools/text_comparison.cjs +2 -2
- package/batteries/tools/text_comparison.mjs +2 -2
- package/batteries/tools/time.cjs +2 -2
- package/batteries/tools/time.mjs +2 -2
- package/batteries/tools/unit_conversion.cjs +2 -2
- package/batteries/tools/unit_conversion.mjs +2 -2
- package/batteries/tools.cjs +2 -2
- package/batteries/tools.mjs +2 -2
- package/batteries/validation.cjs +4 -4
- package/batteries/validation.mjs +4 -4
- package/batteries/vector/chroma.cjs +1 -1
- package/batteries/vector/chroma.mjs +1 -1
- package/batteries/vector/clickhouse.cjs +1 -1
- package/batteries/vector/clickhouse.mjs +1 -1
- package/batteries/vector/cloudflare.cjs +1 -1
- package/batteries/vector/cloudflare.mjs +1 -1
- package/batteries/vector/conformance/index.d.ts +11 -16
- package/batteries/vector/conformance.cjs +107 -36
- package/batteries/vector/conformance.cjs.map +1 -1
- package/batteries/vector/conformance.mjs +84 -13
- package/batteries/vector/conformance.mjs.map +1 -1
- package/batteries/vector/couchbase.cjs +1 -1
- package/batteries/vector/couchbase.mjs +1 -1
- package/batteries/vector/duckdb.cjs +1 -1
- package/batteries/vector/duckdb.mjs +1 -1
- package/batteries/vector/elasticsearch.cjs +1 -1
- package/batteries/vector/elasticsearch.mjs +1 -1
- package/batteries/vector/hnswlib.cjs +1 -1
- package/batteries/vector/hnswlib.mjs +1 -1
- package/batteries/vector/in_memory.cjs +1 -1
- package/batteries/vector/in_memory.mjs +1 -1
- package/batteries/vector/lancedb.cjs +1 -1
- package/batteries/vector/lancedb.mjs +1 -1
- package/batteries/vector/mariadb.cjs +1 -1
- package/batteries/vector/mariadb.mjs +1 -1
- package/batteries/vector/milvus.cjs +1 -1
- package/batteries/vector/milvus.mjs +1 -1
- package/batteries/vector/opensearch.cjs +1 -1
- package/batteries/vector/opensearch.mjs +1 -1
- package/batteries/vector/oracle23ai.cjs +1 -1
- package/batteries/vector/oracle23ai.mjs +1 -1
- package/batteries/vector/orama.cjs +1 -1
- package/batteries/vector/orama.mjs +1 -1
- package/batteries/vector/pgvector.cjs +1 -1
- package/batteries/vector/pgvector.mjs +1 -1
- package/batteries/vector/pinecone.cjs +1 -1
- package/batteries/vector/pinecone.mjs +1 -1
- package/batteries/vector/qdrant.cjs +1 -1
- package/batteries/vector/qdrant.mjs +1 -1
- package/batteries/vector/redis.cjs +1 -1
- package/batteries/vector/redis.mjs +1 -1
- package/batteries/vector/retrievable.cjs +1 -1
- package/batteries/vector/retrievable.mjs +1 -1
- package/batteries/vector/s3vectors.cjs +1 -1
- package/batteries/vector/s3vectors.mjs +1 -1
- package/batteries/vector/sqlite_vec.cjs +1 -1
- package/batteries/vector/sqlite_vec.mjs +1 -1
- package/batteries/vector/typesense.cjs +1 -1
- package/batteries/vector/typesense.mjs +1 -1
- package/batteries/vector/vespa.cjs +1 -1
- package/batteries/vector/vespa.mjs +1 -1
- package/batteries/vector/weaviate.cjs +1 -1
- package/batteries/vector/weaviate.mjs +1 -1
- package/batteries/vector.cjs +1 -1
- package/batteries/vector.mjs +1 -1
- package/batteries.cjs +8 -8
- package/batteries.mjs +8 -8
- package/{chat_common-DXWHxn-w.js → chat_common-CBqn22t1.js} +2 -2
- package/{chat_common-DXWHxn-w.js.map → chat_common-CBqn22t1.js.map} +1 -1
- package/{chat_common-DNLnQBlM.mjs → chat_common-DKw8FDol.mjs} +2 -2
- package/{chat_common-DNLnQBlM.mjs.map → chat_common-DKw8FDol.mjs.map} +1 -1
- package/{common-Ddtq6naG.js → common-0rLuBEeY.js} +7 -7
- package/{common-Ddtq6naG.js.map → common-0rLuBEeY.js.map} +1 -1
- package/{common-DB7HRMf1.mjs → common-oI1niK9Z.mjs} +7 -7
- package/{common-DB7HRMf1.mjs.map → common-oI1niK9Z.mjs.map} +1 -1
- package/common.cjs +7 -7
- package/common.mjs +7 -7
- package/{dispatch_runner-xsvRLCo7.mjs → dispatch_runner-BZDXUe0G.mjs} +4 -4
- package/{dispatch_runner-xsvRLCo7.mjs.map → dispatch_runner-BZDXUe0G.mjs.map} +1 -1
- package/{dispatch_runner-DsLbcGwd.js → dispatch_runner-CKhm-scw.js} +4 -4
- package/{dispatch_runner-DsLbcGwd.js.map → dispatch_runner-CKhm-scw.js.map} +1 -1
- package/dispatch_runner.cjs +1 -1
- package/dispatch_runner.mjs +1 -1
- package/{ecmascript-BZAoi8W2.mjs → ecmascript-B9Z2C24U.mjs} +3 -3
- package/{ecmascript-BZAoi8W2.mjs.map → ecmascript-B9Z2C24U.mjs.map} +1 -1
- package/{ecmascript-dj5rP96h.js → ecmascript-DmrNI2Wo.js} +3 -3
- package/{ecmascript-dj5rP96h.js.map → ecmascript-DmrNI2Wo.js.map} +1 -1
- package/eslint/rules.cjs +1 -1
- package/eslint/rules.mjs +1 -1
- package/eslint.cjs +2 -2
- package/eslint.mjs +2 -2
- package/exceptions.cjs +1 -1
- package/exceptions.mjs +1 -1
- package/forge.cjs +2 -2
- package/forge.mjs +2 -2
- package/guards.cjs +7 -7
- package/guards.mjs +7 -7
- package/{helpers-gUUlDRfs.js → helpers-CObtMmAZ.js} +3 -3
- package/{helpers-gUUlDRfs.js.map → helpers-CObtMmAZ.js.map} +1 -1
- package/{helpers-CtGtJiyo.mjs → helpers-mbn_EsDV.mjs} +3 -3
- package/{helpers-CtGtJiyo.mjs.map → helpers-mbn_EsDV.mjs.map} +1 -1
- package/index.cjs +12 -12
- package/index.mjs +12 -12
- package/{isolation-BQCTQYZ_.js → isolation-7Jrcucgc.js} +11 -11
- package/isolation-7Jrcucgc.js.map +1 -0
- package/{isolation-7xbkc12r.mjs → isolation-CO0NiK8R.mjs} +11 -11
- package/isolation-CO0NiK8R.mjs.map +1 -0
- package/lib/classes/identity.d.ts +6 -3
- package/lib/classes/tokenizable.d.ts +2 -3
- package/mcp/adk-docs-corpus.json +2 -2
- package/package.json +405 -405
- package/{retrievable-DinM3DGL.js → retrievable-BTwjmPnl.js} +3 -3
- package/{retrievable-DinM3DGL.js.map → retrievable-BTwjmPnl.js.map} +1 -1
- package/{retrievable-gxOs7QaJ.mjs → retrievable-CXTAUuuv.mjs} +3 -3
- package/{retrievable-gxOs7QaJ.mjs.map → retrievable-CXTAUuuv.mjs.map} +1 -1
- package/{scrapper-C4HlXNKs.js → scrapper-CJexXXK-.js} +4 -4
- package/{scrapper-C4HlXNKs.js.map → scrapper-CJexXXK-.js.map} +1 -1
- package/{scrapper-COT5I9DB.mjs → scrapper-DiQ5FfDL.mjs} +4 -4
- package/{scrapper-COT5I9DB.mjs.map → scrapper-DiQ5FfDL.mjs.map} +1 -1
- package/{searxng-CRyUWb5a.mjs → searxng-BFTJ6rTE.mjs} +4 -4
- package/{searxng-CRyUWb5a.mjs.map → searxng-BFTJ6rTE.mjs.map} +1 -1
- package/{searxng-W9LO7hIU.js → searxng-DzlGZG4V.js} +4 -4
- package/{searxng-W9LO7hIU.js.map → searxng-DzlGZG4V.js.map} +1 -1
- package/server.json +2 -2
- package/skills/adk-assembly/SKILL.md +2 -2
- package/{spooled_artifact-CU1m9-te.js → spooled_artifact-BpcesRBv.js} +2 -2
- package/{spooled_artifact-CU1m9-te.js.map → spooled_artifact-BpcesRBv.js.map} +1 -1
- package/{spooled_artifact-W_0Y0N3U.mjs → spooled_artifact-Bw_7swIp.mjs} +2 -2
- package/{spooled_artifact-W_0Y0N3U.mjs.map → spooled_artifact-Bw_7swIp.mjs.map} +1 -1
- package/spooled_artifact.cjs +2 -2
- package/spooled_artifact.mjs +2 -2
- package/{spooled_markdown_artifact-FluUIAAV.mjs → spooled_markdown_artifact-vd6eNtIP.mjs} +3 -3
- package/{spooled_markdown_artifact-FluUIAAV.mjs.map → spooled_markdown_artifact-vd6eNtIP.mjs.map} +1 -1
- package/{spooled_markdown_artifact-DypwOWk4.js → spooled_markdown_artifact-wJPnE8Ij.js} +3 -3
- package/{spooled_markdown_artifact-DypwOWk4.js.map → spooled_markdown_artifact-wJPnE8Ij.js.map} +1 -1
- package/{thought-ZHgbMDhV.mjs → thought-CxSaF6Xf.mjs} +48 -7
- package/thought-CxSaF6Xf.mjs.map +1 -0
- package/{thought-tcs8Ayw5.js → thought-Dg_4UZxg.js} +47 -6
- package/thought-Dg_4UZxg.js.map +1 -0
- package/{tokenizable-Cc5XKez7.js → tokenizable-BMZuGWRd.js} +7 -1
- package/tokenizable-BMZuGWRd.js.map +1 -0
- package/{tokenizable-D_lz__Co.mjs → tokenizable-VB4Av8GF.mjs} +7 -1
- package/{tokenizable-D_lz__Co.mjs.map → tokenizable-VB4Av8GF.mjs.map} +1 -1
- package/{tool_call-T2OHWy4k.mjs → tool_call-Cfaj-6zK.mjs} +3 -3
- package/{tool_call-T2OHWy4k.mjs.map → tool_call-Cfaj-6zK.mjs.map} +1 -1
- package/{tool_call-CYc1yGp9.js → tool_call-Fs_Uh5wQ.js} +3 -3
- package/{tool_call-CYc1yGp9.js.map → tool_call-Fs_Uh5wQ.js.map} +1 -1
- package/{tools-DK7SUP6s.mjs → tools-D0MBDh2R.mjs} +6 -6
- package/{tools-DK7SUP6s.mjs.map → tools-D0MBDh2R.mjs.map} +1 -1
- package/{tools-th9347rw.js → tools-rJvfktHR.js} +6 -6
- package/{tools-th9347rw.js.map → tools-rJvfktHR.js.map} +1 -1
- package/{toon-C6XIUaSg.mjs → toon-BSTQnHed.mjs} +4 -4
- package/{toon-C6XIUaSg.mjs.map → toon-BSTQnHed.mjs.map} +1 -1
- package/{toon-C0FZwoup.js → toon-BXPdJRz7.js} +4 -4
- package/{toon-C0FZwoup.js.map → toon-BXPdJRz7.js.map} +1 -1
- package/{turn_runner-BF5eYyLW.mjs → turn_runner-BHHD6h77.mjs} +4 -4
- package/{turn_runner-BF5eYyLW.mjs.map → turn_runner-BHHD6h77.mjs.map} +1 -1
- package/{turn_runner-EYHRPt_r.js → turn_runner-DhLI7OTH.js} +4 -4
- package/{turn_runner-EYHRPt_r.js.map → turn_runner-DhLI7OTH.js.map} +1 -1
- package/turn_runner.cjs +1 -1
- package/turn_runner.mjs +1 -1
- package/types-D6X_aUIb.mjs.map +1 -1
- package/types-DrSosVaM.js.map +1 -1
- package/{validate-lzy9nG_E.mjs → validate-Bi7FGjoq.mjs} +13 -1
- package/{validate-lzy9nG_E.mjs.map → validate-Bi7FGjoq.mjs.map} +1 -1
- package/{validate-CdOS7S2u.js → validate-CkQI-48O.js} +13 -1
- package/{validate-CdOS7S2u.js.map → validate-CkQI-48O.js.map} +1 -1
- package/{xml-C_FSMBjJ.js → xml-CNmgj5Qq.js} +4 -4
- package/{xml-C_FSMBjJ.js.map → xml-CNmgj5Qq.js.map} +1 -1
- package/{xml-BpnJipVO.mjs → xml-CYseDztH.mjs} +4 -4
- package/{xml-BpnJipVO.mjs.map → xml-CYseDztH.mjs.map} +1 -1
- package/{yaml-DAOMzSM3.mjs → yaml-BPBoiOjx.mjs} +4 -4
- package/{yaml-DAOMzSM3.mjs.map → yaml-BPBoiOjx.mjs.map} +1 -1
- package/{yaml-BKeWsvft.js → yaml-CaoIJyRe.js} +4 -4
- package/{yaml-BKeWsvft.js.map → yaml-CaoIJyRe.js.map} +1 -1
- package/artifact_methods-BUCRNQrh.js +0 -1
- package/artifact_methods-CjCGzlP-.mjs +0 -1
- package/isolation-7xbkc12r.mjs.map +0 -1
- package/isolation-BQCTQYZ_.js.map +0 -1
- package/thought-ZHgbMDhV.mjs.map +0 -1
- package/thought-tcs8Ayw5.js.map +0 -1
- package/tokenizable-Cc5XKez7.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,68 @@ you *when* you got it, not *what changed*: a `^` range will float across battery
|
|
|
15
15
|
breaking changes, so pin an exact version if you need stability and read the entry before
|
|
16
16
|
upgrading.
|
|
17
17
|
|
|
18
|
+
## 2026-09-21
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **`@nhtio/adk/batteries/encoding` — a live `Identity` instance now encodes losslessly** (closes
|
|
23
|
+
issue #38). Constructing an ADK primitive (e.g. `Thought`/`Message`) from a live `Identity`
|
|
24
|
+
instance — as the runtime hands to storage callbacks — and then calling `encode()` threw
|
|
25
|
+
`E_ENCODING_FAILED`. Root cause: `Identity.schema` was a bare `validator.object` fragment, and a
|
|
26
|
+
Joi object schema *clones* whatever it validates; cloning an `Identity` produced a look-alike with
|
|
27
|
+
the right prototype but no private fields (the constructor never ran), so `[ENCODE_METHOD]` threw
|
|
28
|
+
reading them. `Identity.schema` is now an `alternatives(customPassthrough, rawObjectSchema)` that
|
|
29
|
+
returns a live instance unchanged — mirroring `Tokenizable.schema` — so string, `RawIdentity`, and
|
|
30
|
+
live-`Identity` inputs all encode and round-trip identically. The passthrough trusts an
|
|
31
|
+
unforgeable per-instance brand (a module-private `WeakSet` populated in the constructor), not a
|
|
32
|
+
`constructor.name` match, so a hand-rolled look-alike cannot bypass validation. Any non-branded
|
|
33
|
+
value — a plain `RawIdentity`, a hand-rolled look-alike, or a **foreign/cross-realm `Identity`**
|
|
34
|
+
(a second copy of the package in the dependency tree, which Joi clones into a prototype-only husk
|
|
35
|
+
with no private fields) — is rebuilt into a genuine local `Identity` after field validation, so
|
|
36
|
+
every consumer stores real, encodable state and a malformed value is rejected rather than retained
|
|
37
|
+
as a husk. An audit of the whole encodable surface (Tokenizable, Memory, Message, Thought,
|
|
38
|
+
Retrievable, ToolCall, Registry, Media, Tool, ToolRegistry) confirmed `Identity` was the only
|
|
39
|
+
affected schema; the rest already nest live instances through custom passthroughs or store them
|
|
40
|
+
without a validating clone.
|
|
41
|
+
|
|
42
|
+
### Internal
|
|
43
|
+
|
|
44
|
+
- **CI — the Node smoke sandbox installs the optional `@toon-format/toon` peer.** The TOON artifact
|
|
45
|
+
battery declares `@toon-format/toon` as an optional peer, but it was missing from the smoke job's
|
|
46
|
+
peer-install list, so the published-package smoke check exercised the TOON converter without its
|
|
47
|
+
parser present and the round-trip spec failed on master. Added it to `smoketester add`.
|
|
48
|
+
- **Tests — the orchestration end-to-end smoke spec imports from `@nhtio/adk`, not `src/`.** The spec
|
|
49
|
+
imported via relative `../../../../src/*` paths, which do not exist in the installed-package smoke
|
|
50
|
+
sandbox; it now imports the public subpaths like every other functional spec.
|
|
51
|
+
|
|
52
|
+
## 2026-09-13
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- **LLM batteries — token accounting opt-out is typed and honoured.** Every adapter's
|
|
57
|
+
`tokenEncoding` option now accepts `TokenEncodingId | null`, matching the runtime schema
|
|
58
|
+
(which already defaulted to `null` to opt out of tiktoken accounting) so the public TypeScript
|
|
59
|
+
surface no longer rejects the documented opt-out. Unregistered encodings fall back to a
|
|
60
|
+
`text.length` heuristic instead of the previous fixed divisor. Bedrock Converse and Gemini
|
|
61
|
+
Generate Content additionally gained parity fixes: null-safe token accounting, corrected
|
|
62
|
+
preflight tool-overhead margins, and validation that mirrors the shared contract.
|
|
63
|
+
|
|
64
|
+
- **`@nhtio/adk/batteries/media` — repeated `image.annotate()` steps compose instead of
|
|
65
|
+
overwriting.** Fusing an image pipeline now concatenates the shape lists of every `annotate`
|
|
66
|
+
step in chronological order rather than keeping only the last, so
|
|
67
|
+
`.image.annotate(a).image.annotate(b)` marks the frame with `a` then `b`. Animated inputs are
|
|
68
|
+
annotated on every frame (the sharp `animated` option is applied on the source), and SVG
|
|
69
|
+
overlay geometry is validated.
|
|
70
|
+
|
|
71
|
+
- **`@nhtio/adk/batteries/sandbox` — abort listeners are released on every terminal path.**
|
|
72
|
+
The caller-signal forwarding listener is now removed idempotently on both child `error` and
|
|
73
|
+
`close`, so a failed spawn or a completed run no longer retains its `AbortController` (which
|
|
74
|
+
could kill a recycled PID). The run-abort listener is likewise released when the run settles.
|
|
75
|
+
|
|
76
|
+
- **`@nhtio/adk/batteries/vector` conformance — decoupled and sequential.** The shared
|
|
77
|
+
conformance suite runs its checks sequentially to avoid backend constraint races, clears its
|
|
78
|
+
timeout timers on every settlement path, and no longer depends on a test framework.
|
|
79
|
+
|
|
18
80
|
## 2026-09-12
|
|
19
81
|
|
|
20
82
|
### Added
|
|
@@ -45,6 +107,18 @@ upgrading.
|
|
|
45
107
|
silently reinterpreted; when omitted the wrapper sniffs the returned shape. A prebuilt
|
|
46
108
|
`SpooledArtifact` is still refused, since it would bypass the deployer's artifact binding.
|
|
47
109
|
|
|
110
|
+
### Fixed
|
|
111
|
+
|
|
112
|
+
- **`gemini_generate_content` — `unsupportedMediaPolicy` schema now matches the other LLM
|
|
113
|
+
batteries and its own type.** The options schema declared `unsupportedMediaPolicy` as a bare
|
|
114
|
+
`string`, so it accepted any string and rejected the valid
|
|
115
|
+
`{ mode: 'fallback-stash'; stashKeys: string[] }` object that the `UnsupportedMediaPolicy` union
|
|
116
|
+
(and `anthropic_messages`, `ollama`, `openai_chat_completions`) permit. It is now the same
|
|
117
|
+
alternatives schema — the `'throw' | 'fallback-stash' | 'synthetic-description'` enum or the
|
|
118
|
+
`{ mode, stashKeys }` object, defaulting to `'throw'` — so a consumer building validation from the
|
|
119
|
+
exported schema treats the option consistently across batteries, and a valid object value no
|
|
120
|
+
longer fails validation on Gemini.
|
|
121
|
+
|
|
48
122
|
## 2026-09-11
|
|
49
123
|
|
|
50
124
|
### Fixed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./common-oI1niK9Z.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("./common-0rLuBEeY.js");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_ecmascript = require("../../ecmascript-
|
|
3
|
+
const require_ecmascript = require("../../ecmascript-DmrNI2Wo.js");
|
|
4
4
|
exports.E_TYPESCRIPT_PEER_MISSING = require_ecmascript.E_TYPESCRIPT_PEER_MISSING;
|
|
5
5
|
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-B9Z2C24U.mjs";
|
|
2
2
|
export { E_TYPESCRIPT_PEER_MISSING, SpooledEcmaScriptArtifact };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_toon = require("../../toon-
|
|
3
|
+
const require_toon = require("../../toon-BXPdJRz7.js");
|
|
4
4
|
exports.E_TOON_DECODE_FAILED = require_toon.E_TOON_DECODE_FAILED;
|
|
5
5
|
exports.E_TOON_PEER_MISSING = require_toon.E_TOON_PEER_MISSING;
|
|
6
6
|
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-BSTQnHed.mjs";
|
|
2
2
|
export { E_TOON_DECODE_FAILED, E_TOON_PEER_MISSING, SpooledToonArtifact, jsonToToonTool, toonToJsonTool };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_xml = require("../../xml-
|
|
3
|
+
const require_xml = require("../../xml-CNmgj5Qq.js");
|
|
4
4
|
exports.E_XML_PARSER_PEER_MISSING = require_xml.E_XML_PARSER_PEER_MISSING;
|
|
5
5
|
exports.E_XML_PARSE_FAILED = require_xml.E_XML_PARSE_FAILED;
|
|
6
6
|
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-CYseDztH.mjs";
|
|
2
2
|
export { E_XML_PARSER_PEER_MISSING, E_XML_PARSE_FAILED, SpooledXmlArtifact, jsonToXmlTool, xmlToJsonTool };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_yaml = require("../../yaml-
|
|
3
|
+
const require_yaml = require("../../yaml-CaoIJyRe.js");
|
|
4
4
|
exports.E_YAML_PARSE_ERROR = require_yaml.E_YAML_PARSE_ERROR;
|
|
5
5
|
exports.E_YAML_PEER_MISSING = require_yaml.E_YAML_PEER_MISSING;
|
|
6
6
|
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-BPBoiOjx.mjs";
|
|
2
2
|
export { E_YAML_PARSE_ERROR, E_YAML_PEER_MISSING, SpooledYamlArtifact, jsonToYamlTool, yamlToJsonTool };
|
package/batteries/artifacts.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_toon = require("../toon-
|
|
4
|
-
const require_yaml = require("../yaml-
|
|
5
|
-
const require_xml = require("../xml-
|
|
6
|
-
const require_ecmascript = require("../ecmascript-
|
|
3
|
+
const require_toon = require("../toon-BXPdJRz7.js");
|
|
4
|
+
const require_yaml = require("../yaml-CaoIJyRe.js");
|
|
5
|
+
const require_xml = require("../xml-CNmgj5Qq.js");
|
|
6
|
+
const require_ecmascript = require("../ecmascript-DmrNI2Wo.js");
|
|
7
7
|
//#region src/batteries/artifacts/index.ts
|
|
8
8
|
/**
|
|
9
9
|
* 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-BSTQnHed.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-BPBoiOjx.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-CYseDztH.mjs";
|
|
4
|
+
import { n as E_TYPESCRIPT_PEER_MISSING, t as SpooledEcmaScriptArtifact } from "../ecmascript-B9Z2C24U.mjs";
|
|
5
5
|
//#region src/batteries/artifacts/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* Registers the four artifact classes with the '@nhtio/encoder' decoder.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_spooled_artifact = require("../../spooled_artifact-
|
|
4
|
-
require("../../common-
|
|
5
|
-
const require_spooled_markdown_artifact = require("../../spooled_markdown_artifact-
|
|
3
|
+
const require_spooled_artifact = require("../../spooled_artifact-BpcesRBv.js");
|
|
4
|
+
require("../../common-0rLuBEeY.js");
|
|
5
|
+
const require_spooled_markdown_artifact = require("../../spooled_markdown_artifact-wJPnE8Ij.js");
|
|
6
6
|
const require_arg_specs = require("../../arg_specs-iYmIM3wI.js");
|
|
7
7
|
let _nhtio_validation = require("@nhtio/validation");
|
|
8
8
|
//#region src/batteries/dev_tools/forge.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p as Tool } from "../../spooled_artifact-
|
|
2
|
-
import "../../common-
|
|
3
|
-
import { n as SpooledJsonArtifact } from "../../spooled_markdown_artifact-
|
|
1
|
+
import { p as Tool } from "../../spooled_artifact-Bw_7swIp.mjs";
|
|
2
|
+
import "../../common-oI1niK9Z.mjs";
|
|
3
|
+
import { n as SpooledJsonArtifact } from "../../spooled_markdown_artifact-vd6eNtIP.mjs";
|
|
4
4
|
import { t as DEV_ARG_SPECS } from "../../arg_specs-H1qM_1QI.mjs";
|
|
5
5
|
import { validator } from "@nhtio/validation";
|
|
6
6
|
//#region src/batteries/dev_tools/forge.ts
|
package/batteries/dev-tools.cjs
CHANGED
|
@@ -2,12 +2,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
require("../chunk-Cek0wNdY.js");
|
|
3
3
|
const require_exceptions = require("../exceptions-DrHnAGQz.js");
|
|
4
4
|
const require_guards = require("../guards-05Uq3J4M.js");
|
|
5
|
-
const require_tokenizable = require("../tokenizable-
|
|
5
|
+
const require_tokenizable = require("../tokenizable-BMZuGWRd.js");
|
|
6
6
|
require("../factories.cjs");
|
|
7
7
|
require("../exceptions.cjs");
|
|
8
8
|
require("../guards.cjs");
|
|
9
9
|
const require_types = require("../types-DrSosVaM.js");
|
|
10
|
-
const require_tools = require("../tools-
|
|
10
|
+
const require_tools = require("../tools-rJvfktHR.js");
|
|
11
11
|
const require_fs_node = require("../fs_node-WwUEiuo6.js");
|
|
12
12
|
const require_patch = require("../patch-BXX9Q0FM.js");
|
|
13
13
|
const require_arg_specs = require("../arg_specs-iYmIM3wI.js");
|
package/batteries/dev-tools.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as createException } from "../exceptions-DRYLe-J4.mjs";
|
|
2
2
|
import { n as isInstanceOf, r as isObject, t as isError } from "../guards-BEpY7lBI.mjs";
|
|
3
|
-
import { D as E_LLM_EXECUTION_GATE_NOT_SUPPORTED } from "../tokenizable-
|
|
3
|
+
import { D as E_LLM_EXECUTION_GATE_NOT_SUPPORTED } from "../tokenizable-VB4Av8GF.mjs";
|
|
4
4
|
import "../factories.mjs";
|
|
5
5
|
import "../exceptions.mjs";
|
|
6
6
|
import "../guards.mjs";
|
|
7
7
|
import { h as createExistingSymlinkGuard, m as classifySandboxPathRejection, v as normalizeSandboxPath } from "../types-D6X_aUIb.mjs";
|
|
8
|
-
import { i as narratingPath, p as resolveMime } from "../tools-
|
|
8
|
+
import { i as narratingPath, p as resolveMime } from "../tools-D0MBDh2R.mjs";
|
|
9
9
|
import { r as createFsNode } from "../fs_node-Cg__jYMW.mjs";
|
|
10
10
|
import { a as parseStructuredPatch, c as runOnion, i as normalizeWorkspacePath, n as applyUpdateHunks, o as decodeText, r as isStructuredPatch, s as isTextual, t as applyOperations } from "../patch-BbC0U8aR.mjs";
|
|
11
11
|
import { t as DEV_ARG_SPECS } from "../arg_specs-H1qM_1QI.mjs";
|
package/batteries/encoding.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_tokenizable = require("../tokenizable-
|
|
4
|
-
const require_spooled_artifact = require("../spooled_artifact-
|
|
5
|
-
const require_thought = require("../thought-
|
|
6
|
-
const require_retrievable = require("../retrievable-
|
|
7
|
-
const require_tool_call = require("../tool_call-
|
|
8
|
-
const require_common = require("../common-
|
|
9
|
-
const require_spooled_markdown_artifact = require("../spooled_markdown_artifact-
|
|
3
|
+
const require_tokenizable = require("../tokenizable-BMZuGWRd.js");
|
|
4
|
+
const require_spooled_artifact = require("../spooled_artifact-BpcesRBv.js");
|
|
5
|
+
const require_thought = require("../thought-Dg_4UZxg.js");
|
|
6
|
+
const require_retrievable = require("../retrievable-BTwjmPnl.js");
|
|
7
|
+
const require_tool_call = require("../tool_call-Fs_Uh5wQ.js");
|
|
8
|
+
const require_common = require("../common-0rLuBEeY.js");
|
|
9
|
+
const require_spooled_markdown_artifact = require("../spooled_markdown_artifact-wJPnE8Ij.js");
|
|
10
10
|
require("../index.cjs");
|
|
11
11
|
const require_batteries_storage_in_memory = require("./storage/in_memory.cjs");
|
|
12
12
|
let _nhtio_encoder = require("@nhtio/encoder");
|
package/batteries/encoding.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { r as Tokenizable } from "../tokenizable-
|
|
2
|
-
import { c as resolveMediaReader, d as ToolRegistry, f as ArtifactTool, g as Registry, l as resolveSpoolReader, o as registerMediaReaderResolver, p as Tool, s as registerSpoolReaderResolver, t as SpooledArtifact } from "../spooled_artifact-
|
|
3
|
-
import { i as Identity, n as Message, r as Memory, t as Thought } from "../thought-
|
|
4
|
-
import { t as Retrievable } from "../retrievable-
|
|
5
|
-
import { n as Media, o as decodeBase64, t as ToolCall } from "../tool_call-
|
|
6
|
-
import { a as inMemoryMediaReader, n as MEDIA_READER_TAG_IN_MEMORY, r as fromFetch, t as MEDIA_READER_TAG_FETCH } from "../common-
|
|
7
|
-
import { n as SpooledJsonArtifact, t as SpooledMarkdownArtifact } from "../spooled_markdown_artifact-
|
|
1
|
+
import { r as Tokenizable } from "../tokenizable-VB4Av8GF.mjs";
|
|
2
|
+
import { c as resolveMediaReader, d as ToolRegistry, f as ArtifactTool, g as Registry, l as resolveSpoolReader, o as registerMediaReaderResolver, p as Tool, s as registerSpoolReaderResolver, t as SpooledArtifact } from "../spooled_artifact-Bw_7swIp.mjs";
|
|
3
|
+
import { i as Identity, n as Message, r as Memory, t as Thought } from "../thought-CxSaF6Xf.mjs";
|
|
4
|
+
import { t as Retrievable } from "../retrievable-CXTAUuuv.mjs";
|
|
5
|
+
import { n as Media, o as decodeBase64, t as ToolCall } from "../tool_call-Cfaj-6zK.mjs";
|
|
6
|
+
import { a as inMemoryMediaReader, n as MEDIA_READER_TAG_IN_MEMORY, r as fromFetch, t as MEDIA_READER_TAG_FETCH } from "../common-oI1niK9Z.mjs";
|
|
7
|
+
import { n as SpooledJsonArtifact, t as SpooledMarkdownArtifact } from "../spooled_markdown_artifact-vd6eNtIP.mjs";
|
|
8
8
|
import "../index.mjs";
|
|
9
9
|
import { InMemorySpoolReader, SPOOL_READER_TAG_IN_MEMORY } from "./storage/in_memory.mjs";
|
|
10
10
|
import { registerClass } from "@nhtio/encoder";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../../chunk-Cek0wNdY.js");
|
|
3
3
|
const require_guards = require("../../../guards-05Uq3J4M.js");
|
|
4
|
-
const require_tool_call = require("../../../tool_call-
|
|
4
|
+
const require_tool_call = require("../../../tool_call-Fs_Uh5wQ.js");
|
|
5
5
|
require("../../../guards.cjs");
|
|
6
6
|
const require_lib_utils_retry = require("../../../lib/utils/retry.cjs");
|
|
7
7
|
const require_batteries_generation__shared = require("../_shared.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as isError } from "../../../guards-BEpY7lBI.mjs";
|
|
2
|
-
import { o as decodeBase64, s as encodeBase64 } from "../../../tool_call-
|
|
2
|
+
import { o as decodeBase64, s as encodeBase64 } from "../../../tool_call-Cfaj-6zK.mjs";
|
|
3
3
|
import "../../../guards.mjs";
|
|
4
4
|
import { computeBackoff, parseRetryAfter, sleepWithJitter } from "../../../lib/utils/retry.mjs";
|
|
5
5
|
import { toBytes } from "../_shared.mjs";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../../chunk-Cek0wNdY.js");
|
|
3
3
|
const require_guards = require("../../../guards-05Uq3J4M.js");
|
|
4
|
-
const require_tool_call = require("../../../tool_call-
|
|
4
|
+
const require_tool_call = require("../../../tool_call-Fs_Uh5wQ.js");
|
|
5
5
|
require("../../../guards.cjs");
|
|
6
6
|
const require_lifecycle = require("../../../lifecycle-vYQJ2rmf.js");
|
|
7
7
|
const require_batteries_generation__shared = require("../_shared.cjs");
|
|
8
8
|
const require_batteries_generation_local_diffusion_exceptions = require("./exceptions.cjs");
|
|
9
|
-
const require_batteries_generation_local_diffusion_validation = require("./validation.cjs");
|
|
10
9
|
const require_batteries_generation_local_diffusion_protocol = require("./protocol.cjs");
|
|
10
|
+
const require_batteries_generation_local_diffusion_validation = require("./validation.cjs");
|
|
11
11
|
//#region src/batteries/generation/local_diffusion/adapter.ts
|
|
12
12
|
/** Node-only local diffusion generation adapter.
|
|
13
13
|
* @module @nhtio/adk/batteries/generation/local_diffusion/adapter
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as isError } from "../../../guards-BEpY7lBI.mjs";
|
|
2
|
-
import { o as decodeBase64, s as encodeBase64 } from "../../../tool_call-
|
|
2
|
+
import { o as decodeBase64, s as encodeBase64 } from "../../../tool_call-Cfaj-6zK.mjs";
|
|
3
3
|
import "../../../guards.mjs";
|
|
4
4
|
import { n as emitLifecycle } from "../../../lifecycle-C4kwYJ-N.mjs";
|
|
5
5
|
import { toBytes } from "../_shared.mjs";
|
|
6
6
|
import { E_LOCAL_DIFFUSION_ABORTED, E_LOCAL_DIFFUSION_BACKEND_ERROR, E_LOCAL_DIFFUSION_BUSY, E_LOCAL_DIFFUSION_DISPOSED, E_LOCAL_DIFFUSION_MALFORMED_FRAME, E_LOCAL_DIFFUSION_REQUEST_TIMEOUT, E_LOCAL_DIFFUSION_STARTUP_TIMEOUT } from "./exceptions.mjs";
|
|
7
|
-
import { validateOptions } from "./validation.mjs";
|
|
8
7
|
import { DEFAULT_PROTOCOL, buildEditCommand, buildGenerateCommand, buildShutdownCommand, buildStopCommand, createFrameReader } from "./protocol.mjs";
|
|
8
|
+
import { validateOptions } from "./validation.mjs";
|
|
9
9
|
//#region src/batteries/generation/local_diffusion/adapter.ts
|
|
10
10
|
/** Node-only local diffusion generation adapter.
|
|
11
11
|
* @module @nhtio/adk/batteries/generation/local_diffusion/adapter
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../../chunk-Cek0wNdY.js");
|
|
3
3
|
const require_guards = require("../../../guards-05Uq3J4M.js");
|
|
4
|
-
const require_tool_call = require("../../../tool_call-
|
|
4
|
+
const require_tool_call = require("../../../tool_call-Fs_Uh5wQ.js");
|
|
5
5
|
require("../../../guards.cjs");
|
|
6
6
|
const require_lib_utils_retry = require("../../../lib/utils/retry.cjs");
|
|
7
7
|
const require_batteries_generation__shared = require("../_shared.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as isError } from "../../../guards-BEpY7lBI.mjs";
|
|
2
|
-
import { o as decodeBase64 } from "../../../tool_call-
|
|
2
|
+
import { o as decodeBase64 } from "../../../tool_call-Cfaj-6zK.mjs";
|
|
3
3
|
import "../../../guards.mjs";
|
|
4
4
|
import { computeBackoff, parseRetryAfter, sleepWithJitter } from "../../../lib/utils/retry.mjs";
|
|
5
5
|
import { toBytes } from "../_shared.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Web Worker {@link IsolationTransport} + `spawnIsolated` convenience
|
|
2
|
+
* Web Worker {@link IsolationTransport} + `spawnIsolated` convenience for browser isolation.
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
5
|
* Implements the `IsolationTransport`/`PortLike` ducks declared (and treated as a read-only contract) in
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* This module is NODE-ONLY: it imports `node:child_process` directly (unlike `serve.ts`'s guest-side
|
|
8
8
|
* duck detection, which never imports `node:*` so it stays loadable in a Worker/browser bundle). See
|
|
9
9
|
* this subpath's `index.ts` for why a real process — rather than a `worker_threads` `Worker` — is the
|
|
10
|
-
* right host-side primitive for
|
|
10
|
+
* right host-side primitive for the Node transport.
|
|
11
11
|
*
|
|
12
12
|
* Two ways to obtain the child:
|
|
13
13
|
*
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* type's doc for the exact surface this module was empirically verified against, including execa≥9.
|
|
31
31
|
*
|
|
32
32
|
* These two forms are mutually exclusive and validated eagerly (this subpath's own local joi schema —
|
|
33
|
-
*
|
|
33
|
+
* the shared `validation.ts` is not touched).
|
|
34
34
|
*
|
|
35
35
|
* `terminate()` sends `SIGTERM` (or the caller's configured signal) and does NOT itself wait for exit
|
|
36
36
|
* or run any grace period of its own — `host.ts`'s `dispose()` already sends a `shutdown` envelope and
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
require("../../chunk-Cek0wNdY.js");
|
|
3
3
|
const require_guards = require("../../guards-05Uq3J4M.js");
|
|
4
4
|
require("../../guards.cjs");
|
|
5
|
-
const require_isolation = require("../../isolation-
|
|
5
|
+
const require_isolation = require("../../isolation-7Jrcucgc.js");
|
|
6
6
|
let _nhtio_validation = require("@nhtio/validation");
|
|
7
7
|
let node_child_process = require("node:child_process");
|
|
8
8
|
//#region src/batteries/isolation/child_process/transport.ts
|
|
@@ -15,7 +15,7 @@ let node_child_process = require("node:child_process");
|
|
|
15
15
|
* This module is NODE-ONLY: it imports `node:child_process` directly (unlike `serve.ts`'s guest-side
|
|
16
16
|
* duck detection, which never imports `node:*` so it stays loadable in a Worker/browser bundle). See
|
|
17
17
|
* this subpath's `index.ts` for why a real process — rather than a `worker_threads` `Worker` — is the
|
|
18
|
-
* right host-side primitive for
|
|
18
|
+
* right host-side primitive for the Node transport.
|
|
19
19
|
*
|
|
20
20
|
* Two ways to obtain the child:
|
|
21
21
|
*
|
|
@@ -38,7 +38,7 @@ let node_child_process = require("node:child_process");
|
|
|
38
38
|
* type's doc for the exact surface this module was empirically verified against, including execa≥9.
|
|
39
39
|
*
|
|
40
40
|
* These two forms are mutually exclusive and validated eagerly (this subpath's own local joi schema —
|
|
41
|
-
*
|
|
41
|
+
* the shared `validation.ts` is not touched).
|
|
42
42
|
*
|
|
43
43
|
* `terminate()` sends `SIGTERM` (or the caller's configured signal) and does NOT itself wait for exit
|
|
44
44
|
* or run any grace period of its own — `host.ts`'s `dispose()` already sends a `shutdown` envelope and
|
|
@@ -52,7 +52,7 @@ let node_child_process = require("node:child_process");
|
|
|
52
52
|
*/
|
|
53
53
|
var isValidationError = (value) => require_guards.isError(value) && Array.isArray(value.details);
|
|
54
54
|
var formatValidationDetails = (err) => err.details.map((d) => d.message).join(" and ");
|
|
55
|
-
/** Local (this-subpath-only) validator for the spawn-shape half of {@link ForkIsolatedOptions} —
|
|
55
|
+
/** Local (this-subpath-only) validator for the spawn-shape half of {@link ForkIsolatedOptions} — the
|
|
56
56
|
* shared `validation.ts` is not modified; this schema only covers the fields this module adds. */
|
|
57
57
|
var forkIsolatedSpawnShapeSchema = _nhtio_validation.validator.object({
|
|
58
58
|
modulePath: _nhtio_validation.validator.alternatives(_nhtio_validation.validator.string().min(1), _nhtio_validation.validator.custom((v, h) => require_guards.isInstanceOf(v, "URL", URL) ? v : h.error("any.invalid"))).optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child_process.cjs","names":[],"sources":["../../../src/batteries/isolation/child_process/transport.ts"],"sourcesContent":["/**\n * Node `child_process`-backed {@link @nhtio/adk/batteries/isolation!IsolationTransport} — forks (or\n * BYO-spawns) a guest process and wraps its IPC channel in the `PortLike` duck the wire protocol is\n * built over.\n *\n * @remarks\n * This module is NODE-ONLY: it imports `node:child_process` directly (unlike `serve.ts`'s guest-side\n * duck detection, which never imports `node:*` so it stays loadable in a Worker/browser bundle). See\n * this subpath's `index.ts` for why a real process — rather than a `worker_threads` `Worker` — is the\n * right host-side primitive for WP3.\n *\n * Two ways to obtain the child:\n *\n * - `{ modulePath, forkOptions? }` — the common case. Calls node's own `child_process.fork(modulePath,\n * forkOptions)`. Unless the caller's `forkOptions` explicitly sets `serialization`, this pins\n * `serialization: 'advanced'` (V8's structured-clone algorithm over the IPC channel) rather than\n * node's default `'json'`. This matters because `codec.ts` treats `TypedArray`/`ArrayBuffer`/\n * `DataView`/`Date`/`RegExp`/`Map`/`Set` as OPAQUE traversal leaves that ship **raw**, trusting the\n * transport to carry them faithfully — under default JSON serialization a `Float32Array` argument\n * would silently degrade to a plain `{0: ..., 1: ...}` object on arrival (empirically confirmed: a\n * `fork()` with no `serialization` override loses `instanceof Float32Array` across the wire). If a\n * caller forces `forkOptions: { serialization: 'json' }` anyway, tier-0 (`raw`) round-trips are\n * restricted to JSON-safe values for THOSE exotic containers; the codec's auto-escalation to tier-1/2\n * still carries functions/Errors/custom-encodables correctly (just paying the `@nhtio/encoder`\n * encode/decode cost) — only raw-tier TypedArray/Map/Set/Date/RegExp fidelity is at risk, and only\n * when the caller opted out of the default explicitly.\n * - `{ spawn }` — a {@link ChildResolver} BYO-spawner seam for callers who need their own process\n * manager (pooling, custom stdio wiring, sandboxing) or who spawn via a wrapper library instead of\n * `fork()` directly. The resolver must return (or resolve to) an {@link IsolatedChildLike} — see that\n * type's doc for the exact surface this module was empirically verified against, including execa≥9.\n *\n * These two forms are mutually exclusive and validated eagerly (this subpath's own local joi schema —\n * WP1's `validation.ts` is not touched).\n *\n * `terminate()` sends `SIGTERM` (or the caller's configured signal) and does NOT itself wait for exit\n * or run any grace period of its own — `host.ts`'s `dispose()` already sends a `shutdown` envelope and\n * waits `disposeGraceMs` for the guest to exit voluntarily before calling `transport.terminate()`\n * unconditionally; duplicating a grace window here would just double it. An `'exit'` that fires while\n * `terminate()`/`recycle()` is in progress is expected and never reported as a crash; any other exit\n * (including a non-zero code, e.g. `process.exit(7)` in the guest) or an `'error'` event on the child\n * fires {@link @nhtio/adk/batteries/isolation!IsolationTransport.onCrash}. `recycle()` (driven by\n * `host.ts`, not implemented in this module) re-enters this same transport's `connect()`, which forks\n * (or re-invokes the resolver) a brand-new child every time — there is no child reuse across recycles.\n */\n\nimport { fork } from 'node:child_process'\nimport { isError, isInstanceOf } from '@nhtio/adk/guards'\nimport { validator, ValidationError } from '@nhtio/validation'\nimport {\n createIsolatedService,\n E_INVALID_ISOLATION_OPTIONS,\n E_ISOLATION_UNSUPPORTED_ENV,\n} from '@nhtio/adk/batteries/isolation'\nimport type { ForkOptions } from 'node:child_process'\nimport type {\n CrashInfo,\n IsolatedService,\n IsolatedServiceOptions,\n IsolatedServiceSpec,\n IsolationTransport,\n PortLike,\n} from '@nhtio/adk/batteries/isolation'\n\n/**\n * The minimal Node `ChildProcess`-shaped duck this transport drives. Structurally satisfied by BOTH:\n *\n * - the object returned by `node:child_process`'s own `fork()`, and\n * - an `execa`≥9 subprocess spawned with `{ ipc: true }` — empirically verified: execa's\n * `Subprocess<OptionsType>` type is `Omit<ChildProcess, keyof ExecaCustomSubprocess<OptionsType>> &\n * ExecaCustomSubprocess<OptionsType>`, i.e. it keeps the classic Node `ChildProcess` EventEmitter\n * surface (`.send()`, `.on('message'|'exit'|'error', ...)`, `.kill()`, `.connected`) alongside\n * execa's own promise-based `sendMessage()`/`getEachMessage()` API. This transport only ever uses the\n * classic EventEmitter surface, so an execa `{ ipc: true }` subprocess satisfies this duck WITHOUT\n * any adapter.\n *\n * execa's channel, like node's own `fork()`, defaults to JSON-style serialization unless the\n * subprocess is spawned with `serialization: 'advanced'` (execa forwards that option straight to the\n * underlying `child_process.fork()` it uses internally for `ipc: true`) — the same \"pin `advanced` for\n * exotic-value fidelity\" requirement documented on {@link ForkIsolatedOptions} applies whether the\n * child came from this module's own `fork()` call or from a caller-supplied {@link ChildResolver}.\n *\n * @remarks\n * A {@link ChildResolver} must NOT itself attach a `'message'` listener to the child it returns before\n * handing it back to this transport (e.g. for logging). Node buffers a child's `message`/`ipc` events\n * until the FIRST listener is attached, then flushes the whole buffer to that one listener exactly\n * once — a resolver-side listener attached first (even just to log) permanently steals the buffered\n * `ready` envelope from `connect()`'s own listener, which then waits out `readyTimeoutMs` for a `ready`\n * that already came and went. execa's `Subprocess` additionally proxies raw child events through its\n * own internal debounced `message` re-emitter (see execa's `lib/ipc/forward.js`), so this applies to\n * execa subprocesses too — empirically confirmed by instrumenting a resolver with a diagnostic\n * `subprocess.on('message', ...)` and observing the resulting connection hang.\n *\n * A {@link ChildResolver} that returns an execa `{ ipc: true }` subprocess should attach its own\n * no-op `.catch(() => {})` to it before returning. execa's subprocess is ITSELF a promise (via\n * `mergePromise`) that settles REJECTED on a non-zero exit or termination signal — including the\n * ordinary `SIGTERM` this transport's `terminate()` sends on every `dispose()`/`recycle()`. Since this\n * transport only ever drives the classic EventEmitter surface (never awaits/`.then()`s the child\n * itself — see this module's `spawnChild` remarks for why an unguarded `await`/`return` of a thenable\n * child is unsafe in the first place), nothing else ever attaches a rejection handler; without one, a\n * routine `terminate()` reports as an unhandled promise rejection.\n */\nexport interface IsolatedChildLike {\n /** Send a message across the IPC channel. Returns `false` (or void, depending on the implementation)\n * when the channel is closed/backed-up; this transport does not currently act on that return value. */\n send?(msg: unknown): boolean | void\n /** Subscribe to a child lifecycle/IPC event (`'message'`, `'exit'`, `'error'`). Listener param typed\n * `any[]` to structurally match node's own `ChildProcess#on` overload set (whose listener signatures\n * are themselves `(...args: any[]) => void`). */\n on(event: string, fn: (...args: any[]) => void): unknown\n /** Unsubscribe, mirroring `.on`. Optional — some resolvers may return a duck without it; this\n * transport degrades to leaking the listener rather than throwing (the process is short-lived and\n * torn down on `terminate()`/`recycle()` regardless). */\n off?(event: string, fn: (...args: any[]) => void): unknown\n /** Alias some ducks expose instead of/alongside `off`. */\n removeListener?(event: string, fn: (...args: any[]) => void): unknown\n /** Send a termination signal to the child. */\n kill(signal?: NodeJS.Signals | number): boolean | void\n /** Whether the IPC channel is currently open. Read once at connect time for a `send`-before-`connect`\n * sanity check; not polled thereafter. */\n connected?: boolean\n}\n\n/**\n * A BYO-spawner resolver — the seam for callers who need their own process manager (a pool, custom\n * stdio, a sandboxing wrapper, or a library like `execa`) instead of this module's own default\n * `fork()`. Invoked once per `connect()` (including every `recycle()`), i.e. once per guest spawn.\n *\n * @remarks\n * The resolver receives the fully-resolved {@link\n * @nhtio/adk/batteries/isolation!IsolatedServiceSpec} so it can name/label the spawned process (e.g. for\n * logging), but is otherwise free to spawn however it likes — this transport only requires the\n * returned value to satisfy {@link IsolatedChildLike}.\n *\n * A returned execa `{ ipc: true }` subprocess is itself thenable (execa mixes `.then`/`.catch`/\n * `.finally` onto it so it can double as \"the child\" and \"a promise for its exit result\"). This\n * transport's own `spawnChild` internals guard against that value being mistaken for a real `Promise`\n * and adopted (which would silently defer \"spawned\" until the child EXITS) — a resolver author does not\n * need to do anything special here, this is called out purely so the mechanism is documented in one\n * place close to where a resolver returns its child.\n */\nexport type ChildResolver = (ctx: {\n spec: IsolatedServiceSpec\n}) => IsolatedChildLike | Promise<IsolatedChildLike>\n\n/** The `{ modulePath, forkOptions? }` variant of {@link ForkIsolatedOptions} — spawns via this\n * module's own `node:child_process.fork()` call. */\nexport interface ForkIsolatedModuleOptions {\n /** Path to the guest's entry module — passed straight through to `child_process.fork()`. Must be a\n * runnable module (already bundled/transpiled if it isn't plain CommonJS/ESM node can load\n * directly — `fork()` cannot load a `.ts` file itself). */\n modulePath: string | URL\n /** Forwarded to `child_process.fork()`. Unless this sets `serialization` explicitly, this transport\n * pins `serialization: 'advanced'` — see this module's top-level remarks. */\n forkOptions?: ForkOptions\n /** Absent in this variant — mutually exclusive with `modulePath`/`forkOptions`. See {@link\n * ForkIsolatedResolverOptions} for the BYO-spawner variant. */\n spawn?: never\n}\n\n/** The `{ spawn }` variant of {@link ForkIsolatedOptions} — spawns via a caller-supplied {@link\n * ChildResolver} instead of this module's own `fork()`. */\nexport interface ForkIsolatedResolverOptions {\n /** Absent in this variant — mutually exclusive with `spawn`. See {@link ForkIsolatedModuleOptions}. */\n modulePath?: never\n /** Absent in this variant — mutually exclusive with `spawn`. See {@link ForkIsolatedModuleOptions}. */\n forkOptions?: never\n /** BYO-spawner resolver, invoked once per `connect()`/`recycle()`. See {@link ChildResolver}. */\n spawn: ChildResolver\n}\n\n/**\n * Options accepted by {@link forkIsolated}/{@link createChildProcessTransport} — extends `host.ts`'s\n * {@link @nhtio/adk/batteries/isolation!IsolatedServiceOptions} with exactly one of the two mutually\n * exclusive spawn shapes: {@link ForkIsolatedModuleOptions} (the common `fork()`-a-module case) or\n * {@link ForkIsolatedResolverOptions} (BYO spawner). Supplying both `modulePath`/`forkOptions` AND\n * `spawn` (or neither) fails eager validation with {@link\n * @nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS}.\n */\nexport type ForkIsolatedOptions = IsolatedServiceOptions &\n (ForkIsolatedModuleOptions | ForkIsolatedResolverOptions)\n\nconst isValidationError = (value: unknown): value is ValidationError =>\n isError(value) && Array.isArray((value as ValidationError).details)\n\nconst formatValidationDetails = (err: ValidationError): string =>\n err.details.map((d) => d.message).join(' and ')\n\n/** Local (this-subpath-only) validator for the spawn-shape half of {@link ForkIsolatedOptions} — WP1's\n * shared `validation.ts` is not modified; this schema only covers the fields this module adds. */\nconst forkIsolatedSpawnShapeSchema = validator\n .object<{ modulePath?: string | URL; forkOptions?: object; spawn?: unknown }>({\n modulePath: validator\n .alternatives(\n validator.string().min(1),\n validator.custom((v, h) => (isInstanceOf(v, 'URL', URL) ? v : h.error('any.invalid')))\n )\n .optional(),\n forkOptions: validator.object().unknown(true).optional(),\n spawn: validator.function().optional(),\n })\n .unknown(true)\n .xor('modulePath', 'spawn')\n .with('forkOptions', 'modulePath')\n\n/**\n * Validate the spawn-shape half of a {@link ForkIsolatedOptions} bag: exactly one of `modulePath` /\n * `spawn` must be present, and `forkOptions` may only accompany `modulePath`.\n *\n * @throws {@link @nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS} on failure.\n */\nconst validateForkIsolatedOptions = (input: object): void => {\n const { error } = forkIsolatedSpawnShapeSchema.validate(input, {\n abortEarly: false,\n convert: false,\n })\n if (error && isValidationError(error)) {\n throw new E_INVALID_ISOLATION_OPTIONS([formatValidationDetails(error)])\n }\n}\n\n/** Structural check for whether the current process can host a `child_process`-backed transport at\n * all (i.e. we are actually running under node, not e.g. a browser polyfill of parts of this module's\n * imports). Mirrors `serve.ts`'s guest-side duck check, but on the HOST side: node's own `process`\n * global always exposes `.pid`, which a browser/worker `globalThis.process` shim would not. */\nconst isNodeHost = (): boolean =>\n typeof globalThis.process?.pid === 'number' && typeof fork === 'function'\n\n/** Reason string threaded into `onCrash` when the child's `'exit'` fires unexpectedly (i.e. not during\n * `terminate()`/`recycle()`). */\nconst exitReason = (code: number | null, signal: NodeJS.Signals | null): string =>\n signal\n ? `child process exited via signal ${signal}`\n : `child process exited with code ${code ?? 'null'}`\n\n/**\n * Build a real {@link @nhtio/adk/batteries/isolation!IsolationTransport} over a node `child_process`\n * (or BYO-resolved) child. `connect()` spawns a fresh child every call (including every `recycle()` —\n * there is no child reuse); `terminate()` sends `SIGTERM` (or `forkOptions.killSignal`/the resolver's\n * own convention) without waiting for exit or imposing any grace period of its own (`host.ts` already\n * owns that via `disposeGraceMs`).\n *\n * @throws {@link @nhtio/adk/batteries/isolation!E_ISOLATION_UNSUPPORTED_ENV} when called outside node\n * (no `process.pid` / no `child_process.fork`).\n * @throws {@link @nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS} when `options` fails the\n * mutual-exclusivity check documented on {@link ForkIsolatedOptions}.\n */\nexport const createChildProcessTransport = <S extends IsolatedServiceSpec>(\n spec: S,\n options: ForkIsolatedOptions\n): IsolationTransport => {\n if (!isNodeHost()) {\n throw new E_ISOLATION_UNSUPPORTED_ENV([\n 'createChildProcessTransport requires a node host (process.pid / child_process.fork unavailable) — this transport cannot run in a browser/worker environment',\n ])\n }\n validateForkIsolatedOptions(options)\n\n let child: IsolatedChildLike | undefined\n let terminating = false\n const crashListeners = new Set<(info: CrashInfo) => void>()\n let messageListener: ((msg: unknown) => void) | undefined\n let exitListener: ((code: number | null, signal: NodeJS.Signals | null) => void) | undefined\n let errorListener: ((err: Error) => void) | undefined\n\n const detachChildListeners = (): void => {\n if (!child) return\n const off = (event: string, fn: ((...a: never[]) => void) | undefined): void => {\n if (!fn) return\n if (child!.off) child!.off(event, fn as never)\n else if (child!.removeListener) child!.removeListener(event, fn as never)\n }\n off('message', messageListener as never)\n off('exit', exitListener as never)\n off('error', errorListener as never)\n messageListener = undefined\n exitListener = undefined\n errorListener = undefined\n }\n\n // Deliberately NOT an `async function`, and deliberately returns a BOXED `{ child }` wrapper rather\n // than the child itself. A resolver-supplied child (e.g. an execa `{ ipc: true }` subprocess) is\n // ITSELF thenable — execa's `mergePromise` mixes `.then`/`.catch`/`.finally` onto the subprocess\n // object so `execa(...)`'s return value can be both \"the child\" and \"awaited for its exit result\".\n // `return`ing (or `await`ing) that value directly from inside an `async function` triggers the\n // language's thenable-ADOPTION rule: the engine treats the returned/awaited thenable as a real\n // Promise and defers settling until IT resolves — which for an execa subprocess is when the CHILD\n // PROCESS EXITS, not when it spawns. That silently turns \"spawn a child\" into \"wait for the child to\n // exit\", hanging every caller of `connect()` for the child's entire lifetime. Empirically confirmed:\n // an `async spawnChild` doing `return options.spawn({ spec })` hangs even when the resolver itself is\n // a plain (non-async) function — the adoption happens at `spawnChild`'s own `return`, not the\n // resolver's. Boxing the child inside a fresh plain object (which has no `.then` of its own) before\n // it ever crosses a `return`/`await` boundary avoids triggering adoption anywhere in the chain.\n const spawnChild = (): Promise<{ child: IsolatedChildLike }> => {\n if ('spawn' in options && options.spawn) {\n const maybe = options.spawn({ spec })\n // A genuine `Promise` (the resolver itself is async/needs to await setup) must still be awaited;\n // a resolver-returned execa subprocess is thenable-DUCK (see this function's remarks) but is not\n // actually `instanceof Promise`, so this check correctly tells the two apart without adopting the\n // duck.\n return isInstanceOf(maybe, 'Promise', Promise)\n ? maybe.then((resolvedChild) => ({ child: resolvedChild }))\n : Promise.resolve({ child: maybe })\n }\n const forkOptions = options.forkOptions ?? {}\n const resolvedForkOptions: ForkOptions =\n forkOptions.serialization !== undefined\n ? forkOptions\n : { ...forkOptions, serialization: 'advanced' }\n return Promise.resolve({ child: fork(options.modulePath!, resolvedForkOptions) })\n }\n\n const connect = async (): Promise<PortLike> => {\n terminating = false\n const { child: spawned } = await spawnChild()\n child = spawned\n\n const port: PortLike = {\n post: (msg) => {\n spawned.send?.(msg)\n },\n onMessage: (fn) => {\n const listener = (msg: unknown): void => fn(msg)\n messageListener = listener\n spawned.on('message', listener as never)\n return () => {\n if (spawned.off) spawned.off('message', listener as never)\n else if (spawned.removeListener) spawned.removeListener('message', listener as never)\n }\n },\n }\n\n exitListener = (code, signal) => {\n if (terminating) return\n const info: CrashInfo = { reason: exitReason(code, signal), code: code ?? null, signal }\n for (const fn of crashListeners) fn(info)\n }\n errorListener = (err) => {\n if (terminating) return\n const info: CrashInfo = { reason: err.message, code: null, signal: null }\n for (const fn of crashListeners) fn(info)\n }\n spawned.on('exit', exitListener as never)\n spawned.on('error', errorListener as never)\n\n return port\n }\n\n const terminate = (): void => {\n terminating = true\n detachChildListeners()\n if (child) {\n const signal = ('forkOptions' in options && options.forkOptions?.killSignal) || 'SIGTERM'\n child.kill(signal as NodeJS.Signals)\n }\n child = undefined\n }\n\n return {\n connect,\n terminate,\n onCrash: (fn) => {\n crashListeners.add(fn)\n return () => crashListeners.delete(fn)\n },\n }\n}\n\n/**\n * Sugar over {@link createChildProcessTransport} + {@link\n * @nhtio/adk/batteries/isolation!createIsolatedService} — the one-call entry point most callers want:\n * fork a guest module (or BYO-spawn one) and get back a ready-to-use {@link\n * @nhtio/adk/batteries/isolation!IsolatedService}.\n *\n * @throws {@link @nhtio/adk/batteries/isolation!E_ISOLATION_UNSUPPORTED_ENV} when called outside node.\n * @throws {@link @nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS} when `options` fails the\n * mutual-exclusivity check documented on {@link ForkIsolatedOptions}, or when `createIsolatedService`'s\n * own option validation fails.\n */\nexport const forkIsolated = <S extends IsolatedServiceSpec>(\n spec: S,\n options: ForkIsolatedOptions\n): IsolatedService<S> => {\n const transport = createChildProcessTransport(spec, options)\n // `options` also carries this subpath's own spawn-shape fields (`modulePath`/`forkOptions`/`spawn`),\n // which `createIsolatedService` must never see — `host.ts` validates its options bag against WP1's\n // `isolatedServiceOptionsSchema` with `.unknown(false)`, so passing the raw bag through would fail\n // eager validation on fields that schema (correctly) doesn't know about. Strip them here rather than\n // loosen WP1's shared schema.\n const spawnShapeKeys = new Set(['modulePath', 'forkOptions', 'spawn'])\n const hostOptions = Object.fromEntries(\n Object.entries(options).filter(([key]) => !spawnShapeKeys.has(key))\n ) as IsolatedServiceOptions\n return createIsolatedService(spec, transport, hostOptions)\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"child_process.cjs","names":[],"sources":["../../../src/batteries/isolation/child_process/transport.ts"],"sourcesContent":["/**\n * Node `child_process`-backed {@link @nhtio/adk/batteries/isolation!IsolationTransport} — forks (or\n * BYO-spawns) a guest process and wraps its IPC channel in the `PortLike` duck the wire protocol is\n * built over.\n *\n * @remarks\n * This module is NODE-ONLY: it imports `node:child_process` directly (unlike `serve.ts`'s guest-side\n * duck detection, which never imports `node:*` so it stays loadable in a Worker/browser bundle). See\n * this subpath's `index.ts` for why a real process — rather than a `worker_threads` `Worker` — is the\n * right host-side primitive for the Node transport.\n *\n * Two ways to obtain the child:\n *\n * - `{ modulePath, forkOptions? }` — the common case. Calls node's own `child_process.fork(modulePath,\n * forkOptions)`. Unless the caller's `forkOptions` explicitly sets `serialization`, this pins\n * `serialization: 'advanced'` (V8's structured-clone algorithm over the IPC channel) rather than\n * node's default `'json'`. This matters because `codec.ts` treats `TypedArray`/`ArrayBuffer`/\n * `DataView`/`Date`/`RegExp`/`Map`/`Set` as OPAQUE traversal leaves that ship **raw**, trusting the\n * transport to carry them faithfully — under default JSON serialization a `Float32Array` argument\n * would silently degrade to a plain `{0: ..., 1: ...}` object on arrival (empirically confirmed: a\n * `fork()` with no `serialization` override loses `instanceof Float32Array` across the wire). If a\n * caller forces `forkOptions: { serialization: 'json' }` anyway, tier-0 (`raw`) round-trips are\n * restricted to JSON-safe values for THOSE exotic containers; the codec's auto-escalation to tier-1/2\n * still carries functions/Errors/custom-encodables correctly (just paying the `@nhtio/encoder`\n * encode/decode cost) — only raw-tier TypedArray/Map/Set/Date/RegExp fidelity is at risk, and only\n * when the caller opted out of the default explicitly.\n * - `{ spawn }` — a {@link ChildResolver} BYO-spawner seam for callers who need their own process\n * manager (pooling, custom stdio wiring, sandboxing) or who spawn via a wrapper library instead of\n * `fork()` directly. The resolver must return (or resolve to) an {@link IsolatedChildLike} — see that\n * type's doc for the exact surface this module was empirically verified against, including execa≥9.\n *\n * These two forms are mutually exclusive and validated eagerly (this subpath's own local joi schema —\n * the shared `validation.ts` is not touched).\n *\n * `terminate()` sends `SIGTERM` (or the caller's configured signal) and does NOT itself wait for exit\n * or run any grace period of its own — `host.ts`'s `dispose()` already sends a `shutdown` envelope and\n * waits `disposeGraceMs` for the guest to exit voluntarily before calling `transport.terminate()`\n * unconditionally; duplicating a grace window here would just double it. An `'exit'` that fires while\n * `terminate()`/`recycle()` is in progress is expected and never reported as a crash; any other exit\n * (including a non-zero code, e.g. `process.exit(7)` in the guest) or an `'error'` event on the child\n * fires {@link @nhtio/adk/batteries/isolation!IsolationTransport.onCrash}. `recycle()` (driven by\n * `host.ts`, not implemented in this module) re-enters this same transport's `connect()`, which forks\n * (or re-invokes the resolver) a brand-new child every time — there is no child reuse across recycles.\n */\n\nimport { fork } from 'node:child_process'\nimport { isError, isInstanceOf } from '@nhtio/adk/guards'\nimport { validator, ValidationError } from '@nhtio/validation'\nimport {\n createIsolatedService,\n E_INVALID_ISOLATION_OPTIONS,\n E_ISOLATION_UNSUPPORTED_ENV,\n} from '@nhtio/adk/batteries/isolation'\nimport type { ForkOptions } from 'node:child_process'\nimport type {\n CrashInfo,\n IsolatedService,\n IsolatedServiceOptions,\n IsolatedServiceSpec,\n IsolationTransport,\n PortLike,\n} from '@nhtio/adk/batteries/isolation'\n\n/**\n * The minimal Node `ChildProcess`-shaped duck this transport drives. Structurally satisfied by BOTH:\n *\n * - the object returned by `node:child_process`'s own `fork()`, and\n * - an `execa`≥9 subprocess spawned with `{ ipc: true }` — empirically verified: execa's\n * `Subprocess<OptionsType>` type is `Omit<ChildProcess, keyof ExecaCustomSubprocess<OptionsType>> &\n * ExecaCustomSubprocess<OptionsType>`, i.e. it keeps the classic Node `ChildProcess` EventEmitter\n * surface (`.send()`, `.on('message'|'exit'|'error', ...)`, `.kill()`, `.connected`) alongside\n * execa's own promise-based `sendMessage()`/`getEachMessage()` API. This transport only ever uses the\n * classic EventEmitter surface, so an execa `{ ipc: true }` subprocess satisfies this duck WITHOUT\n * any adapter.\n *\n * execa's channel, like node's own `fork()`, defaults to JSON-style serialization unless the\n * subprocess is spawned with `serialization: 'advanced'` (execa forwards that option straight to the\n * underlying `child_process.fork()` it uses internally for `ipc: true`) — the same \"pin `advanced` for\n * exotic-value fidelity\" requirement documented on {@link ForkIsolatedOptions} applies whether the\n * child came from this module's own `fork()` call or from a caller-supplied {@link ChildResolver}.\n *\n * @remarks\n * A {@link ChildResolver} must NOT itself attach a `'message'` listener to the child it returns before\n * handing it back to this transport (e.g. for logging). Node buffers a child's `message`/`ipc` events\n * until the FIRST listener is attached, then flushes the whole buffer to that one listener exactly\n * once — a resolver-side listener attached first (even just to log) permanently steals the buffered\n * `ready` envelope from `connect()`'s own listener, which then waits out `readyTimeoutMs` for a `ready`\n * that already came and went. execa's `Subprocess` additionally proxies raw child events through its\n * own internal debounced `message` re-emitter (see execa's `lib/ipc/forward.js`), so this applies to\n * execa subprocesses too — empirically confirmed by instrumenting a resolver with a diagnostic\n * `subprocess.on('message', ...)` and observing the resulting connection hang.\n *\n * A {@link ChildResolver} that returns an execa `{ ipc: true }` subprocess should attach its own\n * no-op `.catch(() => {})` to it before returning. execa's subprocess is ITSELF a promise (via\n * `mergePromise`) that settles REJECTED on a non-zero exit or termination signal — including the\n * ordinary `SIGTERM` this transport's `terminate()` sends on every `dispose()`/`recycle()`. Since this\n * transport only ever drives the classic EventEmitter surface (never awaits/`.then()`s the child\n * itself — see this module's `spawnChild` remarks for why an unguarded `await`/`return` of a thenable\n * child is unsafe in the first place), nothing else ever attaches a rejection handler; without one, a\n * routine `terminate()` reports as an unhandled promise rejection.\n */\nexport interface IsolatedChildLike {\n /** Send a message across the IPC channel. Returns `false` (or void, depending on the implementation)\n * when the channel is closed/backed-up; this transport does not currently act on that return value. */\n send?(msg: unknown): boolean | void\n /** Subscribe to a child lifecycle/IPC event (`'message'`, `'exit'`, `'error'`). Listener param typed\n * `any[]` to structurally match node's own `ChildProcess#on` overload set (whose listener signatures\n * are themselves `(...args: any[]) => void`). */\n on(event: string, fn: (...args: any[]) => void): unknown\n /** Unsubscribe, mirroring `.on`. Optional — some resolvers may return a duck without it; this\n * transport degrades to leaking the listener rather than throwing (the process is short-lived and\n * torn down on `terminate()`/`recycle()` regardless). */\n off?(event: string, fn: (...args: any[]) => void): unknown\n /** Alias some ducks expose instead of/alongside `off`. */\n removeListener?(event: string, fn: (...args: any[]) => void): unknown\n /** Send a termination signal to the child. */\n kill(signal?: NodeJS.Signals | number): boolean | void\n /** Whether the IPC channel is currently open. Read once at connect time for a `send`-before-`connect`\n * sanity check; not polled thereafter. */\n connected?: boolean\n}\n\n/**\n * A BYO-spawner resolver — the seam for callers who need their own process manager (a pool, custom\n * stdio, a sandboxing wrapper, or a library like `execa`) instead of this module's own default\n * `fork()`. Invoked once per `connect()` (including every `recycle()`), i.e. once per guest spawn.\n *\n * @remarks\n * The resolver receives the fully-resolved {@link\n * @nhtio/adk/batteries/isolation!IsolatedServiceSpec} so it can name/label the spawned process (e.g. for\n * logging), but is otherwise free to spawn however it likes — this transport only requires the\n * returned value to satisfy {@link IsolatedChildLike}.\n *\n * A returned execa `{ ipc: true }` subprocess is itself thenable (execa mixes `.then`/`.catch`/\n * `.finally` onto it so it can double as \"the child\" and \"a promise for its exit result\"). This\n * transport's own `spawnChild` internals guard against that value being mistaken for a real `Promise`\n * and adopted (which would silently defer \"spawned\" until the child EXITS) — a resolver author does not\n * need to do anything special here, this is called out purely so the mechanism is documented in one\n * place close to where a resolver returns its child.\n */\nexport type ChildResolver = (ctx: {\n spec: IsolatedServiceSpec\n}) => IsolatedChildLike | Promise<IsolatedChildLike>\n\n/** The `{ modulePath, forkOptions? }` variant of {@link ForkIsolatedOptions} — spawns via this\n * module's own `node:child_process.fork()` call. */\nexport interface ForkIsolatedModuleOptions {\n /** Path to the guest's entry module — passed straight through to `child_process.fork()`. Must be a\n * runnable module (already bundled/transpiled if it isn't plain CommonJS/ESM node can load\n * directly — `fork()` cannot load a `.ts` file itself). */\n modulePath: string | URL\n /** Forwarded to `child_process.fork()`. Unless this sets `serialization` explicitly, this transport\n * pins `serialization: 'advanced'` — see this module's top-level remarks. */\n forkOptions?: ForkOptions\n /** Absent in this variant — mutually exclusive with `modulePath`/`forkOptions`. See {@link\n * ForkIsolatedResolverOptions} for the BYO-spawner variant. */\n spawn?: never\n}\n\n/** The `{ spawn }` variant of {@link ForkIsolatedOptions} — spawns via a caller-supplied {@link\n * ChildResolver} instead of this module's own `fork()`. */\nexport interface ForkIsolatedResolverOptions {\n /** Absent in this variant — mutually exclusive with `spawn`. See {@link ForkIsolatedModuleOptions}. */\n modulePath?: never\n /** Absent in this variant — mutually exclusive with `spawn`. See {@link ForkIsolatedModuleOptions}. */\n forkOptions?: never\n /** BYO-spawner resolver, invoked once per `connect()`/`recycle()`. See {@link ChildResolver}. */\n spawn: ChildResolver\n}\n\n/**\n * Options accepted by {@link forkIsolated}/{@link createChildProcessTransport} — extends `host.ts`'s\n * {@link @nhtio/adk/batteries/isolation!IsolatedServiceOptions} with exactly one of the two mutually\n * exclusive spawn shapes: {@link ForkIsolatedModuleOptions} (the common `fork()`-a-module case) or\n * {@link ForkIsolatedResolverOptions} (BYO spawner). Supplying both `modulePath`/`forkOptions` AND\n * `spawn` (or neither) fails eager validation with {@link\n * @nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS}.\n */\nexport type ForkIsolatedOptions = IsolatedServiceOptions &\n (ForkIsolatedModuleOptions | ForkIsolatedResolverOptions)\n\nconst isValidationError = (value: unknown): value is ValidationError =>\n isError(value) && Array.isArray((value as ValidationError).details)\n\nconst formatValidationDetails = (err: ValidationError): string =>\n err.details.map((d) => d.message).join(' and ')\n\n/** Local (this-subpath-only) validator for the spawn-shape half of {@link ForkIsolatedOptions} — the\n * shared `validation.ts` is not modified; this schema only covers the fields this module adds. */\nconst forkIsolatedSpawnShapeSchema = validator\n .object<{ modulePath?: string | URL; forkOptions?: object; spawn?: unknown }>({\n modulePath: validator\n .alternatives(\n validator.string().min(1),\n validator.custom((v, h) => (isInstanceOf(v, 'URL', URL) ? v : h.error('any.invalid')))\n )\n .optional(),\n forkOptions: validator.object().unknown(true).optional(),\n spawn: validator.function().optional(),\n })\n .unknown(true)\n .xor('modulePath', 'spawn')\n .with('forkOptions', 'modulePath')\n\n/**\n * Validate the spawn-shape half of a {@link ForkIsolatedOptions} bag: exactly one of `modulePath` /\n * `spawn` must be present, and `forkOptions` may only accompany `modulePath`.\n *\n * @throws {@link @nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS} on failure.\n */\nconst validateForkIsolatedOptions = (input: object): void => {\n const { error } = forkIsolatedSpawnShapeSchema.validate(input, {\n abortEarly: false,\n convert: false,\n })\n if (error && isValidationError(error)) {\n throw new E_INVALID_ISOLATION_OPTIONS([formatValidationDetails(error)])\n }\n}\n\n/** Structural check for whether the current process can host a `child_process`-backed transport at\n * all (i.e. we are actually running under node, not e.g. a browser polyfill of parts of this module's\n * imports). Mirrors `serve.ts`'s guest-side duck check, but on the HOST side: node's own `process`\n * global always exposes `.pid`, which a browser/worker `globalThis.process` shim would not. */\nconst isNodeHost = (): boolean =>\n typeof globalThis.process?.pid === 'number' && typeof fork === 'function'\n\n/** Reason string threaded into `onCrash` when the child's `'exit'` fires unexpectedly (i.e. not during\n * `terminate()`/`recycle()`). */\nconst exitReason = (code: number | null, signal: NodeJS.Signals | null): string =>\n signal\n ? `child process exited via signal ${signal}`\n : `child process exited with code ${code ?? 'null'}`\n\n/**\n * Build a real {@link @nhtio/adk/batteries/isolation!IsolationTransport} over a node `child_process`\n * (or BYO-resolved) child. `connect()` spawns a fresh child every call (including every `recycle()` —\n * there is no child reuse); `terminate()` sends `SIGTERM` (or `forkOptions.killSignal`/the resolver's\n * own convention) without waiting for exit or imposing any grace period of its own (`host.ts` already\n * owns that via `disposeGraceMs`).\n *\n * @throws {@link @nhtio/adk/batteries/isolation!E_ISOLATION_UNSUPPORTED_ENV} when called outside node\n * (no `process.pid` / no `child_process.fork`).\n * @throws {@link @nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS} when `options` fails the\n * mutual-exclusivity check documented on {@link ForkIsolatedOptions}.\n */\nexport const createChildProcessTransport = <S extends IsolatedServiceSpec>(\n spec: S,\n options: ForkIsolatedOptions\n): IsolationTransport => {\n if (!isNodeHost()) {\n throw new E_ISOLATION_UNSUPPORTED_ENV([\n 'createChildProcessTransport requires a node host (process.pid / child_process.fork unavailable) — this transport cannot run in a browser/worker environment',\n ])\n }\n validateForkIsolatedOptions(options)\n\n let child: IsolatedChildLike | undefined\n let terminating = false\n const crashListeners = new Set<(info: CrashInfo) => void>()\n let messageListener: ((msg: unknown) => void) | undefined\n let exitListener: ((code: number | null, signal: NodeJS.Signals | null) => void) | undefined\n let errorListener: ((err: Error) => void) | undefined\n\n const detachChildListeners = (): void => {\n if (!child) return\n const off = (event: string, fn: ((...a: never[]) => void) | undefined): void => {\n if (!fn) return\n if (child!.off) child!.off(event, fn as never)\n else if (child!.removeListener) child!.removeListener(event, fn as never)\n }\n off('message', messageListener as never)\n off('exit', exitListener as never)\n off('error', errorListener as never)\n messageListener = undefined\n exitListener = undefined\n errorListener = undefined\n }\n\n // Deliberately NOT an `async function`, and deliberately returns a BOXED `{ child }` wrapper rather\n // than the child itself. A resolver-supplied child (e.g. an execa `{ ipc: true }` subprocess) is\n // ITSELF thenable — execa's `mergePromise` mixes `.then`/`.catch`/`.finally` onto the subprocess\n // object so `execa(...)`'s return value can be both \"the child\" and \"awaited for its exit result\".\n // `return`ing (or `await`ing) that value directly from inside an `async function` triggers the\n // language's thenable-ADOPTION rule: the engine treats the returned/awaited thenable as a real\n // Promise and defers settling until IT resolves — which for an execa subprocess is when the CHILD\n // PROCESS EXITS, not when it spawns. That silently turns \"spawn a child\" into \"wait for the child to\n // exit\", hanging every caller of `connect()` for the child's entire lifetime. Empirically confirmed:\n // an `async spawnChild` doing `return options.spawn({ spec })` hangs even when the resolver itself is\n // a plain (non-async) function — the adoption happens at `spawnChild`'s own `return`, not the\n // resolver's. Boxing the child inside a fresh plain object (which has no `.then` of its own) before\n // it ever crosses a `return`/`await` boundary avoids triggering adoption anywhere in the chain.\n const spawnChild = (): Promise<{ child: IsolatedChildLike }> => {\n if ('spawn' in options && options.spawn) {\n const maybe = options.spawn({ spec })\n // A genuine `Promise` (the resolver itself is async/needs to await setup) must still be awaited;\n // a resolver-returned execa subprocess is thenable-DUCK (see this function's remarks) but is not\n // actually `instanceof Promise`, so this check correctly tells the two apart without adopting the\n // duck.\n return isInstanceOf(maybe, 'Promise', Promise)\n ? maybe.then((resolvedChild) => ({ child: resolvedChild }))\n : Promise.resolve({ child: maybe })\n }\n const forkOptions = options.forkOptions ?? {}\n const resolvedForkOptions: ForkOptions =\n forkOptions.serialization !== undefined\n ? forkOptions\n : { ...forkOptions, serialization: 'advanced' }\n return Promise.resolve({ child: fork(options.modulePath!, resolvedForkOptions) })\n }\n\n const connect = async (): Promise<PortLike> => {\n terminating = false\n const { child: spawned } = await spawnChild()\n child = spawned\n\n const port: PortLike = {\n post: (msg) => {\n spawned.send?.(msg)\n },\n onMessage: (fn) => {\n const listener = (msg: unknown): void => fn(msg)\n messageListener = listener\n spawned.on('message', listener as never)\n return () => {\n if (spawned.off) spawned.off('message', listener as never)\n else if (spawned.removeListener) spawned.removeListener('message', listener as never)\n }\n },\n }\n\n exitListener = (code, signal) => {\n if (terminating) return\n const info: CrashInfo = { reason: exitReason(code, signal), code: code ?? null, signal }\n for (const fn of crashListeners) fn(info)\n }\n errorListener = (err) => {\n if (terminating) return\n const info: CrashInfo = { reason: err.message, code: null, signal: null }\n for (const fn of crashListeners) fn(info)\n }\n spawned.on('exit', exitListener as never)\n spawned.on('error', errorListener as never)\n\n return port\n }\n\n const terminate = (): void => {\n terminating = true\n detachChildListeners()\n if (child) {\n const signal = ('forkOptions' in options && options.forkOptions?.killSignal) || 'SIGTERM'\n child.kill(signal as NodeJS.Signals)\n }\n child = undefined\n }\n\n return {\n connect,\n terminate,\n onCrash: (fn) => {\n crashListeners.add(fn)\n return () => crashListeners.delete(fn)\n },\n }\n}\n\n/**\n * Sugar over {@link createChildProcessTransport} + {@link\n * @nhtio/adk/batteries/isolation!createIsolatedService} — the one-call entry point most callers want:\n * fork a guest module (or BYO-spawn one) and get back a ready-to-use {@link\n * @nhtio/adk/batteries/isolation!IsolatedService}.\n *\n * @throws {@link @nhtio/adk/batteries/isolation!E_ISOLATION_UNSUPPORTED_ENV} when called outside node.\n * @throws {@link @nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS} when `options` fails the\n * mutual-exclusivity check documented on {@link ForkIsolatedOptions}, or when `createIsolatedService`'s\n * own option validation fails.\n */\nexport const forkIsolated = <S extends IsolatedServiceSpec>(\n spec: S,\n options: ForkIsolatedOptions\n): IsolatedService<S> => {\n const transport = createChildProcessTransport(spec, options)\n // `options` also carries this subpath's own spawn-shape fields (`modulePath`/`forkOptions`/`spawn`),\n // which `createIsolatedService` must never see — `host.ts` validates its options bag against the shared\n // `isolatedServiceOptionsSchema` with `.unknown(false)`, so passing the raw bag through would fail\n // eager validation on fields that schema (correctly) doesn't know about. Strip them here rather than\n // loosen the shared schema.\n const spawnShapeKeys = new Set(['modulePath', 'forkOptions', 'spawn'])\n const hostOptions = Object.fromEntries(\n Object.entries(options).filter(([key]) => !spawnShapeKeys.has(key))\n ) as IsolatedServiceOptions\n return createIsolatedService(spec, transport, hostOptions)\n}\n"],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as isInstanceOf, t as isError } from "../../guards-BEpY7lBI.mjs";
|
|
2
2
|
import "../../guards.mjs";
|
|
3
|
-
import { C as E_INVALID_ISOLATION_OPTIONS, k as E_ISOLATION_UNSUPPORTED_ENV, s as createIsolatedService } from "../../isolation-
|
|
3
|
+
import { C as E_INVALID_ISOLATION_OPTIONS, k as E_ISOLATION_UNSUPPORTED_ENV, s as createIsolatedService } from "../../isolation-CO0NiK8R.mjs";
|
|
4
4
|
import { validator } from "@nhtio/validation";
|
|
5
5
|
import { fork } from "node:child_process";
|
|
6
6
|
//#region src/batteries/isolation/child_process/transport.ts
|
|
@@ -13,7 +13,7 @@ import { fork } from "node:child_process";
|
|
|
13
13
|
* This module is NODE-ONLY: it imports `node:child_process` directly (unlike `serve.ts`'s guest-side
|
|
14
14
|
* duck detection, which never imports `node:*` so it stays loadable in a Worker/browser bundle). See
|
|
15
15
|
* this subpath's `index.ts` for why a real process — rather than a `worker_threads` `Worker` — is the
|
|
16
|
-
* right host-side primitive for
|
|
16
|
+
* right host-side primitive for the Node transport.
|
|
17
17
|
*
|
|
18
18
|
* Two ways to obtain the child:
|
|
19
19
|
*
|
|
@@ -36,7 +36,7 @@ import { fork } from "node:child_process";
|
|
|
36
36
|
* type's doc for the exact surface this module was empirically verified against, including execa≥9.
|
|
37
37
|
*
|
|
38
38
|
* These two forms are mutually exclusive and validated eagerly (this subpath's own local joi schema —
|
|
39
|
-
*
|
|
39
|
+
* the shared `validation.ts` is not touched).
|
|
40
40
|
*
|
|
41
41
|
* `terminate()` sends `SIGTERM` (or the caller's configured signal) and does NOT itself wait for exit
|
|
42
42
|
* or run any grace period of its own — `host.ts`'s `dispose()` already sends a `shutdown` envelope and
|
|
@@ -50,7 +50,7 @@ import { fork } from "node:child_process";
|
|
|
50
50
|
*/
|
|
51
51
|
var isValidationError = (value) => isError(value) && Array.isArray(value.details);
|
|
52
52
|
var formatValidationDetails = (err) => err.details.map((d) => d.message).join(" and ");
|
|
53
|
-
/** Local (this-subpath-only) validator for the spawn-shape half of {@link ForkIsolatedOptions} —
|
|
53
|
+
/** Local (this-subpath-only) validator for the spawn-shape half of {@link ForkIsolatedOptions} — the
|
|
54
54
|
* shared `validation.ts` is not modified; this schema only covers the fields this module adds. */
|
|
55
55
|
var forkIsolatedSpawnShapeSchema = validator.object({
|
|
56
56
|
modulePath: validator.alternatives(validator.string().min(1), validator.custom((v, h) => isInstanceOf(v, "URL", URL) ? v : h.error("any.invalid"))).optional(),
|