@openplaybooks/agentfn 0.2.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/LICENSE +21 -0
- package/dist/agent.d.ts +19 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +9 -0
- package/dist/agent.js.map +1 -0
- package/dist/agentfn.d.ts +16 -0
- package/dist/agentfn.d.ts.map +1 -0
- package/dist/agentfn.js +470 -0
- package/dist/agentfn.js.map +1 -0
- package/dist/compose.d.ts +23 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/compose.js +217 -0
- package/dist/compose.js.map +1 -0
- package/dist/feedback.d.ts +78 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +160 -0
- package/dist/feedback.js.map +1 -0
- package/dist/find-converge-root.d.ts +6 -0
- package/dist/find-converge-root.d.ts.map +1 -0
- package/dist/find-converge-root.js +18 -0
- package/dist/find-converge-root.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/prompting.d.ts +32 -0
- package/dist/prompting.d.ts.map +1 -0
- package/dist/prompting.js +103 -0
- package/dist/prompting.js.map +1 -0
- package/dist/provider.d.ts +6 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +10 -0
- package/dist/provider.js.map +1 -0
- package/dist/skills.d.ts +132 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +354 -0
- package/dist/skills.js.map +1 -0
- package/dist/types.d.ts +275 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Converge Framework Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Provider } from "./types.js";
|
|
2
|
+
/** Options for agent() */
|
|
3
|
+
export interface UnifiedAgentOptions<T = string> {
|
|
4
|
+
/** Which provider to use. Only "claude" is supported for agent(). */
|
|
5
|
+
provider?: Provider;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
/** Type alias for the callable agent function */
|
|
9
|
+
export type AgentFn<T = string> = (input?: string) => Promise<{
|
|
10
|
+
data: T;
|
|
11
|
+
raw: string;
|
|
12
|
+
durationMs: number;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated The Claude Agent SDK backend has been removed.
|
|
16
|
+
* Use agentfn() with the CLI backend instead.
|
|
17
|
+
*/
|
|
18
|
+
export declare function agent<T = string>(_options: UnifiedAgentOptions<T>): AgentFn<T>;
|
|
19
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,0BAA0B;AAC1B,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,MAAM;IAC7C,qEAAqE;IACrE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,iDAAiD;AACjD,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,MAAM,IAAI,CAChC,KAAK,CAAC,EAAE,MAAM,KACX,OAAO,CAAC;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,GAAG,MAAM,EAC9B,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAKZ"}
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated The Claude Agent SDK backend has been removed.
|
|
3
|
+
* Use agentfn() with the CLI backend instead.
|
|
4
|
+
*/
|
|
5
|
+
export function agent(_options) {
|
|
6
|
+
throw new Error("agentfn: agent() is not available — the Claude Agent SDK backend has been removed. " +
|
|
7
|
+
"Use agentfn() instead.");
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,UAAU,KAAK,CACnB,QAAgC;IAEhC,MAAM,IAAI,KAAK,CACb,qFAAqF;QACnF,wBAAwB,CAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentFnOptions, AgentFn } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a callable function backed by either Claude or Kimi.
|
|
4
|
+
*
|
|
5
|
+
* Delegates to `claudefn()` or `kimifn()` based on the `provider` option
|
|
6
|
+
* (or the global default). Returns a unified result that includes a
|
|
7
|
+
* `provider` field indicating which backend produced it.
|
|
8
|
+
*
|
|
9
|
+
* Skills handling:
|
|
10
|
+
* - New API: pass `skillsRoot` (+ optional `skills` filter) for explicit control.
|
|
11
|
+
* agentfn creates symlinks for Claude and cleans up after. No prompt injection.
|
|
12
|
+
* - Legacy: `enableSkills: true` (default) auto-detects .converge/ and injects
|
|
13
|
+
* prompt footnotes. Deprecated — will be removed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function agentfn<T = string>(options?: AgentFnOptions<T>): AgentFn<T>;
|
|
16
|
+
//# sourceMappingURL=agentfn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentfn.d.ts","sourceRoot":"","sources":["../src/agentfn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EAEd,OAAO,EAER,MAAM,YAAY,CAAC;AA0BpB;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAiU3E"}
|
package/dist/agentfn.js
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { acpfn } from "@openplaybooks/acpfn";
|
|
2
|
+
import { claudefn } from "@openplaybooks/claudefn";
|
|
3
|
+
import { getDefaultProvider } from "./provider.js";
|
|
4
|
+
async function loadProvider(pkg) {
|
|
5
|
+
try {
|
|
6
|
+
return await import(pkg);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
throw new Error(`Provider "${pkg}" is not installed. Install it with: pnpm add ${pkg}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
import { enhancePrompt } from "./prompting.js";
|
|
13
|
+
import { ensureSkillSymlinks, cleanupSkillSymlinks } from "./skills.js";
|
|
14
|
+
import { findConvergeRoot } from "./find-converge-root.js";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { existsSync } from "node:fs";
|
|
17
|
+
/**
|
|
18
|
+
* Create a callable function backed by either Claude or Kimi.
|
|
19
|
+
*
|
|
20
|
+
* Delegates to `claudefn()` or `kimifn()` based on the `provider` option
|
|
21
|
+
* (or the global default). Returns a unified result that includes a
|
|
22
|
+
* `provider` field indicating which backend produced it.
|
|
23
|
+
*
|
|
24
|
+
* Skills handling:
|
|
25
|
+
* - New API: pass `skillsRoot` (+ optional `skills` filter) for explicit control.
|
|
26
|
+
* agentfn creates symlinks for Claude and cleans up after. No prompt injection.
|
|
27
|
+
* - Legacy: `enableSkills: true` (default) auto-detects .converge/ and injects
|
|
28
|
+
* prompt footnotes. Deprecated — will be removed.
|
|
29
|
+
*/
|
|
30
|
+
export function agentfn(options) {
|
|
31
|
+
const opts = options ?? {};
|
|
32
|
+
const provider = opts.provider ?? getDefaultProvider();
|
|
33
|
+
// Determine skill handling mode:
|
|
34
|
+
// - New: skillsRoot is set → explicit symlink management, no prompt injection
|
|
35
|
+
// - Legacy: enableSkills (default true) → auto-detect + prompt enhancement
|
|
36
|
+
const useNewSkills = !!opts.skillsRoot;
|
|
37
|
+
const useLegacySkills = !useNewSkills && (opts.enableSkills ?? true);
|
|
38
|
+
// ── Stream mode validation ──────────────────────────
|
|
39
|
+
if (opts.mode === "stream" && provider !== "claude") {
|
|
40
|
+
throw new Error(`Stream mode is not supported with ${provider} provider. Use Claude instead.`);
|
|
41
|
+
}
|
|
42
|
+
// ── Stub provider ──────────────────────────────────
|
|
43
|
+
//
|
|
44
|
+
// Deterministic, no-LLM provider for testing the framework's
|
|
45
|
+
// orchestration code paths (do-while loops, wave counter, converge:
|
|
46
|
+
// verdict handling, multi-iteration runs) without burning external
|
|
47
|
+
// API quota.
|
|
48
|
+
//
|
|
49
|
+
// The response is read from env vars in this precedence order:
|
|
50
|
+
// 1. CONVERGE_STUB_RESPONSE_<TASK_ID> — per-task override (highest)
|
|
51
|
+
// 2. CONVERGE_STUB_RESPONSE — global default for the run
|
|
52
|
+
// 3. '' — empty string (falls through to schema default)
|
|
53
|
+
//
|
|
54
|
+
// The response should be JSON when a schema is provided (typical for
|
|
55
|
+
// converge: prompts which expect `{"action":"continue"|"done"}`).
|
|
56
|
+
// Plain string responses pass through when no schema is provided.
|
|
57
|
+
if (provider === "stub") {
|
|
58
|
+
return async (_input) => {
|
|
59
|
+
const start = Date.now();
|
|
60
|
+
// Task-scoped override via current task id, if exposed by execute-task.
|
|
61
|
+
const taskId = process.env.CONVERGE_STUB_TASK_ID || "";
|
|
62
|
+
const perTaskKey = taskId
|
|
63
|
+
? `CONVERGE_STUB_RESPONSE_${taskId.replace(/[^A-Z0-9_]/gi, "_").toUpperCase()}`
|
|
64
|
+
: "";
|
|
65
|
+
const raw = (perTaskKey ? process.env[perTaskKey] : "") ||
|
|
66
|
+
process.env.CONVERGE_STUB_RESPONSE ||
|
|
67
|
+
"";
|
|
68
|
+
let data;
|
|
69
|
+
const schema = opts.schema;
|
|
70
|
+
if (schema && raw) {
|
|
71
|
+
try {
|
|
72
|
+
const parsed = JSON.parse(raw);
|
|
73
|
+
// If a Zod-ish schema is supplied, validate; otherwise pass through.
|
|
74
|
+
if (typeof schema.parse === "function") {
|
|
75
|
+
data = schema.parse(parsed);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
data = parsed;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// If parsing/validation fails, fall back to the raw string cast
|
|
83
|
+
// so callers can inspect what came in.
|
|
84
|
+
data = raw;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
data = raw;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
data,
|
|
92
|
+
raw,
|
|
93
|
+
durationMs: Date.now() - start,
|
|
94
|
+
provider: "stub",
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// ── Call mode ──────────────────────────────────────
|
|
99
|
+
if (provider === "kimi") {
|
|
100
|
+
let fn;
|
|
101
|
+
return async (input) => {
|
|
102
|
+
if (!fn) {
|
|
103
|
+
const mod = await loadProvider("@openplaybooks/kimifn");
|
|
104
|
+
fn = mod.kimifn(toKimiOptions(opts));
|
|
105
|
+
}
|
|
106
|
+
let enhancedInput = input;
|
|
107
|
+
if (useLegacySkills && input) {
|
|
108
|
+
enhancedInput = enhancePrompt(input, { cwd: opts.cwd });
|
|
109
|
+
}
|
|
110
|
+
const result = await fn(enhancedInput);
|
|
111
|
+
return { ...result, provider: "kimi" };
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (provider === "qwen") {
|
|
115
|
+
let fn;
|
|
116
|
+
return async (input) => {
|
|
117
|
+
if (!fn) {
|
|
118
|
+
const mod = await loadProvider("@openplaybooks/qwenfn");
|
|
119
|
+
fn = mod.qwenfn(toQwenOptions(opts));
|
|
120
|
+
}
|
|
121
|
+
let enhancedInput = input;
|
|
122
|
+
if (useLegacySkills && input) {
|
|
123
|
+
enhancedInput = enhancePrompt(input, { cwd: opts.cwd });
|
|
124
|
+
}
|
|
125
|
+
const result = await fn(enhancedInput);
|
|
126
|
+
return { ...result, provider: "qwen" };
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (provider === "gemini") {
|
|
130
|
+
let fn;
|
|
131
|
+
return async (input) => {
|
|
132
|
+
if (!fn) {
|
|
133
|
+
const mod = await loadProvider("@openplaybooks/geminifn");
|
|
134
|
+
fn = mod.geminifn(toGeminiOptions(opts));
|
|
135
|
+
}
|
|
136
|
+
let enhancedInput = input;
|
|
137
|
+
if (useLegacySkills && input) {
|
|
138
|
+
enhancedInput = enhancePrompt(input, { cwd: opts.cwd });
|
|
139
|
+
}
|
|
140
|
+
const result = await fn(enhancedInput);
|
|
141
|
+
return { ...result, provider: "gemini" };
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// ── ACP (Agent SDK) provider ────────────────────────
|
|
145
|
+
if (provider === "acp") {
|
|
146
|
+
const fn = acpfn(toAcpOptions(opts));
|
|
147
|
+
return async (input) => {
|
|
148
|
+
let enhancedInput = input;
|
|
149
|
+
if (useLegacySkills && input) {
|
|
150
|
+
enhancedInput = enhancePrompt(input, { cwd: opts.cwd });
|
|
151
|
+
}
|
|
152
|
+
const result = await fn(enhancedInput);
|
|
153
|
+
return { ...result, provider: "acp" };
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// ── Openfn provider ────────────────────────────────
|
|
157
|
+
if (provider === "openfn") {
|
|
158
|
+
let fn;
|
|
159
|
+
return async (input) => {
|
|
160
|
+
let enhancedInput = input;
|
|
161
|
+
if (useLegacySkills && input) {
|
|
162
|
+
enhancedInput = enhancePrompt(input, { cwd: opts.cwd });
|
|
163
|
+
}
|
|
164
|
+
const baseDir = opts.cwd || process.cwd();
|
|
165
|
+
const projectRoot = findConvergeRoot(baseDir) ?? baseDir;
|
|
166
|
+
const symlinkTargets = [
|
|
167
|
+
join(projectRoot, ".opencode", "skills"),
|
|
168
|
+
join(projectRoot, ".claude", "skills"),
|
|
169
|
+
];
|
|
170
|
+
const createdByTarget = [];
|
|
171
|
+
const linkSkillRoots = (sourceRoot) => {
|
|
172
|
+
if (!sourceRoot || !existsSync(sourceRoot))
|
|
173
|
+
return;
|
|
174
|
+
for (const target of symlinkTargets) {
|
|
175
|
+
const names = ensureSkillSymlinks(sourceRoot, {
|
|
176
|
+
skills: opts.skills,
|
|
177
|
+
targetRoot: target,
|
|
178
|
+
});
|
|
179
|
+
if (names.length > 0)
|
|
180
|
+
createdByTarget.push({ target, names });
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
if (opts.skillDirs && Object.keys(opts.skillDirs).length > 0) {
|
|
184
|
+
const { mkdirSync, symlinkSync, lstatSync } = await import("node:fs");
|
|
185
|
+
for (const [name, absDir] of Object.entries(opts.skillDirs)) {
|
|
186
|
+
for (const targetRoot of symlinkTargets) {
|
|
187
|
+
mkdirSync(targetRoot, { recursive: true });
|
|
188
|
+
const linkPath = join(targetRoot, name);
|
|
189
|
+
try {
|
|
190
|
+
lstatSync(linkPath);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
/* doesn't exist */
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
symlinkSync(absDir, linkPath, "junction");
|
|
198
|
+
const existing = createdByTarget.find((entry) => entry.target === targetRoot);
|
|
199
|
+
if (existing)
|
|
200
|
+
existing.names.push(name);
|
|
201
|
+
else
|
|
202
|
+
createdByTarget.push({ target: targetRoot, names: [name] });
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
console.warn(` ⚠️ Failed skill junction ${name}: ${err.message}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (useNewSkills && opts.skillsRoot) {
|
|
211
|
+
linkSkillRoots(opts.skillsRoot);
|
|
212
|
+
}
|
|
213
|
+
else if (useLegacySkills && projectRoot) {
|
|
214
|
+
linkSkillRoots(join(projectRoot, ".converge", "skills"));
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
if (!fn) {
|
|
218
|
+
const mod = await loadProvider("@openplaybooks/openfn");
|
|
219
|
+
fn = mod.openfn(toOpenfnOptions(opts));
|
|
220
|
+
}
|
|
221
|
+
const result = await fn(enhancedInput);
|
|
222
|
+
return { ...result, provider: "openfn" };
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
for (const { target, names } of createdByTarget) {
|
|
226
|
+
cleanupSkillSymlinks(names, target);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
// ── Codex provider ────────────────────────────────
|
|
232
|
+
if (provider === "codex") {
|
|
233
|
+
let fn;
|
|
234
|
+
return async (input) => {
|
|
235
|
+
if (!fn) {
|
|
236
|
+
const mod = await loadProvider("@openplaybooks/codexfn");
|
|
237
|
+
fn = mod.codexfn(toCodexOptions(opts));
|
|
238
|
+
}
|
|
239
|
+
let enhancedInput = input;
|
|
240
|
+
if (useLegacySkills && input) {
|
|
241
|
+
enhancedInput = enhancePrompt(input, { cwd: opts.cwd });
|
|
242
|
+
}
|
|
243
|
+
const result = await fn(enhancedInput);
|
|
244
|
+
return { ...result, provider: "codex" };
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
// ── DeepCode provider ────────────────────────────────
|
|
248
|
+
if (provider === "deepcode") {
|
|
249
|
+
let fn;
|
|
250
|
+
return async (input) => {
|
|
251
|
+
if (!fn) {
|
|
252
|
+
const mod = await loadProvider("@openplaybooks/deepcodefn");
|
|
253
|
+
fn = mod.deepcodefn(toDeepCodeOptions(opts));
|
|
254
|
+
}
|
|
255
|
+
let enhancedInput = input;
|
|
256
|
+
if (useLegacySkills && input) {
|
|
257
|
+
enhancedInput = enhancePrompt(input, { cwd: opts.cwd });
|
|
258
|
+
}
|
|
259
|
+
const result = await fn(enhancedInput);
|
|
260
|
+
return { ...result, provider: "deepcode" };
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
// ── Claude provider ────────────────────────────────
|
|
264
|
+
let fn;
|
|
265
|
+
return async (input) => {
|
|
266
|
+
if (!fn) {
|
|
267
|
+
fn = claudefn(toClaudeOptions(opts));
|
|
268
|
+
}
|
|
269
|
+
// Legacy prompt enhancement (deprecated path)
|
|
270
|
+
let enhancedInput = input;
|
|
271
|
+
if (useLegacySkills && input) {
|
|
272
|
+
enhancedInput = enhancePrompt(input, { cwd: opts.cwd });
|
|
273
|
+
}
|
|
274
|
+
// Symlink management — new explicit path or legacy auto-detect
|
|
275
|
+
let createdSymlinks = [];
|
|
276
|
+
let symlinkTarget;
|
|
277
|
+
// Skill junctions land at <projectRoot>/.claude/skills/, where projectRoot is
|
|
278
|
+
// the nearest ancestor (or self) containing .converge/.
|
|
279
|
+
const baseDir = opts.cwd || process.cwd();
|
|
280
|
+
const projectRoot = findConvergeRoot(baseDir);
|
|
281
|
+
symlinkTarget = join(projectRoot ?? baseDir, ".claude", "skills");
|
|
282
|
+
if (opts.skillDirs && Object.keys(opts.skillDirs).length > 0) {
|
|
283
|
+
// Direct mapping: skill name → absolute path. Creates absolute symlinks.
|
|
284
|
+
const { mkdirSync, symlinkSync, lstatSync } = await import("node:fs");
|
|
285
|
+
console.log(` 🔗 Creating skill junctions in: ${symlinkTarget}`);
|
|
286
|
+
mkdirSync(symlinkTarget, { recursive: true });
|
|
287
|
+
for (const [name, absDir] of Object.entries(opts.skillDirs)) {
|
|
288
|
+
const linkPath = join(symlinkTarget, name);
|
|
289
|
+
try {
|
|
290
|
+
lstatSync(linkPath);
|
|
291
|
+
console.log(` ⏭ ${name}: already exists`);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
/* doesn't exist */
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
symlinkSync(absDir, linkPath, "junction");
|
|
299
|
+
createdSymlinks.push(name);
|
|
300
|
+
console.log(` ✅ ${name} → ${absDir}`);
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
console.warn(` ⚠️ Failed junction ${name}: ${err.message}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (useNewSkills && opts.skillsRoot) {
|
|
308
|
+
// Explicit skillsRoot → scan dir, create symlinks in .claude/skills/
|
|
309
|
+
const fromRoot = ensureSkillSymlinks(opts.skillsRoot, {
|
|
310
|
+
skills: opts.skills,
|
|
311
|
+
targetRoot: symlinkTarget,
|
|
312
|
+
});
|
|
313
|
+
createdSymlinks.push(...fromRoot);
|
|
314
|
+
}
|
|
315
|
+
else if (useLegacySkills && projectRoot) {
|
|
316
|
+
// Legacy: auto-detect from <projectRoot>/.converge/skills/.
|
|
317
|
+
// symlinkTarget was already set above; reuse it.
|
|
318
|
+
const convergeSkillsDir = join(projectRoot, ".converge", "skills");
|
|
319
|
+
createdSymlinks = ensureSkillSymlinks(convergeSkillsDir, {
|
|
320
|
+
targetRoot: symlinkTarget,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
try {
|
|
324
|
+
const result = await fn(enhancedInput);
|
|
325
|
+
return { ...result, provider: "claude" };
|
|
326
|
+
}
|
|
327
|
+
finally {
|
|
328
|
+
if (createdSymlinks.length > 0 && symlinkTarget) {
|
|
329
|
+
cleanupSkillSymlinks(createdSymlinks, symlinkTarget);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
// ─── Options Mapping ─────────────────────────────────────────
|
|
335
|
+
function toClaudeOptions(opts) {
|
|
336
|
+
return {
|
|
337
|
+
prompt: opts.prompt,
|
|
338
|
+
mode: opts.mode,
|
|
339
|
+
schema: opts.schema,
|
|
340
|
+
hooks: opts.hooks,
|
|
341
|
+
timeoutMs: opts.timeoutMs,
|
|
342
|
+
maxRetries: opts.maxRetries,
|
|
343
|
+
cwd: opts.cwd,
|
|
344
|
+
queue: opts.queue,
|
|
345
|
+
cliFlags: opts.cliFlags,
|
|
346
|
+
allowedTools: opts.allowedTools,
|
|
347
|
+
systemPrompt: opts.systemPrompt,
|
|
348
|
+
systemPromptFile: opts.systemPromptFile,
|
|
349
|
+
signal: opts.signal,
|
|
350
|
+
logDir: opts.logDir,
|
|
351
|
+
env: opts.env,
|
|
352
|
+
// Deprecated SDK-only options — passed through for backward compat
|
|
353
|
+
...(opts.backend && { backend: opts.backend }),
|
|
354
|
+
...(opts.model && { model: opts.model }),
|
|
355
|
+
...(opts.permissionMode !== undefined && {
|
|
356
|
+
permissionMode: opts.permissionMode,
|
|
357
|
+
}),
|
|
358
|
+
...(opts.maxTurns && { maxTurns: opts.maxTurns }),
|
|
359
|
+
...(opts.disallowedTools && { disallowedTools: opts.disallowedTools }),
|
|
360
|
+
...(opts.mcpServers && { mcpServers: opts.mcpServers }),
|
|
361
|
+
...(opts.agents && { agents: opts.agents }),
|
|
362
|
+
...(opts.resume && { resume: opts.resume }),
|
|
363
|
+
...(opts.effort && { effort: opts.effort }),
|
|
364
|
+
...(opts.maxBudgetUsd && { maxBudgetUsd: opts.maxBudgetUsd }),
|
|
365
|
+
...(opts.maxFeedbackTurns && { maxFeedbackTurns: opts.maxFeedbackTurns }),
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function toKimiOptions(opts) {
|
|
369
|
+
return {
|
|
370
|
+
prompt: opts.prompt,
|
|
371
|
+
schema: opts.schema,
|
|
372
|
+
hooks: opts.hooks,
|
|
373
|
+
timeoutMs: opts.timeoutMs,
|
|
374
|
+
maxRetries: opts.maxRetries,
|
|
375
|
+
cwd: opts.cwd,
|
|
376
|
+
queue: opts.queue,
|
|
377
|
+
cliFlags: opts.cliFlags,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function toQwenOptions(opts) {
|
|
381
|
+
return {
|
|
382
|
+
prompt: opts.prompt,
|
|
383
|
+
schema: opts.schema,
|
|
384
|
+
hooks: opts.hooks,
|
|
385
|
+
timeoutMs: opts.timeoutMs,
|
|
386
|
+
maxRetries: opts.maxRetries,
|
|
387
|
+
cwd: opts.cwd,
|
|
388
|
+
queue: opts.queue,
|
|
389
|
+
cliFlags: opts.cliFlags,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function toGeminiOptions(opts) {
|
|
393
|
+
return {
|
|
394
|
+
prompt: opts.prompt,
|
|
395
|
+
schema: opts.schema,
|
|
396
|
+
hooks: opts.hooks,
|
|
397
|
+
timeoutMs: opts.timeoutMs,
|
|
398
|
+
maxRetries: opts.maxRetries,
|
|
399
|
+
cwd: opts.cwd,
|
|
400
|
+
queue: opts.queue,
|
|
401
|
+
cliFlags: opts.cliFlags,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function toAcpOptions(opts) {
|
|
405
|
+
return {
|
|
406
|
+
prompt: opts.prompt,
|
|
407
|
+
schema: opts.schema,
|
|
408
|
+
hooks: opts.hooks,
|
|
409
|
+
timeoutMs: opts.timeoutMs,
|
|
410
|
+
maxRetries: opts.maxRetries,
|
|
411
|
+
cwd: opts.cwd,
|
|
412
|
+
queue: opts.queue,
|
|
413
|
+
allowedTools: opts.allowedTools,
|
|
414
|
+
systemPrompt: opts.systemPrompt,
|
|
415
|
+
systemPromptFile: opts.systemPromptFile,
|
|
416
|
+
signal: opts.signal,
|
|
417
|
+
logDir: opts.logDir,
|
|
418
|
+
model: opts.model,
|
|
419
|
+
maxTurns: opts.maxTurns,
|
|
420
|
+
mcpServers: opts.mcpServers,
|
|
421
|
+
apiKey: opts.apiKey,
|
|
422
|
+
baseUrl: opts.baseUrl,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function toOpenfnOptions(opts) {
|
|
426
|
+
return {
|
|
427
|
+
prompt: opts.prompt,
|
|
428
|
+
schema: opts.schema,
|
|
429
|
+
hooks: opts.hooks,
|
|
430
|
+
timeoutMs: opts.timeoutMs,
|
|
431
|
+
maxRetries: opts.maxRetries,
|
|
432
|
+
cwd: opts.cwd,
|
|
433
|
+
queue: opts.queue,
|
|
434
|
+
signal: opts.signal,
|
|
435
|
+
logDir: opts.logDir,
|
|
436
|
+
model: opts.model,
|
|
437
|
+
baseUrl: opts.baseUrl,
|
|
438
|
+
apiKey: opts.apiKey,
|
|
439
|
+
providers: opts.providers,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function toCodexOptions(opts) {
|
|
443
|
+
return {
|
|
444
|
+
prompt: opts.prompt,
|
|
445
|
+
schema: opts.schema,
|
|
446
|
+
hooks: opts.hooks,
|
|
447
|
+
timeoutMs: opts.timeoutMs,
|
|
448
|
+
maxRetries: opts.maxRetries,
|
|
449
|
+
cwd: opts.cwd,
|
|
450
|
+
queue: opts.queue,
|
|
451
|
+
cliFlags: opts.cliFlags,
|
|
452
|
+
model: opts.model,
|
|
453
|
+
env: opts.env,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function toDeepCodeOptions(opts) {
|
|
457
|
+
return {
|
|
458
|
+
prompt: opts.prompt,
|
|
459
|
+
schema: opts.schema,
|
|
460
|
+
hooks: opts.hooks,
|
|
461
|
+
timeoutMs: opts.timeoutMs,
|
|
462
|
+
maxRetries: opts.maxRetries,
|
|
463
|
+
cwd: opts.cwd,
|
|
464
|
+
queue: opts.queue,
|
|
465
|
+
cliFlags: opts.cliFlags,
|
|
466
|
+
model: opts.model,
|
|
467
|
+
env: opts.env,
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
//# sourceMappingURL=agentfn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentfn.js","sourceRoot":"","sources":["../src/agentfn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAenD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,KAAK,UAAU,YAAY,CAAI,GAAW;IACxC,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,aAAa,GAAG,iDAAiD,GAAG,EAAE,CACvE,CAAC;IACJ,CAAC;AACH,CAAC;AACD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,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AK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAmC;QAC/C,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAI,IAAuB;IACnD,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAsC;QAClD,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ComposeOptions, AgentFnResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a composed function that orchestrates tools via Claude or Kimi.
|
|
4
|
+
*
|
|
5
|
+
* Tools created with `agentfn()` can be passed directly. The composition
|
|
6
|
+
* delegates to the underlying provider's compose implementation.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const translate = agentfn({ prompt: "Translate {{input}} to French" });
|
|
11
|
+
* const summarize = agentfn({ prompt: "Summarize {{input}}", provider: "kimi" });
|
|
12
|
+
*
|
|
13
|
+
* const fn = compose({
|
|
14
|
+
* prompt: "Translate then summarize {{input}}",
|
|
15
|
+
* tools: {
|
|
16
|
+
* translate: { fn: translate, description: "Translate text" },
|
|
17
|
+
* summarize: { fn: summarize, description: "Summarize text" },
|
|
18
|
+
* },
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function compose<T = string>(options: ComposeOptions<T>): (input?: string) => Promise<AgentFnResult<T>>;
|
|
23
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAY,MAAM,YAAY,CAAC;AAsB1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,CAAC,GAAG,MAAM,EAChC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CA0G/C"}
|