@nhtio/adk 0.1.0-master-e068b986 → 0.1.0-master-0c6d984f
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 +54 -9
- package/batteries/embeddings/openai/adapter.cjs +1 -1
- package/batteries/embeddings/openai/adapter.mjs +1 -1
- package/batteries/embeddings/webllm/adapter.cjs +1 -1
- package/batteries/embeddings/webllm/adapter.mjs +1 -1
- package/batteries/llm/ollama/adapter.cjs +5 -5
- package/batteries/llm/ollama/adapter.mjs +5 -5
- package/batteries/llm/ollama/helpers.cjs +2 -2
- package/batteries/llm/ollama/helpers.mjs +2 -2
- package/batteries/llm/ollama/validation.cjs +1 -1
- package/batteries/llm/ollama/validation.mjs +1 -1
- package/batteries/llm/openai_chat_completions/adapter.cjs +5 -5
- package/batteries/llm/openai_chat_completions/adapter.mjs +5 -5
- package/batteries/llm/openai_chat_completions/helpers.cjs +2 -2
- package/batteries/llm/openai_chat_completions/helpers.mjs +2 -2
- package/batteries/llm/openai_chat_completions/validation.cjs +1 -1
- package/batteries/llm/openai_chat_completions/validation.mjs +1 -1
- package/batteries/llm/webllm_chat_completions/adapter.cjs +5 -5
- package/batteries/llm/webllm_chat_completions/adapter.mjs +5 -5
- package/batteries/llm/webllm_chat_completions/validation.cjs +1 -1
- package/batteries/llm/webllm_chat_completions/validation.mjs +1 -1
- package/batteries/storage/flydrive.cjs +1 -1
- package/batteries/storage/flydrive.mjs +1 -1
- package/batteries/storage/in_memory.cjs +1 -1
- package/batteries/storage/in_memory.mjs +1 -1
- package/batteries/storage/opfs.cjs +1 -1
- package/batteries/storage/opfs.mjs +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 +2 -2
- package/batteries/tools/color.mjs +2 -2
- package/batteries/tools/comparison.cjs +3 -3
- package/batteries/tools/comparison.mjs +3 -3
- package/batteries/tools/data_structure.cjs +3 -3
- package/batteries/tools/data_structure.mjs +3 -3
- package/batteries/tools/datetime_extended.cjs +3 -3
- package/batteries/tools/datetime_extended.mjs +3 -3
- package/batteries/tools/datetime_math.cjs +3 -3
- package/batteries/tools/datetime_math.mjs +3 -3
- package/batteries/tools/encoding.cjs +3 -3
- package/batteries/tools/encoding.mjs +3 -3
- package/batteries/tools/formatting.cjs +3 -3
- package/batteries/tools/formatting.mjs +3 -3
- package/batteries/tools/geo_basics.cjs +2 -2
- package/batteries/tools/geo_basics.mjs +2 -2
- package/batteries/tools/index.d.ts +2 -0
- package/batteries/tools/math.cjs +3 -3
- package/batteries/tools/math.mjs +3 -3
- package/batteries/tools/memory.cjs +6 -6
- package/batteries/tools/memory.mjs +6 -6
- package/batteries/tools/parsing.cjs +4 -4
- package/batteries/tools/parsing.mjs +4 -4
- package/batteries/tools/retrievables.cjs +5 -5
- package/batteries/tools/retrievables.mjs +5 -5
- 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/index.d.ts +47 -20
- package/batteries/tools/searxng.cjs +2 -1
- package/batteries/tools/searxng.mjs +2 -2
- package/batteries/tools/standing_instructions.cjs +4 -4
- package/batteries/tools/standing_instructions.mjs +4 -4
- package/batteries/tools/statistics.cjs +4 -4
- package/batteries/tools/statistics.mjs +4 -4
- package/batteries/tools/string_processing.cjs +3 -3
- package/batteries/tools/string_processing.mjs +3 -3
- package/batteries/tools/structured_data.cjs +3 -3
- package/batteries/tools/structured_data.mjs +3 -3
- 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 +3 -3
- package/batteries/tools/time.mjs +3 -3
- package/batteries/tools/unit_conversion.cjs +2 -2
- package/batteries/tools/unit_conversion.mjs +2 -2
- 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 +13 -1
- package/batteries/tools.mjs +4 -2
- package/batteries/vector/arangodb.cjs +1 -1
- package/batteries/vector/arangodb.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/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/filters.cjs +1 -1
- package/batteries/vector/filters.mjs +1 -1
- package/batteries/vector/hnswlib.cjs +1 -1
- package/batteries/vector/hnswlib.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/meilisearch.cjs +1 -1
- package/batteries/vector/meilisearch.mjs +1 -1
- package/batteries/vector/migrate.cjs +1 -1
- package/batteries/vector/migrate.mjs +1 -1
- package/batteries/vector/mongodb.cjs +1 -1
- package/batteries/vector/mongodb.mjs +1 -1
- package/batteries/vector/neo4j.cjs +1 -1
- package/batteries/vector/neo4j.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/pinecone.cjs +1 -1
- package/batteries/vector/pinecone.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/solr.cjs +1 -1
- package/batteries/vector/solr.mjs +1 -1
- package/batteries/vector/surrealdb.cjs +1 -1
- package/batteries/vector/surrealdb.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.cjs +13 -1
- package/batteries.mjs +4 -2
- package/{common-DwyIhf5B.mjs → common-DYDUi99O.mjs} +7 -7
- package/{common-DwyIhf5B.mjs.map → common-DYDUi99O.mjs.map} +1 -1
- package/{common-Do0PmqEC.js → common-DZl3ADJs.js} +7 -7
- package/{common-Do0PmqEC.js.map → common-DZl3ADJs.js.map} +1 -1
- package/common.cjs +7 -7
- package/common.d.ts +1 -1
- package/common.mjs +7 -7
- package/{dispatch_runner-Bh12zRee.mjs → dispatch_runner--ZhdDWRZ.mjs} +3 -3
- package/{dispatch_runner-Bh12zRee.mjs.map → dispatch_runner--ZhdDWRZ.mjs.map} +1 -1
- package/{dispatch_runner-BCfDikZn.js → dispatch_runner-nHDKkxye.js} +3 -3
- package/{dispatch_runner-BCfDikZn.js.map → dispatch_runner-nHDKkxye.js.map} +1 -1
- package/dispatch_runner.cjs +1 -1
- package/dispatch_runner.mjs +1 -1
- package/eslint/rules.cjs +2 -2
- package/eslint/rules.mjs +2 -2
- package/eslint.cjs +3 -3
- package/eslint.mjs +3 -3
- package/forge.cjs +4 -4
- package/forge.mjs +4 -4
- package/guards.cjs +8 -8
- package/guards.mjs +8 -8
- package/index.cjs +10 -10
- package/index.mjs +10 -10
- package/mcp/adk-docs-corpus.json +1 -1
- package/package.json +202 -187
- package/scrapper-CR-MFDCm.js +462 -0
- package/scrapper-CR-MFDCm.js.map +1 -0
- package/scrapper-Djl6ga2K.mjs +432 -0
- package/scrapper-Djl6ga2K.mjs.map +1 -0
- package/{searxng-COD67eJC.js → searxng-CMhRD5xo.js} +84 -88
- package/searxng-CMhRD5xo.js.map +1 -0
- package/{searxng-oL3Z5Qo2.mjs → searxng-yWwuON_Y.mjs} +77 -87
- package/searxng-yWwuON_Y.mjs.map +1 -0
- package/skills/adk-assembly/SKILL.md +2 -2
- package/{spooled_artifact-BsM1EfRB.mjs → spooled_artifact-7eePq7JA.mjs} +3 -3
- package/{spooled_artifact-BsM1EfRB.mjs.map → spooled_artifact-7eePq7JA.mjs.map} +1 -1
- package/{spooled_artifact-B6XRZYFt.js → spooled_artifact-DX8LLyUX.js} +3 -3
- package/{spooled_artifact-B6XRZYFt.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-DyevhaL6.js → spooled_markdown_artifact-ClX72lek.js} +3 -3
- package/{spooled_markdown_artifact-DyevhaL6.js.map → spooled_markdown_artifact-ClX72lek.js.map} +1 -1
- package/{spooled_markdown_artifact-DJnjD3Ti.mjs → spooled_markdown_artifact-wkrBF3oX.mjs} +3 -3
- package/{spooled_markdown_artifact-DJnjD3Ti.mjs.map → spooled_markdown_artifact-wkrBF3oX.mjs.map} +1 -1
- package/{thought-DzcSu2Y6.mjs → thought-B_vxAiKU.mjs} +3 -3
- package/{thought-DzcSu2Y6.mjs.map → thought-B_vxAiKU.mjs.map} +1 -1
- package/{thought-DhElxSkZ.js → thought-DLwpF7MI.js} +3 -3
- package/{thought-DhElxSkZ.js.map → thought-DLwpF7MI.js.map} +1 -1
- package/{tool-DjUJeSzk.js → tool-D5WGVIcI.js} +3 -3
- package/{tool-DjUJeSzk.js.map → tool-D5WGVIcI.js.map} +1 -1
- package/{tool-DMvZFz9h.mjs → tool-wMYMVl60.mjs} +3 -3
- package/{tool-DMvZFz9h.mjs.map → tool-wMYMVl60.mjs.map} +1 -1
- package/{tool_call-DhAW70EY.mjs → tool_call-B4-_-vjG.mjs} +4 -4
- package/{tool_call-DhAW70EY.mjs.map → tool_call-B4-_-vjG.mjs.map} +1 -1
- package/{tool_call-CGec5078.js → tool_call-DixVlW40.js} +4 -4
- package/{tool_call-CGec5078.js.map → tool_call-DixVlW40.js.map} +1 -1
- package/{tool_registry-BuMKln6b.mjs → tool_registry-791Vrjtf.mjs} +142 -142
- package/tool_registry-791Vrjtf.mjs.map +1 -0
- package/{tool_registry-C5wfDxaq.js → tool_registry-CKJPze3j.js} +141 -141
- package/tool_registry-CKJPze3j.js.map +1 -0
- package/{turn_runner-CfrZZ-ZJ.js → turn_runner-HXImLGIn.js} +5 -5
- package/{turn_runner-CfrZZ-ZJ.js.map → turn_runner-HXImLGIn.js.map} +1 -1
- package/{turn_runner-BQCupiHC.mjs → turn_runner-ZyYO-Kti.mjs} +5 -5
- package/{turn_runner-BQCupiHC.mjs.map → turn_runner-ZyYO-Kti.mjs.map} +1 -1
- package/turn_runner.cjs +1 -1
- package/turn_runner.mjs +1 -1
- package/searxng-COD67eJC.js.map +0 -1
- package/searxng-oL3Z5Qo2.mjs.map +0 -1
- package/tool_registry-BuMKln6b.mjs.map +0 -1
- package/tool_registry-C5wfDxaq.js.map +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../../chunk-Ble4zEEl.js");
|
|
3
|
+
const require_tool_registry = require("../../tool_registry-CKJPze3j.js");
|
|
4
|
+
const require_spooled_artifact = require("../../spooled_artifact-DX8LLyUX.js");
|
|
5
|
+
require("../../guards.cjs");
|
|
6
|
+
require("../../spooled_artifact.cjs");
|
|
7
|
+
//#region src/batteries/tools/_shared/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the configured headers (a static object or a sync/async resolver) for a single request.
|
|
10
|
+
*
|
|
11
|
+
* @param headers - The static header record, the resolver, or `undefined`.
|
|
12
|
+
* @returns A fresh, owned copy of the resolved headers (`{}` when none supplied).
|
|
13
|
+
*/
|
|
14
|
+
var resolveHeaders = async (headers) => {
|
|
15
|
+
if (typeof headers === "function") return { ...await headers() };
|
|
16
|
+
return { ...headers ?? {} };
|
|
17
|
+
};
|
|
18
|
+
/** Unwrap a resolved value that may be a module namespace whose `default` is the constructor. */
|
|
19
|
+
var unwrapDefault = (value) => {
|
|
20
|
+
if (require_tool_registry.isObject(value) && "default" in value) {
|
|
21
|
+
const def = value.default;
|
|
22
|
+
if (require_spooled_artifact.SpooledArtifact.isSpooledArtifactConstructor(def)) return def;
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Resolve an {@link ArtifactResolver} to the **sync** `() => SpooledArtifactCtor` that
|
|
28
|
+
* `Tool.artifactConstructor` requires (the wrap-site and the construction-time validator both
|
|
29
|
+
* invoke it synchronously, so an async resolver cannot be passed straight through).
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* A bare constructor is itself a function, so it is distinguished from a resolver via
|
|
33
|
+
* `SpooledArtifact.isSpooledArtifactConstructor` (the same duck-typed guard the core validator
|
|
34
|
+
* uses) rather than by arity. Async because a dynamic-import resolver must be awaited here.
|
|
35
|
+
*
|
|
36
|
+
* @param resolver - The artifact configuration. When `undefined`, callers should fall back to
|
|
37
|
+
* their own default (this function rejects `undefined` so the default lives with the caller).
|
|
38
|
+
* @param onInvalid - Throws a battery-scoped error; receives a human-readable reason.
|
|
39
|
+
* @returns A sync `() => SpooledArtifactCtor` suitable for `Tool.artifactConstructor`.
|
|
40
|
+
*/
|
|
41
|
+
var resolveArtifact = async (resolver, onInvalid) => {
|
|
42
|
+
if (require_spooled_artifact.SpooledArtifact.isSpooledArtifactConstructor(resolver)) {
|
|
43
|
+
const ctor = resolver;
|
|
44
|
+
return () => ctor;
|
|
45
|
+
}
|
|
46
|
+
if (typeof resolver !== "function") onInvalid("artifact must be a SpooledArtifact constructor or a resolver returning one");
|
|
47
|
+
let resolved;
|
|
48
|
+
try {
|
|
49
|
+
resolved = await resolver();
|
|
50
|
+
} catch (err) {
|
|
51
|
+
onInvalid(`artifact resolver threw: ${require_tool_registry.isError(err) ? err.message : String(err)}`);
|
|
52
|
+
}
|
|
53
|
+
resolved = unwrapDefault(resolved);
|
|
54
|
+
if (!require_spooled_artifact.SpooledArtifact.isSpooledArtifactConstructor(resolved)) onInvalid("artifact resolver did not resolve to a SpooledArtifact constructor");
|
|
55
|
+
const ctor = resolved;
|
|
56
|
+
return () => ctor;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Synchronous {@link resolveArtifact}: accepts only the {@link SyncArtifactResolver} subset and
|
|
60
|
+
* throws (via `onInvalid`) on an async resolver — a runtime guard for JS callers who bypass the
|
|
61
|
+
* compile-time narrowing.
|
|
62
|
+
*
|
|
63
|
+
* @param resolver - A constructor or a sync resolver.
|
|
64
|
+
* @param onInvalid - Throws a battery-scoped error; receives a human-readable reason.
|
|
65
|
+
* @returns A sync `() => SpooledArtifactCtor` suitable for `Tool.artifactConstructor`.
|
|
66
|
+
*/
|
|
67
|
+
var resolveArtifactSync = (resolver, onInvalid) => {
|
|
68
|
+
if (require_spooled_artifact.SpooledArtifact.isSpooledArtifactConstructor(resolver)) {
|
|
69
|
+
const ctor = resolver;
|
|
70
|
+
return () => ctor;
|
|
71
|
+
}
|
|
72
|
+
if (typeof resolver !== "function") onInvalid("artifact must be a SpooledArtifact constructor or a resolver returning one");
|
|
73
|
+
let resolved;
|
|
74
|
+
try {
|
|
75
|
+
resolved = resolver();
|
|
76
|
+
} catch (err) {
|
|
77
|
+
onInvalid(`artifact resolver threw: ${require_tool_registry.isError(err) ? err.message : String(err)}`);
|
|
78
|
+
}
|
|
79
|
+
if (require_tool_registry.isInstanceOf(resolved, "Promise", Promise)) onInvalid("artifact resolver is async; use the async factory variant for dynamic-import resolvers");
|
|
80
|
+
resolved = unwrapDefault(resolved);
|
|
81
|
+
if (!require_spooled_artifact.SpooledArtifact.isSpooledArtifactConstructor(resolved)) onInvalid("artifact resolver did not resolve to a SpooledArtifact constructor");
|
|
82
|
+
const ctor = resolved;
|
|
83
|
+
return () => ctor;
|
|
84
|
+
};
|
|
85
|
+
/** Internal sentinel a short-circuiting input stage throws to unwind the pipeline immediately. */
|
|
86
|
+
var SHORT_CIRCUIT = Symbol("adk.tools.shortCircuit");
|
|
87
|
+
/** `true` when `value` is the short-circuit sentinel produced by {@link makeShortCircuit}. */
|
|
88
|
+
var isShortCircuit = (value) => require_tool_registry.isObject(value) && value[SHORT_CIRCUIT] === true;
|
|
89
|
+
/**
|
|
90
|
+
* Build a `shortCircuit(result)` function for an input-pipeline context. Calling it throws the
|
|
91
|
+
* internal sentinel, which {@link runInputPipeline} catches and converts into the verbatim result
|
|
92
|
+
* (skipping the HTTP request entirely — e.g. a cache hit).
|
|
93
|
+
*
|
|
94
|
+
* @returns A function that, when called with a result string, throws the short-circuit sentinel.
|
|
95
|
+
*/
|
|
96
|
+
var makeShortCircuit = () => {
|
|
97
|
+
return (result) => {
|
|
98
|
+
throw {
|
|
99
|
+
[SHORT_CIRCUIT]: true,
|
|
100
|
+
result
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Run an input pipeline over `ctx`. Returns the short-circuit string when a stage short-circuited,
|
|
106
|
+
* or `undefined` when the pipeline reached its terminal handler. A non-terminal pipeline (a stage
|
|
107
|
+
* that neither called `next()` nor short-circuited) throws — the caller converts it to an
|
|
108
|
+
* `Error:` string.
|
|
109
|
+
*
|
|
110
|
+
* @param mw - The `Middleware` instance holding the stages (a fresh `.runner()` is minted here).
|
|
111
|
+
* @param ctx - The mutable input context handed to each stage.
|
|
112
|
+
* @param label - Battery name, used in the non-terminal error message.
|
|
113
|
+
* @returns The short-circuit result string, or `undefined` if the pipeline ran to completion.
|
|
114
|
+
*/
|
|
115
|
+
var runInputPipeline = async (mw, ctx, label) => {
|
|
116
|
+
let reached = false;
|
|
117
|
+
let caught;
|
|
118
|
+
await mw.runner().errorHandler(async (error) => {
|
|
119
|
+
caught = error;
|
|
120
|
+
}).finalHandler(async () => {
|
|
121
|
+
reached = true;
|
|
122
|
+
}).run((fn, next) => Promise.resolve(fn(ctx, next)));
|
|
123
|
+
if (caught !== void 0) {
|
|
124
|
+
if (isShortCircuit(caught)) return caught.result;
|
|
125
|
+
throw caught;
|
|
126
|
+
}
|
|
127
|
+
if (!reached) throw new Error(`${label} input pipeline did not call next() and did not short-circuit.`);
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Run an output pipeline over `ctx`; rethrow any stage error to the caller's try/catch. A
|
|
131
|
+
* non-terminal pipeline (no `next()`) throws.
|
|
132
|
+
*
|
|
133
|
+
* @param mw - The `Middleware` instance holding the stages (a fresh `.runner()` is minted here).
|
|
134
|
+
* @param ctx - The mutable output context handed to each stage.
|
|
135
|
+
* @param label - Battery name, used in the non-terminal error message.
|
|
136
|
+
*/
|
|
137
|
+
var runOutputPipeline = async (mw, ctx, label) => {
|
|
138
|
+
let reached = false;
|
|
139
|
+
let caught;
|
|
140
|
+
await mw.runner().errorHandler(async (error) => {
|
|
141
|
+
caught = error;
|
|
142
|
+
}).finalHandler(async () => {
|
|
143
|
+
reached = true;
|
|
144
|
+
}).run((fn, next) => Promise.resolve(fn(ctx, next)));
|
|
145
|
+
if (caught !== void 0) throw caught;
|
|
146
|
+
if (!reached) throw new Error(`${label} output pipeline did not call next().`);
|
|
147
|
+
};
|
|
148
|
+
//#endregion
|
|
149
|
+
exports.isShortCircuit = isShortCircuit;
|
|
150
|
+
exports.makeShortCircuit = makeShortCircuit;
|
|
151
|
+
exports.resolveArtifact = resolveArtifact;
|
|
152
|
+
exports.resolveArtifactSync = resolveArtifactSync;
|
|
153
|
+
exports.resolveHeaders = resolveHeaders;
|
|
154
|
+
exports.runInputPipeline = runInputPipeline;
|
|
155
|
+
exports.runOutputPipeline = runOutputPipeline;
|
|
156
|
+
|
|
157
|
+
//# sourceMappingURL=_shared.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.cjs","names":[],"sources":["../../../src/batteries/tools/_shared/index.ts"],"sourcesContent":["/**\n * Cross-battery helpers shared by the configured HTTP tool batteries (SearXNG, Scrapper, …).\n *\n * @module @nhtio/adk/batteries/tools/_shared\n *\n * @remarks\n * These are internal building blocks for the *factory-style* tool batteries — the ones that talk\n * to a configured HTTP instance behind custom auth and expose input/output middleware pipelines.\n * Rather than each battery carry its own copy, the common machinery lives here:\n *\n * - {@link resolveArtifact} / {@link resolveArtifactSync} — turn an {@link ArtifactResolver}\n * (a constructor, a sync resolver, or an async / dynamic-import resolver) into the **sync**\n * `() => SpooledArtifactConstructor` that `Tool.artifactConstructor` requires. Mirrors the vector\n * battery's `resolveClientCtor`.\n * - {@link resolveHeaders} — collapse a static header object or a (sync/async) resolver into a\n * plain header record for one request (refreshable-auth friendly).\n * - {@link runInputPipeline} / {@link runOutputPipeline} — the onion middleware runners (fresh\n * runner per call, short-circuit + non-terminal detection), generic over the context type.\n *\n * This module imports harness primitives only through their specific subpath barrels\n * (`@nhtio/adk/spooled_artifact`, `@nhtio/adk/forge`, `@nhtio/adk/guards`) per the batteries\n * barrel-only rule.\n */\n\nimport { Middleware } from '@nhtio/middleware'\nimport { SpooledArtifact } from '@nhtio/adk/spooled_artifact'\nimport { isError, isObject, isInstanceOf } from '@nhtio/adk/guards'\nimport type { NextFn } from '@nhtio/middleware'\nimport type { SpooledArtifactConstructor } from '@nhtio/adk/forge'\n\n// ── Header resolution ────────────────────────────────────────────────────────\n\n/** A static set of request headers (used for custom instance authentication). */\nexport type ToolHeaders = Record<string, string>\n\n/**\n * A resolver returning request headers, sync or async. Use this form when the auth token is\n * refreshable — the resolver runs on every request, so a fresh token can be minted per call.\n */\nexport type ToolHeadersResolver = () => ToolHeaders | Promise<ToolHeaders>\n\n/**\n * Resolve the configured headers (a static object or a sync/async resolver) for a single request.\n *\n * @param headers - The static header record, the resolver, or `undefined`.\n * @returns A fresh, owned copy of the resolved headers (`{}` when none supplied).\n */\nexport const resolveHeaders = async (\n headers: ToolHeaders | ToolHeadersResolver | undefined\n): Promise<ToolHeaders> => {\n if (typeof headers === 'function') return { ...(await headers()) }\n return { ...(headers ?? {}) }\n}\n\n// ── Artifact resolver ────────────────────────────────────────────────────────\n\n/** Convenience alias for the spooled-artifact constructor a tool wraps its output in. */\nexport type SpooledArtifactCtor = SpooledArtifactConstructor\n\n/**\n * The artifact configuration accepted by a factory: a constructor, a sync resolver, or an async /\n * dynamic-import resolver (which may yield a module namespace whose `default` is the constructor).\n *\n * @remarks\n * Mirrors the vector battery's `client` resolver and `Tool.artifactConstructor`'s indirection. The\n * async form lets a consumer `() => import('@nhtio/adk/spooled_artifact').then(m => m.SpooledMarkdownArtifact)`\n * so the artifact class never enters their static module graph.\n */\nexport type ArtifactResolver =\n | SpooledArtifactCtor\n | (() => SpooledArtifactCtor | { default: SpooledArtifactCtor })\n | (() => Promise<SpooledArtifactCtor | { default: SpooledArtifactCtor }>)\n\n/** The sync subset of {@link ArtifactResolver} — a constructor or a sync resolver (no Promise). */\nexport type SyncArtifactResolver =\n | SpooledArtifactCtor\n | (() => SpooledArtifactCtor | { default: SpooledArtifactCtor })\n\n/** Unwrap a resolved value that may be a module namespace whose `default` is the constructor. */\nconst unwrapDefault = (value: unknown): unknown => {\n if (isObject(value) && 'default' in value) {\n const def = (value as { default?: unknown }).default\n if (SpooledArtifact.isSpooledArtifactConstructor(def)) return def\n }\n return value\n}\n\n/**\n * Resolve an {@link ArtifactResolver} to the **sync** `() => SpooledArtifactCtor` that\n * `Tool.artifactConstructor` requires (the wrap-site and the construction-time validator both\n * invoke it synchronously, so an async resolver cannot be passed straight through).\n *\n * @remarks\n * A bare constructor is itself a function, so it is distinguished from a resolver via\n * `SpooledArtifact.isSpooledArtifactConstructor` (the same duck-typed guard the core validator\n * uses) rather than by arity. Async because a dynamic-import resolver must be awaited here.\n *\n * @param resolver - The artifact configuration. When `undefined`, callers should fall back to\n * their own default (this function rejects `undefined` so the default lives with the caller).\n * @param onInvalid - Throws a battery-scoped error; receives a human-readable reason.\n * @returns A sync `() => SpooledArtifactCtor` suitable for `Tool.artifactConstructor`.\n */\nexport const resolveArtifact = async (\n resolver: ArtifactResolver,\n onInvalid: (reason: string) => never\n): Promise<() => SpooledArtifactCtor> => {\n // A constructor: hand back a thunk that returns it.\n if (SpooledArtifact.isSpooledArtifactConstructor(resolver)) {\n const ctor = resolver\n return () => ctor\n }\n // Otherwise it must be a resolver function.\n if (typeof resolver !== 'function') {\n onInvalid('artifact must be a SpooledArtifact constructor or a resolver returning one')\n }\n let resolved: unknown\n try {\n resolved = await (resolver as () => unknown)()\n } catch (err) {\n onInvalid(`artifact resolver threw: ${isError(err) ? err.message : String(err)}`)\n }\n resolved = unwrapDefault(resolved)\n if (!SpooledArtifact.isSpooledArtifactConstructor(resolved)) {\n onInvalid('artifact resolver did not resolve to a SpooledArtifact constructor')\n }\n const ctor = resolved as SpooledArtifactCtor\n return () => ctor\n}\n\n/**\n * Synchronous {@link resolveArtifact}: accepts only the {@link SyncArtifactResolver} subset and\n * throws (via `onInvalid`) on an async resolver — a runtime guard for JS callers who bypass the\n * compile-time narrowing.\n *\n * @param resolver - A constructor or a sync resolver.\n * @param onInvalid - Throws a battery-scoped error; receives a human-readable reason.\n * @returns A sync `() => SpooledArtifactCtor` suitable for `Tool.artifactConstructor`.\n */\nexport const resolveArtifactSync = (\n resolver: SyncArtifactResolver,\n onInvalid: (reason: string) => never\n): (() => SpooledArtifactCtor) => {\n if (SpooledArtifact.isSpooledArtifactConstructor(resolver)) {\n const ctor = resolver\n return () => ctor\n }\n if (typeof resolver !== 'function') {\n onInvalid('artifact must be a SpooledArtifact constructor or a resolver returning one')\n }\n let resolved: unknown\n try {\n resolved = (resolver as () => unknown)()\n } catch (err) {\n onInvalid(`artifact resolver threw: ${isError(err) ? err.message : String(err)}`)\n }\n if (isInstanceOf(resolved, 'Promise', Promise)) {\n onInvalid(\n 'artifact resolver is async; use the async factory variant for dynamic-import resolvers'\n )\n }\n resolved = unwrapDefault(resolved)\n if (!SpooledArtifact.isSpooledArtifactConstructor(resolved)) {\n onInvalid('artifact resolver did not resolve to a SpooledArtifact constructor')\n }\n const ctor = resolved as SpooledArtifactCtor\n return () => ctor\n}\n\n// ── Middleware pipeline runners ──────────────────────────────────────────────\n\n/** Internal sentinel a short-circuiting input stage throws to unwind the pipeline immediately. */\nconst SHORT_CIRCUIT = Symbol('adk.tools.shortCircuit')\n\ninterface ShortCircuitSignal {\n [SHORT_CIRCUIT]: true\n result: string\n}\n\n/** `true` when `value` is the short-circuit sentinel produced by {@link makeShortCircuit}. */\nexport const isShortCircuit = (value: unknown): value is { result: string } =>\n isObject(value) && (value as Record<symbol, unknown>)[SHORT_CIRCUIT] === true\n\n/**\n * Build a `shortCircuit(result)` function for an input-pipeline context. Calling it throws the\n * internal sentinel, which {@link runInputPipeline} catches and converts into the verbatim result\n * (skipping the HTTP request entirely — e.g. a cache hit).\n *\n * @returns A function that, when called with a result string, throws the short-circuit sentinel.\n */\nexport const makeShortCircuit = (): ((result: string) => never) => {\n return (result: string): never => {\n const signal: ShortCircuitSignal = { [SHORT_CIRCUIT]: true, result }\n throw signal\n }\n}\n\n/** A generic onion middleware stage over a mutable context `C`. */\nexport type MiddlewareFn<C> = (ctx: C, next: NextFn) => void | Promise<void>\n\n/**\n * Run an input pipeline over `ctx`. Returns the short-circuit string when a stage short-circuited,\n * or `undefined` when the pipeline reached its terminal handler. A non-terminal pipeline (a stage\n * that neither called `next()` nor short-circuited) throws — the caller converts it to an\n * `Error:` string.\n *\n * @param mw - The `Middleware` instance holding the stages (a fresh `.runner()` is minted here).\n * @param ctx - The mutable input context handed to each stage.\n * @param label - Battery name, used in the non-terminal error message.\n * @returns The short-circuit result string, or `undefined` if the pipeline ran to completion.\n */\nexport const runInputPipeline = async <C>(\n mw: Middleware<MiddlewareFn<C>>,\n ctx: C,\n label: string\n): Promise<string | undefined> => {\n let reached = false\n let caught: unknown\n await mw\n .runner()\n .errorHandler(async (error: unknown) => {\n caught = error\n })\n .finalHandler(async () => {\n reached = true\n })\n .run((fn, next) => Promise.resolve(fn(ctx, next)))\n\n if (caught !== undefined) {\n if (isShortCircuit(caught)) return caught.result\n throw caught\n }\n if (!reached) {\n throw new Error(`${label} input pipeline did not call next() and did not short-circuit.`)\n }\n return undefined\n}\n\n/**\n * Run an output pipeline over `ctx`; rethrow any stage error to the caller's try/catch. A\n * non-terminal pipeline (no `next()`) throws.\n *\n * @param mw - The `Middleware` instance holding the stages (a fresh `.runner()` is minted here).\n * @param ctx - The mutable output context handed to each stage.\n * @param label - Battery name, used in the non-terminal error message.\n */\nexport const runOutputPipeline = async <C>(\n mw: Middleware<MiddlewareFn<C>>,\n ctx: C,\n label: string\n): Promise<void> => {\n let reached = false\n let caught: unknown\n await mw\n .runner()\n .errorHandler(async (error: unknown) => {\n caught = error\n })\n .finalHandler(async () => {\n reached = true\n })\n .run((fn, next) => Promise.resolve(fn(ctx, next)))\n\n if (caught !== undefined) throw caught\n if (!reached) throw new Error(`${label} output pipeline did not call next().`)\n}\n"],"mappings":";;;;;;;;;;;;;AA+CA,IAAa,iBAAiB,OAC5B,YACyB;CACzB,IAAI,OAAO,YAAY,YAAY,OAAO,EAAE,GAAI,MAAM,QAAQ,EAAG;CACjE,OAAO,EAAE,GAAI,WAAW,CAAC,EAAG;AAC9B;;AA2BA,IAAM,iBAAiB,UAA4B;CACjD,IAAI,sBAAA,SAAS,KAAK,KAAK,aAAa,OAAO;EACzC,MAAM,MAAO,MAAgC;EAC7C,IAAI,yBAAA,gBAAgB,6BAA6B,GAAG,GAAG,OAAO;CAChE;CACA,OAAO;AACT;;;;;;;;;;;;;;;;AAiBA,IAAa,kBAAkB,OAC7B,UACA,cACuC;CAEvC,IAAI,yBAAA,gBAAgB,6BAA6B,QAAQ,GAAG;EAC1D,MAAM,OAAO;EACb,aAAa;CACf;CAEA,IAAI,OAAO,aAAa,YACtB,UAAU,4EAA4E;CAExF,IAAI;CACJ,IAAI;EACF,WAAW,MAAO,SAA2B;CAC/C,SAAS,KAAK;EACZ,UAAU,4BAA4B,sBAAA,QAAQ,GAAG,IAAI,IAAI,UAAU,OAAO,GAAG,GAAG;CAClF;CACA,WAAW,cAAc,QAAQ;CACjC,IAAI,CAAC,yBAAA,gBAAgB,6BAA6B,QAAQ,GACxD,UAAU,oEAAoE;CAEhF,MAAM,OAAO;CACb,aAAa;AACf;;;;;;;;;;AAWA,IAAa,uBACX,UACA,cACgC;CAChC,IAAI,yBAAA,gBAAgB,6BAA6B,QAAQ,GAAG;EAC1D,MAAM,OAAO;EACb,aAAa;CACf;CACA,IAAI,OAAO,aAAa,YACtB,UAAU,4EAA4E;CAExF,IAAI;CACJ,IAAI;EACF,WAAY,SAA2B;CACzC,SAAS,KAAK;EACZ,UAAU,4BAA4B,sBAAA,QAAQ,GAAG,IAAI,IAAI,UAAU,OAAO,GAAG,GAAG;CAClF;CACA,IAAI,sBAAA,aAAa,UAAU,WAAW,OAAO,GAC3C,UACE,wFACF;CAEF,WAAW,cAAc,QAAQ;CACjC,IAAI,CAAC,yBAAA,gBAAgB,6BAA6B,QAAQ,GACxD,UAAU,oEAAoE;CAEhF,MAAM,OAAO;CACb,aAAa;AACf;;AAKA,IAAM,gBAAgB,OAAO,wBAAwB;;AAQrD,IAAa,kBAAkB,UAC7B,sBAAA,SAAS,KAAK,KAAM,MAAkC,mBAAmB;;;;;;;;AAS3E,IAAa,yBAAsD;CACjE,QAAQ,WAA0B;EAEhC,MAAM;IADgC,gBAAgB;GAAM;EACtD;CACR;AACF;;;;;;;;;;;;AAgBA,IAAa,mBAAmB,OAC9B,IACA,KACA,UACgC;CAChC,IAAI,UAAU;CACd,IAAI;CACJ,MAAM,GACH,OAAO,EACP,aAAa,OAAO,UAAmB;EACtC,SAAS;CACX,CAAC,EACA,aAAa,YAAY;EACxB,UAAU;CACZ,CAAC,EACA,KAAK,IAAI,SAAS,QAAQ,QAAQ,GAAG,KAAK,IAAI,CAAC,CAAC;CAEnD,IAAI,WAAW,KAAA,GAAW;EACxB,IAAI,eAAe,MAAM,GAAG,OAAO,OAAO;EAC1C,MAAM;CACR;CACA,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,GAAG,MAAM,+DAA+D;AAG5F;;;;;;;;;AAUA,IAAa,oBAAoB,OAC/B,IACA,KACA,UACkB;CAClB,IAAI,UAAU;CACd,IAAI;CACJ,MAAM,GACH,OAAO,EACP,aAAa,OAAO,UAAmB;EACtC,SAAS;CACX,CAAC,EACA,aAAa,YAAY;EACxB,UAAU;CACZ,CAAC,EACA,KAAK,IAAI,SAAS,QAAQ,QAAQ,GAAG,KAAK,IAAI,CAAC,CAAC;CAEnD,IAAI,WAAW,KAAA,GAAW,MAAM;CAChC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,GAAG,MAAM,sCAAsC;AAC/E"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { c as isObject, o as isError, s as isInstanceOf } from "../../tool_registry-791Vrjtf.mjs";
|
|
2
|
+
import { t as SpooledArtifact } from "../../spooled_artifact-7eePq7JA.mjs";
|
|
3
|
+
import "../../guards.mjs";
|
|
4
|
+
import "../../spooled_artifact.mjs";
|
|
5
|
+
//#region src/batteries/tools/_shared/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the configured headers (a static object or a sync/async resolver) for a single request.
|
|
8
|
+
*
|
|
9
|
+
* @param headers - The static header record, the resolver, or `undefined`.
|
|
10
|
+
* @returns A fresh, owned copy of the resolved headers (`{}` when none supplied).
|
|
11
|
+
*/
|
|
12
|
+
var resolveHeaders = async (headers) => {
|
|
13
|
+
if (typeof headers === "function") return { ...await headers() };
|
|
14
|
+
return { ...headers ?? {} };
|
|
15
|
+
};
|
|
16
|
+
/** Unwrap a resolved value that may be a module namespace whose `default` is the constructor. */
|
|
17
|
+
var unwrapDefault = (value) => {
|
|
18
|
+
if (isObject(value) && "default" in value) {
|
|
19
|
+
const def = value.default;
|
|
20
|
+
if (SpooledArtifact.isSpooledArtifactConstructor(def)) return def;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Resolve an {@link ArtifactResolver} to the **sync** `() => SpooledArtifactCtor` that
|
|
26
|
+
* `Tool.artifactConstructor` requires (the wrap-site and the construction-time validator both
|
|
27
|
+
* invoke it synchronously, so an async resolver cannot be passed straight through).
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* A bare constructor is itself a function, so it is distinguished from a resolver via
|
|
31
|
+
* `SpooledArtifact.isSpooledArtifactConstructor` (the same duck-typed guard the core validator
|
|
32
|
+
* uses) rather than by arity. Async because a dynamic-import resolver must be awaited here.
|
|
33
|
+
*
|
|
34
|
+
* @param resolver - The artifact configuration. When `undefined`, callers should fall back to
|
|
35
|
+
* their own default (this function rejects `undefined` so the default lives with the caller).
|
|
36
|
+
* @param onInvalid - Throws a battery-scoped error; receives a human-readable reason.
|
|
37
|
+
* @returns A sync `() => SpooledArtifactCtor` suitable for `Tool.artifactConstructor`.
|
|
38
|
+
*/
|
|
39
|
+
var resolveArtifact = async (resolver, onInvalid) => {
|
|
40
|
+
if (SpooledArtifact.isSpooledArtifactConstructor(resolver)) {
|
|
41
|
+
const ctor = resolver;
|
|
42
|
+
return () => ctor;
|
|
43
|
+
}
|
|
44
|
+
if (typeof resolver !== "function") onInvalid("artifact must be a SpooledArtifact constructor or a resolver returning one");
|
|
45
|
+
let resolved;
|
|
46
|
+
try {
|
|
47
|
+
resolved = await resolver();
|
|
48
|
+
} catch (err) {
|
|
49
|
+
onInvalid(`artifact resolver threw: ${isError(err) ? err.message : String(err)}`);
|
|
50
|
+
}
|
|
51
|
+
resolved = unwrapDefault(resolved);
|
|
52
|
+
if (!SpooledArtifact.isSpooledArtifactConstructor(resolved)) onInvalid("artifact resolver did not resolve to a SpooledArtifact constructor");
|
|
53
|
+
const ctor = resolved;
|
|
54
|
+
return () => ctor;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Synchronous {@link resolveArtifact}: accepts only the {@link SyncArtifactResolver} subset and
|
|
58
|
+
* throws (via `onInvalid`) on an async resolver — a runtime guard for JS callers who bypass the
|
|
59
|
+
* compile-time narrowing.
|
|
60
|
+
*
|
|
61
|
+
* @param resolver - A constructor or a sync resolver.
|
|
62
|
+
* @param onInvalid - Throws a battery-scoped error; receives a human-readable reason.
|
|
63
|
+
* @returns A sync `() => SpooledArtifactCtor` suitable for `Tool.artifactConstructor`.
|
|
64
|
+
*/
|
|
65
|
+
var resolveArtifactSync = (resolver, onInvalid) => {
|
|
66
|
+
if (SpooledArtifact.isSpooledArtifactConstructor(resolver)) {
|
|
67
|
+
const ctor = resolver;
|
|
68
|
+
return () => ctor;
|
|
69
|
+
}
|
|
70
|
+
if (typeof resolver !== "function") onInvalid("artifact must be a SpooledArtifact constructor or a resolver returning one");
|
|
71
|
+
let resolved;
|
|
72
|
+
try {
|
|
73
|
+
resolved = resolver();
|
|
74
|
+
} catch (err) {
|
|
75
|
+
onInvalid(`artifact resolver threw: ${isError(err) ? err.message : String(err)}`);
|
|
76
|
+
}
|
|
77
|
+
if (isInstanceOf(resolved, "Promise", Promise)) onInvalid("artifact resolver is async; use the async factory variant for dynamic-import resolvers");
|
|
78
|
+
resolved = unwrapDefault(resolved);
|
|
79
|
+
if (!SpooledArtifact.isSpooledArtifactConstructor(resolved)) onInvalid("artifact resolver did not resolve to a SpooledArtifact constructor");
|
|
80
|
+
const ctor = resolved;
|
|
81
|
+
return () => ctor;
|
|
82
|
+
};
|
|
83
|
+
/** Internal sentinel a short-circuiting input stage throws to unwind the pipeline immediately. */
|
|
84
|
+
var SHORT_CIRCUIT = Symbol("adk.tools.shortCircuit");
|
|
85
|
+
/** `true` when `value` is the short-circuit sentinel produced by {@link makeShortCircuit}. */
|
|
86
|
+
var isShortCircuit = (value) => isObject(value) && value[SHORT_CIRCUIT] === true;
|
|
87
|
+
/**
|
|
88
|
+
* Build a `shortCircuit(result)` function for an input-pipeline context. Calling it throws the
|
|
89
|
+
* internal sentinel, which {@link runInputPipeline} catches and converts into the verbatim result
|
|
90
|
+
* (skipping the HTTP request entirely — e.g. a cache hit).
|
|
91
|
+
*
|
|
92
|
+
* @returns A function that, when called with a result string, throws the short-circuit sentinel.
|
|
93
|
+
*/
|
|
94
|
+
var makeShortCircuit = () => {
|
|
95
|
+
return (result) => {
|
|
96
|
+
throw {
|
|
97
|
+
[SHORT_CIRCUIT]: true,
|
|
98
|
+
result
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Run an input pipeline over `ctx`. Returns the short-circuit string when a stage short-circuited,
|
|
104
|
+
* or `undefined` when the pipeline reached its terminal handler. A non-terminal pipeline (a stage
|
|
105
|
+
* that neither called `next()` nor short-circuited) throws — the caller converts it to an
|
|
106
|
+
* `Error:` string.
|
|
107
|
+
*
|
|
108
|
+
* @param mw - The `Middleware` instance holding the stages (a fresh `.runner()` is minted here).
|
|
109
|
+
* @param ctx - The mutable input context handed to each stage.
|
|
110
|
+
* @param label - Battery name, used in the non-terminal error message.
|
|
111
|
+
* @returns The short-circuit result string, or `undefined` if the pipeline ran to completion.
|
|
112
|
+
*/
|
|
113
|
+
var runInputPipeline = async (mw, ctx, label) => {
|
|
114
|
+
let reached = false;
|
|
115
|
+
let caught;
|
|
116
|
+
await mw.runner().errorHandler(async (error) => {
|
|
117
|
+
caught = error;
|
|
118
|
+
}).finalHandler(async () => {
|
|
119
|
+
reached = true;
|
|
120
|
+
}).run((fn, next) => Promise.resolve(fn(ctx, next)));
|
|
121
|
+
if (caught !== void 0) {
|
|
122
|
+
if (isShortCircuit(caught)) return caught.result;
|
|
123
|
+
throw caught;
|
|
124
|
+
}
|
|
125
|
+
if (!reached) throw new Error(`${label} input pipeline did not call next() and did not short-circuit.`);
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Run an output pipeline over `ctx`; rethrow any stage error to the caller's try/catch. A
|
|
129
|
+
* non-terminal pipeline (no `next()`) throws.
|
|
130
|
+
*
|
|
131
|
+
* @param mw - The `Middleware` instance holding the stages (a fresh `.runner()` is minted here).
|
|
132
|
+
* @param ctx - The mutable output context handed to each stage.
|
|
133
|
+
* @param label - Battery name, used in the non-terminal error message.
|
|
134
|
+
*/
|
|
135
|
+
var runOutputPipeline = async (mw, ctx, label) => {
|
|
136
|
+
let reached = false;
|
|
137
|
+
let caught;
|
|
138
|
+
await mw.runner().errorHandler(async (error) => {
|
|
139
|
+
caught = error;
|
|
140
|
+
}).finalHandler(async () => {
|
|
141
|
+
reached = true;
|
|
142
|
+
}).run((fn, next) => Promise.resolve(fn(ctx, next)));
|
|
143
|
+
if (caught !== void 0) throw caught;
|
|
144
|
+
if (!reached) throw new Error(`${label} output pipeline did not call next().`);
|
|
145
|
+
};
|
|
146
|
+
//#endregion
|
|
147
|
+
export { isShortCircuit, makeShortCircuit, resolveArtifact, resolveArtifactSync, resolveHeaders, runInputPipeline, runOutputPipeline };
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=_shared.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.mjs","names":[],"sources":["../../../src/batteries/tools/_shared/index.ts"],"sourcesContent":["/**\n * Cross-battery helpers shared by the configured HTTP tool batteries (SearXNG, Scrapper, …).\n *\n * @module @nhtio/adk/batteries/tools/_shared\n *\n * @remarks\n * These are internal building blocks for the *factory-style* tool batteries — the ones that talk\n * to a configured HTTP instance behind custom auth and expose input/output middleware pipelines.\n * Rather than each battery carry its own copy, the common machinery lives here:\n *\n * - {@link resolveArtifact} / {@link resolveArtifactSync} — turn an {@link ArtifactResolver}\n * (a constructor, a sync resolver, or an async / dynamic-import resolver) into the **sync**\n * `() => SpooledArtifactConstructor` that `Tool.artifactConstructor` requires. Mirrors the vector\n * battery's `resolveClientCtor`.\n * - {@link resolveHeaders} — collapse a static header object or a (sync/async) resolver into a\n * plain header record for one request (refreshable-auth friendly).\n * - {@link runInputPipeline} / {@link runOutputPipeline} — the onion middleware runners (fresh\n * runner per call, short-circuit + non-terminal detection), generic over the context type.\n *\n * This module imports harness primitives only through their specific subpath barrels\n * (`@nhtio/adk/spooled_artifact`, `@nhtio/adk/forge`, `@nhtio/adk/guards`) per the batteries\n * barrel-only rule.\n */\n\nimport { Middleware } from '@nhtio/middleware'\nimport { SpooledArtifact } from '@nhtio/adk/spooled_artifact'\nimport { isError, isObject, isInstanceOf } from '@nhtio/adk/guards'\nimport type { NextFn } from '@nhtio/middleware'\nimport type { SpooledArtifactConstructor } from '@nhtio/adk/forge'\n\n// ── Header resolution ────────────────────────────────────────────────────────\n\n/** A static set of request headers (used for custom instance authentication). */\nexport type ToolHeaders = Record<string, string>\n\n/**\n * A resolver returning request headers, sync or async. Use this form when the auth token is\n * refreshable — the resolver runs on every request, so a fresh token can be minted per call.\n */\nexport type ToolHeadersResolver = () => ToolHeaders | Promise<ToolHeaders>\n\n/**\n * Resolve the configured headers (a static object or a sync/async resolver) for a single request.\n *\n * @param headers - The static header record, the resolver, or `undefined`.\n * @returns A fresh, owned copy of the resolved headers (`{}` when none supplied).\n */\nexport const resolveHeaders = async (\n headers: ToolHeaders | ToolHeadersResolver | undefined\n): Promise<ToolHeaders> => {\n if (typeof headers === 'function') return { ...(await headers()) }\n return { ...(headers ?? {}) }\n}\n\n// ── Artifact resolver ────────────────────────────────────────────────────────\n\n/** Convenience alias for the spooled-artifact constructor a tool wraps its output in. */\nexport type SpooledArtifactCtor = SpooledArtifactConstructor\n\n/**\n * The artifact configuration accepted by a factory: a constructor, a sync resolver, or an async /\n * dynamic-import resolver (which may yield a module namespace whose `default` is the constructor).\n *\n * @remarks\n * Mirrors the vector battery's `client` resolver and `Tool.artifactConstructor`'s indirection. The\n * async form lets a consumer `() => import('@nhtio/adk/spooled_artifact').then(m => m.SpooledMarkdownArtifact)`\n * so the artifact class never enters their static module graph.\n */\nexport type ArtifactResolver =\n | SpooledArtifactCtor\n | (() => SpooledArtifactCtor | { default: SpooledArtifactCtor })\n | (() => Promise<SpooledArtifactCtor | { default: SpooledArtifactCtor }>)\n\n/** The sync subset of {@link ArtifactResolver} — a constructor or a sync resolver (no Promise). */\nexport type SyncArtifactResolver =\n | SpooledArtifactCtor\n | (() => SpooledArtifactCtor | { default: SpooledArtifactCtor })\n\n/** Unwrap a resolved value that may be a module namespace whose `default` is the constructor. */\nconst unwrapDefault = (value: unknown): unknown => {\n if (isObject(value) && 'default' in value) {\n const def = (value as { default?: unknown }).default\n if (SpooledArtifact.isSpooledArtifactConstructor(def)) return def\n }\n return value\n}\n\n/**\n * Resolve an {@link ArtifactResolver} to the **sync** `() => SpooledArtifactCtor` that\n * `Tool.artifactConstructor` requires (the wrap-site and the construction-time validator both\n * invoke it synchronously, so an async resolver cannot be passed straight through).\n *\n * @remarks\n * A bare constructor is itself a function, so it is distinguished from a resolver via\n * `SpooledArtifact.isSpooledArtifactConstructor` (the same duck-typed guard the core validator\n * uses) rather than by arity. Async because a dynamic-import resolver must be awaited here.\n *\n * @param resolver - The artifact configuration. When `undefined`, callers should fall back to\n * their own default (this function rejects `undefined` so the default lives with the caller).\n * @param onInvalid - Throws a battery-scoped error; receives a human-readable reason.\n * @returns A sync `() => SpooledArtifactCtor` suitable for `Tool.artifactConstructor`.\n */\nexport const resolveArtifact = async (\n resolver: ArtifactResolver,\n onInvalid: (reason: string) => never\n): Promise<() => SpooledArtifactCtor> => {\n // A constructor: hand back a thunk that returns it.\n if (SpooledArtifact.isSpooledArtifactConstructor(resolver)) {\n const ctor = resolver\n return () => ctor\n }\n // Otherwise it must be a resolver function.\n if (typeof resolver !== 'function') {\n onInvalid('artifact must be a SpooledArtifact constructor or a resolver returning one')\n }\n let resolved: unknown\n try {\n resolved = await (resolver as () => unknown)()\n } catch (err) {\n onInvalid(`artifact resolver threw: ${isError(err) ? err.message : String(err)}`)\n }\n resolved = unwrapDefault(resolved)\n if (!SpooledArtifact.isSpooledArtifactConstructor(resolved)) {\n onInvalid('artifact resolver did not resolve to a SpooledArtifact constructor')\n }\n const ctor = resolved as SpooledArtifactCtor\n return () => ctor\n}\n\n/**\n * Synchronous {@link resolveArtifact}: accepts only the {@link SyncArtifactResolver} subset and\n * throws (via `onInvalid`) on an async resolver — a runtime guard for JS callers who bypass the\n * compile-time narrowing.\n *\n * @param resolver - A constructor or a sync resolver.\n * @param onInvalid - Throws a battery-scoped error; receives a human-readable reason.\n * @returns A sync `() => SpooledArtifactCtor` suitable for `Tool.artifactConstructor`.\n */\nexport const resolveArtifactSync = (\n resolver: SyncArtifactResolver,\n onInvalid: (reason: string) => never\n): (() => SpooledArtifactCtor) => {\n if (SpooledArtifact.isSpooledArtifactConstructor(resolver)) {\n const ctor = resolver\n return () => ctor\n }\n if (typeof resolver !== 'function') {\n onInvalid('artifact must be a SpooledArtifact constructor or a resolver returning one')\n }\n let resolved: unknown\n try {\n resolved = (resolver as () => unknown)()\n } catch (err) {\n onInvalid(`artifact resolver threw: ${isError(err) ? err.message : String(err)}`)\n }\n if (isInstanceOf(resolved, 'Promise', Promise)) {\n onInvalid(\n 'artifact resolver is async; use the async factory variant for dynamic-import resolvers'\n )\n }\n resolved = unwrapDefault(resolved)\n if (!SpooledArtifact.isSpooledArtifactConstructor(resolved)) {\n onInvalid('artifact resolver did not resolve to a SpooledArtifact constructor')\n }\n const ctor = resolved as SpooledArtifactCtor\n return () => ctor\n}\n\n// ── Middleware pipeline runners ──────────────────────────────────────────────\n\n/** Internal sentinel a short-circuiting input stage throws to unwind the pipeline immediately. */\nconst SHORT_CIRCUIT = Symbol('adk.tools.shortCircuit')\n\ninterface ShortCircuitSignal {\n [SHORT_CIRCUIT]: true\n result: string\n}\n\n/** `true` when `value` is the short-circuit sentinel produced by {@link makeShortCircuit}. */\nexport const isShortCircuit = (value: unknown): value is { result: string } =>\n isObject(value) && (value as Record<symbol, unknown>)[SHORT_CIRCUIT] === true\n\n/**\n * Build a `shortCircuit(result)` function for an input-pipeline context. Calling it throws the\n * internal sentinel, which {@link runInputPipeline} catches and converts into the verbatim result\n * (skipping the HTTP request entirely — e.g. a cache hit).\n *\n * @returns A function that, when called with a result string, throws the short-circuit sentinel.\n */\nexport const makeShortCircuit = (): ((result: string) => never) => {\n return (result: string): never => {\n const signal: ShortCircuitSignal = { [SHORT_CIRCUIT]: true, result }\n throw signal\n }\n}\n\n/** A generic onion middleware stage over a mutable context `C`. */\nexport type MiddlewareFn<C> = (ctx: C, next: NextFn) => void | Promise<void>\n\n/**\n * Run an input pipeline over `ctx`. Returns the short-circuit string when a stage short-circuited,\n * or `undefined` when the pipeline reached its terminal handler. A non-terminal pipeline (a stage\n * that neither called `next()` nor short-circuited) throws — the caller converts it to an\n * `Error:` string.\n *\n * @param mw - The `Middleware` instance holding the stages (a fresh `.runner()` is minted here).\n * @param ctx - The mutable input context handed to each stage.\n * @param label - Battery name, used in the non-terminal error message.\n * @returns The short-circuit result string, or `undefined` if the pipeline ran to completion.\n */\nexport const runInputPipeline = async <C>(\n mw: Middleware<MiddlewareFn<C>>,\n ctx: C,\n label: string\n): Promise<string | undefined> => {\n let reached = false\n let caught: unknown\n await mw\n .runner()\n .errorHandler(async (error: unknown) => {\n caught = error\n })\n .finalHandler(async () => {\n reached = true\n })\n .run((fn, next) => Promise.resolve(fn(ctx, next)))\n\n if (caught !== undefined) {\n if (isShortCircuit(caught)) return caught.result\n throw caught\n }\n if (!reached) {\n throw new Error(`${label} input pipeline did not call next() and did not short-circuit.`)\n }\n return undefined\n}\n\n/**\n * Run an output pipeline over `ctx`; rethrow any stage error to the caller's try/catch. A\n * non-terminal pipeline (no `next()`) throws.\n *\n * @param mw - The `Middleware` instance holding the stages (a fresh `.runner()` is minted here).\n * @param ctx - The mutable output context handed to each stage.\n * @param label - Battery name, used in the non-terminal error message.\n */\nexport const runOutputPipeline = async <C>(\n mw: Middleware<MiddlewareFn<C>>,\n ctx: C,\n label: string\n): Promise<void> => {\n let reached = false\n let caught: unknown\n await mw\n .runner()\n .errorHandler(async (error: unknown) => {\n caught = error\n })\n .finalHandler(async () => {\n reached = true\n })\n .run((fn, next) => Promise.resolve(fn(ctx, next)))\n\n if (caught !== undefined) throw caught\n if (!reached) throw new Error(`${label} output pipeline did not call next().`)\n}\n"],"mappings":";;;;;;;;;;;AA+CA,IAAa,iBAAiB,OAC5B,YACyB;CACzB,IAAI,OAAO,YAAY,YAAY,OAAO,EAAE,GAAI,MAAM,QAAQ,EAAG;CACjE,OAAO,EAAE,GAAI,WAAW,CAAC,EAAG;AAC9B;;AA2BA,IAAM,iBAAiB,UAA4B;CACjD,IAAI,SAAS,KAAK,KAAK,aAAa,OAAO;EACzC,MAAM,MAAO,MAAgC;EAC7C,IAAI,gBAAgB,6BAA6B,GAAG,GAAG,OAAO;CAChE;CACA,OAAO;AACT;;;;;;;;;;;;;;;;AAiBA,IAAa,kBAAkB,OAC7B,UACA,cACuC;CAEvC,IAAI,gBAAgB,6BAA6B,QAAQ,GAAG;EAC1D,MAAM,OAAO;EACb,aAAa;CACf;CAEA,IAAI,OAAO,aAAa,YACtB,UAAU,4EAA4E;CAExF,IAAI;CACJ,IAAI;EACF,WAAW,MAAO,SAA2B;CAC/C,SAAS,KAAK;EACZ,UAAU,4BAA4B,QAAQ,GAAG,IAAI,IAAI,UAAU,OAAO,GAAG,GAAG;CAClF;CACA,WAAW,cAAc,QAAQ;CACjC,IAAI,CAAC,gBAAgB,6BAA6B,QAAQ,GACxD,UAAU,oEAAoE;CAEhF,MAAM,OAAO;CACb,aAAa;AACf;;;;;;;;;;AAWA,IAAa,uBACX,UACA,cACgC;CAChC,IAAI,gBAAgB,6BAA6B,QAAQ,GAAG;EAC1D,MAAM,OAAO;EACb,aAAa;CACf;CACA,IAAI,OAAO,aAAa,YACtB,UAAU,4EAA4E;CAExF,IAAI;CACJ,IAAI;EACF,WAAY,SAA2B;CACzC,SAAS,KAAK;EACZ,UAAU,4BAA4B,QAAQ,GAAG,IAAI,IAAI,UAAU,OAAO,GAAG,GAAG;CAClF;CACA,IAAI,aAAa,UAAU,WAAW,OAAO,GAC3C,UACE,wFACF;CAEF,WAAW,cAAc,QAAQ;CACjC,IAAI,CAAC,gBAAgB,6BAA6B,QAAQ,GACxD,UAAU,oEAAoE;CAEhF,MAAM,OAAO;CACb,aAAa;AACf;;AAKA,IAAM,gBAAgB,OAAO,wBAAwB;;AAQrD,IAAa,kBAAkB,UAC7B,SAAS,KAAK,KAAM,MAAkC,mBAAmB;;;;;;;;AAS3E,IAAa,yBAAsD;CACjE,QAAQ,WAA0B;EAEhC,MAAM;IADgC,gBAAgB;GAAM;EACtD;CACR;AACF;;;;;;;;;;;;AAgBA,IAAa,mBAAmB,OAC9B,IACA,KACA,UACgC;CAChC,IAAI,UAAU;CACd,IAAI;CACJ,MAAM,GACH,OAAO,EACP,aAAa,OAAO,UAAmB;EACtC,SAAS;CACX,CAAC,EACA,aAAa,YAAY;EACxB,UAAU;CACZ,CAAC,EACA,KAAK,IAAI,SAAS,QAAQ,QAAQ,GAAG,KAAK,IAAI,CAAC,CAAC;CAEnD,IAAI,WAAW,KAAA,GAAW;EACxB,IAAI,eAAe,MAAM,GAAG,OAAO,OAAO;EAC1C,MAAM;CACR;CACA,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,GAAG,MAAM,+DAA+D;AAG5F;;;;;;;;;AAUA,IAAa,oBAAoB,OAC/B,IACA,KACA,UACkB;CAClB,IAAI,UAAU;CACd,IAAI;CACJ,MAAM,GACH,OAAO,EACP,aAAa,OAAO,UAAmB;EACtC,SAAS;CACX,CAAC,EACA,aAAa,YAAY;EACxB,UAAU;CACZ,CAAC,EACA,KAAK,IAAI,SAAS,QAAQ,QAAQ,GAAG,KAAK,IAAI,CAAC,CAAC;CAEnD,IAAI,WAAW,KAAA,GAAW,MAAM;CAChC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,GAAG,MAAM,sCAAsC;AAC/E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool = require("../../tool-
|
|
4
|
-
require("../../common-
|
|
3
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
4
|
+
require("../../common-DZl3ADJs.js");
|
|
5
5
|
let _nhtio_validation = require("@nhtio/validation");
|
|
6
6
|
//#region src/batteries/tools/color/index.ts
|
|
7
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Tool } from "../../tool-
|
|
2
|
-
import "../../common-
|
|
1
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
2
|
+
import "../../common-DYDUi99O.mjs";
|
|
3
3
|
import { validator } from "@nhtio/validation";
|
|
4
4
|
//#region src/batteries/tools/color/index.ts
|
|
5
5
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool_registry = require("../../tool_registry-
|
|
4
|
-
const require_tool = require("../../tool-
|
|
5
|
-
require("../../common-
|
|
3
|
+
const require_tool_registry = require("../../tool_registry-CKJPze3j.js");
|
|
4
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
5
|
+
require("../../common-DZl3ADJs.js");
|
|
6
6
|
require("../../guards.cjs");
|
|
7
7
|
let _nhtio_validation = require("@nhtio/validation");
|
|
8
8
|
//#region src/batteries/tools/comparison/index.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as isError } from "../../tool_registry-
|
|
2
|
-
import { t as Tool } from "../../tool-
|
|
3
|
-
import "../../common-
|
|
1
|
+
import { o as isError } from "../../tool_registry-791Vrjtf.mjs";
|
|
2
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
3
|
+
import "../../common-DYDUi99O.mjs";
|
|
4
4
|
import "../../guards.mjs";
|
|
5
5
|
import { validator } from "@nhtio/validation";
|
|
6
6
|
//#region src/batteries/tools/comparison/index.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool_registry = require("../../tool_registry-
|
|
4
|
-
const require_tool = require("../../tool-
|
|
5
|
-
require("../../common-
|
|
3
|
+
const require_tool_registry = require("../../tool_registry-CKJPze3j.js");
|
|
4
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
5
|
+
require("../../common-DZl3ADJs.js");
|
|
6
6
|
require("../../guards.cjs");
|
|
7
7
|
const require_lib_helpers_bignum = require("../../lib/helpers/bignum.cjs");
|
|
8
8
|
let _nhtio_validation = require("@nhtio/validation");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as isObject, o as isError } from "../../tool_registry-
|
|
2
|
-
import { t as Tool } from "../../tool-
|
|
3
|
-
import "../../common-
|
|
1
|
+
import { c as isObject, o as isError } from "../../tool_registry-791Vrjtf.mjs";
|
|
2
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
3
|
+
import "../../common-DYDUi99O.mjs";
|
|
4
4
|
import "../../guards.mjs";
|
|
5
5
|
import { bigMean, bigSum, bigToNumber, formatBig } from "../../lib/helpers/bignum.mjs";
|
|
6
6
|
import { validator } from "@nhtio/validation";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool = require("../../tool-
|
|
4
|
-
require("../../common-
|
|
5
|
-
let luxon = require("luxon");
|
|
3
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
4
|
+
require("../../common-DZl3ADJs.js");
|
|
6
5
|
let _nhtio_validation = require("@nhtio/validation");
|
|
6
|
+
let luxon = require("luxon");
|
|
7
7
|
let chrono_node = require("chrono-node");
|
|
8
8
|
chrono_node = require_chunk.__toESM(chrono_node);
|
|
9
9
|
//#region src/batteries/tools/datetime_extended/index.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as Tool } from "../../tool-
|
|
2
|
-
import "../../common-
|
|
3
|
-
import { DateTime, IANAZone } from "luxon";
|
|
1
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
2
|
+
import "../../common-DYDUi99O.mjs";
|
|
4
3
|
import { validator } from "@nhtio/validation";
|
|
4
|
+
import { DateTime, IANAZone } from "luxon";
|
|
5
5
|
import * as chrono from "chrono-node";
|
|
6
6
|
//#region src/batteries/tools/datetime_extended/index.ts
|
|
7
7
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool = require("../../tool-
|
|
4
|
-
require("../../common-
|
|
5
|
-
let luxon = require("luxon");
|
|
3
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
4
|
+
require("../../common-DZl3ADJs.js");
|
|
6
5
|
let _nhtio_validation = require("@nhtio/validation");
|
|
6
|
+
let luxon = require("luxon");
|
|
7
7
|
//#region src/batteries/tools/datetime_math/index.ts
|
|
8
8
|
/**
|
|
9
9
|
* Pre-constructed tools for ISO datetime arithmetic, differences, and timezone-aware formatting.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as Tool } from "../../tool-
|
|
2
|
-
import "../../common-
|
|
3
|
-
import { DateTime, Duration, IANAZone } from "luxon";
|
|
1
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
2
|
+
import "../../common-DYDUi99O.mjs";
|
|
4
3
|
import { validator } from "@nhtio/validation";
|
|
4
|
+
import { DateTime, Duration, IANAZone } from "luxon";
|
|
5
5
|
//#region src/batteries/tools/datetime_math/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* Pre-constructed tools for ISO datetime arithmetic, differences, and timezone-aware formatting.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool_registry = require("../../tool_registry-
|
|
4
|
-
const require_tool = require("../../tool-
|
|
5
|
-
require("../../common-
|
|
3
|
+
const require_tool_registry = require("../../tool_registry-CKJPze3j.js");
|
|
4
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
5
|
+
require("../../common-DZl3ADJs.js");
|
|
6
6
|
require("../../guards.cjs");
|
|
7
7
|
let _nhtio_validation = require("@nhtio/validation");
|
|
8
8
|
//#region src/batteries/tools/encoding/index.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as isError } from "../../tool_registry-
|
|
2
|
-
import { t as Tool } from "../../tool-
|
|
3
|
-
import "../../common-
|
|
1
|
+
import { o as isError } from "../../tool_registry-791Vrjtf.mjs";
|
|
2
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
3
|
+
import "../../common-DYDUi99O.mjs";
|
|
4
4
|
import "../../guards.mjs";
|
|
5
5
|
import { validator } from "@nhtio/validation";
|
|
6
6
|
//#region src/batteries/tools/encoding/index.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool_registry = require("../../tool_registry-
|
|
4
|
-
const require_tool = require("../../tool-
|
|
5
|
-
require("../../common-
|
|
3
|
+
const require_tool_registry = require("../../tool_registry-CKJPze3j.js");
|
|
4
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
5
|
+
require("../../common-DZl3ADJs.js");
|
|
6
6
|
require("../../guards.cjs");
|
|
7
7
|
let _nhtio_validation = require("@nhtio/validation");
|
|
8
8
|
//#region src/batteries/tools/formatting/index.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as isError } from "../../tool_registry-
|
|
2
|
-
import { t as Tool } from "../../tool-
|
|
3
|
-
import "../../common-
|
|
1
|
+
import { o as isError } from "../../tool_registry-791Vrjtf.mjs";
|
|
2
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
3
|
+
import "../../common-DYDUi99O.mjs";
|
|
4
4
|
import "../../guards.mjs";
|
|
5
5
|
import { validator } from "@nhtio/validation";
|
|
6
6
|
//#region src/batteries/tools/formatting/index.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool = require("../../tool-
|
|
4
|
-
require("../../common-
|
|
3
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
4
|
+
require("../../common-DZl3ADJs.js");
|
|
5
5
|
let _nhtio_validation = require("@nhtio/validation");
|
|
6
6
|
//#region src/batteries/tools/geo_basics/index.ts
|
|
7
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Tool } from "../../tool-
|
|
2
|
-
import "../../common-
|
|
1
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
2
|
+
import "../../common-DYDUi99O.mjs";
|
|
3
3
|
import { validator } from "@nhtio/validation";
|
|
4
4
|
//#region src/batteries/tools/geo_basics/index.ts
|
|
5
5
|
/**
|
|
@@ -22,6 +22,7 @@ export * from "./math/index";
|
|
|
22
22
|
export * from "./memory/index";
|
|
23
23
|
export * from "./parsing/index";
|
|
24
24
|
export * from "./retrievables/index";
|
|
25
|
+
export * from "./scrapper/index";
|
|
25
26
|
export * from "./searxng/index";
|
|
26
27
|
export * from "./standing_instructions/index";
|
|
27
28
|
export * from "./statistics/index";
|
|
@@ -29,5 +30,6 @@ export * from "./string_processing/index";
|
|
|
29
30
|
export * from "./structured_data/index";
|
|
30
31
|
export * from "./text_analysis/index";
|
|
31
32
|
export * from "./text_comparison/index";
|
|
33
|
+
export * from "./web_retrieval/index";
|
|
32
34
|
export * from "./time/index";
|
|
33
35
|
export * from "./unit_conversion/index";
|
package/batteries/tools/math.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool_registry = require("../../tool_registry-
|
|
4
|
-
const require_tool = require("../../tool-
|
|
5
|
-
require("../../common-
|
|
3
|
+
const require_tool_registry = require("../../tool_registry-CKJPze3j.js");
|
|
4
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
5
|
+
require("../../common-DZl3ADJs.js");
|
|
6
6
|
require("../../guards.cjs");
|
|
7
7
|
let _nhtio_validation = require("@nhtio/validation");
|
|
8
8
|
let mathjs = require("mathjs");
|
package/batteries/tools/math.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as isError, s as isInstanceOf } from "../../tool_registry-
|
|
2
|
-
import { t as Tool } from "../../tool-
|
|
3
|
-
import "../../common-
|
|
1
|
+
import { o as isError, s as isInstanceOf } from "../../tool_registry-791Vrjtf.mjs";
|
|
2
|
+
import { t as Tool } from "../../tool-wMYMVl60.mjs";
|
|
3
|
+
import "../../common-DYDUi99O.mjs";
|
|
4
4
|
import "../../guards.mjs";
|
|
5
5
|
import { validator } from "@nhtio/validation";
|
|
6
6
|
import { all, create } from "mathjs";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Ble4zEEl.js");
|
|
3
|
-
const require_tool_registry = require("../../tool_registry-
|
|
4
|
-
const require_thought = require("../../thought-
|
|
5
|
-
const require_tool = require("../../tool-
|
|
6
|
-
require("../../common-
|
|
7
|
-
const require_spooled_markdown_artifact = require("../../spooled_markdown_artifact-
|
|
3
|
+
const require_tool_registry = require("../../tool_registry-CKJPze3j.js");
|
|
4
|
+
const require_thought = require("../../thought-DLwpF7MI.js");
|
|
5
|
+
const require_tool = require("../../tool-D5WGVIcI.js");
|
|
6
|
+
require("../../common-DZl3ADJs.js");
|
|
7
|
+
const require_spooled_markdown_artifact = require("../../spooled_markdown_artifact-ClX72lek.js");
|
|
8
8
|
require("../../guards.cjs");
|
|
9
|
+
let _nhtio_validation = require("@nhtio/validation");
|
|
9
10
|
let luxon = require("luxon");
|
|
10
11
|
let uuid = require("uuid");
|
|
11
|
-
let _nhtio_validation = require("@nhtio/validation");
|
|
12
12
|
//#region src/batteries/tools/memory/index.ts
|
|
13
13
|
/**
|
|
14
14
|
* Pre-constructed CRUD tools for model-visible ADK memory management.
|