@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/dist/compose.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { getDefaultProvider } from "./provider.js";
|
|
2
|
+
async function loadProvider(pkg) {
|
|
3
|
+
try {
|
|
4
|
+
return await import(pkg);
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
throw new Error(`Provider "${pkg}" is not installed. Install it with: pnpm add ${pkg}`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
import { enhancePrompt } from "./prompting.js";
|
|
11
|
+
import { ensureSkillSymlinks, cleanupSkillSymlinks } from "./skills.js";
|
|
12
|
+
import { findConvergeRoot } from "./find-converge-root.js";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
/**
|
|
15
|
+
* Create a composed function that orchestrates tools via Claude or Kimi.
|
|
16
|
+
*
|
|
17
|
+
* Tools created with `agentfn()` can be passed directly. The composition
|
|
18
|
+
* delegates to the underlying provider's compose implementation.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const translate = agentfn({ prompt: "Translate {{input}} to French" });
|
|
23
|
+
* const summarize = agentfn({ prompt: "Summarize {{input}}", provider: "kimi" });
|
|
24
|
+
*
|
|
25
|
+
* const fn = compose({
|
|
26
|
+
* prompt: "Translate then summarize {{input}}",
|
|
27
|
+
* tools: {
|
|
28
|
+
* translate: { fn: translate, description: "Translate text" },
|
|
29
|
+
* summarize: { fn: summarize, description: "Summarize text" },
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function compose(options) {
|
|
35
|
+
const provider = options.provider ?? getDefaultProvider();
|
|
36
|
+
const useNewSkills = !!options.skillsRoot;
|
|
37
|
+
const useLegacySkills = !useNewSkills && (options.enableSkills ?? true);
|
|
38
|
+
if (provider === "kimi") {
|
|
39
|
+
let fn;
|
|
40
|
+
return async (input) => {
|
|
41
|
+
if (!fn) {
|
|
42
|
+
const mod = await loadProvider("@openplaybooks/kimifn");
|
|
43
|
+
fn = mod.compose(toKimiComposeOptions(options));
|
|
44
|
+
}
|
|
45
|
+
let enhancedInput = input;
|
|
46
|
+
if (useLegacySkills && input) {
|
|
47
|
+
enhancedInput = enhancePrompt(input, { cwd: options.cwd });
|
|
48
|
+
}
|
|
49
|
+
const result = await fn(enhancedInput);
|
|
50
|
+
return { ...result, provider: "kimi" };
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (provider === "qwen") {
|
|
54
|
+
let fn;
|
|
55
|
+
return async (input) => {
|
|
56
|
+
if (!fn) {
|
|
57
|
+
const mod = await loadProvider("@openplaybooks/qwenfn");
|
|
58
|
+
fn = mod.compose(toQwenComposeOptions(options));
|
|
59
|
+
}
|
|
60
|
+
let enhancedInput = input;
|
|
61
|
+
if (useLegacySkills && input) {
|
|
62
|
+
enhancedInput = enhancePrompt(input, { cwd: options.cwd });
|
|
63
|
+
}
|
|
64
|
+
const result = await fn(enhancedInput);
|
|
65
|
+
return { ...result, provider: "qwen" };
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (provider === "gemini") {
|
|
69
|
+
let fn;
|
|
70
|
+
return async (input) => {
|
|
71
|
+
if (!fn) {
|
|
72
|
+
const mod = await loadProvider("@openplaybooks/geminifn");
|
|
73
|
+
fn = mod.compose(toGeminiComposeOptions(options));
|
|
74
|
+
}
|
|
75
|
+
let enhancedInput = input;
|
|
76
|
+
if (useLegacySkills && input) {
|
|
77
|
+
enhancedInput = enhancePrompt(input, { cwd: options.cwd });
|
|
78
|
+
}
|
|
79
|
+
const result = await fn(enhancedInput);
|
|
80
|
+
return { ...result, provider: "gemini" };
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Codex provider
|
|
84
|
+
if (provider === "codex") {
|
|
85
|
+
let fn;
|
|
86
|
+
return async (input) => {
|
|
87
|
+
if (!fn) {
|
|
88
|
+
const mod = await loadProvider("@openplaybooks/codexfn");
|
|
89
|
+
fn = mod.compose(toCodexComposeOptions(options));
|
|
90
|
+
}
|
|
91
|
+
let enhancedInput = input;
|
|
92
|
+
if (useLegacySkills && input) {
|
|
93
|
+
enhancedInput = enhancePrompt(input, { cwd: options.cwd });
|
|
94
|
+
}
|
|
95
|
+
const result = await fn(enhancedInput);
|
|
96
|
+
return { ...result, provider: "codex" };
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// Claude provider — supports symlinks
|
|
100
|
+
let fn;
|
|
101
|
+
return async (input) => {
|
|
102
|
+
if (!fn) {
|
|
103
|
+
const mod = await loadProvider("@openplaybooks/claudefn");
|
|
104
|
+
fn = mod.compose(toClaudeComposeOptions(options));
|
|
105
|
+
}
|
|
106
|
+
let enhancedInput = input;
|
|
107
|
+
if (useLegacySkills && input) {
|
|
108
|
+
enhancedInput = enhancePrompt(input, { cwd: options.cwd });
|
|
109
|
+
}
|
|
110
|
+
// Symlink management for new API
|
|
111
|
+
let createdSymlinks = [];
|
|
112
|
+
let symlinkTarget;
|
|
113
|
+
if (useNewSkills && options.skillsRoot) {
|
|
114
|
+
const baseDir = options.cwd || process.cwd();
|
|
115
|
+
const projectRoot = findConvergeRoot(baseDir);
|
|
116
|
+
symlinkTarget = join(projectRoot ?? baseDir, ".claude", "skills");
|
|
117
|
+
createdSymlinks = ensureSkillSymlinks(options.skillsRoot, {
|
|
118
|
+
skills: options.skills,
|
|
119
|
+
targetRoot: symlinkTarget,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const result = await fn(enhancedInput);
|
|
124
|
+
return { ...result, provider: "claude" };
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
if (createdSymlinks.length > 0 && symlinkTarget) {
|
|
128
|
+
cleanupSkillSymlinks(createdSymlinks, symlinkTarget);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// ─── Options Mapping ─────────────────────────────────────────
|
|
134
|
+
function toClaudeComposeOptions(opts) {
|
|
135
|
+
return {
|
|
136
|
+
prompt: opts.prompt,
|
|
137
|
+
tools: opts.tools,
|
|
138
|
+
composeMode: opts.composeMode,
|
|
139
|
+
schema: opts.schema,
|
|
140
|
+
hooks: opts.hooks,
|
|
141
|
+
timeoutMs: opts.timeoutMs,
|
|
142
|
+
maxRetries: opts.maxRetries,
|
|
143
|
+
maxIterations: opts.maxIterations,
|
|
144
|
+
cwd: opts.cwd,
|
|
145
|
+
queue: opts.queue,
|
|
146
|
+
cliFlags: opts.cliFlags,
|
|
147
|
+
allowedTools: opts.allowedTools,
|
|
148
|
+
systemPrompt: opts.systemPrompt,
|
|
149
|
+
// Deprecated SDK-only options — passed through for backward compat
|
|
150
|
+
...(opts.backend && { backend: opts.backend }),
|
|
151
|
+
...(opts.model && { model: opts.model }),
|
|
152
|
+
...(opts.permissionMode !== undefined && {
|
|
153
|
+
permissionMode: opts.permissionMode,
|
|
154
|
+
}),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function toKimiComposeOptions(opts) {
|
|
158
|
+
return {
|
|
159
|
+
prompt: opts.prompt,
|
|
160
|
+
tools: opts.tools,
|
|
161
|
+
composeMode: opts.composeMode,
|
|
162
|
+
schema: opts.schema,
|
|
163
|
+
hooks: opts.hooks,
|
|
164
|
+
timeoutMs: opts.timeoutMs,
|
|
165
|
+
maxRetries: opts.maxRetries,
|
|
166
|
+
maxIterations: opts.maxIterations,
|
|
167
|
+
cwd: opts.cwd,
|
|
168
|
+
queue: opts.queue,
|
|
169
|
+
cliFlags: opts.cliFlags,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function toQwenComposeOptions(opts) {
|
|
173
|
+
return {
|
|
174
|
+
prompt: opts.prompt,
|
|
175
|
+
tools: opts.tools,
|
|
176
|
+
composeMode: opts.composeMode,
|
|
177
|
+
schema: opts.schema,
|
|
178
|
+
hooks: opts.hooks,
|
|
179
|
+
timeoutMs: opts.timeoutMs,
|
|
180
|
+
maxRetries: opts.maxRetries,
|
|
181
|
+
maxIterations: opts.maxIterations,
|
|
182
|
+
cwd: opts.cwd,
|
|
183
|
+
queue: opts.queue,
|
|
184
|
+
cliFlags: opts.cliFlags,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function toGeminiComposeOptions(opts) {
|
|
188
|
+
return {
|
|
189
|
+
prompt: opts.prompt,
|
|
190
|
+
tools: opts.tools,
|
|
191
|
+
composeMode: opts.composeMode,
|
|
192
|
+
schema: opts.schema,
|
|
193
|
+
hooks: opts.hooks,
|
|
194
|
+
timeoutMs: opts.timeoutMs,
|
|
195
|
+
maxRetries: opts.maxRetries,
|
|
196
|
+
maxIterations: opts.maxIterations,
|
|
197
|
+
cwd: opts.cwd,
|
|
198
|
+
queue: opts.queue,
|
|
199
|
+
cliFlags: opts.cliFlags,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function toCodexComposeOptions(opts) {
|
|
203
|
+
return {
|
|
204
|
+
prompt: opts.prompt,
|
|
205
|
+
tools: opts.tools,
|
|
206
|
+
composeMode: opts.composeMode,
|
|
207
|
+
schema: opts.schema,
|
|
208
|
+
hooks: opts.hooks,
|
|
209
|
+
timeoutMs: opts.timeoutMs,
|
|
210
|
+
maxRetries: opts.maxRetries,
|
|
211
|
+
maxIterations: opts.maxIterations,
|
|
212
|
+
cwd: opts.cwd,
|
|
213
|
+
queue: opts.queue,
|
|
214
|
+
cliFlags: opts.cliFlags,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAMA,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,E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AAC;AAED,SAAS,sBAAsB,CAC7B,IAAuB;IAEvB,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAoD;QAChE,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAyC;QACrD,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAyC;QACrD,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAC5B,IAAuB;IAEvB,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAmD;QAC/D,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAwC;QACpD,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAwC;QACpD,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Feedback — send follow-up messages to a completed agent session.
|
|
3
|
+
*
|
|
4
|
+
* Uses the session ID from an initial agentfn() call to resume the
|
|
5
|
+
* conversation and request structured output (status, summary, errors, etc.).
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentFnResult, Provider } from "./types.js";
|
|
8
|
+
export interface AgentFeedbackOptions {
|
|
9
|
+
/** Session ID from the original agentfn result */
|
|
10
|
+
sessionId: string;
|
|
11
|
+
/** Follow-up prompt to send */
|
|
12
|
+
prompt: string;
|
|
13
|
+
/** Which provider was used (only "claude" supports resume) */
|
|
14
|
+
provider?: Provider;
|
|
15
|
+
/** Working directory */
|
|
16
|
+
cwd?: string;
|
|
17
|
+
/** Max time in ms (default: 120_000) */
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
/** Extra CLI flags */
|
|
20
|
+
cliFlags?: string[];
|
|
21
|
+
/** Allowed tools for the follow-up */
|
|
22
|
+
allowedTools?: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Send a follow-up message to an existing agent session.
|
|
26
|
+
*
|
|
27
|
+
* This resumes the conversation so the agent has full context from the
|
|
28
|
+
* initial task execution. Useful for requesting structured completion
|
|
29
|
+
* reports after a oneshot task finishes.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const ask = agentfn({ prompt: "Build the component" });
|
|
34
|
+
* const result = await ask("Create a Button component");
|
|
35
|
+
*
|
|
36
|
+
* // Ask for a structured completion report
|
|
37
|
+
* const report = await agentSendFeedback({
|
|
38
|
+
* sessionId: result.sessionId!,
|
|
39
|
+
* prompt: TASK_COMPLETION_PROMPT,
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function agentSendFeedback(opts: AgentFeedbackOptions): Promise<AgentFnResult<string>>;
|
|
44
|
+
/**
|
|
45
|
+
* Standard follow-up prompt for task completion reports.
|
|
46
|
+
*
|
|
47
|
+
* Asks the agent to produce a structured XML report with:
|
|
48
|
+
* - Task status (completed | partial | failed)
|
|
49
|
+
* - Summary of what was done
|
|
50
|
+
* - Errors encountered
|
|
51
|
+
* - Follow-up action suggestions
|
|
52
|
+
*/
|
|
53
|
+
export declare const TASK_COMPLETION_PROMPT = "Now that you have finished the task, provide a structured completion report.\n\nRespond ONLY with the following XML \u2014 no other text before or after:\n\n<task-report>\n <status>completed | partial | failed</status>\n <summary>\n A concise summary of what you did (2-4 sentences).\n Include key files created or modified.\n </summary>\n <errors>\n List any errors encountered, or \"none\" if everything succeeded.\n Include error messages and which step they occurred in.\n </errors>\n <follow-up-actions>\n Suggest 1-3 concrete next steps the user should take.\n Each action should be specific and actionable.\n </follow-up-actions>\n</task-report>";
|
|
54
|
+
/**
|
|
55
|
+
* Parse the XML task-report into a structured object.
|
|
56
|
+
*/
|
|
57
|
+
export interface TaskCompletionReport {
|
|
58
|
+
status: "completed" | "partial" | "failed";
|
|
59
|
+
summary: string;
|
|
60
|
+
errors: string;
|
|
61
|
+
followUpActions: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse a task completion report from XML output.
|
|
65
|
+
* Falls back to raw text if XML parsing fails.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseTaskReport(raw: string): TaskCompletionReport;
|
|
68
|
+
/**
|
|
69
|
+
* Format a TaskCompletionReport as a markdown document.
|
|
70
|
+
*/
|
|
71
|
+
export declare function formatReportAsMarkdown(report: TaskCompletionReport, meta?: {
|
|
72
|
+
taskId?: string;
|
|
73
|
+
taskTitle?: string;
|
|
74
|
+
epicTitle?: string;
|
|
75
|
+
durationMs?: number;
|
|
76
|
+
timestamp?: string;
|
|
77
|
+
}): string;
|
|
78
|
+
//# sourceMappingURL=feedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../src/feedback.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAuChC;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,0qBAkBpB,CAAC;AAEhB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAmBjE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,oBAAoB,EAC5B,IAAI,CAAC,EAAE;IACL,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,MAAM,CAuDR"}
|
package/dist/feedback.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Feedback — send follow-up messages to a completed agent session.
|
|
3
|
+
*
|
|
4
|
+
* Uses the session ID from an initial agentfn() call to resume the
|
|
5
|
+
* conversation and request structured output (status, summary, errors, etc.).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Send a follow-up message to an existing agent session.
|
|
9
|
+
*
|
|
10
|
+
* This resumes the conversation so the agent has full context from the
|
|
11
|
+
* initial task execution. Useful for requesting structured completion
|
|
12
|
+
* reports after a oneshot task finishes.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const ask = agentfn({ prompt: "Build the component" });
|
|
17
|
+
* const result = await ask("Create a Button component");
|
|
18
|
+
*
|
|
19
|
+
* // Ask for a structured completion report
|
|
20
|
+
* const report = await agentSendFeedback({
|
|
21
|
+
* sessionId: result.sessionId!,
|
|
22
|
+
* prompt: TASK_COMPLETION_PROMPT,
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export async function agentSendFeedback(opts) {
|
|
27
|
+
const provider = opts.provider ?? "claude";
|
|
28
|
+
if (provider !== "claude") {
|
|
29
|
+
throw new Error(`agentSendFeedback: resume/feedback is only supported for the "claude" provider, got "${provider}"`);
|
|
30
|
+
}
|
|
31
|
+
if (!opts.sessionId) {
|
|
32
|
+
throw new Error("agentSendFeedback: sessionId is required");
|
|
33
|
+
}
|
|
34
|
+
let claudeSendFeedback;
|
|
35
|
+
try {
|
|
36
|
+
const mod = await import("@openplaybooks/claudefn");
|
|
37
|
+
claudeSendFeedback = mod.sendFeedback;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
throw new Error(`Provider "@openplaybooks/claudefn" is not installed. Install it with: pnpm add @openplaybooks/claudefn`);
|
|
41
|
+
}
|
|
42
|
+
const result = await claudeSendFeedback({
|
|
43
|
+
sessionId: opts.sessionId,
|
|
44
|
+
prompt: opts.prompt,
|
|
45
|
+
cwd: opts.cwd,
|
|
46
|
+
timeoutMs: opts.timeoutMs,
|
|
47
|
+
cliFlags: opts.cliFlags,
|
|
48
|
+
allowedTools: opts.allowedTools,
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
data: result.data,
|
|
52
|
+
raw: result.raw,
|
|
53
|
+
durationMs: result.durationMs,
|
|
54
|
+
provider: "claude",
|
|
55
|
+
sessionId: opts.sessionId,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/* ------------------------------------------------------------------ */
|
|
59
|
+
/* Standard Feedback Prompts */
|
|
60
|
+
/* ------------------------------------------------------------------ */
|
|
61
|
+
/**
|
|
62
|
+
* Standard follow-up prompt for task completion reports.
|
|
63
|
+
*
|
|
64
|
+
* Asks the agent to produce a structured XML report with:
|
|
65
|
+
* - Task status (completed | partial | failed)
|
|
66
|
+
* - Summary of what was done
|
|
67
|
+
* - Errors encountered
|
|
68
|
+
* - Follow-up action suggestions
|
|
69
|
+
*/
|
|
70
|
+
export const TASK_COMPLETION_PROMPT = `Now that you have finished the task, provide a structured completion report.
|
|
71
|
+
|
|
72
|
+
Respond ONLY with the following XML — no other text before or after:
|
|
73
|
+
|
|
74
|
+
<task-report>
|
|
75
|
+
<status>completed | partial | failed</status>
|
|
76
|
+
<summary>
|
|
77
|
+
A concise summary of what you did (2-4 sentences).
|
|
78
|
+
Include key files created or modified.
|
|
79
|
+
</summary>
|
|
80
|
+
<errors>
|
|
81
|
+
List any errors encountered, or "none" if everything succeeded.
|
|
82
|
+
Include error messages and which step they occurred in.
|
|
83
|
+
</errors>
|
|
84
|
+
<follow-up-actions>
|
|
85
|
+
Suggest 1-3 concrete next steps the user should take.
|
|
86
|
+
Each action should be specific and actionable.
|
|
87
|
+
</follow-up-actions>
|
|
88
|
+
</task-report>`;
|
|
89
|
+
/**
|
|
90
|
+
* Parse a task completion report from XML output.
|
|
91
|
+
* Falls back to raw text if XML parsing fails.
|
|
92
|
+
*/
|
|
93
|
+
export function parseTaskReport(raw) {
|
|
94
|
+
const extract = (tag) => {
|
|
95
|
+
const match = raw.match(new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`));
|
|
96
|
+
return match ? match[1].trim() : "";
|
|
97
|
+
};
|
|
98
|
+
const statusRaw = extract("status");
|
|
99
|
+
const status = (["completed", "partial", "failed"].includes(statusRaw)
|
|
100
|
+
? statusRaw
|
|
101
|
+
: "partial");
|
|
102
|
+
return {
|
|
103
|
+
status,
|
|
104
|
+
summary: extract("summary") || raw.slice(0, 500),
|
|
105
|
+
errors: extract("errors") || "none",
|
|
106
|
+
followUpActions: extract("follow-up-actions") || "none",
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Format a TaskCompletionReport as a markdown document.
|
|
111
|
+
*/
|
|
112
|
+
export function formatReportAsMarkdown(report, meta) {
|
|
113
|
+
const lines = [];
|
|
114
|
+
// Header
|
|
115
|
+
const title = meta?.taskTitle || "Task Completion Report";
|
|
116
|
+
lines.push(`# ${title}`);
|
|
117
|
+
lines.push("");
|
|
118
|
+
// Metadata
|
|
119
|
+
if (meta) {
|
|
120
|
+
lines.push("## Metadata");
|
|
121
|
+
lines.push("");
|
|
122
|
+
if (meta.taskId)
|
|
123
|
+
lines.push(`- **Task ID:** ${meta.taskId}`);
|
|
124
|
+
if (meta.epicTitle)
|
|
125
|
+
lines.push(`- **Epic:** ${meta.epicTitle}`);
|
|
126
|
+
if (meta.durationMs)
|
|
127
|
+
lines.push(`- **Duration:** ${(meta.durationMs / 1000).toFixed(1)}s`);
|
|
128
|
+
lines.push(`- **Timestamp:** ${meta.timestamp || new Date().toISOString()}`);
|
|
129
|
+
lines.push("");
|
|
130
|
+
}
|
|
131
|
+
// Status
|
|
132
|
+
const statusEmoji = report.status === "completed"
|
|
133
|
+
? "DONE"
|
|
134
|
+
: report.status === "partial"
|
|
135
|
+
? "PARTIAL"
|
|
136
|
+
: "FAILED";
|
|
137
|
+
lines.push(`## Status: ${statusEmoji}`);
|
|
138
|
+
lines.push("");
|
|
139
|
+
// Summary
|
|
140
|
+
lines.push("## Summary");
|
|
141
|
+
lines.push("");
|
|
142
|
+
lines.push(report.summary);
|
|
143
|
+
lines.push("");
|
|
144
|
+
// Errors
|
|
145
|
+
if (report.errors && report.errors !== "none") {
|
|
146
|
+
lines.push("## Errors");
|
|
147
|
+
lines.push("");
|
|
148
|
+
lines.push(report.errors);
|
|
149
|
+
lines.push("");
|
|
150
|
+
}
|
|
151
|
+
// Follow-up Actions
|
|
152
|
+
if (report.followUpActions && report.followUpActions !== "none") {
|
|
153
|
+
lines.push("## Follow-up Actions");
|
|
154
|
+
lines.push("");
|
|
155
|
+
lines.push(report.followUpActions);
|
|
156
|
+
lines.push("");
|
|
157
|
+
}
|
|
158
|
+
return lines.join("\n");
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.js","sourceRoot":"","sources":["../src/feedback.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAA0B;IAE1B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAE3C,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,wFAAwF,QAAQ,GAAG,CACpG,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,kBAAyE,CAAC;IAC9E,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;QACpD,kBAAkB,GAAG,GAAG,CAAC,YAAY,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC;QACtC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,SAAS,EAAE,IA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AAC,CAAC;IACxC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,UAAU;IACV,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,SAAS;IACT,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,oBAAoB;IACpB,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,KAAK,MAAM,EAAE,CAAC;QAChE,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-converge-root.d.ts","sourceRoot":"","sources":["../src/find-converge-root.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQhE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Project root = nearest ancestor (or self) containing `.converge/`.
|
|
5
|
+
* Returns null if no such ancestor exists.
|
|
6
|
+
*/
|
|
7
|
+
export function findConvergeRoot(startDir) {
|
|
8
|
+
let dir = resolve(startDir);
|
|
9
|
+
while (true) {
|
|
10
|
+
if (existsSync(join(dir, ".converge")))
|
|
11
|
+
return dir;
|
|
12
|
+
const parent = dirname(dir);
|
|
13
|
+
if (parent === dir)
|
|
14
|
+
return null;
|
|
15
|
+
dir = parent;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=find-converge-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-converge-root.js","sourceRoot":"","sources":["../src/find-converge-root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,IAAI,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YAAE,OAAO,GAAG,CAAC;QACnD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAChC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { agentfn } from "./agentfn.js";
|
|
2
|
+
export { agentSendFeedback, TASK_COMPLETION_PROMPT, parseTaskReport, formatReportAsMarkdown, } from "./feedback.js";
|
|
3
|
+
export type { AgentFeedbackOptions, TaskCompletionReport } from "./feedback.js";
|
|
4
|
+
export { compose } from "./compose.js";
|
|
5
|
+
export { agent } from "./agent.js";
|
|
6
|
+
export type { UnifiedAgentOptions, AgentFn as AgentAgentFn } from "./agent.js";
|
|
7
|
+
export { getDefaultProvider, setDefaultProvider } from "./provider.js";
|
|
8
|
+
export { enhancePrompt, listSkills, listAgents } from "./prompting.js";
|
|
9
|
+
export type { EnhancePromptOptions } from "./prompting.js";
|
|
10
|
+
export { discoverSkills, loadSkill, loadSkillFromRoots, parseFrontmatter, stripFrontmatter, ensureSkillSymlinks, cleanupSkillSymlinks, discoverAgents, getSkillPath, getSkillMeta, getAgentPath, getAgentMeta, } from "./skills.js";
|
|
11
|
+
export type { SkillInfo, SkillContent, SymlinkOptions } from "./skills.js";
|
|
12
|
+
export { parseToolCalls as acpParseToolCalls, buildToolPreamble as acpBuildToolPreamble, buildCodePreamble as acpBuildCodePreamble, extractCode as acpExtractCode, executeCode as acpExecuteCode, } from "@openplaybooks/acpfn";
|
|
13
|
+
export type { Provider, AgentFnHooks, AgentFnResult, AgentFn, AgentFnOptions, ToolDef, ComposeHooks, ComposeOptions, PromptInput, ExecutionMode, Backend, PermissionMode, SessionEvent, Session, StreamCallOptions, StreamFn, AgentResult, AgentHooks, ClaudeAgentOptions, McpServerConfig, AgentDefinition, ClaudeFnOptions, ClaudeFnResult, ClaudeFn, KimiFnOptions, KimiFnResult, KimiFn, QwenFnOptions, QwenFnResult, QwenFn, GeminiFnOptions, GeminiFnResult, GeminiFn, AcpFnOptions, AcpFnResult, AcpFn, OpenFnOptions, OpenFnResult, OpenFn, GlobalQueueOptions, } from "./types.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EACL,iBAAiB,EACjB,sBAAsB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,EACZ,MAAM,EAEN,aAAa,EACb,YAAY,EACZ,MAAM,EAEN,eAAe,EACf,cAAc,EACd,QAAQ,EAER,YAAY,EACZ,WAAW,EACX,KAAK,EAEL,aAAa,EACb,YAAY,EACZ,MAAM,EAEN,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// ─── Core ───────────────────────────────────────────────────
|
|
2
|
+
export { agentfn } from "./agentfn.js";
|
|
3
|
+
// ─── Feedback ───────────────────────────────────────────────
|
|
4
|
+
export { agentSendFeedback, TASK_COMPLETION_PROMPT, parseTaskReport, formatReportAsMarkdown, } from "./feedback.js";
|
|
5
|
+
// ─── Compose ────────────────────────────────────────────────
|
|
6
|
+
export { compose } from "./compose.js";
|
|
7
|
+
// ─── Agent (Claude only) ───────────────────────────────────
|
|
8
|
+
export { agent } from "./agent.js";
|
|
9
|
+
// ─── Provider ───────────────────────────────────────────────
|
|
10
|
+
export { getDefaultProvider, setDefaultProvider } from "./provider.js";
|
|
11
|
+
// ─── Prompting (legacy — deprecated) ────────────────────────
|
|
12
|
+
export { enhancePrompt, listSkills, listAgents } from "./prompting.js";
|
|
13
|
+
// ─── Skills ─────────────────────────────────────────────────
|
|
14
|
+
export {
|
|
15
|
+
// New parameterized API
|
|
16
|
+
discoverSkills, loadSkill, loadSkillFromRoots, parseFrontmatter, stripFrontmatter, ensureSkillSymlinks, cleanupSkillSymlinks,
|
|
17
|
+
// Agent utilities
|
|
18
|
+
discoverAgents,
|
|
19
|
+
// Metadata loaders
|
|
20
|
+
getSkillPath, getSkillMeta, getAgentPath, getAgentMeta, } from "./skills.js";
|
|
21
|
+
// ─── Utilities (re-exported from acpfn) ─────────────────────
|
|
22
|
+
export { parseToolCalls as acpParseToolCalls, buildToolPreamble as acpBuildToolPreamble, buildCodePreamble as acpBuildCodePreamble, extractCode as acpExtractCode, executeCode as acpExecuteCode, } from "@openplaybooks/acpfn";
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,+DAA+D;AAC/D,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAGvB,+DAA+D;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,8DAA8D;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,+DAA+D;AAC/D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEvE,+DAA+D;AAC/D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGvE,+DAA+D;AAC/D,OAAO;AACL,wBAAwB;AACxB,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB;AACpB,kBAAkB;AAClB,cAAc;AACd,mBAAmB;AACnB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,+DAA+D;AAC/D,OAAO,EACL,cAAc,IAAI,iBAAiB,EACnC,iBAAiB,IAAI,oBAAoB,EACzC,iBAAiB,IAAI,oBAAoB,EACzC,WAAW,IAAI,cAAc,EAC7B,WAAW,IAAI,cAAc,GAC9B,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt enhancement and injection module.
|
|
3
|
+
*
|
|
4
|
+
* Handles general prompt manipulation, including:
|
|
5
|
+
* - Skill/agent reference enhancement
|
|
6
|
+
* - Prompt templating and injection
|
|
7
|
+
* - Context augmentation
|
|
8
|
+
*
|
|
9
|
+
* Note: The enhancePrompt function uses legacy auto-detection.
|
|
10
|
+
* New code should use discoverSkills/loadSkill from skills.ts directly
|
|
11
|
+
* and format prompts at the application level.
|
|
12
|
+
*/
|
|
13
|
+
import { listSkills, listAgents } from "./skills.js";
|
|
14
|
+
export interface EnhancePromptOptions {
|
|
15
|
+
/** Working directory for finding .converge folder */
|
|
16
|
+
cwd?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Application-level prompt formatting should be done by the caller.
|
|
20
|
+
* This function uses legacy auto-detection of .converge/ directories.
|
|
21
|
+
*
|
|
22
|
+
* Enhance a prompt by adding footnote references to skills and agents.
|
|
23
|
+
*
|
|
24
|
+
* - /skill refs point to .converge/{name}/SKILL.md
|
|
25
|
+
* - @agent refs point to .converge/{name}/AGENT.md or .converge/{name}.md (fallback to SKILL.md)
|
|
26
|
+
*
|
|
27
|
+
* Returns the enhanced prompt with skill/agent footnotes.
|
|
28
|
+
* The AI can load these files on-demand when needed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function enhancePrompt(prompt: string, options?: EnhancePromptOptions): string;
|
|
31
|
+
export { listSkills, listAgents };
|
|
32
|
+
//# sourceMappingURL=prompting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompting.d.ts","sourceRoot":"","sources":["../src/prompting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,UAAU,EACV,UAAU,EAKX,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA8BD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,oBAAoB,GAC7B,MAAM,CAiER;AAGD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
|