@inkeep/agents-run-api 0.23.3 → 0.23.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +68 -5
- package/dist/index.js +68 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -12069,7 +12069,17 @@ var generatePreviewRoute = zodOpenapi.createRoute({
|
|
|
12069
12069
|
tenantId: z6.z.string(),
|
|
12070
12070
|
projectId: z6.z.string(),
|
|
12071
12071
|
id: z6.z.string()
|
|
12072
|
-
})
|
|
12072
|
+
}),
|
|
12073
|
+
body: {
|
|
12074
|
+
content: {
|
|
12075
|
+
"application/json": {
|
|
12076
|
+
schema: z6.z.object({
|
|
12077
|
+
instructions: z6.z.string().optional().describe("Custom instructions for modifying the component"),
|
|
12078
|
+
existingCode: z6.z.string().optional().describe("Existing component code to modify")
|
|
12079
|
+
})
|
|
12080
|
+
}
|
|
12081
|
+
}
|
|
12082
|
+
}
|
|
12073
12083
|
},
|
|
12074
12084
|
responses: {
|
|
12075
12085
|
200: {
|
|
@@ -12090,7 +12100,18 @@ var generatePreviewRoute = zodOpenapi.createRoute({
|
|
|
12090
12100
|
});
|
|
12091
12101
|
app4.openapi(generatePreviewRoute, async (c) => {
|
|
12092
12102
|
const { tenantId, projectId, id } = c.req.valid("param");
|
|
12093
|
-
|
|
12103
|
+
const body = c.req.valid("json");
|
|
12104
|
+
const { instructions, existingCode } = body;
|
|
12105
|
+
logger26.info(
|
|
12106
|
+
{
|
|
12107
|
+
tenantId,
|
|
12108
|
+
projectId,
|
|
12109
|
+
dataComponentId: id,
|
|
12110
|
+
hasInstructions: !!instructions,
|
|
12111
|
+
hasExistingCode: !!existingCode
|
|
12112
|
+
},
|
|
12113
|
+
"Generating component preview"
|
|
12114
|
+
);
|
|
12094
12115
|
const dataComponent = await agentsCore.getDataComponent(dbClient_default)({
|
|
12095
12116
|
scopes: { tenantId, projectId },
|
|
12096
12117
|
dataComponentId: id
|
|
@@ -12110,7 +12131,7 @@ app4.openapi(generatePreviewRoute, async (c) => {
|
|
|
12110
12131
|
message: "Project base model configuration is required"
|
|
12111
12132
|
});
|
|
12112
12133
|
}
|
|
12113
|
-
const prompt = buildGenerationPrompt(dataComponent);
|
|
12134
|
+
const prompt = buildGenerationPrompt(dataComponent, instructions, existingCode);
|
|
12114
12135
|
try {
|
|
12115
12136
|
const modelConfig = ModelFactory.prepareGenerationConfig(project.models.base);
|
|
12116
12137
|
const previewSchema = z6.z.object({
|
|
@@ -12126,10 +12147,12 @@ app4.openapi(generatePreviewRoute, async (c) => {
|
|
|
12126
12147
|
c.header("Content-Type", "text/plain; charset=utf-8");
|
|
12127
12148
|
c.header("Cache-Control", "no-cache");
|
|
12128
12149
|
c.header("Connection", "keep-alive");
|
|
12150
|
+
const existingData = existingCode && dataComponent.preview?.data ? dataComponent.preview.data : null;
|
|
12129
12151
|
return streaming.stream(c, async (stream3) => {
|
|
12130
12152
|
try {
|
|
12131
12153
|
for await (const partialObject of result.partialObjectStream) {
|
|
12132
|
-
|
|
12154
|
+
const outputObject = instructions && existingData ? { ...partialObject, data: existingData } : partialObject;
|
|
12155
|
+
await stream3.write(JSON.stringify(outputObject) + "\n");
|
|
12133
12156
|
}
|
|
12134
12157
|
} catch (error) {
|
|
12135
12158
|
logger26.error(
|
|
@@ -12152,10 +12175,50 @@ app4.openapi(generatePreviewRoute, async (c) => {
|
|
|
12152
12175
|
});
|
|
12153
12176
|
}
|
|
12154
12177
|
});
|
|
12155
|
-
function buildGenerationPrompt(dataComponent) {
|
|
12178
|
+
function buildGenerationPrompt(dataComponent, instructions, existingCode) {
|
|
12156
12179
|
const propsSchema = dataComponent.props || {};
|
|
12157
12180
|
const propsJson = JSON.stringify(propsSchema, null, 2);
|
|
12158
12181
|
const componentName = sanitizeComponentName(dataComponent.name);
|
|
12182
|
+
if (instructions && existingCode) {
|
|
12183
|
+
return `You are an expert React and Tailwind CSS developer. You need to modify an existing React component based on specific instructions.
|
|
12184
|
+
|
|
12185
|
+
COMPONENT DETAILS:
|
|
12186
|
+
- Original Name: ${dataComponent.name}
|
|
12187
|
+
- Component Function Name: ${componentName}
|
|
12188
|
+
- Description: ${dataComponent.description}
|
|
12189
|
+
- Props Schema (JSON Schema): ${propsJson}
|
|
12190
|
+
|
|
12191
|
+
EXISTING COMPONENT CODE:
|
|
12192
|
+
\`\`\`jsx
|
|
12193
|
+
${existingCode}
|
|
12194
|
+
\`\`\`
|
|
12195
|
+
|
|
12196
|
+
MODIFICATION INSTRUCTIONS:
|
|
12197
|
+
${instructions}
|
|
12198
|
+
|
|
12199
|
+
REQUIREMENTS:
|
|
12200
|
+
1. Modify the existing component code according to the instructions
|
|
12201
|
+
2. Keep using Tailwind CSS SEMANTIC COLOR CLASSES (bg-background, text-foreground, etc.)
|
|
12202
|
+
3. Maintain the balanced spacing and design principles from the original
|
|
12203
|
+
4. Keep using lucide-react icons where appropriate
|
|
12204
|
+
5. DO NOT include export statements - just the imports and function
|
|
12205
|
+
6. DO NOT include TypeScript type annotations
|
|
12206
|
+
7. Component name should remain: ${componentName}
|
|
12207
|
+
8. DO NOT regenerate sample data - keep the same data structure
|
|
12208
|
+
|
|
12209
|
+
OUTPUT FORMAT:
|
|
12210
|
+
You need to generate only one thing:
|
|
12211
|
+
1. "code": The modified React component code as a string
|
|
12212
|
+
|
|
12213
|
+
Return ONLY the code field, the data field will be reused from the existing preview.
|
|
12214
|
+
|
|
12215
|
+
EXAMPLE OUTPUT:
|
|
12216
|
+
{
|
|
12217
|
+
"code": "import { Mail, User } from 'lucide-react';\\n\\nfunction ${componentName}(props) {\\n // Modified component code here\\n}"
|
|
12218
|
+
}
|
|
12219
|
+
|
|
12220
|
+
Focus on making the requested changes while maintaining the component's quality and design principles.`;
|
|
12221
|
+
}
|
|
12159
12222
|
return `You are an expert React and Tailwind CSS developer. Generate a beautiful, modern React component for displaying data and sample data to preview it.
|
|
12160
12223
|
|
|
12161
12224
|
COMPONENT DETAILS:
|
package/dist/index.js
CHANGED
|
@@ -10576,7 +10576,17 @@ var generatePreviewRoute = createRoute({
|
|
|
10576
10576
|
tenantId: z.string(),
|
|
10577
10577
|
projectId: z.string(),
|
|
10578
10578
|
id: z.string()
|
|
10579
|
-
})
|
|
10579
|
+
}),
|
|
10580
|
+
body: {
|
|
10581
|
+
content: {
|
|
10582
|
+
"application/json": {
|
|
10583
|
+
schema: z.object({
|
|
10584
|
+
instructions: z.string().optional().describe("Custom instructions for modifying the component"),
|
|
10585
|
+
existingCode: z.string().optional().describe("Existing component code to modify")
|
|
10586
|
+
})
|
|
10587
|
+
}
|
|
10588
|
+
}
|
|
10589
|
+
}
|
|
10580
10590
|
},
|
|
10581
10591
|
responses: {
|
|
10582
10592
|
200: {
|
|
@@ -10597,7 +10607,18 @@ var generatePreviewRoute = createRoute({
|
|
|
10597
10607
|
});
|
|
10598
10608
|
app4.openapi(generatePreviewRoute, async (c) => {
|
|
10599
10609
|
const { tenantId, projectId, id } = c.req.valid("param");
|
|
10600
|
-
|
|
10610
|
+
const body = c.req.valid("json");
|
|
10611
|
+
const { instructions, existingCode } = body;
|
|
10612
|
+
logger22.info(
|
|
10613
|
+
{
|
|
10614
|
+
tenantId,
|
|
10615
|
+
projectId,
|
|
10616
|
+
dataComponentId: id,
|
|
10617
|
+
hasInstructions: !!instructions,
|
|
10618
|
+
hasExistingCode: !!existingCode
|
|
10619
|
+
},
|
|
10620
|
+
"Generating component preview"
|
|
10621
|
+
);
|
|
10601
10622
|
const dataComponent = await getDataComponent(dbClient_default)({
|
|
10602
10623
|
scopes: { tenantId, projectId },
|
|
10603
10624
|
dataComponentId: id
|
|
@@ -10617,7 +10638,7 @@ app4.openapi(generatePreviewRoute, async (c) => {
|
|
|
10617
10638
|
message: "Project base model configuration is required"
|
|
10618
10639
|
});
|
|
10619
10640
|
}
|
|
10620
|
-
const prompt = buildGenerationPrompt(dataComponent);
|
|
10641
|
+
const prompt = buildGenerationPrompt(dataComponent, instructions, existingCode);
|
|
10621
10642
|
try {
|
|
10622
10643
|
const modelConfig = ModelFactory.prepareGenerationConfig(project.models.base);
|
|
10623
10644
|
const previewSchema = z.object({
|
|
@@ -10633,10 +10654,12 @@ app4.openapi(generatePreviewRoute, async (c) => {
|
|
|
10633
10654
|
c.header("Content-Type", "text/plain; charset=utf-8");
|
|
10634
10655
|
c.header("Cache-Control", "no-cache");
|
|
10635
10656
|
c.header("Connection", "keep-alive");
|
|
10657
|
+
const existingData = existingCode && dataComponent.preview?.data ? dataComponent.preview.data : null;
|
|
10636
10658
|
return stream(c, async (stream3) => {
|
|
10637
10659
|
try {
|
|
10638
10660
|
for await (const partialObject of result.partialObjectStream) {
|
|
10639
|
-
|
|
10661
|
+
const outputObject = instructions && existingData ? { ...partialObject, data: existingData } : partialObject;
|
|
10662
|
+
await stream3.write(JSON.stringify(outputObject) + "\n");
|
|
10640
10663
|
}
|
|
10641
10664
|
} catch (error) {
|
|
10642
10665
|
logger22.error(
|
|
@@ -10659,10 +10682,50 @@ app4.openapi(generatePreviewRoute, async (c) => {
|
|
|
10659
10682
|
});
|
|
10660
10683
|
}
|
|
10661
10684
|
});
|
|
10662
|
-
function buildGenerationPrompt(dataComponent) {
|
|
10685
|
+
function buildGenerationPrompt(dataComponent, instructions, existingCode) {
|
|
10663
10686
|
const propsSchema = dataComponent.props || {};
|
|
10664
10687
|
const propsJson = JSON.stringify(propsSchema, null, 2);
|
|
10665
10688
|
const componentName = sanitizeComponentName(dataComponent.name);
|
|
10689
|
+
if (instructions && existingCode) {
|
|
10690
|
+
return `You are an expert React and Tailwind CSS developer. You need to modify an existing React component based on specific instructions.
|
|
10691
|
+
|
|
10692
|
+
COMPONENT DETAILS:
|
|
10693
|
+
- Original Name: ${dataComponent.name}
|
|
10694
|
+
- Component Function Name: ${componentName}
|
|
10695
|
+
- Description: ${dataComponent.description}
|
|
10696
|
+
- Props Schema (JSON Schema): ${propsJson}
|
|
10697
|
+
|
|
10698
|
+
EXISTING COMPONENT CODE:
|
|
10699
|
+
\`\`\`jsx
|
|
10700
|
+
${existingCode}
|
|
10701
|
+
\`\`\`
|
|
10702
|
+
|
|
10703
|
+
MODIFICATION INSTRUCTIONS:
|
|
10704
|
+
${instructions}
|
|
10705
|
+
|
|
10706
|
+
REQUIREMENTS:
|
|
10707
|
+
1. Modify the existing component code according to the instructions
|
|
10708
|
+
2. Keep using Tailwind CSS SEMANTIC COLOR CLASSES (bg-background, text-foreground, etc.)
|
|
10709
|
+
3. Maintain the balanced spacing and design principles from the original
|
|
10710
|
+
4. Keep using lucide-react icons where appropriate
|
|
10711
|
+
5. DO NOT include export statements - just the imports and function
|
|
10712
|
+
6. DO NOT include TypeScript type annotations
|
|
10713
|
+
7. Component name should remain: ${componentName}
|
|
10714
|
+
8. DO NOT regenerate sample data - keep the same data structure
|
|
10715
|
+
|
|
10716
|
+
OUTPUT FORMAT:
|
|
10717
|
+
You need to generate only one thing:
|
|
10718
|
+
1. "code": The modified React component code as a string
|
|
10719
|
+
|
|
10720
|
+
Return ONLY the code field, the data field will be reused from the existing preview.
|
|
10721
|
+
|
|
10722
|
+
EXAMPLE OUTPUT:
|
|
10723
|
+
{
|
|
10724
|
+
"code": "import { Mail, User } from 'lucide-react';\\n\\nfunction ${componentName}(props) {\\n // Modified component code here\\n}"
|
|
10725
|
+
}
|
|
10726
|
+
|
|
10727
|
+
Focus on making the requested changes while maintaining the component's quality and design principles.`;
|
|
10728
|
+
}
|
|
10666
10729
|
return `You are an expert React and Tailwind CSS developer. Generate a beautiful, modern React component for displaying data and sample data to preview it.
|
|
10667
10730
|
|
|
10668
10731
|
COMPONENT DETAILS:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-run-api",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.4",
|
|
4
4
|
"description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"traverse": "^0.6.11",
|
|
53
53
|
"ts-pattern": "^5.7.1",
|
|
54
54
|
"zod": "^4.1.11",
|
|
55
|
-
"@inkeep/agents-core": "^0.23.
|
|
55
|
+
"@inkeep/agents-core": "^0.23.4"
|
|
56
56
|
},
|
|
57
57
|
"optionalDependencies": {
|
|
58
58
|
"keytar": "^7.9.0"
|