@smithers-orchestrator/agents 0.24.2 → 0.25.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/package.json +15 -5
- package/src/AgentLike.ts +5 -0
- package/src/AmpAgent.js +15 -5
- package/src/AmpAgentOptions.ts +6 -0
- package/src/BaseCliAgent/BaseCliAgent.js +198 -10
- package/src/BaseCliAgent/createAgentStdoutTextEmitter.js +21 -3
- package/src/BaseCliAgent/index.d.ts +467 -0
- package/src/ClaudeCodeAgent.js +6 -2
- package/src/CodexAgent.js +4 -0
- package/src/GeminiAgent.js +34 -224
- package/src/GeminiAgentOptions.ts +4 -9
- package/src/OpenCodeAgent.js +2 -12
- package/src/OpenCodeAgentOptions.ts +19 -0
- package/src/PiAgent.js +4 -0
- package/src/cli-capabilities/CliAgentCapabilityAdapterId.ts +0 -1
- package/src/cli-capabilities/getCliAgentCapabilityDoctorReport.js +3 -2
- package/src/cli-capabilities/getCliAgentCapabilityReport.js +0 -6
- package/src/cli-surface/cliAgentSurfaceManifest.js +1 -40
- package/src/createElevenLabsTextToSpeechTool.js +128 -0
- package/src/createElevenLabsTextToSpeechTool.ts +33 -0
- package/src/diagnostics/getDiagnosticStrategy.js +163 -35
- package/src/document-parsing/DocumentParsingProvider.ts +13 -0
- package/src/document-parsing/DocumentParsingResult.ts +13 -0
- package/src/document-parsing/DocumentParsingToolset.ts +4 -0
- package/src/document-parsing/DocumentParsingToolsetOptions.ts +9 -0
- package/src/document-parsing/createDocumentParsingToolset.d.ts +9 -0
- package/src/document-parsing/createDocumentParsingToolset.js +416 -0
- package/src/http/CreateHttpToolOptions.ts +4 -0
- package/src/http/HttpToolAuth.ts +15 -0
- package/src/http/HttpToolInput.ts +11 -0
- package/src/http/HttpToolOutput.ts +7 -0
- package/src/http/createHttpTool.js +136 -0
- package/src/image-generation/ImageGenerationProvider.ts +7 -0
- package/src/image-generation/ImageGenerationRequest.ts +8 -0
- package/src/image-generation/ImageGenerationResult.ts +10 -0
- package/src/image-generation/ImageGenerationToolOptions.ts +10 -0
- package/src/image-generation/createImageGenerationTool.d.ts +18 -0
- package/src/image-generation/createImageGenerationTool.js +92 -0
- package/src/index.d.ts +490 -147
- package/src/index.js +23 -5
- package/src/streamResultToGenerateResult.js +55 -26
- package/src/transcription/createTranscriptionTool.js +182 -0
- package/src/transcription/createTranscriptionTool.ts +29 -0
- package/src/transcription/index.js +1 -0
- package/src/transcription/index.ts +6 -0
- package/src/web-search/GroundedWebSearchProvider.ts +21 -0
- package/src/web-search/GroundedWebSearchToolset.ts +6 -0
- package/src/web-search/createBraveSearchProvider.js +53 -0
- package/src/web-search/createExaSearchProvider.js +72 -0
- package/src/web-search/createGroundedWebSearchToolset.js +110 -0
- package/src/web-search/createSerperSearchProvider.js +63 -0
- package/src/web-search/createTavilySearchProvider.js +59 -0
- package/src/web-search/index.js +5 -0
- package/src/zodToOpenAISchema.js +4 -0
- package/src/OpenCodeAgent.ts +0 -43
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** @typedef {import("./GroundedWebSearchProvider.ts").GroundedWebSearchProvider} GroundedWebSearchProvider */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {{ apiKey: string; baseUrl?: string; fetch?: typeof fetch }} options
|
|
5
|
+
* @returns {GroundedWebSearchProvider}
|
|
6
|
+
*/
|
|
7
|
+
export function createSerperSearchProvider(options) {
|
|
8
|
+
return {
|
|
9
|
+
name: "serper",
|
|
10
|
+
kind: "fresh",
|
|
11
|
+
async search(input) {
|
|
12
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
13
|
+
const response = await fetchImpl(options.baseUrl ?? "https://google.serper.dev/search", {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
"content-type": "application/json",
|
|
17
|
+
"x-api-key": options.apiKey,
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify({
|
|
20
|
+
q: input.query,
|
|
21
|
+
num: input.maxResults,
|
|
22
|
+
...freshnessParams(input.freshness),
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
const body = await readJson(response, "Serper");
|
|
26
|
+
const results = Array.isArray(body.organic) ? body.organic : [];
|
|
27
|
+
return results.map((result) => ({
|
|
28
|
+
title: String(result.title ?? result.link ?? "Untitled"),
|
|
29
|
+
url: String(result.link ?? ""),
|
|
30
|
+
snippet: result.snippet,
|
|
31
|
+
publishedDate: result.date,
|
|
32
|
+
})).filter((result) => result.url);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @param {string | undefined} freshness */
|
|
38
|
+
function freshnessParams(freshness) {
|
|
39
|
+
const tbs = freshnessTbs(freshness);
|
|
40
|
+
return tbs ? { tbs } : {};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @param {string | undefined} freshness */
|
|
44
|
+
function freshnessTbs(freshness) {
|
|
45
|
+
if (freshness === "day") return "qdr:d";
|
|
46
|
+
if (freshness === "week") return "qdr:w";
|
|
47
|
+
if (freshness === "month") return "qdr:m";
|
|
48
|
+
if (freshness === "year") return "qdr:y";
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {Response} response
|
|
54
|
+
* @param {string} provider
|
|
55
|
+
* @returns {Promise<any>}
|
|
56
|
+
*/
|
|
57
|
+
async function readJson(response, provider) {
|
|
58
|
+
const text = await response.text();
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
throw new Error(`${provider} search failed (${response.status}): ${text}`);
|
|
61
|
+
}
|
|
62
|
+
return text ? JSON.parse(text) : {};
|
|
63
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** @typedef {import("./GroundedWebSearchProvider.ts").GroundedWebSearchProvider} GroundedWebSearchProvider */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {{ apiKey: string; baseUrl?: string; fetch?: typeof fetch }} options
|
|
5
|
+
* @returns {GroundedWebSearchProvider}
|
|
6
|
+
*/
|
|
7
|
+
export function createTavilySearchProvider(options) {
|
|
8
|
+
return {
|
|
9
|
+
name: "tavily",
|
|
10
|
+
kind: "fresh",
|
|
11
|
+
async search(input) {
|
|
12
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
13
|
+
const response = await fetchImpl(`${options.baseUrl ?? "https://api.tavily.com"}/search`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
"content-type": "application/json",
|
|
17
|
+
authorization: `Bearer ${options.apiKey}`,
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify({
|
|
20
|
+
query: input.query,
|
|
21
|
+
max_results: input.maxResults,
|
|
22
|
+
topic: input.freshness ? "news" : "general",
|
|
23
|
+
days: freshnessDays(input.freshness),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
const body = await readJson(response, "Tavily");
|
|
27
|
+
const results = Array.isArray(body.results) ? body.results : [];
|
|
28
|
+
return results.map((result) => ({
|
|
29
|
+
title: String(result.title ?? result.url ?? "Untitled"),
|
|
30
|
+
url: String(result.url ?? ""),
|
|
31
|
+
snippet: result.content,
|
|
32
|
+
publishedDate: result.published_date,
|
|
33
|
+
score: typeof result.score === "number" ? result.score : undefined,
|
|
34
|
+
})).filter((result) => result.url);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** @param {string | undefined} freshness */
|
|
40
|
+
function freshnessDays(freshness) {
|
|
41
|
+
if (freshness === "day") return 1;
|
|
42
|
+
if (freshness === "week") return 7;
|
|
43
|
+
if (freshness === "month") return 30;
|
|
44
|
+
if (freshness === "year") return 365;
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {Response} response
|
|
50
|
+
* @param {string} provider
|
|
51
|
+
* @returns {Promise<any>}
|
|
52
|
+
*/
|
|
53
|
+
async function readJson(response, provider) {
|
|
54
|
+
const text = await response.text();
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
throw new Error(`${provider} search failed (${response.status}): ${text}`);
|
|
57
|
+
}
|
|
58
|
+
return text ? JSON.parse(text) : {};
|
|
59
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createGroundedWebSearchToolset } from "./createGroundedWebSearchToolset.js";
|
|
2
|
+
export { createExaSearchProvider } from "./createExaSearchProvider.js";
|
|
3
|
+
export { createTavilySearchProvider } from "./createTavilySearchProvider.js";
|
|
4
|
+
export { createBraveSearchProvider } from "./createBraveSearchProvider.js";
|
|
5
|
+
export { createSerperSearchProvider } from "./createSerperSearchProvider.js";
|
package/src/zodToOpenAISchema.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertZodV4 } from "@smithers-orchestrator/errors/assertZodV4";
|
|
1
2
|
import { sanitizeForOpenAI } from "./sanitizeForOpenAI.js";
|
|
2
3
|
/**
|
|
3
4
|
* Convert a Zod schema to an OpenAI-safe JSON Schema object.
|
|
@@ -9,6 +10,9 @@ import { sanitizeForOpenAI } from "./sanitizeForOpenAI.js";
|
|
|
9
10
|
* ```
|
|
10
11
|
*/
|
|
11
12
|
export async function zodToOpenAISchema(zodSchema) {
|
|
13
|
+
// z.toJSONSchema() reads Zod v4 internals; a v3 schema throws a cryptic
|
|
14
|
+
// `schema._zod.def` TypeError. Surface a clear, actionable error instead.
|
|
15
|
+
assertZodV4(zodSchema);
|
|
12
16
|
const { z } = await import("zod");
|
|
13
17
|
const jsonSchema = z.toJSONSchema(zodSchema);
|
|
14
18
|
sanitizeForOpenAI(jsonSchema);
|
package/src/OpenCodeAgent.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type CliOutputInterpreter, BaseCliAgent } from "./BaseCliAgent";
|
|
2
|
-
import type { BaseCliAgentOptions } from "./BaseCliAgent";
|
|
3
|
-
import { type AgentCapabilityRegistry } from "./capability-registry";
|
|
4
|
-
|
|
5
|
-
export type OpenCodeAgentOptions = BaseCliAgentOptions & {
|
|
6
|
-
/** Model identifier (e.g., "anthropic/claude-opus-4-20250514", "openai/gpt-5.4") */
|
|
7
|
-
model?: string;
|
|
8
|
-
/** OpenCode agent name (maps to --agent flag, selects predefined agent config) */
|
|
9
|
-
agentName?: string;
|
|
10
|
-
/** Files to attach to the prompt via -f flags */
|
|
11
|
-
attachFiles?: string[];
|
|
12
|
-
/** Continue a previous session */
|
|
13
|
-
continueSession?: boolean;
|
|
14
|
-
/** Resume a specific session by ID */
|
|
15
|
-
sessionId?: string;
|
|
16
|
-
/** Provider-specific model variant/reasoning effort level */
|
|
17
|
-
variant?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export declare function createOpenCodeCapabilityRegistry(
|
|
21
|
-
opts?: OpenCodeAgentOptions
|
|
22
|
-
): AgentCapabilityRegistry;
|
|
23
|
-
|
|
24
|
-
export declare class OpenCodeAgent extends BaseCliAgent {
|
|
25
|
-
private readonly opts: OpenCodeAgentOptions;
|
|
26
|
-
readonly capabilities: AgentCapabilityRegistry;
|
|
27
|
-
readonly cliEngine: "opencode";
|
|
28
|
-
constructor(opts?: OpenCodeAgentOptions);
|
|
29
|
-
createOutputInterpreter(): CliOutputInterpreter;
|
|
30
|
-
buildCommand(params: {
|
|
31
|
-
prompt: string;
|
|
32
|
-
systemPrompt?: string;
|
|
33
|
-
cwd: string;
|
|
34
|
-
options: any;
|
|
35
|
-
}): Promise<{
|
|
36
|
-
command: string;
|
|
37
|
-
args: string[];
|
|
38
|
-
outputFormat: "stream-json";
|
|
39
|
-
env?: Record<string, string>;
|
|
40
|
-
stdoutBannerPatterns: RegExp[];
|
|
41
|
-
stdoutErrorPatterns: RegExp[];
|
|
42
|
-
}>;
|
|
43
|
-
}
|