@developerz.ai/ai-claude-compat 0.0.4 → 0.0.5
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/subagent.d.ts +16 -4
- package/dist/subagent.js +12 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export { type ReadFileInput, type ReadFileOutput, readFileTool, type ToolInit, t
|
|
|
8
8
|
export { resolveInside } from './safe-path.ts';
|
|
9
9
|
export { type GlobInput, type GlobOutput, type GrepInput, type GrepOutput, globTool, globToRegExp, grepTool, } from './search-tools.ts';
|
|
10
10
|
export { loadSkills, type SkillDefinition } from './skills-loader.ts';
|
|
11
|
-
export { composeSystemPrompt, createSubagent, type SubagentConfig } from './subagent.ts';
|
|
11
|
+
export { composeSystemPrompt, createSubagent, SUBMIT_TOOL_NAME, type SubagentConfig, submittedOutput, } from './subagent.ts';
|
package/dist/index.js
CHANGED
|
@@ -8,4 +8,4 @@ export { readFileTool, writeFileTool, } from "./fs-tools.js";
|
|
|
8
8
|
export { resolveInside } from "./safe-path.js";
|
|
9
9
|
export { globTool, globToRegExp, grepTool, } from "./search-tools.js";
|
|
10
10
|
export { loadSkills } from "./skills-loader.js";
|
|
11
|
-
export { composeSystemPrompt, createSubagent } from "./subagent.js";
|
|
11
|
+
export { composeSystemPrompt, createSubagent, SUBMIT_TOOL_NAME, submittedOutput, } from "./subagent.js";
|
package/dist/subagent.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import { type LanguageModel, type
|
|
1
|
+
import { type LanguageModel, type Tool, ToolLoopAgent, type ToolSet } from 'ai';
|
|
2
|
+
import type { z } from 'zod';
|
|
2
3
|
import { type EnvInfo } from './env-block.ts';
|
|
4
|
+
export declare const SUBMIT_TOOL_NAME = "submit";
|
|
3
5
|
export declare function composeSystemPrompt(style: string, rolePrefix: string, env: string | EnvInfo): string;
|
|
4
|
-
export type SubagentConfig<TOOLS extends ToolSet
|
|
6
|
+
export type SubagentConfig<TOOLS extends ToolSet> = {
|
|
5
7
|
model: LanguageModel;
|
|
6
8
|
tools: TOOLS;
|
|
7
9
|
systemPrompt: string;
|
|
8
|
-
|
|
10
|
+
submit: Tool;
|
|
9
11
|
maxSteps?: number;
|
|
10
12
|
};
|
|
11
|
-
export declare function createSubagent<TOOLS extends ToolSet
|
|
13
|
+
export declare function createSubagent<TOOLS extends ToolSet>(config: SubagentConfig<TOOLS>, defaultMaxSteps: number): ToolLoopAgent<never, TOOLS>;
|
|
14
|
+
type StepsResult = {
|
|
15
|
+
steps: ReadonlyArray<{
|
|
16
|
+
toolCalls: ReadonlyArray<{
|
|
17
|
+
toolName: string;
|
|
18
|
+
input: unknown;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
export declare function submittedOutput<OUTPUT>(result: StepsResult, outputSchema: z.ZodType<OUTPUT>): OUTPUT | undefined;
|
|
23
|
+
export {};
|
package/dist/subagent.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { stepCountIs, ToolLoopAgent } from 'ai';
|
|
1
|
+
import { hasToolCall, stepCountIs, ToolLoopAgent, } from 'ai';
|
|
2
2
|
import { envBlock } from "./env-block.js";
|
|
3
|
+
export const SUBMIT_TOOL_NAME = 'submit';
|
|
3
4
|
export function composeSystemPrompt(style, rolePrefix, env) {
|
|
4
5
|
const info = typeof env === 'string' ? { cwd: env, isGitRepo: true } : env;
|
|
5
6
|
return `${style}${rolePrefix}\n${envBlock(info)}`;
|
|
@@ -7,9 +8,16 @@ export function composeSystemPrompt(style, rolePrefix, env) {
|
|
|
7
8
|
export function createSubagent(config, defaultMaxSteps) {
|
|
8
9
|
return new ToolLoopAgent({
|
|
9
10
|
model: config.model,
|
|
10
|
-
tools: config.tools,
|
|
11
|
+
tools: { ...config.tools, submit: config.submit },
|
|
11
12
|
instructions: config.systemPrompt,
|
|
12
|
-
|
|
13
|
-
stopWhen: stepCountIs(config.maxSteps ?? defaultMaxSteps),
|
|
13
|
+
stopWhen: [stepCountIs(config.maxSteps ?? defaultMaxSteps), hasToolCall(SUBMIT_TOOL_NAME)],
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
+
export function submittedOutput(result, outputSchema) {
|
|
17
|
+
const call = result.steps
|
|
18
|
+
.flatMap((step) => step.toolCalls)
|
|
19
|
+
.find((toolCall) => toolCall.toolName === SUBMIT_TOOL_NAME);
|
|
20
|
+
if (!call)
|
|
21
|
+
return undefined;
|
|
22
|
+
return outputSchema.parse(call.input);
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@developerz.ai/ai-claude-compat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Claude-Code-style agent primitives for the Vercel AI SDK: FS/bash tools, an <env> system-context block, a subagent-as-tool factory, and .claude/ skills/agents loading.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|