@nhtio/adk 1.20260607.2 → 1.20260609.1
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 +230 -0
- package/batteries/embeddings/openai/adapter.cjs +1 -1
- package/batteries/embeddings/openai/adapter.mjs +1 -1
- package/batteries/embeddings/openai/exceptions.cjs +1 -1
- package/batteries/embeddings/openai/exceptions.mjs +1 -1
- package/batteries/embeddings/openai/types.d.ts +7 -0
- package/batteries/embeddings/webllm/adapter.cjs +1 -1
- package/batteries/embeddings/webllm/adapter.mjs +1 -1
- package/batteries/embeddings/webllm/exceptions.cjs +1 -1
- package/batteries/embeddings/webllm/exceptions.mjs +1 -1
- package/batteries/llm/chat_common/helpers.d.ts +165 -0
- package/batteries/llm/chat_common/types.d.ts +309 -0
- package/batteries/llm/index.d.ts +5 -0
- package/batteries/llm/ollama/adapter.cjs +736 -0
- package/batteries/llm/ollama/adapter.cjs.map +1 -0
- package/batteries/llm/ollama/adapter.d.ts +64 -0
- package/batteries/llm/ollama/adapter.mjs +734 -0
- package/batteries/llm/ollama/adapter.mjs.map +1 -0
- package/batteries/llm/ollama/exceptions.cjs +105 -0
- package/batteries/llm/ollama/exceptions.cjs.map +1 -0
- package/batteries/llm/ollama/exceptions.d.ts +112 -0
- package/batteries/llm/ollama/exceptions.mjs +96 -0
- package/batteries/llm/ollama/exceptions.mjs.map +1 -0
- package/batteries/llm/ollama/helpers.cjs +487 -0
- package/batteries/llm/ollama/helpers.cjs.map +1 -0
- package/batteries/llm/ollama/helpers.d.ts +158 -0
- package/batteries/llm/ollama/helpers.mjs +450 -0
- package/batteries/llm/ollama/helpers.mjs.map +1 -0
- package/batteries/llm/ollama/index.d.ts +29 -0
- package/batteries/llm/ollama/types.cjs +2 -0
- package/batteries/llm/ollama/types.d.ts +334 -0
- package/batteries/llm/ollama/types.mjs +0 -0
- package/batteries/llm/ollama/validation.cjs +130 -0
- package/batteries/llm/ollama/validation.cjs.map +1 -0
- package/batteries/llm/ollama/validation.d.ts +31 -0
- package/batteries/llm/ollama/validation.mjs +127 -0
- package/batteries/llm/ollama/validation.mjs.map +1 -0
- package/batteries/llm/ollama.cjs +54 -0
- package/batteries/llm/ollama.mjs +6 -0
- package/batteries/llm/openai_chat_completions/adapter.cjs +36 -19
- package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -1
- package/batteries/llm/openai_chat_completions/adapter.mjs +23 -6
- package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -1
- package/batteries/llm/openai_chat_completions/exceptions.cjs +1 -1
- package/batteries/llm/openai_chat_completions/exceptions.mjs +1 -1
- package/batteries/llm/openai_chat_completions/helpers.cjs +80 -320
- package/batteries/llm/openai_chat_completions/helpers.cjs.map +1 -1
- package/batteries/llm/openai_chat_completions/helpers.d.ts +68 -144
- package/batteries/llm/openai_chat_completions/helpers.mjs +40 -280
- package/batteries/llm/openai_chat_completions/helpers.mjs.map +1 -1
- package/batteries/llm/openai_chat_completions/types.d.ts +273 -181
- package/batteries/llm/openai_chat_completions/validation.cjs +2 -2
- package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -1
- package/batteries/llm/openai_chat_completions/validation.mjs +2 -2
- package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -1
- package/batteries/llm/openai_chat_completions.cjs +29 -28
- package/batteries/llm/openai_chat_completions.mjs +2 -1
- package/batteries/llm/webllm_chat_completions/adapter.cjs +38 -19
- package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -1
- package/batteries/llm/webllm_chat_completions/adapter.d.ts +18 -0
- package/batteries/llm/webllm_chat_completions/adapter.mjs +25 -6
- package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -1
- package/batteries/llm/webllm_chat_completions/exceptions.cjs +1 -1
- package/batteries/llm/webllm_chat_completions/exceptions.mjs +1 -1
- package/batteries/llm/webllm_chat_completions/helpers.cjs +29 -28
- package/batteries/llm/webllm_chat_completions/helpers.mjs +2 -1
- package/batteries/llm/webllm_chat_completions/types.d.ts +21 -0
- package/batteries/llm/webllm_chat_completions/validation.cjs +13 -1
- package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -1
- package/batteries/llm/webllm_chat_completions/validation.d.ts +12 -0
- package/batteries/llm/webllm_chat_completions/validation.mjs +13 -1
- package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -1
- package/batteries/llm/webllm_chat_completions.cjs +29 -28
- package/batteries/llm/webllm_chat_completions.mjs +2 -1
- package/batteries/llm.cjs +44 -28
- package/batteries/llm.mjs +9 -4
- package/batteries/storage/flydrive.cjs +1 -1
- package/batteries/storage/flydrive.mjs +1 -1
- package/batteries/storage/in_memory/index.d.ts +1 -1
- package/batteries/storage/in_memory.cjs +2 -2
- package/batteries/storage/in_memory.cjs.map +1 -1
- package/batteries/storage/in_memory.mjs +2 -2
- package/batteries/storage/in_memory.mjs.map +1 -1
- package/batteries/storage/opfs/index.d.ts +19 -0
- package/batteries/storage/opfs.cjs +1 -1
- package/batteries/storage/opfs.cjs.map +1 -1
- package/batteries/storage/opfs.mjs +1 -1
- package/batteries/storage/opfs.mjs.map +1 -1
- package/batteries/tools/_shared/index.d.ts +121 -0
- package/batteries/tools/_shared.cjs +157 -0
- package/batteries/tools/_shared.cjs.map +1 -0
- package/batteries/tools/_shared.mjs +149 -0
- package/batteries/tools/_shared.mjs.map +1 -0
- package/batteries/tools/color.cjs +3 -2
- package/batteries/tools/color.cjs.map +1 -1
- package/batteries/tools/color.mjs +3 -2
- package/batteries/tools/color.mjs.map +1 -1
- package/batteries/tools/comparison.cjs +4 -3
- package/batteries/tools/comparison.cjs.map +1 -1
- package/batteries/tools/comparison.mjs +4 -3
- package/batteries/tools/comparison.mjs.map +1 -1
- package/batteries/tools/data_structure.cjs +30 -10
- package/batteries/tools/data_structure.cjs.map +1 -1
- package/batteries/tools/data_structure.mjs +30 -10
- package/batteries/tools/data_structure.mjs.map +1 -1
- package/batteries/tools/datetime_extended.cjs +5 -10
- package/batteries/tools/datetime_extended.cjs.map +1 -1
- package/batteries/tools/datetime_extended.mjs +5 -10
- package/batteries/tools/datetime_extended.mjs.map +1 -1
- package/batteries/tools/datetime_math.cjs +2 -2
- package/batteries/tools/datetime_math.mjs +2 -2
- package/batteries/tools/encoding.cjs +13 -4
- package/batteries/tools/encoding.cjs.map +1 -1
- package/batteries/tools/encoding.mjs +13 -4
- package/batteries/tools/encoding.mjs.map +1 -1
- package/batteries/tools/formatting.cjs +4 -4
- package/batteries/tools/formatting.cjs.map +1 -1
- package/batteries/tools/formatting.mjs +4 -4
- package/batteries/tools/formatting.mjs.map +1 -1
- package/batteries/tools/geo_basics.cjs +2 -2
- package/batteries/tools/geo_basics.mjs +2 -2
- package/batteries/tools/index.d.ts +3 -0
- package/batteries/tools/math.cjs +10 -8
- package/batteries/tools/math.cjs.map +1 -1
- package/batteries/tools/math.mjs +10 -8
- package/batteries/tools/math.mjs.map +1 -1
- package/batteries/tools/memory.cjs +5 -5
- package/batteries/tools/memory.mjs +5 -5
- package/batteries/tools/parsing.cjs +9 -5
- package/batteries/tools/parsing.cjs.map +1 -1
- package/batteries/tools/parsing.mjs +9 -5
- package/batteries/tools/parsing.mjs.map +1 -1
- package/batteries/tools/retrievables.cjs +4 -4
- package/batteries/tools/retrievables.mjs +4 -4
- package/batteries/tools/scrapper/exceptions.d.ts +21 -0
- package/batteries/tools/scrapper/index.d.ts +172 -0
- package/batteries/tools/scrapper/shared.d.ts +139 -0
- package/batteries/tools/scrapper.cjs +8 -0
- package/batteries/tools/scrapper.mjs +2 -0
- package/batteries/tools/searxng/exceptions.d.ts +21 -0
- package/batteries/tools/searxng/index.d.ts +177 -0
- package/batteries/tools/searxng.cjs +6 -0
- package/batteries/tools/searxng.mjs +2 -0
- package/batteries/tools/standing_instructions.cjs +4 -4
- package/batteries/tools/standing_instructions.mjs +4 -4
- package/batteries/tools/statistics.cjs +54 -43
- package/batteries/tools/statistics.cjs.map +1 -1
- package/batteries/tools/statistics.mjs +54 -43
- package/batteries/tools/statistics.mjs.map +1 -1
- package/batteries/tools/string_processing.cjs +5 -5
- package/batteries/tools/string_processing.cjs.map +1 -1
- package/batteries/tools/string_processing.mjs +5 -5
- package/batteries/tools/string_processing.mjs.map +1 -1
- package/batteries/tools/structured_data.cjs +8 -13
- package/batteries/tools/structured_data.cjs.map +1 -1
- package/batteries/tools/structured_data.mjs +8 -13
- package/batteries/tools/structured_data.mjs.map +1 -1
- 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 +10 -8
- package/batteries/tools/unit_conversion.cjs.map +1 -1
- package/batteries/tools/unit_conversion.mjs +10 -8
- package/batteries/tools/unit_conversion.mjs.map +1 -1
- package/batteries/tools/web_retrieval/index.d.ts +186 -0
- package/batteries/tools/web_retrieval.cjs +206 -0
- package/batteries/tools/web_retrieval.cjs.map +1 -0
- package/batteries/tools/web_retrieval.mjs +201 -0
- package/batteries/tools/web_retrieval.mjs.map +1 -0
- package/batteries/tools.cjs +15 -0
- package/batteries/tools.mjs +4 -1
- package/batteries/vector/arangodb/index.d.ts +2 -0
- package/batteries/vector/arangodb.cjs +2 -1
- package/batteries/vector/arangodb.cjs.map +1 -1
- package/batteries/vector/arangodb.mjs +2 -1
- package/batteries/vector/arangodb.mjs.map +1 -1
- package/batteries/vector/builder.cjs +31 -0
- package/batteries/vector/builder.cjs.map +1 -1
- package/batteries/vector/builder.d.ts +58 -0
- package/batteries/vector/builder.mjs +31 -0
- package/batteries/vector/builder.mjs.map +1 -1
- package/batteries/vector/chroma/index.d.ts +4 -0
- package/batteries/vector/chroma.cjs +3 -0
- package/batteries/vector/chroma.cjs.map +1 -1
- package/batteries/vector/chroma.mjs +3 -0
- package/batteries/vector/chroma.mjs.map +1 -1
- package/batteries/vector/clickhouse/index.d.ts +2 -0
- package/batteries/vector/clickhouse.cjs +2 -1
- package/batteries/vector/clickhouse.cjs.map +1 -1
- package/batteries/vector/clickhouse.mjs +2 -1
- package/batteries/vector/clickhouse.mjs.map +1 -1
- package/batteries/vector/cloudflare/index.d.ts +2 -0
- package/batteries/vector/cloudflare.cjs +2 -1
- package/batteries/vector/cloudflare.cjs.map +1 -1
- package/batteries/vector/cloudflare.mjs +2 -1
- package/batteries/vector/cloudflare.mjs.map +1 -1
- package/batteries/vector/conformance/index.d.ts +22 -0
- package/batteries/vector/conformance.cjs +22 -0
- package/batteries/vector/conformance.cjs.map +1 -1
- package/batteries/vector/conformance.mjs +22 -0
- package/batteries/vector/conformance.mjs.map +1 -1
- package/batteries/vector/contract.cjs +22 -0
- package/batteries/vector/contract.cjs.map +1 -1
- package/batteries/vector/contract.d.ts +51 -0
- package/batteries/vector/contract.mjs +22 -0
- package/batteries/vector/contract.mjs.map +1 -1
- package/batteries/vector/couchbase/index.d.ts +2 -0
- package/batteries/vector/couchbase.cjs +2 -1
- package/batteries/vector/couchbase.cjs.map +1 -1
- package/batteries/vector/couchbase.mjs +2 -1
- package/batteries/vector/couchbase.mjs.map +1 -1
- package/batteries/vector/duckdb/index.d.ts +2 -0
- package/batteries/vector/duckdb.cjs +2 -1
- package/batteries/vector/duckdb.cjs.map +1 -1
- package/batteries/vector/duckdb.mjs +2 -1
- package/batteries/vector/duckdb.mjs.map +1 -1
- package/batteries/vector/elasticsearch/index.d.ts +2 -0
- package/batteries/vector/elasticsearch.cjs +2 -1
- package/batteries/vector/elasticsearch.cjs.map +1 -1
- package/batteries/vector/elasticsearch.mjs +2 -1
- package/batteries/vector/elasticsearch.mjs.map +1 -1
- package/batteries/vector/exceptions.cjs +1 -1
- package/batteries/vector/exceptions.mjs +1 -1
- package/batteries/vector/factory.cjs +6 -0
- package/batteries/vector/factory.cjs.map +1 -1
- package/batteries/vector/factory.d.ts +14 -0
- package/batteries/vector/factory.mjs +6 -0
- package/batteries/vector/factory.mjs.map +1 -1
- package/batteries/vector/filters.cjs +22 -1
- package/batteries/vector/filters.cjs.map +1 -1
- package/batteries/vector/filters.d.ts +38 -0
- package/batteries/vector/filters.mjs +22 -1
- package/batteries/vector/filters.mjs.map +1 -1
- package/batteries/vector/helpers.cjs +13 -0
- package/batteries/vector/helpers.cjs.map +1 -1
- package/batteries/vector/helpers.d.ts +14 -0
- package/batteries/vector/helpers.mjs +13 -0
- package/batteries/vector/helpers.mjs.map +1 -1
- package/batteries/vector/hnswlib/index.d.ts +2 -0
- package/batteries/vector/hnswlib.cjs +2 -1
- package/batteries/vector/hnswlib.cjs.map +1 -1
- package/batteries/vector/hnswlib.mjs +2 -1
- package/batteries/vector/hnswlib.mjs.map +1 -1
- package/batteries/vector/in_memory/index.d.ts +1 -0
- package/batteries/vector/in_memory.cjs +1 -0
- package/batteries/vector/in_memory.cjs.map +1 -1
- package/batteries/vector/in_memory.mjs +1 -0
- package/batteries/vector/in_memory.mjs.map +1 -1
- package/batteries/vector/lancedb/index.d.ts +2 -0
- package/batteries/vector/lancedb.cjs +2 -1
- package/batteries/vector/lancedb.cjs.map +1 -1
- package/batteries/vector/lancedb.mjs +2 -1
- package/batteries/vector/lancedb.mjs.map +1 -1
- package/batteries/vector/mariadb/index.d.ts +2 -0
- package/batteries/vector/mariadb.cjs +2 -1
- package/batteries/vector/mariadb.cjs.map +1 -1
- package/batteries/vector/mariadb.mjs +2 -1
- package/batteries/vector/mariadb.mjs.map +1 -1
- package/batteries/vector/meilisearch/index.d.ts +2 -0
- package/batteries/vector/meilisearch.cjs +2 -1
- package/batteries/vector/meilisearch.cjs.map +1 -1
- package/batteries/vector/meilisearch.mjs +2 -1
- package/batteries/vector/meilisearch.mjs.map +1 -1
- package/batteries/vector/migrate.cjs +18 -1
- package/batteries/vector/migrate.cjs.map +1 -1
- package/batteries/vector/migrate.d.ts +31 -0
- package/batteries/vector/migrate.mjs +18 -1
- package/batteries/vector/migrate.mjs.map +1 -1
- package/batteries/vector/milvus/index.d.ts +5 -0
- package/batteries/vector/milvus.cjs +4 -0
- package/batteries/vector/milvus.cjs.map +1 -1
- package/batteries/vector/milvus.mjs +4 -0
- package/batteries/vector/milvus.mjs.map +1 -1
- package/batteries/vector/mongodb/index.d.ts +2 -0
- package/batteries/vector/mongodb.cjs +2 -1
- package/batteries/vector/mongodb.cjs.map +1 -1
- package/batteries/vector/mongodb.mjs +2 -1
- package/batteries/vector/mongodb.mjs.map +1 -1
- package/batteries/vector/neo4j/index.d.ts +2 -0
- package/batteries/vector/neo4j.cjs +2 -1
- package/batteries/vector/neo4j.cjs.map +1 -1
- package/batteries/vector/neo4j.mjs +2 -1
- package/batteries/vector/neo4j.mjs.map +1 -1
- package/batteries/vector/opensearch/index.d.ts +2 -0
- package/batteries/vector/opensearch.cjs +2 -1
- package/batteries/vector/opensearch.cjs.map +1 -1
- package/batteries/vector/opensearch.mjs +2 -1
- package/batteries/vector/opensearch.mjs.map +1 -1
- package/batteries/vector/oracle23ai/index.d.ts +2 -0
- package/batteries/vector/oracle23ai.cjs +2 -1
- package/batteries/vector/oracle23ai.cjs.map +1 -1
- package/batteries/vector/oracle23ai.mjs +2 -1
- package/batteries/vector/oracle23ai.mjs.map +1 -1
- package/batteries/vector/orama/index.d.ts +1 -0
- package/batteries/vector/orama.cjs +1 -0
- package/batteries/vector/orama.cjs.map +1 -1
- package/batteries/vector/orama.mjs +1 -0
- package/batteries/vector/orama.mjs.map +1 -1
- package/batteries/vector/pgvector/index.d.ts +9 -2
- package/batteries/vector/pgvector.cjs +4 -0
- package/batteries/vector/pgvector.cjs.map +1 -1
- package/batteries/vector/pgvector.mjs +4 -0
- package/batteries/vector/pgvector.mjs.map +1 -1
- package/batteries/vector/pinecone/index.d.ts +5 -0
- package/batteries/vector/pinecone.cjs +3 -1
- package/batteries/vector/pinecone.cjs.map +1 -1
- package/batteries/vector/pinecone.mjs +3 -1
- package/batteries/vector/pinecone.mjs.map +1 -1
- package/batteries/vector/plan.d.ts +27 -0
- package/batteries/vector/qdrant/index.d.ts +5 -0
- package/batteries/vector/qdrant.cjs +4 -0
- package/batteries/vector/qdrant.cjs.map +1 -1
- package/batteries/vector/qdrant.mjs +4 -0
- package/batteries/vector/qdrant.mjs.map +1 -1
- package/batteries/vector/redis/index.d.ts +2 -0
- package/batteries/vector/redis.cjs +2 -1
- package/batteries/vector/redis.cjs.map +1 -1
- package/batteries/vector/redis.mjs +2 -1
- package/batteries/vector/redis.mjs.map +1 -1
- package/batteries/vector/retrievable.cjs +9 -1
- package/batteries/vector/retrievable.cjs.map +1 -1
- package/batteries/vector/retrievable.mjs +9 -1
- package/batteries/vector/retrievable.mjs.map +1 -1
- package/batteries/vector/retrievable_glue.d.ts +21 -0
- package/batteries/vector/s3vectors/index.d.ts +2 -0
- package/batteries/vector/s3vectors.cjs +2 -1
- package/batteries/vector/s3vectors.cjs.map +1 -1
- package/batteries/vector/s3vectors.mjs +2 -1
- package/batteries/vector/s3vectors.mjs.map +1 -1
- package/batteries/vector/schema.cjs +28 -0
- package/batteries/vector/schema.cjs.map +1 -1
- package/batteries/vector/schema.d.ts +39 -0
- package/batteries/vector/schema.mjs +28 -0
- package/batteries/vector/schema.mjs.map +1 -1
- package/batteries/vector/solr/index.d.ts +2 -0
- package/batteries/vector/solr.cjs +2 -1
- package/batteries/vector/solr.cjs.map +1 -1
- package/batteries/vector/solr.mjs +2 -1
- package/batteries/vector/solr.mjs.map +1 -1
- package/batteries/vector/sqlite_vec/index.d.ts +6 -3
- package/batteries/vector/sqlite_vec.cjs +2 -0
- package/batteries/vector/sqlite_vec.cjs.map +1 -1
- package/batteries/vector/sqlite_vec.mjs +2 -0
- package/batteries/vector/sqlite_vec.mjs.map +1 -1
- package/batteries/vector/surrealdb/index.d.ts +2 -0
- package/batteries/vector/surrealdb.cjs +2 -1
- package/batteries/vector/surrealdb.cjs.map +1 -1
- package/batteries/vector/surrealdb.mjs +2 -1
- package/batteries/vector/surrealdb.mjs.map +1 -1
- package/batteries/vector/types.d.ts +27 -0
- package/batteries/vector/typesense/index.d.ts +2 -0
- package/batteries/vector/typesense.cjs +2 -1
- package/batteries/vector/typesense.cjs.map +1 -1
- package/batteries/vector/typesense.mjs +2 -1
- package/batteries/vector/typesense.mjs.map +1 -1
- package/batteries/vector/validation.cjs +14 -0
- package/batteries/vector/validation.cjs.map +1 -1
- package/batteries/vector/validation.d.ts +14 -0
- package/batteries/vector/validation.mjs +14 -0
- package/batteries/vector/validation.mjs.map +1 -1
- package/batteries/vector/vector_store_constructor.cjs +1 -1
- package/batteries/vector/vector_store_constructor.cjs.map +1 -1
- package/batteries/vector/vector_store_constructor.d.ts +1 -1
- package/batteries/vector/vector_store_constructor.mjs +1 -1
- package/batteries/vector/vector_store_constructor.mjs.map +1 -1
- package/batteries/vector/vespa/index.d.ts +2 -0
- package/batteries/vector/vespa.cjs +2 -1
- package/batteries/vector/vespa.cjs.map +1 -1
- package/batteries/vector/vespa.mjs +2 -1
- package/batteries/vector/vespa.mjs.map +1 -1
- package/batteries/vector/weaviate/index.d.ts +2 -0
- package/batteries/vector/weaviate.cjs +2 -1
- package/batteries/vector/weaviate.cjs.map +1 -1
- package/batteries/vector/weaviate.mjs +2 -1
- package/batteries/vector/weaviate.mjs.map +1 -1
- package/batteries.cjs +58 -28
- package/batteries.mjs +12 -5
- package/{common-BT0nfCi9.mjs → common-DYDUi99O.mjs} +9 -9
- package/common-DYDUi99O.mjs.map +1 -0
- package/{common-Cj8TaQ9U.js → common-DZl3ADJs.js} +9 -9
- package/common-DZl3ADJs.js.map +1 -0
- package/common.cjs +7 -7
- package/common.mjs +7 -7
- package/{dispatch_runner-DPcS7Y_M.mjs → dispatch_runner--ZhdDWRZ.mjs} +27 -5
- package/{dispatch_runner-DPcS7Y_M.mjs.map → dispatch_runner--ZhdDWRZ.mjs.map} +1 -1
- package/{dispatch_runner-BHBNupqp.js → dispatch_runner-nHDKkxye.js} +27 -5
- package/{dispatch_runner-BHBNupqp.js.map → dispatch_runner-nHDKkxye.js.map} +1 -1
- package/dispatch_runner.cjs +1 -1
- package/dispatch_runner.d.ts +1 -1
- package/dispatch_runner.mjs +1 -1
- package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs +1 -0
- package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs.map +1 -1
- package/eslint/rules/artifact_tool_forbids_artifact_constructor.d.ts +1 -0
- package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs +1 -0
- package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs.map +1 -1
- package/eslint/rules/no_model_in_tool_handler.cjs +1 -0
- package/eslint/rules/no_model_in_tool_handler.cjs.map +1 -1
- package/eslint/rules/no_model_in_tool_handler.d.ts +1 -0
- package/eslint/rules/no_model_in_tool_handler.mjs +1 -0
- package/eslint/rules/no_model_in_tool_handler.mjs.map +1 -1
- package/eslint/rules/require_validator_any_required.cjs +1 -0
- package/eslint/rules/require_validator_any_required.cjs.map +1 -1
- package/eslint/rules/require_validator_any_required.d.ts +1 -0
- package/eslint/rules/require_validator_any_required.mjs +1 -0
- package/eslint/rules/require_validator_any_required.mjs.map +1 -1
- package/eslint/rules/thought_payload_requires_replay_tag.cjs +1 -0
- package/eslint/rules/thought_payload_requires_replay_tag.cjs.map +1 -1
- package/eslint/rules/thought_payload_requires_replay_tag.d.ts +1 -0
- package/eslint/rules/thought_payload_requires_replay_tag.mjs +1 -0
- package/eslint/rules/thought_payload_requires_replay_tag.mjs.map +1 -1
- package/eslint/rules/token_encoding_requires_context_window.cjs +1 -0
- package/eslint/rules/token_encoding_requires_context_window.cjs.map +1 -1
- package/eslint/rules/token_encoding_requires_context_window.d.ts +1 -0
- package/eslint/rules/token_encoding_requires_context_window.mjs +1 -0
- package/eslint/rules/token_encoding_requires_context_window.mjs.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-BeWH2FwP.mjs → exceptions-BDhN0Xzr.mjs} +3 -2
- package/exceptions-BDhN0Xzr.mjs.map +1 -0
- package/{exceptions-CitH5wZI.js → exceptions-BRXrUKiW.js} +3 -2
- package/exceptions-BRXrUKiW.js.map +1 -0
- package/exceptions.cjs +2 -2
- package/exceptions.mjs +2 -2
- package/factories.cjs +1 -1
- package/factories.mjs +1 -1
- package/forge.cjs +4 -4
- package/forge.d.ts +1 -1
- package/forge.mjs +4 -4
- package/guards.cjs +9 -9
- package/guards.mjs +9 -9
- package/helpers-DSTFxTiC.js +497 -0
- package/helpers-DSTFxTiC.js.map +1 -0
- package/helpers-xhrQbMAG.mjs +306 -0
- package/helpers-xhrQbMAG.mjs.map +1 -0
- package/index.cjs +12 -12
- package/index.mjs +12 -12
- package/lib/classes/base_exception.d.ts +1 -0
- package/lib/classes/media.d.ts +10 -0
- package/lib/classes/retrievable.d.ts +1 -1
- package/lib/classes/spooled_json_artifact.d.ts +1 -1
- package/lib/classes/spooled_markdown_artifact.d.ts +1 -0
- package/lib/classes/tokenizable.d.ts +3 -0
- package/lib/classes/tool.d.ts +8 -0
- package/lib/classes/turn_gate.d.ts +6 -0
- package/lib/dispatch_runner.d.ts +4 -32
- package/lib/helpers/bignum.cjs +82 -0
- package/lib/helpers/bignum.cjs.map +1 -0
- package/lib/helpers/bignum.d.ts +52 -0
- package/lib/helpers/bignum.mjs +74 -0
- package/lib/helpers/bignum.mjs.map +1 -0
- package/lib/turn_runner.d.ts +1 -1
- package/lib/types/dispatch_runner.d.ts +83 -0
- package/lib/utils/exceptions.d.ts +1 -1
- package/lib/utils/retry.cjs.map +1 -1
- package/lib/utils/retry.d.ts +2 -0
- package/lib/utils/retry.mjs.map +1 -1
- package/mcp/adk-docs-corpus.json +1 -1
- package/package.json +259 -204
- package/{runtime-j92CNi5z.mjs → runtime-Bz5zA8wc.mjs} +2 -2
- package/{runtime-j92CNi5z.mjs.map → runtime-Bz5zA8wc.mjs.map} +1 -1
- package/{runtime-MFFcJrRv.js → runtime-DslE1aBw.js} +2 -2
- package/{runtime-MFFcJrRv.js.map → runtime-DslE1aBw.js.map} +1 -1
- package/scrapper-BHM1mCde.mjs +432 -0
- package/scrapper-BHM1mCde.mjs.map +1 -0
- package/scrapper-BeweWurk.js +462 -0
- package/scrapper-BeweWurk.js.map +1 -0
- package/searxng-BJFulNcK.mjs +247 -0
- package/searxng-BJFulNcK.mjs.map +1 -0
- package/searxng-B_D--V5q.js +265 -0
- package/searxng-B_D--V5q.js.map +1 -0
- package/skills/adk-assembly/SKILL.md +2 -2
- package/{spooled_artifact-CHoZgWwI.mjs → spooled_artifact-7eePq7JA.mjs} +5 -5
- package/{spooled_artifact-CHoZgWwI.mjs.map → spooled_artifact-7eePq7JA.mjs.map} +1 -1
- package/{spooled_artifact-BTq6Nzfy.js → spooled_artifact-DX8LLyUX.js} +5 -5
- package/{spooled_artifact-BTq6Nzfy.js.map → spooled_artifact-DX8LLyUX.js.map} +1 -1
- package/spooled_artifact.cjs +2 -2
- package/spooled_artifact.mjs +2 -2
- package/{spooled_markdown_artifact-CALSDxIx.js → spooled_markdown_artifact-ClX72lek.js} +4 -4
- package/spooled_markdown_artifact-ClX72lek.js.map +1 -0
- package/{spooled_markdown_artifact-Ci5UL7l4.mjs → spooled_markdown_artifact-wkrBF3oX.mjs} +4 -4
- package/spooled_markdown_artifact-wkrBF3oX.mjs.map +1 -0
- package/{thought-D34QQZZ9.mjs → thought-B_vxAiKU.mjs} +5 -5
- package/{thought-D34QQZZ9.mjs.map → thought-B_vxAiKU.mjs.map} +1 -1
- package/{thought-BbwhJ1wb.js → thought-DLwpF7MI.js} +5 -5
- package/{thought-BbwhJ1wb.js.map → thought-DLwpF7MI.js.map} +1 -1
- package/{tool-CVyZkFC7.js → tool-D5WGVIcI.js} +4 -4
- package/{tool-CVyZkFC7.js.map → tool-D5WGVIcI.js.map} +1 -1
- package/{tool-CMhaDRNd.mjs → tool-wMYMVl60.mjs} +4 -4
- package/{tool-CMhaDRNd.mjs.map → tool-wMYMVl60.mjs.map} +1 -1
- package/{tool_call-CV5qVNlb.mjs → tool_call-B4-_-vjG.mjs} +5 -5
- package/tool_call-B4-_-vjG.mjs.map +1 -0
- package/{tool_call-Db68hB7y.js → tool_call-DixVlW40.js} +5 -5
- package/tool_call-DixVlW40.js.map +1 -0
- package/{tool_registry-D1pSSlsd.mjs → tool_registry-791Vrjtf.mjs} +4 -3
- package/tool_registry-791Vrjtf.mjs.map +1 -0
- package/{tool_registry-DYUYqXvo.js → tool_registry-CKJPze3j.js} +4 -3
- package/tool_registry-CKJPze3j.js.map +1 -0
- package/{turn_runner-DqWHNP80.js → turn_runner-HXImLGIn.js} +7 -7
- package/turn_runner-HXImLGIn.js.map +1 -0
- package/{turn_runner-fg1Wc3dK.mjs → turn_runner-ZyYO-Kti.mjs} +7 -7
- package/turn_runner-ZyYO-Kti.mjs.map +1 -0
- package/turn_runner.cjs +1 -1
- package/turn_runner.mjs +1 -1
- package/types.d.ts +1 -1
- package/common-BT0nfCi9.mjs.map +0 -1
- package/common-Cj8TaQ9U.js.map +0 -1
- package/exceptions-BeWH2FwP.mjs.map +0 -1
- package/exceptions-CitH5wZI.js.map +0 -1
- package/spooled_markdown_artifact-CALSDxIx.js.map +0 -1
- package/spooled_markdown_artifact-Ci5UL7l4.mjs.map +0 -1
- package/tool_call-CV5qVNlb.mjs.map +0 -1
- package/tool_call-Db68hB7y.js.map +0 -1
- package/tool_registry-D1pSSlsd.mjs.map +0 -1
- package/tool_registry-DYUYqXvo.js.map +0 -1
- package/turn_runner-DqWHNP80.js.map +0 -1
- package/turn_runner-fg1Wc3dK.mjs.map +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swappable translation helpers for rendering ADK state into native Ollama `/api/chat` requests.
|
|
3
|
+
*
|
|
4
|
+
* @module @nhtio/adk/batteries/llm/ollama/helpers
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The wire-shape-agnostic helpers (`renderUntrustedContent`, `renderMemories`,
|
|
8
|
+
* `renderChatCompletionsSystemPrompt`, `toolsToChatCompletionsTools`, …) are shared with the OpenAI
|
|
9
|
+
* battery via the internal `../chat_common/helpers` submodule and re-exported here under their
|
|
10
|
+
* original names. Only the Ollama-WIRE-SPECIFIC helpers are defined here:
|
|
11
|
+
* `renderOllamaTimelineMessage` (flat `content` + base64 `images[]` + `thinking`),
|
|
12
|
+
* `renderOllamaToolCallResult` (string-only result content), `buildOllamaHistory` (synthetic
|
|
13
|
+
* `assistant.tool_calls` with object-form `arguments` + `tool`-role messages labelled by
|
|
14
|
+
* `tool_name`), and `ollamaToolsFromTools` (alias of the shared tool-definition renderer — native
|
|
15
|
+
* `/api/chat` uses the same function-tool wire shape).
|
|
16
|
+
*
|
|
17
|
+
* Native `/api/chat` supports only base64 `images[]`; every non-image modality routes through the
|
|
18
|
+
* `unsupportedMediaPolicy` fallback (stash text / synthetic description) or throws.
|
|
19
|
+
*/
|
|
20
|
+
import { Media } from "../../../common";
|
|
21
|
+
import { toolsToChatCompletionsTools } from "../chat_common/helpers";
|
|
22
|
+
import type { ChatHelpersCommon } from "../chat_common/types";
|
|
23
|
+
import type { OllamaMessage, OllamaTool, OllamaHelpers, ChatCompletionsBucketOrder, UnsupportedMediaPolicy } from "./types";
|
|
24
|
+
import type { Tool, ArtifactTool, ToolRegistry, Tokenizable, Memory, Message, Thought, ToolCall, Retrievable, SpooledArtifact } from "../../../common";
|
|
25
|
+
export { descriptionToChatCompletionsJsonSchema, defaultDescriptionToChatCompletionsJsonSchema, renderUntrustedContent, defaultRenderUntrustedContent, renderTrustedContent, defaultRenderTrustedContent, renderStandingInstructions, defaultRenderStandingInstructions, renderMemories, defaultRenderMemories, renderRetrievableSafetyDirective, defaultRenderRetrievableSafetyDirective, renderFirstPartyRetrievables, defaultRenderFirstPartyRetrievables, renderThirdPartyPublicRetrievables, defaultRenderThirdPartyPublicRetrievables, renderThirdPartyPrivateRetrievables, defaultRenderThirdPartyPrivateRetrievables, renderRetrievables, defaultRenderRetrievables, renderThought, defaultRenderThought, filterThoughts, defaultFilterThoughts, toolsToChatCompletionsTools, defaultToolsToChatCompletionsTools, renderChatCompletionsSystemPrompt, defaultRenderChatCompletionsSystemPrompt, } from "../chat_common/helpers";
|
|
26
|
+
/**
|
|
27
|
+
* Convert ADK tools to the native Ollama `tools[]` wire. Native `/api/chat` uses the identical
|
|
28
|
+
* `{ type: 'function', function: { name, description, parameters } }` shape as Chat Completions, so
|
|
29
|
+
* this is an alias of the shared renderer.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ollamaToolsFromTools: (tools: ReadonlyArray<Tool | ArtifactTool>, deps: Parameters<typeof toolsToChatCompletionsTools>[1]) => OllamaTool[];
|
|
32
|
+
/** Default implementation of {@link OllamaHelpers}-style tool translation; alias of {@link ollamaToolsFromTools}. */
|
|
33
|
+
export declare const defaultOllamaToolsFromTools: (tools: ReadonlyArray<Tool | ArtifactTool>, deps: Parameters<typeof toolsToChatCompletionsTools>[1]) => OllamaTool[];
|
|
34
|
+
/**
|
|
35
|
+
* Renders a single timeline {@link @nhtio/adk!Message} into a native Ollama message — flattening any
|
|
36
|
+
* media into the base64 `images[]` array, surfacing reasoning as `thinking`, and wrapping textual
|
|
37
|
+
* bodies in the appropriate trust envelope.
|
|
38
|
+
*/
|
|
39
|
+
export declare const renderOllamaTimelineMessage: (input: {
|
|
40
|
+
message: Message;
|
|
41
|
+
selfIdentity: string;
|
|
42
|
+
unsupportedMediaPolicy: UnsupportedMediaPolicy;
|
|
43
|
+
warn?: (msg: string) => void;
|
|
44
|
+
}) => Promise<OllamaMessage>;
|
|
45
|
+
/** Default timeline-message renderer; alias of {@link renderOllamaTimelineMessage}. */
|
|
46
|
+
export declare const defaultRenderOllamaTimelineMessage: (input: {
|
|
47
|
+
message: Message;
|
|
48
|
+
selfIdentity: string;
|
|
49
|
+
unsupportedMediaPolicy: UnsupportedMediaPolicy;
|
|
50
|
+
warn?: (msg: string) => void;
|
|
51
|
+
}) => Promise<OllamaMessage>;
|
|
52
|
+
/**
|
|
53
|
+
* Render a tool-call result to native Ollama tool-message content (always a string). Media results
|
|
54
|
+
* are routed through the internal media renderer: images cannot ride on a tool-role message's
|
|
55
|
+
* `content`, so an image result is replaced with a short text marker (the image bytes are not
|
|
56
|
+
* re-sent on a tool message); non-image media use the same fallback-text path as elsewhere.
|
|
57
|
+
*/
|
|
58
|
+
export declare const renderOllamaToolCallResult: (input: {
|
|
59
|
+
toolCall: ToolCall;
|
|
60
|
+
results: Tokenizable | SpooledArtifact | SpooledArtifact[] | Media | Media[];
|
|
61
|
+
tool: Tool | ArtifactTool | undefined;
|
|
62
|
+
renderUntrustedContent: ChatHelpersCommon["renderUntrustedContent"];
|
|
63
|
+
renderTrustedContent: ChatHelpersCommon["renderTrustedContent"];
|
|
64
|
+
unsupportedMediaPolicy: UnsupportedMediaPolicy;
|
|
65
|
+
warn?: (msg: string) => void;
|
|
66
|
+
}) => Promise<string>;
|
|
67
|
+
/** Default tool-call-result renderer; alias of {@link renderOllamaToolCallResult}. */
|
|
68
|
+
export declare const defaultRenderOllamaToolCallResult: (input: {
|
|
69
|
+
toolCall: ToolCall;
|
|
70
|
+
results: Tokenizable | SpooledArtifact | SpooledArtifact[] | Media | Media[];
|
|
71
|
+
tool: Tool | ArtifactTool | undefined;
|
|
72
|
+
renderUntrustedContent: ChatHelpersCommon["renderUntrustedContent"];
|
|
73
|
+
renderTrustedContent: ChatHelpersCommon["renderTrustedContent"];
|
|
74
|
+
unsupportedMediaPolicy: UnsupportedMediaPolicy;
|
|
75
|
+
warn?: (msg: string) => void;
|
|
76
|
+
}) => Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* Assembles the complete native Ollama message history for a dispatch — system prompt and content
|
|
79
|
+
* buckets, the interleaved timeline of messages/thoughts/tool calls, and the collected opaque
|
|
80
|
+
* reasoning payloads — by delegating to the injected sub-renderers.
|
|
81
|
+
*/
|
|
82
|
+
export declare const buildOllamaHistory: (input: {
|
|
83
|
+
systemPrompt: Tokenizable;
|
|
84
|
+
standingInstructions: Iterable<Tokenizable>;
|
|
85
|
+
memories: Iterable<Memory>;
|
|
86
|
+
retrievables: Iterable<Retrievable>;
|
|
87
|
+
messages: Iterable<Message>;
|
|
88
|
+
thoughts: Iterable<Thought>;
|
|
89
|
+
toolCalls: Iterable<ToolCall>;
|
|
90
|
+
tools: ToolRegistry;
|
|
91
|
+
renderedToolCallResults: Map<string, string>;
|
|
92
|
+
bucketOrder: ChatCompletionsBucketOrder;
|
|
93
|
+
selfIdentity: string;
|
|
94
|
+
thoughtSurfacing: "all-self" | "latest-self" | "all";
|
|
95
|
+
replayCompatibility: ReadonlyArray<string>;
|
|
96
|
+
unsupportedMediaPolicy: UnsupportedMediaPolicy;
|
|
97
|
+
renderOllamaToolCallResult: OllamaHelpers["renderOllamaToolCallResult"];
|
|
98
|
+
renderChatCompletionsSystemPrompt: ChatHelpersCommon["renderChatCompletionsSystemPrompt"];
|
|
99
|
+
renderStandingInstructions: ChatHelpersCommon["renderStandingInstructions"];
|
|
100
|
+
renderMemories: ChatHelpersCommon["renderMemories"];
|
|
101
|
+
renderRetrievables: ChatHelpersCommon["renderRetrievables"];
|
|
102
|
+
renderRetrievableSafetyDirective: ChatHelpersCommon["renderRetrievableSafetyDirective"];
|
|
103
|
+
renderFirstPartyRetrievables: ChatHelpersCommon["renderFirstPartyRetrievables"];
|
|
104
|
+
renderThirdPartyPublicRetrievables: ChatHelpersCommon["renderThirdPartyPublicRetrievables"];
|
|
105
|
+
renderThirdPartyPrivateRetrievables: ChatHelpersCommon["renderThirdPartyPrivateRetrievables"];
|
|
106
|
+
renderOllamaTimelineMessage: OllamaHelpers["renderOllamaTimelineMessage"];
|
|
107
|
+
renderThought: ChatHelpersCommon["renderThought"];
|
|
108
|
+
filterThoughts: ChatHelpersCommon["filterThoughts"];
|
|
109
|
+
renderUntrustedContent: ChatHelpersCommon["renderUntrustedContent"];
|
|
110
|
+
renderTrustedContent: ChatHelpersCommon["renderTrustedContent"];
|
|
111
|
+
warn?: (msg: string) => void;
|
|
112
|
+
}) => Promise<{
|
|
113
|
+
messages: OllamaMessage[];
|
|
114
|
+
reasoningPayloads: Array<{
|
|
115
|
+
id: string;
|
|
116
|
+
replayCompatibility: string;
|
|
117
|
+
payload: unknown;
|
|
118
|
+
}>;
|
|
119
|
+
}>;
|
|
120
|
+
/** Default native-history assembler; alias of {@link buildOllamaHistory}. */
|
|
121
|
+
export declare const defaultBuildOllamaHistory: (input: {
|
|
122
|
+
systemPrompt: Tokenizable;
|
|
123
|
+
standingInstructions: Iterable<Tokenizable>;
|
|
124
|
+
memories: Iterable<Memory>;
|
|
125
|
+
retrievables: Iterable<Retrievable>;
|
|
126
|
+
messages: Iterable<Message>;
|
|
127
|
+
thoughts: Iterable<Thought>;
|
|
128
|
+
toolCalls: Iterable<ToolCall>;
|
|
129
|
+
tools: ToolRegistry;
|
|
130
|
+
renderedToolCallResults: Map<string, string>;
|
|
131
|
+
bucketOrder: ChatCompletionsBucketOrder;
|
|
132
|
+
selfIdentity: string;
|
|
133
|
+
thoughtSurfacing: "all-self" | "latest-self" | "all";
|
|
134
|
+
replayCompatibility: ReadonlyArray<string>;
|
|
135
|
+
unsupportedMediaPolicy: UnsupportedMediaPolicy;
|
|
136
|
+
renderOllamaToolCallResult: OllamaHelpers["renderOllamaToolCallResult"];
|
|
137
|
+
renderChatCompletionsSystemPrompt: ChatHelpersCommon["renderChatCompletionsSystemPrompt"];
|
|
138
|
+
renderStandingInstructions: ChatHelpersCommon["renderStandingInstructions"];
|
|
139
|
+
renderMemories: ChatHelpersCommon["renderMemories"];
|
|
140
|
+
renderRetrievables: ChatHelpersCommon["renderRetrievables"];
|
|
141
|
+
renderRetrievableSafetyDirective: ChatHelpersCommon["renderRetrievableSafetyDirective"];
|
|
142
|
+
renderFirstPartyRetrievables: ChatHelpersCommon["renderFirstPartyRetrievables"];
|
|
143
|
+
renderThirdPartyPublicRetrievables: ChatHelpersCommon["renderThirdPartyPublicRetrievables"];
|
|
144
|
+
renderThirdPartyPrivateRetrievables: ChatHelpersCommon["renderThirdPartyPrivateRetrievables"];
|
|
145
|
+
renderOllamaTimelineMessage: OllamaHelpers["renderOllamaTimelineMessage"];
|
|
146
|
+
renderThought: ChatHelpersCommon["renderThought"];
|
|
147
|
+
filterThoughts: ChatHelpersCommon["filterThoughts"];
|
|
148
|
+
renderUntrustedContent: ChatHelpersCommon["renderUntrustedContent"];
|
|
149
|
+
renderTrustedContent: ChatHelpersCommon["renderTrustedContent"];
|
|
150
|
+
warn?: (msg: string) => void;
|
|
151
|
+
}) => Promise<{
|
|
152
|
+
messages: OllamaMessage[];
|
|
153
|
+
reasoningPayloads: Array<{
|
|
154
|
+
id: string;
|
|
155
|
+
replayCompatibility: string;
|
|
156
|
+
payload: unknown;
|
|
157
|
+
}>;
|
|
158
|
+
}>;
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import "../../../common-DYDUi99O.mjs";
|
|
2
|
+
import { n as Media } from "../../../tool_call-B4-_-vjG.mjs";
|
|
3
|
+
import "../../../guards.mjs";
|
|
4
|
+
import { A as retrievableToAttrs, C as renderRetrievables, D as renderThought, E as renderThirdPartyPublicRetrievables, M as toolsToChatCompletionsTools, O as renderTrustedContent, S as renderRetrievableSafetyDirective, T as renderThirdPartyPrivateRetrievables, _ as filterThoughts, a as defaultRenderMemories, b as renderFirstPartyRetrievables, c as defaultRenderStandingInstructions, d as defaultRenderThought, f as defaultRenderTrustedContent, g as escapeXmlAttribute, h as descriptionToChatCompletionsJsonSchema, i as defaultRenderFirstPartyRetrievables, k as renderUntrustedContent, l as defaultRenderThirdPartyPrivateRetrievables, m as defaultToolsToChatCompletionsTools, n as defaultFilterThoughts, o as defaultRenderRetrievableSafetyDirective, p as defaultRenderUntrustedContent, r as defaultRenderChatCompletionsSystemPrompt, s as defaultRenderRetrievables, t as defaultDescriptionToChatCompletionsJsonSchema, u as defaultRenderThirdPartyPublicRetrievables, v as memoryToAttrs, w as renderStandingInstructions, x as renderMemories, y as renderChatCompletionsSystemPrompt } from "../../../helpers-xhrQbMAG.mjs";
|
|
5
|
+
import { E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY } from "./exceptions.mjs";
|
|
6
|
+
//#region src/batteries/llm/ollama/helpers.ts
|
|
7
|
+
/**
|
|
8
|
+
* Swappable translation helpers for rendering ADK state into native Ollama `/api/chat` requests.
|
|
9
|
+
*
|
|
10
|
+
* @module @nhtio/adk/batteries/llm/ollama/helpers
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* The wire-shape-agnostic helpers (`renderUntrustedContent`, `renderMemories`,
|
|
14
|
+
* `renderChatCompletionsSystemPrompt`, `toolsToChatCompletionsTools`, …) are shared with the OpenAI
|
|
15
|
+
* battery via the internal `../chat_common/helpers` submodule and re-exported here under their
|
|
16
|
+
* original names. Only the Ollama-WIRE-SPECIFIC helpers are defined here:
|
|
17
|
+
* `renderOllamaTimelineMessage` (flat `content` + base64 `images[]` + `thinking`),
|
|
18
|
+
* `renderOllamaToolCallResult` (string-only result content), `buildOllamaHistory` (synthetic
|
|
19
|
+
* `assistant.tool_calls` with object-form `arguments` + `tool`-role messages labelled by
|
|
20
|
+
* `tool_name`), and `ollamaToolsFromTools` (alias of the shared tool-definition renderer — native
|
|
21
|
+
* `/api/chat` uses the same function-tool wire shape).
|
|
22
|
+
*
|
|
23
|
+
* Native `/api/chat` supports only base64 `images[]`; every non-image modality routes through the
|
|
24
|
+
* `unsupportedMediaPolicy` fallback (stash text / synthetic description) or throws.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Convert ADK tools to the native Ollama `tools[]` wire. Native `/api/chat` uses the identical
|
|
28
|
+
* `{ type: 'function', function: { name, description, parameters } }` shape as Chat Completions, so
|
|
29
|
+
* this is an alias of the shared renderer.
|
|
30
|
+
*/
|
|
31
|
+
var ollamaToolsFromTools = (tools, deps) => toolsToChatCompletionsTools(tools, deps);
|
|
32
|
+
/** Default implementation of {@link OllamaHelpers}-style tool translation; alias of {@link ollamaToolsFromTools}. */
|
|
33
|
+
var defaultOllamaToolsFromTools = ollamaToolsFromTools;
|
|
34
|
+
var DEFAULT_STASH_FALLBACK_KEYS = [
|
|
35
|
+
"text:transcript",
|
|
36
|
+
"text:caption",
|
|
37
|
+
"text:description"
|
|
38
|
+
];
|
|
39
|
+
var modalityHazardToAttr = (h) => {
|
|
40
|
+
if (h === "inert") return "inert";
|
|
41
|
+
if (h === "extractable-instructions") return "extractable";
|
|
42
|
+
return "opaque";
|
|
43
|
+
};
|
|
44
|
+
var formatBytesHumanReadable = (bytes) => {
|
|
45
|
+
if (bytes === void 0 || !Number.isFinite(bytes)) return "unknown size";
|
|
46
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
47
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
48
|
+
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
49
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
50
|
+
};
|
|
51
|
+
var isMediaTextStashEntry = (e) => {
|
|
52
|
+
if (!e || typeof e !== "object") return false;
|
|
53
|
+
const r = e;
|
|
54
|
+
return typeof r.value === "string" && typeof r.trustTier === "string";
|
|
55
|
+
};
|
|
56
|
+
var resolveFallbackStash = (media, keys) => {
|
|
57
|
+
for (const key of keys) {
|
|
58
|
+
const entry = media.stash.get(key);
|
|
59
|
+
if (isMediaTextStashEntry(entry)) return {
|
|
60
|
+
text: entry.value,
|
|
61
|
+
entryTier: entry.trustTier
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var renderTextInEnvelope = (text, args) => {
|
|
66
|
+
if (args.trustTier === "first-party") return args.renderTrustedContent(text, {
|
|
67
|
+
nonce: args.nonce,
|
|
68
|
+
kind: "media-fallback",
|
|
69
|
+
tool: args.toolName,
|
|
70
|
+
modality: args.modality
|
|
71
|
+
});
|
|
72
|
+
return args.renderUntrustedContent(text, {
|
|
73
|
+
nonce: args.nonce,
|
|
74
|
+
kind: "media-fallback",
|
|
75
|
+
tool: args.toolName,
|
|
76
|
+
modality: args.modality
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
var renderSyntheticMediaDescription = (media, byteLen) => `[media: ${media.filename}, ${media.mimeType}, ${formatBytesHumanReadable(byteLen)}]`;
|
|
80
|
+
/**
|
|
81
|
+
* Render a single {@link Media} for the native Ollama wire. Images become a base64 entry pushed to
|
|
82
|
+
* the message's `images[]` array (returned via `image`); every other modality is unsupported and
|
|
83
|
+
* routes through `unsupportedMediaPolicy` to a text envelope (returned via `text`) or throws.
|
|
84
|
+
*/
|
|
85
|
+
var renderMediaForOllama = async (input) => {
|
|
86
|
+
const { media, toolName, nonce, unsupportedMediaPolicy, warn } = input;
|
|
87
|
+
const modality = modalityHazardToAttr(media.modalityHazard);
|
|
88
|
+
if (media.kind === "image") return { image: await media.asBase64() };
|
|
89
|
+
const fallbackText = async (keys, allowSyntheticFallthrough) => {
|
|
90
|
+
const fallback = resolveFallbackStash(media, keys);
|
|
91
|
+
if (fallback) return { text: renderTextInEnvelope(fallback.text, {
|
|
92
|
+
trustTier: fallback.entryTier,
|
|
93
|
+
modality,
|
|
94
|
+
nonce,
|
|
95
|
+
toolName,
|
|
96
|
+
renderTrustedContent: input.renderTrustedContent,
|
|
97
|
+
renderUntrustedContent: input.renderUntrustedContent
|
|
98
|
+
}) };
|
|
99
|
+
if (!allowSyntheticFallthrough) warn?.(`unsupportedMediaPolicy='fallback-stash' for ${media.filename}: no matching stash entry — falling through to synthetic description.`);
|
|
100
|
+
return { text: renderTextInEnvelope(renderSyntheticMediaDescription(media, await media.byteLength()), {
|
|
101
|
+
trustTier: media.trustTier,
|
|
102
|
+
modality,
|
|
103
|
+
nonce,
|
|
104
|
+
toolName,
|
|
105
|
+
renderTrustedContent: input.renderTrustedContent,
|
|
106
|
+
renderUntrustedContent: input.renderUntrustedContent
|
|
107
|
+
}) };
|
|
108
|
+
};
|
|
109
|
+
if (unsupportedMediaPolicy === "throw") throw new E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY([
|
|
110
|
+
media.kind,
|
|
111
|
+
media.mimeType,
|
|
112
|
+
media.filename
|
|
113
|
+
]);
|
|
114
|
+
if (unsupportedMediaPolicy === "fallback-stash" || typeof unsupportedMediaPolicy === "object" && unsupportedMediaPolicy.mode === "fallback-stash") return fallbackText(typeof unsupportedMediaPolicy === "object" ? unsupportedMediaPolicy.stashKeys : DEFAULT_STASH_FALLBACK_KEYS, false);
|
|
115
|
+
return fallbackText([], true);
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Renders a single timeline {@link @nhtio/adk!Message} into a native Ollama message — flattening any
|
|
119
|
+
* media into the base64 `images[]` array, surfacing reasoning as `thinking`, and wrapping textual
|
|
120
|
+
* bodies in the appropriate trust envelope.
|
|
121
|
+
*/
|
|
122
|
+
var renderOllamaTimelineMessage = async (input) => {
|
|
123
|
+
const { message, selfIdentity, unsupportedMediaPolicy, warn } = input;
|
|
124
|
+
const identifier = message.identity?.identifier !== void 0 && message.identity?.identifier !== null ? String(message.identity.identifier) : "";
|
|
125
|
+
const representationRaw = message.identity?.representation !== void 0 && message.identity?.representation !== null ? message.identity.representation.toString() : "";
|
|
126
|
+
const representation = representationRaw.length > 0 ? representationRaw : identifier;
|
|
127
|
+
const text = message.content !== void 0 ? message.content.toString() : "";
|
|
128
|
+
const createdAtStr = message.createdAt.toISO?.() ?? "";
|
|
129
|
+
const createdAtAttr = createdAtStr ? ` createdAt="${escapeXmlAttribute(createdAtStr)}"` : "";
|
|
130
|
+
const attachments = message.attachments;
|
|
131
|
+
let envelopeText;
|
|
132
|
+
let role;
|
|
133
|
+
if (message.role === "user") {
|
|
134
|
+
role = "user";
|
|
135
|
+
if (identifier.length === 0) envelopeText = text;
|
|
136
|
+
else {
|
|
137
|
+
const fromAttr = escapeXmlAttribute(representation);
|
|
138
|
+
envelopeText = `<message_${message.id} from="${fromAttr}" role="user"${createdAtAttr}>\n${text}\n</message_${message.id}>`;
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
role = "assistant";
|
|
142
|
+
if (identifier.length === 0 || identifier === selfIdentity) envelopeText = text;
|
|
143
|
+
else {
|
|
144
|
+
const fromAttr = escapeXmlAttribute(representation);
|
|
145
|
+
envelopeText = `<peer_agent_output_${message.id} from="${fromAttr}"${createdAtAttr}>\n${text}\n</peer_agent_output_${message.id}>`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const images = [];
|
|
149
|
+
const extraTexts = [];
|
|
150
|
+
for (const media of attachments) {
|
|
151
|
+
const rendered = await renderMediaForOllama({
|
|
152
|
+
media,
|
|
153
|
+
toolName: void 0,
|
|
154
|
+
nonce: message.id,
|
|
155
|
+
unsupportedMediaPolicy,
|
|
156
|
+
renderTrustedContent,
|
|
157
|
+
renderUntrustedContent,
|
|
158
|
+
warn
|
|
159
|
+
});
|
|
160
|
+
if (rendered.image !== void 0) images.push(rendered.image);
|
|
161
|
+
if (rendered.text !== void 0) extraTexts.push(rendered.text);
|
|
162
|
+
}
|
|
163
|
+
const contentParts = [];
|
|
164
|
+
if (envelopeText.length > 0) contentParts.push(envelopeText);
|
|
165
|
+
for (const t of extraTexts) contentParts.push(t);
|
|
166
|
+
const out = {
|
|
167
|
+
role,
|
|
168
|
+
content: contentParts.join("\n")
|
|
169
|
+
};
|
|
170
|
+
if (images.length > 0) out.images = images;
|
|
171
|
+
return out;
|
|
172
|
+
};
|
|
173
|
+
/** Default timeline-message renderer; alias of {@link renderOllamaTimelineMessage}. */
|
|
174
|
+
var defaultRenderOllamaTimelineMessage = renderOllamaTimelineMessage;
|
|
175
|
+
var looksLikeSpooledArtifact = (value) => {
|
|
176
|
+
if (!value || typeof value !== "object") return false;
|
|
177
|
+
const v = value;
|
|
178
|
+
return typeof v.asString === "function" && typeof v.byteLength === "function" && typeof v.lineCount === "function" && typeof v.estimateTokens === "function";
|
|
179
|
+
};
|
|
180
|
+
var renderArtifactHandleBody = (toolCall, artifact, byteLength, lineCount) => {
|
|
181
|
+
const ctor = artifact.constructor;
|
|
182
|
+
const methods = ctor?.toolMethods ?? [];
|
|
183
|
+
const lines = [];
|
|
184
|
+
lines.push(`This tool returned a large artifact that was not inlined to preserve context budget.`);
|
|
185
|
+
lines.push(``);
|
|
186
|
+
lines.push(`Artifact metadata:`);
|
|
187
|
+
lines.push(`- callId: ${toolCall.id}`);
|
|
188
|
+
lines.push(`- kind: ${ctor?.constructor?.name ?? "SpooledArtifact"}`);
|
|
189
|
+
lines.push(`- byteLength: ${byteLength}`);
|
|
190
|
+
lines.push(`- lineCount: ${lineCount}`);
|
|
191
|
+
lines.push(``);
|
|
192
|
+
lines.push(`To read this artifact in this turn, call one of the following tools with`);
|
|
193
|
+
lines.push(`callId=${toolCall.id}:`);
|
|
194
|
+
for (const m of methods) if (m.description) lines.push(`- ${m.name} — ${m.description}`);
|
|
195
|
+
else lines.push(`- ${m.name}`);
|
|
196
|
+
lines.push(``);
|
|
197
|
+
lines.push(`The artifact persists in this turn's context — multiple queries against the same callId are allowed and efficient. Do not assume the body has been inlined anywhere else.`);
|
|
198
|
+
return lines.join("\n");
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Render a tool-call result to native Ollama tool-message content (always a string). Media results
|
|
202
|
+
* are routed through the internal media renderer: images cannot ride on a tool-role message's
|
|
203
|
+
* `content`, so an image result is replaced with a short text marker (the image bytes are not
|
|
204
|
+
* re-sent on a tool message); non-image media use the same fallback-text path as elsewhere.
|
|
205
|
+
*/
|
|
206
|
+
var renderOllamaToolCallResult = async (input) => {
|
|
207
|
+
const { toolCall, results, tool, warn, unsupportedMediaPolicy } = input;
|
|
208
|
+
const isTrusted = tool !== null && tool !== void 0 && tool.trusted === true;
|
|
209
|
+
if (tool === void 0) warn?.(`Tool "${toolCall.tool}" is not present in the bound tool registry at render time; defaulting to untrusted envelope.`);
|
|
210
|
+
const isMediaResult = Media.isMedia(results);
|
|
211
|
+
const isMediaArrayResult = Array.isArray(results) && results.length > 0 && results.every((r) => Media.isMedia(r));
|
|
212
|
+
if (isMediaResult || isMediaArrayResult) {
|
|
213
|
+
const mediaList = isMediaResult ? [results] : results;
|
|
214
|
+
const parts = [];
|
|
215
|
+
for (const media of mediaList) {
|
|
216
|
+
const rendered = await renderMediaForOllama({
|
|
217
|
+
media,
|
|
218
|
+
toolName: toolCall.tool,
|
|
219
|
+
nonce: toolCall.checksum,
|
|
220
|
+
unsupportedMediaPolicy,
|
|
221
|
+
renderTrustedContent: input.renderTrustedContent,
|
|
222
|
+
renderUntrustedContent: input.renderUntrustedContent,
|
|
223
|
+
warn
|
|
224
|
+
});
|
|
225
|
+
if (rendered.text !== void 0) parts.push(rendered.text);
|
|
226
|
+
else {
|
|
227
|
+
const byteLen = await media.byteLength();
|
|
228
|
+
parts.push(input.renderUntrustedContent(renderSyntheticMediaDescription(media, byteLen), {
|
|
229
|
+
nonce: toolCall.checksum,
|
|
230
|
+
kind: "tool-result-image",
|
|
231
|
+
tool: toolCall.tool,
|
|
232
|
+
modality: modalityHazardToAttr(media.modalityHazard)
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return parts.join("\n");
|
|
237
|
+
}
|
|
238
|
+
if (Array.isArray(results)) {
|
|
239
|
+
const parts = [];
|
|
240
|
+
for (const a of results) parts.push(await a.asString());
|
|
241
|
+
const joined = parts.join("\n\n");
|
|
242
|
+
return isTrusted ? input.renderTrustedContent(joined, {
|
|
243
|
+
nonce: toolCall.checksum,
|
|
244
|
+
kind: "trusted-tool-result",
|
|
245
|
+
tool: toolCall.tool
|
|
246
|
+
}) : input.renderUntrustedContent(joined, {
|
|
247
|
+
nonce: toolCall.checksum,
|
|
248
|
+
kind: "tool-result",
|
|
249
|
+
tool: toolCall.tool
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
const isSpooled = looksLikeSpooledArtifact(results);
|
|
253
|
+
if (isSpooled && toolCall.inline === false) {
|
|
254
|
+
const artifact = results;
|
|
255
|
+
let byteLength = 0;
|
|
256
|
+
let lineCount = 0;
|
|
257
|
+
try {
|
|
258
|
+
byteLength = await artifact.byteLength();
|
|
259
|
+
} catch {
|
|
260
|
+
byteLength = 0;
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
lineCount = await artifact.lineCount();
|
|
264
|
+
} catch {
|
|
265
|
+
lineCount = 0;
|
|
266
|
+
}
|
|
267
|
+
const body = renderArtifactHandleBody(toolCall, artifact, byteLength, lineCount);
|
|
268
|
+
return input.renderUntrustedContent(body, {
|
|
269
|
+
nonce: toolCall.checksum,
|
|
270
|
+
kind: "artifact-handle",
|
|
271
|
+
tool: toolCall.tool
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
if (!isSpooled && toolCall.inline === false) warn?.(`Tool call ${toolCall.id} has inline=false but results is a Tokenizable (not a SpooledArtifact); rendering inline anyway.`);
|
|
275
|
+
const body = isSpooled ? await results.asString() : results.toString();
|
|
276
|
+
return isTrusted ? input.renderTrustedContent(body, {
|
|
277
|
+
nonce: toolCall.checksum,
|
|
278
|
+
kind: "trusted-tool-result",
|
|
279
|
+
tool: toolCall.tool
|
|
280
|
+
}) : input.renderUntrustedContent(body, {
|
|
281
|
+
nonce: toolCall.checksum,
|
|
282
|
+
kind: "tool-result",
|
|
283
|
+
tool: toolCall.tool
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
/** Default tool-call-result renderer; alias of {@link renderOllamaToolCallResult}. */
|
|
287
|
+
var defaultRenderOllamaToolCallResult = renderOllamaToolCallResult;
|
|
288
|
+
/**
|
|
289
|
+
* Assembles the complete native Ollama message history for a dispatch — system prompt and content
|
|
290
|
+
* buckets, the interleaved timeline of messages/thoughts/tool calls, and the collected opaque
|
|
291
|
+
* reasoning payloads — by delegating to the injected sub-renderers.
|
|
292
|
+
*/
|
|
293
|
+
var buildOllamaHistory = async (input) => {
|
|
294
|
+
const out = [];
|
|
295
|
+
const reasoningPayloads = [];
|
|
296
|
+
const buckets = input.bucketOrder;
|
|
297
|
+
const timelineIdx = buckets.indexOf("timeline");
|
|
298
|
+
const leadingSystem = await input.renderChatCompletionsSystemPrompt({
|
|
299
|
+
systemPrompt: input.systemPrompt,
|
|
300
|
+
standingInstructions: input.standingInstructions,
|
|
301
|
+
memories: input.memories,
|
|
302
|
+
retrievables: input.retrievables,
|
|
303
|
+
bucketOrder: buckets,
|
|
304
|
+
renderStandingInstructions: input.renderStandingInstructions,
|
|
305
|
+
renderMemories: input.renderMemories,
|
|
306
|
+
renderRetrievables: input.renderRetrievables,
|
|
307
|
+
renderRetrievableSafetyDirective: input.renderRetrievableSafetyDirective,
|
|
308
|
+
renderFirstPartyRetrievables: input.renderFirstPartyRetrievables,
|
|
309
|
+
renderThirdPartyPublicRetrievables: input.renderThirdPartyPublicRetrievables,
|
|
310
|
+
renderThirdPartyPrivateRetrievables: input.renderThirdPartyPrivateRetrievables,
|
|
311
|
+
renderUntrustedContent: input.renderUntrustedContent
|
|
312
|
+
});
|
|
313
|
+
if (leadingSystem.length > 0) out.push({
|
|
314
|
+
role: "system",
|
|
315
|
+
content: leadingSystem
|
|
316
|
+
});
|
|
317
|
+
const includesTimeline = timelineIdx !== -1;
|
|
318
|
+
if (includesTimeline) {
|
|
319
|
+
const survivingThoughts = input.filterThoughts(input.thoughts, input.thoughtSurfacing, input.selfIdentity, input.replayCompatibility);
|
|
320
|
+
const items = [];
|
|
321
|
+
for (const m of input.messages) items.push({
|
|
322
|
+
kind: "message",
|
|
323
|
+
createdAt: m.createdAt.toMillis(),
|
|
324
|
+
value: m
|
|
325
|
+
});
|
|
326
|
+
for (const t of survivingThoughts) items.push({
|
|
327
|
+
kind: "thought",
|
|
328
|
+
createdAt: t.createdAt.toMillis(),
|
|
329
|
+
value: t
|
|
330
|
+
});
|
|
331
|
+
for (const tc of input.toolCalls) items.push({
|
|
332
|
+
kind: "toolCall",
|
|
333
|
+
createdAt: tc.createdAt.toMillis(),
|
|
334
|
+
value: tc
|
|
335
|
+
});
|
|
336
|
+
items.sort((a, b) => a.createdAt - b.createdAt);
|
|
337
|
+
const replaySet = new Set([...input.replayCompatibility]);
|
|
338
|
+
for (const item of items) if (item.kind === "message") out.push(await input.renderOllamaTimelineMessage({
|
|
339
|
+
message: item.value,
|
|
340
|
+
selfIdentity: input.selfIdentity,
|
|
341
|
+
unsupportedMediaPolicy: input.unsupportedMediaPolicy,
|
|
342
|
+
warn: input.warn
|
|
343
|
+
}));
|
|
344
|
+
else if (item.kind === "thought") {
|
|
345
|
+
const t = item.value;
|
|
346
|
+
const identifier = String(t.identity?.identifier ?? "");
|
|
347
|
+
const isSelf = identifier === input.selfIdentity;
|
|
348
|
+
const hasPayload = t.payload !== void 0;
|
|
349
|
+
const compatTag = t.replayCompatibility;
|
|
350
|
+
if (hasPayload && compatTag && replaySet.has(compatTag)) {
|
|
351
|
+
reasoningPayloads.push({
|
|
352
|
+
id: t.id,
|
|
353
|
+
replayCompatibility: compatTag,
|
|
354
|
+
payload: t.payload
|
|
355
|
+
});
|
|
356
|
+
const envelope = input.renderThought(t.content.toString(), {
|
|
357
|
+
nonce: t.id,
|
|
358
|
+
kind: "opaque-reasoning",
|
|
359
|
+
from: identifier,
|
|
360
|
+
createdAt: t.createdAt?.toISO?.() ?? void 0,
|
|
361
|
+
replayCompatibility: compatTag
|
|
362
|
+
}, t.payload);
|
|
363
|
+
out.push({
|
|
364
|
+
role: "assistant",
|
|
365
|
+
content: envelope
|
|
366
|
+
});
|
|
367
|
+
} else if (!hasPayload) {
|
|
368
|
+
const envelope = input.renderThought(t.content.toString(), {
|
|
369
|
+
nonce: t.id,
|
|
370
|
+
kind: isSelf ? "self-reasoning" : "peer-reasoning",
|
|
371
|
+
from: identifier,
|
|
372
|
+
createdAt: t.createdAt?.toISO?.() ?? void 0
|
|
373
|
+
});
|
|
374
|
+
out.push({
|
|
375
|
+
role: "assistant",
|
|
376
|
+
content: envelope
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
} else {
|
|
380
|
+
const tc = item.value;
|
|
381
|
+
const args = tc.args !== null && typeof tc.args === "object" && !Array.isArray(tc.args) ? tc.args : {};
|
|
382
|
+
out.push({
|
|
383
|
+
role: "assistant",
|
|
384
|
+
content: "",
|
|
385
|
+
tool_calls: [{ function: {
|
|
386
|
+
name: tc.tool,
|
|
387
|
+
arguments: args
|
|
388
|
+
} }]
|
|
389
|
+
});
|
|
390
|
+
let rendered = input.renderedToolCallResults.get(tc.id);
|
|
391
|
+
if (rendered === void 0) {
|
|
392
|
+
const tool = input.tools.get?.(tc.tool);
|
|
393
|
+
rendered = await input.renderOllamaToolCallResult({
|
|
394
|
+
toolCall: tc,
|
|
395
|
+
results: tc.results,
|
|
396
|
+
tool,
|
|
397
|
+
renderUntrustedContent: input.renderUntrustedContent,
|
|
398
|
+
renderTrustedContent: input.renderTrustedContent,
|
|
399
|
+
unsupportedMediaPolicy: input.unsupportedMediaPolicy,
|
|
400
|
+
warn: input.warn
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
out.push({
|
|
404
|
+
role: "tool",
|
|
405
|
+
content: rendered,
|
|
406
|
+
tool_name: tc.tool
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (includesTimeline) {
|
|
411
|
+
const trailingParts = [];
|
|
412
|
+
for (let i = timelineIdx + 1; i < buckets.length; i++) {
|
|
413
|
+
const label = buckets[i];
|
|
414
|
+
if (label === "standingInstructions") {
|
|
415
|
+
const block = input.renderStandingInstructions(input.standingInstructions);
|
|
416
|
+
if (block.length > 0) trailingParts.push(block);
|
|
417
|
+
} else if (label === "memories") {
|
|
418
|
+
const wrapped = [];
|
|
419
|
+
for (const m of input.memories) wrapped.push(memoryToAttrs(m));
|
|
420
|
+
const block = input.renderMemories(wrapped);
|
|
421
|
+
if (block.length > 0) trailingParts.push(block);
|
|
422
|
+
} else if (label === "retrievables") {
|
|
423
|
+
const wrapped = [];
|
|
424
|
+
for (const r of input.retrievables) wrapped.push(retrievableToAttrs(r));
|
|
425
|
+
const block = await input.renderRetrievables(wrapped, {
|
|
426
|
+
renderRetrievableSafetyDirective: input.renderRetrievableSafetyDirective,
|
|
427
|
+
renderFirstPartyRetrievables: input.renderFirstPartyRetrievables,
|
|
428
|
+
renderThirdPartyPublicRetrievables: input.renderThirdPartyPublicRetrievables,
|
|
429
|
+
renderThirdPartyPrivateRetrievables: input.renderThirdPartyPrivateRetrievables,
|
|
430
|
+
renderUntrustedContent: input.renderUntrustedContent
|
|
431
|
+
});
|
|
432
|
+
if (block.length > 0) trailingParts.push(block);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (trailingParts.length > 0) out.push({
|
|
436
|
+
role: "system",
|
|
437
|
+
content: trailingParts.join("\n\n")
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
messages: out,
|
|
442
|
+
reasoningPayloads
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
/** Default native-history assembler; alias of {@link buildOllamaHistory}. */
|
|
446
|
+
var defaultBuildOllamaHistory = buildOllamaHistory;
|
|
447
|
+
//#endregion
|
|
448
|
+
export { buildOllamaHistory, defaultBuildOllamaHistory, defaultDescriptionToChatCompletionsJsonSchema, defaultFilterThoughts, defaultOllamaToolsFromTools, defaultRenderChatCompletionsSystemPrompt, defaultRenderFirstPartyRetrievables, defaultRenderMemories, defaultRenderOllamaTimelineMessage, defaultRenderOllamaToolCallResult, defaultRenderRetrievableSafetyDirective, defaultRenderRetrievables, defaultRenderStandingInstructions, defaultRenderThirdPartyPrivateRetrievables, defaultRenderThirdPartyPublicRetrievables, defaultRenderThought, defaultRenderTrustedContent, defaultRenderUntrustedContent, defaultToolsToChatCompletionsTools, descriptionToChatCompletionsJsonSchema, filterThoughts, ollamaToolsFromTools, renderChatCompletionsSystemPrompt, renderFirstPartyRetrievables, renderMemories, renderOllamaTimelineMessage, renderOllamaToolCallResult, renderRetrievableSafetyDirective, renderRetrievables, renderStandingInstructions, renderThirdPartyPrivateRetrievables, renderThirdPartyPublicRetrievables, renderThought, renderTrustedContent, renderUntrustedContent, toolsToChatCompletionsTools };
|
|
449
|
+
|
|
450
|
+
//# sourceMappingURL=helpers.mjs.map
|