@ariaflowagents/config 0.7.0 ā 0.8.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/dist/agent-architect/index.d.ts +10 -0
- package/dist/agent-architect/index.d.ts.map +1 -0
- package/dist/agent-architect/index.js +131 -0
- package/dist/agent-architect/index.js.map +1 -0
- package/dist/agent-architect/prompt-generator.d.ts +9 -0
- package/dist/agent-architect/prompt-generator.d.ts.map +1 -0
- package/dist/agent-architect/prompt-generator.js +155 -0
- package/dist/agent-architect/prompt-generator.js.map +1 -0
- package/dist/agent-architect/rfc-emitter.d.ts +18 -0
- package/dist/agent-architect/rfc-emitter.d.ts.map +1 -0
- package/dist/agent-architect/rfc-emitter.js +350 -0
- package/dist/agent-architect/rfc-emitter.js.map +1 -0
- package/dist/agent-architect/tool-recommender.d.ts +8 -0
- package/dist/agent-architect/tool-recommender.d.ts.map +1 -0
- package/dist/agent-architect/tool-recommender.js +87 -0
- package/dist/agent-architect/tool-recommender.js.map +1 -0
- package/dist/agent-architect/types.d.ts +904 -0
- package/dist/agent-architect/types.d.ts.map +1 -0
- package/dist/agent-architect/types.js +89 -0
- package/dist/agent-architect/types.js.map +1 -0
- package/dist/agent-architect/use-case-analyzer.d.ts +8 -0
- package/dist/agent-architect/use-case-analyzer.d.ts.map +1 -0
- package/dist/agent-architect/use-case-analyzer.js +76 -0
- package/dist/agent-architect/use-case-analyzer.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +890 -0
- package/dist/cli.js.map +1 -1
- package/dist/llm-flow-generator.d.ts.map +1 -1
- package/dist/llm-flow-generator.js +31 -73
- package/dist/llm-flow-generator.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ArchitectOptions, type ArchitectResult, type AgentMode, type DomainAnalysis, type ToolRecommendation, type SixLayerPrompt, type DetailLevel } from './types.js';
|
|
2
|
+
export interface RunArchitectOptions extends ArchitectOptions {
|
|
3
|
+
model?: string;
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
mode?: AgentMode;
|
|
6
|
+
detailLevel?: DetailLevel;
|
|
7
|
+
}
|
|
8
|
+
export declare function runArchitect(options: RunArchitectOptions): Promise<ArchitectResult>;
|
|
9
|
+
export { type DomainAnalysis, type ToolRecommendation, type SixLayerPrompt };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-architect/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,WAAW,EAEjB,MAAM,YAAY,CAAC;AA4BpB,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,eAAe,CAAC,CA+H1B;AAED,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { analyzeUseCase } from './use-case-analyzer.js';
|
|
2
|
+
import { recommendTools, getToolPolicy } from './tool-recommender.js';
|
|
3
|
+
import { generateSixLayerPrompt, renderSixLayerPromptAsMarkdown, renderSixLayerPromptAsTypeScript } from './prompt-generator.js';
|
|
4
|
+
import { generateRfcMarkdown } from './rfc-emitter.js';
|
|
5
|
+
import { generateFlowTemplateWithLLM } from '../llm-flow-generator.js';
|
|
6
|
+
import { emitFlowTypeScriptModule } from '../flow-codegen.js';
|
|
7
|
+
import { AgentBlueprintSchema, } from './types.js';
|
|
8
|
+
function toSlug(value) {
|
|
9
|
+
return value
|
|
10
|
+
.toLowerCase()
|
|
11
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
12
|
+
.replace(/^-+|-+$/g, '')
|
|
13
|
+
.slice(0, 64) || 'generated-agent';
|
|
14
|
+
}
|
|
15
|
+
function toTitleCase(value) {
|
|
16
|
+
return value
|
|
17
|
+
.replace(/[_-]+/g, ' ')
|
|
18
|
+
.replace(/\s+/g, ' ')
|
|
19
|
+
.trim()
|
|
20
|
+
.split(' ')
|
|
21
|
+
.map(word => (word ? word[0].toUpperCase() + word.slice(1) : ''))
|
|
22
|
+
.join(' ');
|
|
23
|
+
}
|
|
24
|
+
function toTsConstCase(value) {
|
|
25
|
+
const clean = value.replace(/[^a-zA-Z0-9]+/g, ' ').trim();
|
|
26
|
+
const words = clean.split(/\s+/).filter(Boolean);
|
|
27
|
+
if (words.length === 0)
|
|
28
|
+
return 'generatedAgent';
|
|
29
|
+
const [head, ...tail] = words;
|
|
30
|
+
return `${head.toLowerCase()}${tail.map(word => word[0].toUpperCase() + word.slice(1).toLowerCase()).join('')}`;
|
|
31
|
+
}
|
|
32
|
+
export async function runArchitect(options) {
|
|
33
|
+
const { useCase, mode = 'hybrid', target = 'both', name, model, contextText, timeoutMs = 120000, detailLevel = 'detailed', } = options;
|
|
34
|
+
console.log('\nš Analyzing use case with LLM...');
|
|
35
|
+
const domainAnalysis = await analyzeUseCase(useCase, {
|
|
36
|
+
model,
|
|
37
|
+
contextText,
|
|
38
|
+
timeoutMs,
|
|
39
|
+
});
|
|
40
|
+
console.log(' Domain:', domainAnalysis.domain);
|
|
41
|
+
console.log(' Entities:', domainAnalysis.entities.join(', '));
|
|
42
|
+
console.log(' Workflows:', domainAnalysis.workflows.join(', '));
|
|
43
|
+
console.log('\nš ļø Recommending tools with LLM...');
|
|
44
|
+
const toolRecommendations = await recommendTools(useCase, domainAnalysis, {
|
|
45
|
+
model,
|
|
46
|
+
timeoutMs,
|
|
47
|
+
});
|
|
48
|
+
console.log(' Recommended tools:');
|
|
49
|
+
for (const tool of toolRecommendations) {
|
|
50
|
+
console.log(` - ${tool.toolName} (${tool.priority})`);
|
|
51
|
+
}
|
|
52
|
+
const blueprintId = toSlug(name ?? useCase);
|
|
53
|
+
const displayName = name ? toTitleCase(name) : toTitleCase(blueprintId);
|
|
54
|
+
console.log('\nš Generating 6-layer prompt with LLM...');
|
|
55
|
+
const promptLayers = await generateSixLayerPrompt(displayName, useCase, domainAnalysis, toolRecommendations, mode, { model, timeoutMs });
|
|
56
|
+
let flowJson;
|
|
57
|
+
let flowTs;
|
|
58
|
+
if (mode !== 'llm') {
|
|
59
|
+
console.log('\nš Generating flow for ' + mode + ' mode...');
|
|
60
|
+
try {
|
|
61
|
+
flowJson = await generateFlowTemplateWithLLM({
|
|
62
|
+
useCase,
|
|
63
|
+
direction: 'inbound',
|
|
64
|
+
agentName: displayName,
|
|
65
|
+
model: model ?? 'gpt-5-mini',
|
|
66
|
+
llmMode: mode === 'flow' ? 'full' : 'hybrid',
|
|
67
|
+
contextText,
|
|
68
|
+
timeoutMs,
|
|
69
|
+
});
|
|
70
|
+
console.log(' Flow nodes:', flowJson?.nodes?.length ?? 0);
|
|
71
|
+
if (target === 'code' || target === 'both') {
|
|
72
|
+
flowTs = emitFlowTypeScriptModule(flowJson, { constName: `${toTsConstCase(blueprintId)}Flow` });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.warn(' Flow generation failed, continuing without flow:', error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const blueprint = {
|
|
80
|
+
id: blueprintId,
|
|
81
|
+
name: displayName,
|
|
82
|
+
useCase,
|
|
83
|
+
mode,
|
|
84
|
+
target,
|
|
85
|
+
domainAnalysis: {
|
|
86
|
+
...domainAnalysis,
|
|
87
|
+
constraints: domainAnalysis.constraints ?? [],
|
|
88
|
+
},
|
|
89
|
+
selectedTools: toolRecommendations.map(t => t.toolName),
|
|
90
|
+
toolRecommendations,
|
|
91
|
+
toolPolicy: getToolPolicy(toolRecommendations),
|
|
92
|
+
promptLayers,
|
|
93
|
+
evalPlan: {
|
|
94
|
+
scenarios: [
|
|
95
|
+
'happy_path_conversation',
|
|
96
|
+
'tool_failure_recovery',
|
|
97
|
+
'invalid_user_input',
|
|
98
|
+
'policy_refusal',
|
|
99
|
+
'edge_case_handling',
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
generationMeta: {
|
|
103
|
+
generatedAt: new Date().toISOString(),
|
|
104
|
+
model: model ?? 'gpt-5-mini',
|
|
105
|
+
llmRequired: true,
|
|
106
|
+
llmEnabled: true,
|
|
107
|
+
llmMode: mode,
|
|
108
|
+
interactive: options.interactive ?? false,
|
|
109
|
+
clarificationCount: 0,
|
|
110
|
+
clarifications: [],
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
const promptMarkdown = renderSixLayerPromptAsMarkdown(displayName, promptLayers);
|
|
114
|
+
const promptConstName = toTsConstCase(blueprintId);
|
|
115
|
+
const promptTypeScript = renderSixLayerPromptAsTypeScript(promptConstName, promptLayers);
|
|
116
|
+
const artifacts = {
|
|
117
|
+
prompt: promptMarkdown,
|
|
118
|
+
flow: flowJson,
|
|
119
|
+
code: {
|
|
120
|
+
prompt: promptTypeScript,
|
|
121
|
+
flow: flowTs,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const rfcMarkdown = generateRfcMarkdown(blueprint, artifacts, detailLevel);
|
|
125
|
+
artifacts.rfc = rfcMarkdown;
|
|
126
|
+
return {
|
|
127
|
+
blueprint: AgentBlueprintSchema.parse(blueprint),
|
|
128
|
+
artifacts,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"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AAG,gCAAgC,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;IAEzF,MAAM,SAAS,GAAiC;QAC9C,MAAM,EAAE,cAAc;QACtB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,MAAM,EAAE,gBAAgB;YACxB,IAAI,EAAE,MAAM;SACb;KACF,CAAC;IAEF,MAAM,WAAW,GAAG,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IAC3E,SAAS,CAAC,GAAG,GAAG,WAAW,CAAC;IAE5B,OAAO;QACL,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC,SAAS,CAAC;QAChD,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type DomainAnalysis, type ToolRecommendation, type SixLayerPrompt } from './types.js';
|
|
2
|
+
export interface PromptGeneratorOptions {
|
|
3
|
+
model?: string;
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function generateSixLayerPrompt(agentName: string, useCase: string, domainAnalysis: DomainAnalysis, toolRecommendations: ToolRecommendation[], mode: 'llm' | 'flow' | 'hybrid', options?: PromptGeneratorOptions): Promise<SixLayerPrompt>;
|
|
7
|
+
export declare function renderSixLayerPromptAsMarkdown(agentName: string, prompt: SixLayerPrompt): string;
|
|
8
|
+
export declare function renderSixLayerPromptAsTypeScript(constName: string, prompt: SixLayerPrompt): string;
|
|
9
|
+
//# sourceMappingURL=prompt-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-generator.d.ts","sourceRoot":"","sources":["../../src/agent-architect/prompt-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAwB,MAAM,YAAY,CAAC;AAqGrH,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,cAAc,EAC9B,mBAAmB,EAAE,kBAAkB,EAAE,EACzC,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,EAC/B,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,cAAc,CAAC,CA8BzB;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,cAAc,GACrB,MAAM,CA6BR;AAED,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,cAAc,GACrB,MAAM,CAMR"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { generateObject } from 'ai';
|
|
2
|
+
import { openai } from '@ai-sdk/openai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { SixLayerPromptSchema } from './types.js';
|
|
5
|
+
const SixLayerPromptLLMSchema = z.object({
|
|
6
|
+
identityAndRole: z.object({
|
|
7
|
+
name: z.string().describe('Layer identifier'),
|
|
8
|
+
content: z.string().describe('The actual prompt text for this layer'),
|
|
9
|
+
purpose: z.string().describe('Why this layer exists'),
|
|
10
|
+
}),
|
|
11
|
+
safetyAndGuardrails: z.object({
|
|
12
|
+
name: z.string().describe('Layer identifier'),
|
|
13
|
+
content: z.string().describe('The actual prompt text for this layer'),
|
|
14
|
+
purpose: z.string().describe('Why this layer exists'),
|
|
15
|
+
}),
|
|
16
|
+
toolContract: z.object({
|
|
17
|
+
name: z.string().describe('Layer identifier'),
|
|
18
|
+
content: z.string().describe('The actual prompt text for this layer'),
|
|
19
|
+
purpose: z.string().describe('Why this layer exists'),
|
|
20
|
+
}),
|
|
21
|
+
reasoningWorkflow: z.object({
|
|
22
|
+
name: z.string().describe('Layer identifier'),
|
|
23
|
+
content: z.string().describe('The actual prompt text for this layer'),
|
|
24
|
+
purpose: z.string().describe('Why this layer exists'),
|
|
25
|
+
}),
|
|
26
|
+
executionPolicy: z.object({
|
|
27
|
+
name: z.string().describe('Layer identifier'),
|
|
28
|
+
content: z.string().describe('The actual prompt text for this layer'),
|
|
29
|
+
purpose: z.string().describe('Why this layer exists'),
|
|
30
|
+
}),
|
|
31
|
+
outputConstraints: z.object({
|
|
32
|
+
name: z.string().describe('Layer identifier'),
|
|
33
|
+
content: z.string().describe('The actual prompt text for this layer'),
|
|
34
|
+
purpose: z.string().describe('Why this layer exists'),
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
function resolveModel(modelInput) {
|
|
38
|
+
const requested = modelInput?.trim() || 'gpt-5-mini';
|
|
39
|
+
const modelId = requested.startsWith('openai:') ? requested.slice('openai:'.length).trim() : requested;
|
|
40
|
+
return openai(modelId || 'gpt-5-mini');
|
|
41
|
+
}
|
|
42
|
+
function buildPromptGenerationPrompt(agentName, useCase, domainAnalysis, toolRecommendations, mode) {
|
|
43
|
+
const toolsList = toolRecommendations.map(t => `- ${t.toolName}: ${t.description} (${t.priority})`).join('\n');
|
|
44
|
+
return `Generate a 6-layer system prompt for a conversational AI agent.
|
|
45
|
+
|
|
46
|
+
## Agent Identity
|
|
47
|
+
- Name: ${agentName}
|
|
48
|
+
- Use Case: ${useCase}
|
|
49
|
+
|
|
50
|
+
## Domain Analysis
|
|
51
|
+
- Domain: ${domainAnalysis.domain}
|
|
52
|
+
${domainAnalysis.subDomain ? `- Sub-domain: ${domainAnalysis.subDomain}` : ''}
|
|
53
|
+
- Entities: ${domainAnalysis.entities.join(', ')}
|
|
54
|
+
- Workflows: ${domainAnalysis.workflows.join(', ')}
|
|
55
|
+
- User Intents: ${domainAnalysis.userIntents.join(', ')}
|
|
56
|
+
- Key Outcomes: ${domainAnalysis.keyOutcomes.join(', ')}
|
|
57
|
+
|
|
58
|
+
## Recommended Tools
|
|
59
|
+
${toolsList}
|
|
60
|
+
|
|
61
|
+
## Agent Mode
|
|
62
|
+
${mode === 'llm' ? 'Pure LLM agent - uses tools but no structured flow' : mode === 'flow' ? 'Flow-based agent - follows structured conversation flow' : 'Hybrid agent - flow with LLM detours'}
|
|
63
|
+
|
|
64
|
+
## Your Task
|
|
65
|
+
Generate each of the 6 prompt layers:
|
|
66
|
+
|
|
67
|
+
### Layer 1: Identity and Role
|
|
68
|
+
Who is the agent? What is its purpose? What tone should it use?
|
|
69
|
+
|
|
70
|
+
### Layer 2: Safety and Guardrails
|
|
71
|
+
What should the agent NEVER do? What are the safety constraints? When should it escalate?
|
|
72
|
+
|
|
73
|
+
### Layer 3: Tool Contract
|
|
74
|
+
What tools are available? When should each be used? What happens on tool failure?
|
|
75
|
+
|
|
76
|
+
### Layer 4: Reasoning Workflow
|
|
77
|
+
How should the agent think through conversations? What questions to ask? In what order?
|
|
78
|
+
|
|
79
|
+
### Layer 5: Execution Policy
|
|
80
|
+
How does the agent behave in ${mode} mode? What are the rules for tool calls vs user messages?
|
|
81
|
+
|
|
82
|
+
### Layer 6: Output Constraints
|
|
83
|
+
How should responses be formatted? What verification steps before final actions?
|
|
84
|
+
|
|
85
|
+
For each layer, provide:
|
|
86
|
+
- name: Layer identifier
|
|
87
|
+
- content: The actual prompt text
|
|
88
|
+
- purpose: Why this layer exists
|
|
89
|
+
|
|
90
|
+
Make the prompts specific to this use case, not generic templates.`;
|
|
91
|
+
}
|
|
92
|
+
export async function generateSixLayerPrompt(agentName, useCase, domainAnalysis, toolRecommendations, mode, options = {}) {
|
|
93
|
+
const model = resolveModel(options.model);
|
|
94
|
+
const timeoutMs = options.timeoutMs ?? 60000;
|
|
95
|
+
if (!process.env.OPENAI_API_KEY) {
|
|
96
|
+
throw new Error('OPENAI_API_KEY is required for LLM prompt generation');
|
|
97
|
+
}
|
|
98
|
+
const result = await Promise.race([
|
|
99
|
+
generateObject({
|
|
100
|
+
model,
|
|
101
|
+
schema: SixLayerPromptLLMSchema,
|
|
102
|
+
system: `You are an expert prompt engineer for conversational AI agents.
|
|
103
|
+
Generate 6-layer system prompts based on the OpenAI-inspired context model:
|
|
104
|
+
1. Identity and Role
|
|
105
|
+
2. Safety and Guardrails
|
|
106
|
+
3. Tool Contract
|
|
107
|
+
4. Reasoning Workflow
|
|
108
|
+
5. Execution Policy
|
|
109
|
+
6. Output Constraints
|
|
110
|
+
|
|
111
|
+
Each layer should be specific to the use case, not generic.`,
|
|
112
|
+
prompt: buildPromptGenerationPrompt(agentName, useCase, domainAnalysis, toolRecommendations, mode),
|
|
113
|
+
}),
|
|
114
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`Prompt generation timed out after ${timeoutMs}ms`)), timeoutMs)),
|
|
115
|
+
]);
|
|
116
|
+
return SixLayerPromptSchema.parse(result.object);
|
|
117
|
+
}
|
|
118
|
+
export function renderSixLayerPromptAsMarkdown(agentName, prompt) {
|
|
119
|
+
return [
|
|
120
|
+
`# ${agentName} System Prompt`,
|
|
121
|
+
'',
|
|
122
|
+
`## 1. Identity and Role`,
|
|
123
|
+
'',
|
|
124
|
+
prompt.identityAndRole.content,
|
|
125
|
+
'',
|
|
126
|
+
`## 2. Safety and Guardrails`,
|
|
127
|
+
'',
|
|
128
|
+
prompt.safetyAndGuardrails.content,
|
|
129
|
+
'',
|
|
130
|
+
`## 3. Tool Contract`,
|
|
131
|
+
'',
|
|
132
|
+
prompt.toolContract.content,
|
|
133
|
+
'',
|
|
134
|
+
`## 4. Reasoning Workflow`,
|
|
135
|
+
'',
|
|
136
|
+
prompt.reasoningWorkflow.content,
|
|
137
|
+
'',
|
|
138
|
+
`## 5. Execution Policy`,
|
|
139
|
+
'',
|
|
140
|
+
prompt.executionPolicy.content,
|
|
141
|
+
'',
|
|
142
|
+
`## 6. Output Constraints`,
|
|
143
|
+
'',
|
|
144
|
+
prompt.outputConstraints.content,
|
|
145
|
+
'',
|
|
146
|
+
].join('\n');
|
|
147
|
+
}
|
|
148
|
+
export function renderSixLayerPromptAsTypeScript(constName, prompt) {
|
|
149
|
+
const serialized = JSON.stringify(prompt, null, 2);
|
|
150
|
+
return `export const ${constName}SystemPrompt = ${serialized} as const;
|
|
151
|
+
|
|
152
|
+
export default ${constName}SystemPrompt;
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=prompt-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-generator.js","sourceRoot":"","sources":["../../src/agent-architect/prompt-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAqE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAErH,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC;QACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC7C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;QACrE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;KACtD,CAAC;IACF,mBAAmB,EAAE,CAAC,CAAC,MAAM,CAAC;QAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC7C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;QACrE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;KACtD,CAAC;IACF,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC7C,OAAO,EAAE,CAAC,CAAC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QAChC,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,SAAiB,EACjB,MAAsB;IAEtB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACnD,OAAO,gBAAgB,SAAS,kBAAkB,UAAU;;iBAE7C,SAAS;CACzB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type AgentBlueprint, type DetailLevel } from './types.js';
|
|
2
|
+
export declare function generateRfcMarkdown(blueprint: AgentBlueprint, artifacts: {
|
|
3
|
+
prompt?: string;
|
|
4
|
+
flow?: object;
|
|
5
|
+
}, detailLevel?: DetailLevel): string;
|
|
6
|
+
export declare function generateToolSpecifications(recommendations: {
|
|
7
|
+
toolName: string;
|
|
8
|
+
description: string;
|
|
9
|
+
whenToUse: string;
|
|
10
|
+
onError?: string;
|
|
11
|
+
}[]): Array<{
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: Record<string, unknown>;
|
|
15
|
+
outputSchema: Record<string, unknown>;
|
|
16
|
+
integrationSteps: string[];
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=rfc-emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rfc-emitter.d.ts","sourceRoot":"","sources":["../../src/agent-architect/rfc-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAgHnE,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,cAAc,EACzB,SAAS,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7C,WAAW,GAAE,WAAwB,GACpC,MAAM,CAmIR;AAED,wBAAgB,0BAA0B,CACxC,eAAe,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GAChG,KAAK,CAAC;IACP,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC,CAQD"}
|