@sema-agent/core 2.8.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/send-message-tool.js +37 -29
- package/dist/agents/subagent.js +91 -4
- package/dist/brain/circuit-breaker.js +18 -8
- package/dist/brain/retry.d.ts +1 -0
- package/dist/brain/retry.js +29 -7
- package/dist/brain/stream-engine.d.ts +1 -0
- package/dist/brain/stream-engine.js +74 -12
- package/dist/config/defaults.d.ts +1 -0
- package/dist/config/defaults.js +1 -0
- package/dist/core/auto-compaction.js +9 -1
- package/dist/core/background-agent-store.d.ts +2 -0
- package/dist/core/background-agent-store.js +20 -0
- package/dist/core/mcp.js +8 -5
- package/dist/core/runner/assemble-result.d.ts +1 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/prepare-task.d.ts +2 -1
- package/dist/core/runner/prepare-task.js +61 -20
- package/dist/core/runner/runtask.js +38 -12
- package/dist/core/runner/tool-disclosure.d.ts +8 -3
- package/dist/core/runner/tool-disclosure.js +39 -10
- package/dist/core/skills-directory.d.ts +1 -1
- package/dist/core/skills-directory.js +257 -28
- package/dist/core/task-registry-agent.d.ts +2 -1
- package/dist/core/task-registry-agent.js +50 -54
- package/dist/core/task-registry.d.ts +1 -0
- package/dist/core/task-registry.js +1 -1
- package/dist/core/types.d.ts +9 -1
- package/dist/engine/compaction/compaction.js +71 -20
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +1 -0
- package/dist/orchestration/run-workflow-tool.js +4 -1
- package/dist/orchestration/workflow.d.ts +1 -1
- package/dist/orchestration/workflow.js +20 -12
- package/dist/tools/fs/bash-readonly-classifier.js +83 -17
- package/dist/tools/fs/fs-bash.js +17 -11
- package/dist/tools/fs/fs-shared.d.ts +1 -0
- package/dist/tools/fs/fs-shared.js +44 -2
- package/dist/tools/web.d.ts +15 -0
- package/dist/tools/web.js +42 -0
- package/package.json +1 -1
package/dist/tools/web.js
CHANGED
|
@@ -798,3 +798,45 @@ export function createWebSearchTool(config) {
|
|
|
798
798
|
},
|
|
799
799
|
};
|
|
800
800
|
}
|
|
801
|
+
export function createSearxngSearchBackend(baseUrl, options = {}) {
|
|
802
|
+
const doFetch = options.fetchImpl ?? globalThis.fetch;
|
|
803
|
+
const timeoutMs = options.timeoutMs ?? 10_000;
|
|
804
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
805
|
+
return async (query, signal, opts) => {
|
|
806
|
+
const q = opts?.allowedDomains && opts.allowedDomains.length > 0
|
|
807
|
+
? `${opts.allowedDomains.map((d) => `site:${d}`).join(" OR ")} ${query}`
|
|
808
|
+
: query;
|
|
809
|
+
const url = new URL(`${base}/search`);
|
|
810
|
+
url.searchParams.set("q", q);
|
|
811
|
+
url.searchParams.set("format", "json");
|
|
812
|
+
for (const [k, v] of Object.entries(options.extraParams ?? {}))
|
|
813
|
+
url.searchParams.set(k, v);
|
|
814
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
815
|
+
const res = await doFetch(url, { signal: signal ? AbortSignal.any([signal, timeout]) : timeout, headers: { accept: "application/json" } });
|
|
816
|
+
if (!res.ok)
|
|
817
|
+
throw new Error(`SearXNG ${res.status} ${res.statusText} from ${base}/search`);
|
|
818
|
+
const body = (await res.json());
|
|
819
|
+
if (!Array.isArray(body.results))
|
|
820
|
+
throw new Error(`SearXNG returned no results array from ${base}/search — is format=json enabled on this instance?`);
|
|
821
|
+
return body.results
|
|
822
|
+
.filter((r) => typeof r.url === "string" && r.url !== "")
|
|
823
|
+
.map((r) => ({
|
|
824
|
+
title: typeof r.title === "string" && r.title !== "" ? r.title : r.url,
|
|
825
|
+
url: r.url,
|
|
826
|
+
snippet: typeof r.content === "string" ? r.content : "",
|
|
827
|
+
}));
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
export async function probeSearchBackend(search, options) {
|
|
831
|
+
const budget = options?.timeoutMs ?? 15_000;
|
|
832
|
+
try {
|
|
833
|
+
const results = await Promise.race([
|
|
834
|
+
search("connectivity probe", AbortSignal.timeout(budget)),
|
|
835
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`probe timed out after ${budget}ms`)), budget)),
|
|
836
|
+
]);
|
|
837
|
+
return { ok: true, results: results.length };
|
|
838
|
+
}
|
|
839
|
+
catch (e) {
|
|
840
|
+
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
841
|
+
}
|
|
842
|
+
}
|