@nestbox-ai/cli 1.0.64 → 1.0.67
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/README.md +43 -16
- package/dist/agents/docProc/anthropic.d.ts +21 -0
- package/dist/agents/docProc/anthropic.js +225 -0
- package/dist/agents/docProc/anthropic.js.map +1 -0
- package/dist/agents/docProc/index.d.ts +2 -20
- package/dist/agents/docProc/index.js +7 -223
- package/dist/agents/docProc/index.js.map +1 -1
- package/dist/agents/docProc/openai.d.ts +16 -0
- package/dist/agents/docProc/openai.js +222 -0
- package/dist/agents/docProc/openai.js.map +1 -0
- package/dist/agents/reportGenerator/anthropic.d.ts +19 -0
- package/dist/agents/reportGenerator/anthropic.js +212 -0
- package/dist/agents/reportGenerator/anthropic.js.map +1 -0
- package/dist/agents/reportGenerator/index.d.ts +2 -18
- package/dist/agents/reportGenerator/index.js +7 -207
- package/dist/agents/reportGenerator/index.js.map +1 -1
- package/dist/agents/reportGenerator/openai.d.ts +16 -0
- package/dist/agents/reportGenerator/openai.js +203 -0
- package/dist/agents/reportGenerator/openai.js.map +1 -0
- package/dist/commands/generate/docProc.js +27 -16
- package/dist/commands/generate/docProc.js.map +1 -1
- package/dist/commands/generate/reportComposer.js +26 -15
- package/dist/commands/generate/reportComposer.js.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/docProc/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/docProc/index.ts"],"names":[],"mappings":";;;AAAA,yCAAiI;AAAxH,4GAAA,eAAe,OAAA;AAA2C,oHAAA,aAAa,OAA2B;AAC3G,mCAAuH;AAA9G,mHAAA,yBAAyB,OAAA;AAA6B,8GAAA,aAAa,OAAwB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DocProcAgentResult } from './anthropic';
|
|
2
|
+
export type { DocProcAgentResult };
|
|
3
|
+
export interface DocProcOpenAIAgentOptions {
|
|
4
|
+
/** Full instruction text (from the instructions file) */
|
|
5
|
+
instructions: string;
|
|
6
|
+
/** OpenAI API key */
|
|
7
|
+
openAiApiKey: string;
|
|
8
|
+
/** OpenAI model ID, e.g. "gpt-4o" */
|
|
9
|
+
model?: string;
|
|
10
|
+
/** Maximum agentic iterations before giving up */
|
|
11
|
+
maxIterations?: number;
|
|
12
|
+
/** Called on each status update (for spinner / logging) */
|
|
13
|
+
onProgress?: (message: string) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const DEFAULT_MODEL = "gpt-4o";
|
|
16
|
+
export declare function runDocProcAgentWithOpenAI(options: DocProcOpenAIAgentOptions): Promise<DocProcAgentResult>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DEFAULT_MODEL = void 0;
|
|
16
|
+
exports.runDocProcAgentWithOpenAI = runDocProcAgentWithOpenAI;
|
|
17
|
+
const openai_1 = __importDefault(require("openai"));
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
21
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
22
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
23
|
+
const AGENTS_DIR = __dirname;
|
|
24
|
+
exports.DEFAULT_MODEL = 'gpt-4o';
|
|
25
|
+
const DEFAULT_MAX_ITERATIONS = 8;
|
|
26
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
27
|
+
function readLocalFile(filename) {
|
|
28
|
+
return fs_1.default.readFileSync(path_1.default.join(AGENTS_DIR, filename), 'utf8');
|
|
29
|
+
}
|
|
30
|
+
function validateYaml(content, schemaContent) {
|
|
31
|
+
var _a;
|
|
32
|
+
const preprocessed = content.replace(/\$\{[^}]+\}/g, 'env-var-placeholder');
|
|
33
|
+
let data;
|
|
34
|
+
try {
|
|
35
|
+
data = js_yaml_1.default.load(preprocessed);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
return { valid: false, errors: [`YAML parse error: ${e.message}`] };
|
|
39
|
+
}
|
|
40
|
+
let schema;
|
|
41
|
+
try {
|
|
42
|
+
schema = js_yaml_1.default.load(schemaContent);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
return { valid: false, errors: [`Schema parse error: ${e.message}`] };
|
|
46
|
+
}
|
|
47
|
+
const ajv = new ajv_1.default({ strict: false, allErrors: true });
|
|
48
|
+
ajv.addFormat('uri', () => true);
|
|
49
|
+
const validate = ajv.compile(schema);
|
|
50
|
+
const ok = validate(data);
|
|
51
|
+
if (ok)
|
|
52
|
+
return { valid: true, errors: [] };
|
|
53
|
+
const errors = ((_a = validate.errors) !== null && _a !== void 0 ? _a : []).map((err) => {
|
|
54
|
+
const loc = err.instancePath || '(root)';
|
|
55
|
+
return `[${loc}] ${err.message}`;
|
|
56
|
+
});
|
|
57
|
+
return { valid: false, errors };
|
|
58
|
+
}
|
|
59
|
+
// ─── System Prompt ────────────────────────────────────────────────────────────
|
|
60
|
+
function buildSystemPrompt() {
|
|
61
|
+
const systemPrompt = readLocalFile('SYSTEM_PROMPT.md');
|
|
62
|
+
const configGuide = readLocalFile('CONFIG_GUIDE.md');
|
|
63
|
+
const evalGuide = readLocalFile('EVAL_GUIDE.md');
|
|
64
|
+
return `${systemPrompt}\n\n---\n\n${configGuide}\n\n---\n\n${evalGuide}`;
|
|
65
|
+
}
|
|
66
|
+
// ─── Tool Definitions ─────────────────────────────────────────────────────────
|
|
67
|
+
const TOOLS = [
|
|
68
|
+
{
|
|
69
|
+
type: 'function',
|
|
70
|
+
function: {
|
|
71
|
+
name: 'write_and_validate_config',
|
|
72
|
+
description: 'Write the config.yaml content and validate it against the schema. Returns "VALID" on success or a list of validation errors to fix.',
|
|
73
|
+
parameters: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
yaml_content: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'The complete YAML content for config.yaml',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
required: ['yaml_content'],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: 'function',
|
|
87
|
+
function: {
|
|
88
|
+
name: 'write_and_validate_eval',
|
|
89
|
+
description: 'Write the eval.yaml content and validate it against the schema. Returns "VALID" on success or a list of validation errors to fix.',
|
|
90
|
+
parameters: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
yaml_content: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: 'The complete YAML content for eval.yaml',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
required: ['yaml_content'],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: 'function',
|
|
104
|
+
function: {
|
|
105
|
+
name: 'finish',
|
|
106
|
+
description: 'Signal that both files are complete and valid. Call this only after both write_and_validate_config and write_and_validate_eval have returned "VALID".',
|
|
107
|
+
parameters: {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
summary: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Brief summary of what was generated and why key choices were made',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: ['summary'],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
// ─── Agent ────────────────────────────────────────────────────────────────────
|
|
121
|
+
function runDocProcAgentWithOpenAI(options) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
var _a;
|
|
124
|
+
const { instructions, openAiApiKey, model = exports.DEFAULT_MODEL, maxIterations = DEFAULT_MAX_ITERATIONS, onProgress = () => { }, } = options;
|
|
125
|
+
const configSchema = readLocalFile('config.schema.yaml');
|
|
126
|
+
const evalSchema = readLocalFile('eval-test-cases.schema.yaml');
|
|
127
|
+
const client = new openai_1.default({ apiKey: openAiApiKey });
|
|
128
|
+
let latestConfig = '';
|
|
129
|
+
let latestEval = '';
|
|
130
|
+
let configValid = false;
|
|
131
|
+
let evalValid = false;
|
|
132
|
+
let finished = false;
|
|
133
|
+
let iteration = 0;
|
|
134
|
+
function executeTool(name, input) {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
if (name === 'write_and_validate_config') {
|
|
137
|
+
const content = (_a = input.yaml_content) !== null && _a !== void 0 ? _a : '';
|
|
138
|
+
latestConfig = content;
|
|
139
|
+
const result = validateYaml(content, configSchema);
|
|
140
|
+
configValid = result.valid;
|
|
141
|
+
if (result.valid)
|
|
142
|
+
return 'VALID';
|
|
143
|
+
return `VALIDATION ERRORS — fix all of these before calling again:\n${result.errors.map((e) => ` • ${e}`).join('\n')}`;
|
|
144
|
+
}
|
|
145
|
+
if (name === 'write_and_validate_eval') {
|
|
146
|
+
const content = (_b = input.yaml_content) !== null && _b !== void 0 ? _b : '';
|
|
147
|
+
latestEval = content;
|
|
148
|
+
const result = validateYaml(content, evalSchema);
|
|
149
|
+
evalValid = result.valid;
|
|
150
|
+
if (result.valid)
|
|
151
|
+
return 'VALID';
|
|
152
|
+
return `VALIDATION ERRORS — fix all of these before calling again:\n${result.errors.map((e) => ` • ${e}`).join('\n')}`;
|
|
153
|
+
}
|
|
154
|
+
if (name === 'finish') {
|
|
155
|
+
if (!configValid || !evalValid) {
|
|
156
|
+
return 'Cannot finish: not all files have passed validation yet. Call write_and_validate_config and write_and_validate_eval first and ensure both return "VALID".';
|
|
157
|
+
}
|
|
158
|
+
finished = true;
|
|
159
|
+
return 'Done.';
|
|
160
|
+
}
|
|
161
|
+
return `Unknown tool: ${name}`;
|
|
162
|
+
}
|
|
163
|
+
const systemPromptText = buildSystemPrompt();
|
|
164
|
+
const messages = [
|
|
165
|
+
{ role: 'system', content: systemPromptText },
|
|
166
|
+
{
|
|
167
|
+
role: 'user',
|
|
168
|
+
content: `Here are the instructions for the pipeline you need to configure:\n\n${instructions}\n\nGenerate the config.yaml and eval.yaml files now. Use the tools to write and validate them.`,
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
onProgress('Starting agent...');
|
|
172
|
+
while (iteration < maxIterations && !finished) {
|
|
173
|
+
iteration++;
|
|
174
|
+
onProgress(`Iteration ${iteration}/${maxIterations} — calling OpenAI...`);
|
|
175
|
+
const response = yield client.chat.completions.create({
|
|
176
|
+
model,
|
|
177
|
+
messages,
|
|
178
|
+
tools: TOOLS,
|
|
179
|
+
// Force the model to call a tool every turn.
|
|
180
|
+
tool_choice: 'required',
|
|
181
|
+
});
|
|
182
|
+
const message = response.choices[0].message;
|
|
183
|
+
messages.push(message);
|
|
184
|
+
if (response.choices[0].finish_reason !== 'tool_calls') {
|
|
185
|
+
onProgress(`Agent stopped unexpectedly: ${response.choices[0].finish_reason}`);
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
const toolResultMessages = [];
|
|
189
|
+
for (const toolCall of (_a = message.tool_calls) !== null && _a !== void 0 ? _a : []) {
|
|
190
|
+
if (toolCall.type !== 'function')
|
|
191
|
+
continue;
|
|
192
|
+
onProgress(` → tool: ${toolCall.function.name}`);
|
|
193
|
+
const input = JSON.parse(toolCall.function.arguments);
|
|
194
|
+
const result = executeTool(toolCall.function.name, input);
|
|
195
|
+
onProgress(` ${result.startsWith('VALID') ? '✓ valid' : result.split('\n')[0]}`);
|
|
196
|
+
toolResultMessages.push({
|
|
197
|
+
role: 'tool',
|
|
198
|
+
tool_call_id: toolCall.id,
|
|
199
|
+
content: result,
|
|
200
|
+
});
|
|
201
|
+
if (finished)
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
if (toolResultMessages.length > 0) {
|
|
205
|
+
messages.push(...toolResultMessages);
|
|
206
|
+
}
|
|
207
|
+
if (finished)
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
if (iteration >= maxIterations && !finished) {
|
|
211
|
+
onProgress(`Warning: reached max iterations (${maxIterations}) without finishing.`);
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
configYaml: latestConfig,
|
|
215
|
+
evalYaml: latestEval,
|
|
216
|
+
iterations: iteration,
|
|
217
|
+
configValid,
|
|
218
|
+
evalValid,
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../src/agents/docProc/openai.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA+IA,8DAwHC;AAvQD,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AACxB,sDAA2B;AAC3B,8CAAsB;AAyBtB,iFAAiF;AAEjF,MAAM,UAAU,GAAG,SAAS,CAAC;AAChB,QAAA,aAAa,GAAG,QAAQ,CAAC;AACtC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC,gFAAgF;AAEhF,SAAS,aAA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AI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAEpF,kBAAkB,CAAC,IAAI,CAAC;oBACtB,IAAI,EAAE,MAAM;oBACZ,YAAY,EAAE,QAAQ,CAAC,EAAE;oBACzB,OAAO,EAAE,MAAM;iBAChB,CAAC,CAAC;gBAEH,IAAI,QAAQ;oBAAE,MAAM;YACtB,CAAC;YAED,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClC,QAAQ,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC;YACvC,CAAC;YAED,IAAI,QAAQ;gBAAE,MAAM;QACtB,CAAC;QAED,IAAI,SAAS,IAAI,aAAa,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,UAAU,CAAC,oCAAoC,aAAa,sBAAsB,CAAC,CAAC;QACtF,CAAC;QAED,OAAO;YACL,UAAU,EAAE,YAAY;YACxB,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE,SAAS;YACrB,WAAW;YACX,SAAS;SACV,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ReportComposerAgentOptions {
|
|
2
|
+
/** Full instruction text (from the instructions file) */
|
|
3
|
+
instructions: string;
|
|
4
|
+
/** Anthropic API key */
|
|
5
|
+
anthropicApiKey: string;
|
|
6
|
+
/** Claude model ID, e.g. "claude-sonnet-4-6" */
|
|
7
|
+
model?: string;
|
|
8
|
+
/** Maximum agentic iterations before giving up */
|
|
9
|
+
maxIterations?: number;
|
|
10
|
+
/** Called on each status update (for spinner / logging) */
|
|
11
|
+
onProgress?: (message: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface ReportComposerAgentResult {
|
|
14
|
+
reportYaml: string;
|
|
15
|
+
iterations: number;
|
|
16
|
+
reportValid: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEFAULT_MODEL = "claude-sonnet-4-6";
|
|
19
|
+
export declare function runReportComposerAgent(options: ReportComposerAgentOptions): Promise<ReportComposerAgentResult>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DEFAULT_MODEL = void 0;
|
|
16
|
+
exports.runReportComposerAgent = runReportComposerAgent;
|
|
17
|
+
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
21
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
22
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
23
|
+
const AGENTS_DIR = __dirname;
|
|
24
|
+
exports.DEFAULT_MODEL = 'claude-sonnet-4-6';
|
|
25
|
+
const DEFAULT_MAX_ITERATIONS = 5;
|
|
26
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
27
|
+
function readLocalFile(filename) {
|
|
28
|
+
return fs_1.default.readFileSync(path_1.default.join(AGENTS_DIR, filename), 'utf8');
|
|
29
|
+
}
|
|
30
|
+
function validateYaml(content, schemaContent) {
|
|
31
|
+
var _a;
|
|
32
|
+
// Replace ${ENV_VAR} and ${ENV_VAR:-default} references with a plain string
|
|
33
|
+
// so YAML parses cleanly and AJV treats them as valid string values.
|
|
34
|
+
const preprocessed = content.replace(/\$\{[^}]+\}/g, 'env-var-placeholder');
|
|
35
|
+
let data;
|
|
36
|
+
try {
|
|
37
|
+
data = js_yaml_1.default.load(preprocessed);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return { valid: false, errors: [`YAML parse error: ${e.message}`] };
|
|
41
|
+
}
|
|
42
|
+
let schema;
|
|
43
|
+
try {
|
|
44
|
+
schema = js_yaml_1.default.load(schemaContent);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return { valid: false, errors: [`Schema parse error: ${e.message}`] };
|
|
48
|
+
}
|
|
49
|
+
// Remove $schema so AJV doesn't try to resolve the meta-schema URI
|
|
50
|
+
// (AJV 8 defaults to draft-07 and doesn't recognise draft 2020-12).
|
|
51
|
+
delete schema['$schema'];
|
|
52
|
+
const ajv = new ajv_1.default({ strict: false, allErrors: true });
|
|
53
|
+
// Suppress "unknown format 'uri' ignored" console warnings from AJV
|
|
54
|
+
ajv.addFormat('uri', () => true);
|
|
55
|
+
const validate = ajv.compile(schema);
|
|
56
|
+
const ok = validate(data);
|
|
57
|
+
if (ok)
|
|
58
|
+
return { valid: true, errors: [] };
|
|
59
|
+
const errors = ((_a = validate.errors) !== null && _a !== void 0 ? _a : []).map((err) => {
|
|
60
|
+
const loc = err.instancePath || '(root)';
|
|
61
|
+
return `[${loc}] ${err.message}`;
|
|
62
|
+
});
|
|
63
|
+
return { valid: false, errors };
|
|
64
|
+
}
|
|
65
|
+
// ─── System Prompt ────────────────────────────────────────────────────────────
|
|
66
|
+
function buildSystemPrompt() {
|
|
67
|
+
const systemPrompt = readLocalFile('SYSTEM_PROMPT.md');
|
|
68
|
+
const configGuide = readLocalFile('REPORT_CONFIG_GUIDE.md');
|
|
69
|
+
const example1 = readLocalFile('annual_report_10k.yaml');
|
|
70
|
+
const example2 = readLocalFile('vc_portfolio_monitoring.yaml');
|
|
71
|
+
return [
|
|
72
|
+
systemPrompt,
|
|
73
|
+
'---',
|
|
74
|
+
configGuide,
|
|
75
|
+
'---',
|
|
76
|
+
'# Example 1: Annual Report / 10-K Analysis\n\n```yaml\n' + example1 + '\n```',
|
|
77
|
+
'---',
|
|
78
|
+
'# Example 2: VC Portfolio Monitoring\n\n```yaml\n' + example2 + '\n```',
|
|
79
|
+
].join('\n\n');
|
|
80
|
+
}
|
|
81
|
+
// ─── Tool Definitions ─────────────────────────────────────────────────────────
|
|
82
|
+
const TOOLS = [
|
|
83
|
+
{
|
|
84
|
+
name: 'write_and_validate_report',
|
|
85
|
+
description: 'Write the report.yaml content and validate it against the schema. Returns "VALID" on success or a list of validation errors to fix.',
|
|
86
|
+
input_schema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
yaml_content: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
description: 'The complete YAML content for report.yaml',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
required: ['yaml_content'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'finish',
|
|
99
|
+
description: 'Signal that the report.yaml is complete and valid. Call this only after write_and_validate_report has returned "VALID".',
|
|
100
|
+
input_schema: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
summary: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
description: 'Brief summary of what was generated and why key choices were made',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
required: ['summary'],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
// ─── Agent ────────────────────────────────────────────────────────────────────
|
|
113
|
+
function runReportComposerAgent(options) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const { instructions, anthropicApiKey, model = exports.DEFAULT_MODEL, maxIterations = DEFAULT_MAX_ITERATIONS, onProgress = () => { }, } = options;
|
|
116
|
+
const reportSchema = readLocalFile('report_config.schema.yaml');
|
|
117
|
+
const client = new sdk_1.default({ apiKey: anthropicApiKey });
|
|
118
|
+
let latestReport = '';
|
|
119
|
+
let reportValid = false;
|
|
120
|
+
let finished = false;
|
|
121
|
+
let iteration = 0;
|
|
122
|
+
function executeTool(name, input) {
|
|
123
|
+
var _a;
|
|
124
|
+
if (name === 'write_and_validate_report') {
|
|
125
|
+
const content = (_a = input.yaml_content) !== null && _a !== void 0 ? _a : '';
|
|
126
|
+
latestReport = content;
|
|
127
|
+
const result = validateYaml(content, reportSchema);
|
|
128
|
+
reportValid = result.valid;
|
|
129
|
+
if (result.valid)
|
|
130
|
+
return 'VALID';
|
|
131
|
+
return `VALIDATION ERRORS — fix all of these before calling again:\n${result.errors.map((e) => ` • ${e}`).join('\n')}`;
|
|
132
|
+
}
|
|
133
|
+
if (name === 'finish') {
|
|
134
|
+
if (!reportValid) {
|
|
135
|
+
return 'Cannot finish: the report has not passed schema validation yet. Call write_and_validate_report first and ensure it returns "VALID".';
|
|
136
|
+
}
|
|
137
|
+
finished = true;
|
|
138
|
+
return 'Done.';
|
|
139
|
+
}
|
|
140
|
+
return `Unknown tool: ${name}`;
|
|
141
|
+
}
|
|
142
|
+
// Build the system prompt once and mark it for caching.
|
|
143
|
+
// On iteration 1 the prompt is written to the cache (normal price).
|
|
144
|
+
// On iterations 2+ the large system prompt is read from cache at
|
|
145
|
+
// 10% of the normal input token price.
|
|
146
|
+
const systemPromptText = buildSystemPrompt();
|
|
147
|
+
const systemPrompt = [
|
|
148
|
+
{
|
|
149
|
+
type: 'text',
|
|
150
|
+
text: systemPromptText,
|
|
151
|
+
cache_control: { type: 'ephemeral' },
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
const messages = [
|
|
155
|
+
{
|
|
156
|
+
role: 'user',
|
|
157
|
+
content: `Here are the instructions for the report you need to configure:\n\n${instructions}\n\nGenerate the report.yaml file now. Use the tools to write and validate it.`,
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
onProgress('Starting agent...');
|
|
161
|
+
while (iteration < maxIterations && !finished) {
|
|
162
|
+
iteration++;
|
|
163
|
+
onProgress(`Iteration ${iteration}/${maxIterations} — calling Claude...`);
|
|
164
|
+
const response = yield client.messages.create({
|
|
165
|
+
model,
|
|
166
|
+
max_tokens: 8096,
|
|
167
|
+
system: systemPrompt,
|
|
168
|
+
tools: TOOLS,
|
|
169
|
+
// Force Claude to call a tool every turn — prevents it from
|
|
170
|
+
// replying with plain text and exiting the loop prematurely.
|
|
171
|
+
tool_choice: { type: 'any' },
|
|
172
|
+
messages,
|
|
173
|
+
});
|
|
174
|
+
// Append assistant turn
|
|
175
|
+
messages.push({ role: 'assistant', content: response.content });
|
|
176
|
+
if (response.stop_reason !== 'tool_use') {
|
|
177
|
+
onProgress(`Agent stopped unexpectedly: ${response.stop_reason}`);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
// Process all tool calls and collect results
|
|
181
|
+
const toolResults = [];
|
|
182
|
+
for (const block of response.content) {
|
|
183
|
+
if (block.type !== 'tool_use')
|
|
184
|
+
continue;
|
|
185
|
+
onProgress(` → tool: ${block.name}`);
|
|
186
|
+
const result = executeTool(block.name, block.input);
|
|
187
|
+
onProgress(` ${result.startsWith('VALID') ? '✓ valid' : result.split('\n')[0]}`);
|
|
188
|
+
toolResults.push({
|
|
189
|
+
type: 'tool_result',
|
|
190
|
+
tool_use_id: block.id,
|
|
191
|
+
content: result,
|
|
192
|
+
});
|
|
193
|
+
if (finished)
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
if (toolResults.length > 0) {
|
|
197
|
+
messages.push({ role: 'user', content: toolResults });
|
|
198
|
+
}
|
|
199
|
+
if (finished)
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
if (iteration >= maxIterations && !finished) {
|
|
203
|
+
onProgress(`Warning: reached max iterations (${maxIterations}) without finishing.`);
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
reportYaml: latestReport,
|
|
207
|
+
iterations: iteration,
|
|
208
|
+
reportValid,
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/agents/reportGenerator/anthropic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA0IA,wDAyHC;AAnQD,4DAA0C;AAC1C,4CAAoB;AACpB,gDAAwB;AACxB,sDAA2B;AAC3B,8CAAsB;AA4BtB,iFAAiF;AAEjF,MAAM,UAAU,GAAG,SAAS,CAAC;AAChB,QAAA,aAAa,GAAG,mBAAmB,CAAC;AACjD,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC,gFAAgF;AAEhF,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,YAAY,CAAC,OAAe,EAAE,aAAqB;;IAC1D,4EAA4E;IAC5E,qEAAqE;IACrE,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;IAE5E,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,iBAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,qBAAqB,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;IACtE,CAAC;IAED,IAAI,MAA+B,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,GAAG,iBAAI,CA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AAI,CAAC;oBACf,IAAI,EAAE,aAAa;oBACnB,WAAW,EAAE,KAAK,CAAC,EAAE;oBACrB,OAAO,EAAE,MAAM;iBAChB,CAAC,CAAC;gBAEH,IAAI,QAAQ;oBAAE,MAAM;YACtB,CAAC;YAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;YACxD,CAAC;YAED,IAAI,QAAQ;gBAAE,MAAM;QACtB,CAAC;QAED,IAAI,SAAS,IAAI,aAAa,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,UAAU,CAAC,oCAAoC,aAAa,sBAAsB,CAAC,CAAC;QACtF,CAAC;QAED,OAAO;YACL,UAAU,EAAE,YAAY;YACxB,UAAU,EAAE,SAAS;YACrB,WAAW;SACZ,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
instructions: string;
|
|
4
|
-
/** Anthropic API key */
|
|
5
|
-
anthropicApiKey: string;
|
|
6
|
-
/** Claude model ID, e.g. "claude-sonnet-4-6" */
|
|
7
|
-
model?: string;
|
|
8
|
-
/** Maximum agentic iterations before giving up */
|
|
9
|
-
maxIterations?: number;
|
|
10
|
-
/** Called on each status update (for spinner / logging) */
|
|
11
|
-
onProgress?: (message: string) => void;
|
|
12
|
-
}
|
|
13
|
-
export interface ReportComposerAgentResult {
|
|
14
|
-
reportYaml: string;
|
|
15
|
-
iterations: number;
|
|
16
|
-
reportValid: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare function runReportComposerAgent(options: ReportComposerAgentOptions): Promise<ReportComposerAgentResult>;
|
|
1
|
+
export { runReportComposerAgent, ReportComposerAgentOptions, ReportComposerAgentResult, DEFAULT_MODEL as ANTHROPIC_DEFAULT_MODEL } from './anthropic';
|
|
2
|
+
export { runReportComposerAgentWithOpenAI, ReportComposerOpenAIAgentOptions, DEFAULT_MODEL as OPENAI_DEFAULT_MODEL } from './openai';
|