@agent-native/core 0.7.30 → 0.7.31
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/a2a/artifact-response.d.ts +9 -0
- package/dist/a2a/artifact-response.d.ts.map +1 -0
- package/dist/a2a/artifact-response.js +154 -0
- package/dist/a2a/artifact-response.js.map +1 -0
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +3 -0
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/workspacify.d.ts.map +1 -1
- package/dist/cli/workspacify.js +5 -0
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/deploy/workspace-deploy.js +0 -7
- package/dist/deploy/workspace-deploy.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +27 -1
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/builder-browser.d.ts +0 -1
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +14 -15
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/templates/default/package.json +2 -1
- package/dist/templates/workspace-root/package.json +2 -1
- package/package.json +1 -1
- package/src/templates/default/package.json +2 -1
- package/src/templates/workspace-root/package.json +2 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface A2AToolResultSummary {
|
|
2
|
+
tool: string;
|
|
3
|
+
result: string;
|
|
4
|
+
}
|
|
5
|
+
export interface A2AArtifactResponseOptions {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function appendA2AArtifactLinks(responseText: string, toolResults: A2AToolResultSummary[], options?: A2AArtifactResponseOptions): string;
|
|
9
|
+
//# sourceMappingURL=artifact-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-response.d.ts","sourceRoot":"","sources":["../../src/a2a/artifact-response.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA6KD,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,oBAAoB,EAAE,EACnC,OAAO,GAAE,0BAA+B,GACvC,MAAM,CA0CR"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
function asRecord(value) {
|
|
2
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
3
|
+
? value
|
|
4
|
+
: null;
|
|
5
|
+
}
|
|
6
|
+
function stringValue(value) {
|
|
7
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
8
|
+
}
|
|
9
|
+
function parseToolResultJson(result) {
|
|
10
|
+
const trimmed = result.trim();
|
|
11
|
+
if (!trimmed || /^Error(?:\s|:)/i.test(trimmed))
|
|
12
|
+
return null;
|
|
13
|
+
try {
|
|
14
|
+
return asRecord(JSON.parse(trimmed));
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Dev shell wrappers may include console output before the returned JSON.
|
|
18
|
+
const firstBrace = trimmed.indexOf("{");
|
|
19
|
+
const lastBrace = trimmed.lastIndexOf("}");
|
|
20
|
+
if (firstBrace < 0 || lastBrace <= firstBrace)
|
|
21
|
+
return null;
|
|
22
|
+
try {
|
|
23
|
+
return asRecord(JSON.parse(trimmed.slice(firstBrace, lastBrace + 1)));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function normalizeBaseUrl(baseUrl) {
|
|
31
|
+
const trimmed = baseUrl?.trim();
|
|
32
|
+
return trimmed ? trimmed.replace(/\/+$/, "") : undefined;
|
|
33
|
+
}
|
|
34
|
+
function artifactUrl(baseUrl, path) {
|
|
35
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
36
|
+
return base ? `${base}${path}` : path;
|
|
37
|
+
}
|
|
38
|
+
function responseAlreadyMentionsPath(text, path) {
|
|
39
|
+
return text.includes(path);
|
|
40
|
+
}
|
|
41
|
+
function responseMentionsDesignShell(text, shell) {
|
|
42
|
+
if (!text.trim())
|
|
43
|
+
return true;
|
|
44
|
+
return text.includes(shell.id) || text.includes(`/design/${shell.id}`);
|
|
45
|
+
}
|
|
46
|
+
function responseAlreadyWarnsIncompleteDesign(text) {
|
|
47
|
+
return /(?:not ready|still working|processing|no renderable|no files|failed|could not|cannot|can't)/i.test(text);
|
|
48
|
+
}
|
|
49
|
+
function collectArtifacts(results) {
|
|
50
|
+
const documents = new Map();
|
|
51
|
+
const designShells = new Map();
|
|
52
|
+
const generatedDesigns = new Map();
|
|
53
|
+
for (const toolResult of results) {
|
|
54
|
+
const parsed = parseToolResultJson(toolResult.result);
|
|
55
|
+
if (!parsed)
|
|
56
|
+
continue;
|
|
57
|
+
if (toolResult.tool === "create-document") {
|
|
58
|
+
const id = stringValue(parsed.id);
|
|
59
|
+
if (id) {
|
|
60
|
+
documents.set(id, { id, title: stringValue(parsed.title) });
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (toolResult.tool === "create-design") {
|
|
65
|
+
const id = stringValue(parsed.id);
|
|
66
|
+
if (id) {
|
|
67
|
+
designShells.set(id, { id, title: stringValue(parsed.title) });
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (toolResult.tool === "generate-design") {
|
|
72
|
+
const id = stringValue(parsed.designId);
|
|
73
|
+
if (!id)
|
|
74
|
+
continue;
|
|
75
|
+
const savedFiles = Array.isArray(parsed.savedFiles)
|
|
76
|
+
? parsed.savedFiles
|
|
77
|
+
: [];
|
|
78
|
+
const rawFileCount = parsed.fileCount;
|
|
79
|
+
const fileCount = typeof rawFileCount === "number" && Number.isFinite(rawFileCount)
|
|
80
|
+
? rawFileCount
|
|
81
|
+
: savedFiles.length;
|
|
82
|
+
if (fileCount > 0) {
|
|
83
|
+
generatedDesigns.set(id, { id, fileCount });
|
|
84
|
+
}
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (toolResult.tool === "create-file") {
|
|
88
|
+
const id = stringValue(parsed.designId);
|
|
89
|
+
if (!id)
|
|
90
|
+
continue;
|
|
91
|
+
const renderable = parsed.renderable === true ||
|
|
92
|
+
stringValue(parsed.fileType) === "html" ||
|
|
93
|
+
stringValue(parsed.fileType) === "jsx";
|
|
94
|
+
if (renderable) {
|
|
95
|
+
const previous = generatedDesigns.get(id);
|
|
96
|
+
generatedDesigns.set(id, {
|
|
97
|
+
id,
|
|
98
|
+
fileCount: (previous?.fileCount ?? 0) + 1,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
documents: [...documents.values()],
|
|
105
|
+
designShells: [...designShells.values()],
|
|
106
|
+
generatedDesigns: [...generatedDesigns.values()],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function formatDocumentLine(document, baseUrl) {
|
|
110
|
+
const label = document.title ? `Document "${document.title}"` : "Document";
|
|
111
|
+
return `- ${label}: ${artifactUrl(baseUrl, `/page/${document.id}`)} (ID: ${document.id})`;
|
|
112
|
+
}
|
|
113
|
+
function formatDesignLine(design, baseUrl) {
|
|
114
|
+
const fileLabel = design.fileCount === 1 ? "1 file" : `${design.fileCount} files`;
|
|
115
|
+
return `- Design: ${artifactUrl(baseUrl, `/design/${design.id}`)} (ID: ${design.id}, ${fileLabel})`;
|
|
116
|
+
}
|
|
117
|
+
function formatIncompleteDesignMessage(shells) {
|
|
118
|
+
const ids = shells.map((shell) => shell.id).join(", ");
|
|
119
|
+
const noun = shells.length === 1 ? "project shell" : "project shells";
|
|
120
|
+
return (`The design is not ready yet. Design ${noun} ${ids} ` +
|
|
121
|
+
"exists, but no renderable files were saved, so I cannot return it as a completed artifact.");
|
|
122
|
+
}
|
|
123
|
+
export function appendA2AArtifactLinks(responseText, toolResults, options = {}) {
|
|
124
|
+
const baseUrl = normalizeBaseUrl(options.baseUrl);
|
|
125
|
+
const { documents, designShells, generatedDesigns } = collectArtifacts(toolResults);
|
|
126
|
+
const generatedDesignIds = new Set(generatedDesigns.map((design) => design.id));
|
|
127
|
+
const incompleteShells = designShells.filter((shell) => !generatedDesignIds.has(shell.id));
|
|
128
|
+
let text = responseText.trim() === "(no response)" ? "" : responseText.trim();
|
|
129
|
+
if (generatedDesigns.length === 0 &&
|
|
130
|
+
incompleteShells.length > 0 &&
|
|
131
|
+
!responseAlreadyWarnsIncompleteDesign(text) &&
|
|
132
|
+
(incompleteShells.some((shell) => responseMentionsDesignShell(text, shell)) ||
|
|
133
|
+
/\b(?:done|created|ready|here(?:'s| is)|complete|finished)\b/i.test(text))) {
|
|
134
|
+
return formatIncompleteDesignMessage(incompleteShells);
|
|
135
|
+
}
|
|
136
|
+
const missingLines = [];
|
|
137
|
+
for (const document of documents) {
|
|
138
|
+
const path = `/page/${document.id}`;
|
|
139
|
+
if (!responseAlreadyMentionsPath(text, path)) {
|
|
140
|
+
missingLines.push(formatDocumentLine(document, baseUrl));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
for (const design of generatedDesigns) {
|
|
144
|
+
const path = `/design/${design.id}`;
|
|
145
|
+
if (!responseAlreadyMentionsPath(text, path)) {
|
|
146
|
+
missingLines.push(formatDesignLine(design, baseUrl));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (missingLines.length === 0)
|
|
150
|
+
return text;
|
|
151
|
+
const artifactBlock = `Artifacts:\n${missingLines.join("\n")}`;
|
|
152
|
+
return text ? `${text}\n\n${artifactBlock}` : artifactBlock;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=artifact-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-response.js","sourceRoot":"","sources":["../../src/a2a/artifact-response.ts"],"names":[],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","sourcesContent":["export interface A2AToolResultSummary {\n tool: string;\n result: string;\n}\n\nexport interface A2AArtifactResponseOptions {\n baseUrl?: string;\n}\n\ninterface CreatedDocumentArtifact {\n id: string;\n title?: string;\n}\n\ninterface CreatedDesignShell {\n id: string;\n title?: string;\n}\n\ninterface GeneratedDesignArtifact {\n id: string;\n fileCount: number;\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null;\n}\n\nfunction stringValue(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction parseToolResultJson(result: string): Record<string, unknown> | null {\n const trimmed = result.trim();\n if (!trimmed || /^Error(?:\\s|:)/i.test(trimmed)) return null;\n\n try {\n return asRecord(JSON.parse(trimmed));\n } catch {\n // Dev shell wrappers may include console output before the returned JSON.\n const firstBrace = trimmed.indexOf(\"{\");\n const lastBrace = trimmed.lastIndexOf(\"}\");\n if (firstBrace < 0 || lastBrace <= firstBrace) return null;\n try {\n return asRecord(JSON.parse(trimmed.slice(firstBrace, lastBrace + 1)));\n } catch {\n return null;\n }\n }\n}\n\nfunction normalizeBaseUrl(baseUrl: string | undefined): string | undefined {\n const trimmed = baseUrl?.trim();\n return trimmed ? trimmed.replace(/\\/+$/, \"\") : undefined;\n}\n\nfunction artifactUrl(baseUrl: string | undefined, path: string): string {\n const base = normalizeBaseUrl(baseUrl);\n return base ? `${base}${path}` : path;\n}\n\nfunction responseAlreadyMentionsPath(text: string, path: string): boolean {\n return text.includes(path);\n}\n\nfunction responseMentionsDesignShell(\n text: string,\n shell: CreatedDesignShell,\n): boolean {\n if (!text.trim()) return true;\n return text.includes(shell.id) || text.includes(`/design/${shell.id}`);\n}\n\nfunction responseAlreadyWarnsIncompleteDesign(text: string): boolean {\n return /(?:not ready|still working|processing|no renderable|no files|failed|could not|cannot|can't)/i.test(\n text,\n );\n}\n\nfunction collectArtifacts(results: A2AToolResultSummary[]): {\n documents: CreatedDocumentArtifact[];\n designShells: CreatedDesignShell[];\n generatedDesigns: GeneratedDesignArtifact[];\n} {\n const documents = new Map<string, CreatedDocumentArtifact>();\n const designShells = new Map<string, CreatedDesignShell>();\n const generatedDesigns = new Map<string, GeneratedDesignArtifact>();\n\n for (const toolResult of results) {\n const parsed = parseToolResultJson(toolResult.result);\n if (!parsed) continue;\n\n if (toolResult.tool === \"create-document\") {\n const id = stringValue(parsed.id);\n if (id) {\n documents.set(id, { id, title: stringValue(parsed.title) });\n }\n continue;\n }\n\n if (toolResult.tool === \"create-design\") {\n const id = stringValue(parsed.id);\n if (id) {\n designShells.set(id, { id, title: stringValue(parsed.title) });\n }\n continue;\n }\n\n if (toolResult.tool === \"generate-design\") {\n const id = stringValue(parsed.designId);\n if (!id) continue;\n\n const savedFiles = Array.isArray(parsed.savedFiles)\n ? parsed.savedFiles\n : [];\n const rawFileCount = parsed.fileCount;\n const fileCount =\n typeof rawFileCount === \"number\" && Number.isFinite(rawFileCount)\n ? rawFileCount\n : savedFiles.length;\n\n if (fileCount > 0) {\n generatedDesigns.set(id, { id, fileCount });\n }\n continue;\n }\n\n if (toolResult.tool === \"create-file\") {\n const id = stringValue(parsed.designId);\n if (!id) continue;\n const renderable =\n parsed.renderable === true ||\n stringValue(parsed.fileType) === \"html\" ||\n stringValue(parsed.fileType) === \"jsx\";\n\n if (renderable) {\n const previous = generatedDesigns.get(id);\n generatedDesigns.set(id, {\n id,\n fileCount: (previous?.fileCount ?? 0) + 1,\n });\n }\n }\n }\n\n return {\n documents: [...documents.values()],\n designShells: [...designShells.values()],\n generatedDesigns: [...generatedDesigns.values()],\n };\n}\n\nfunction formatDocumentLine(\n document: CreatedDocumentArtifact,\n baseUrl: string | undefined,\n): string {\n const label = document.title ? `Document \"${document.title}\"` : \"Document\";\n return `- ${label}: ${artifactUrl(baseUrl, `/page/${document.id}`)} (ID: ${document.id})`;\n}\n\nfunction formatDesignLine(\n design: GeneratedDesignArtifact,\n baseUrl: string | undefined,\n): string {\n const fileLabel =\n design.fileCount === 1 ? \"1 file\" : `${design.fileCount} files`;\n return `- Design: ${artifactUrl(baseUrl, `/design/${design.id}`)} (ID: ${design.id}, ${fileLabel})`;\n}\n\nfunction formatIncompleteDesignMessage(shells: CreatedDesignShell[]): string {\n const ids = shells.map((shell) => shell.id).join(\", \");\n const noun = shells.length === 1 ? \"project shell\" : \"project shells\";\n return (\n `The design is not ready yet. Design ${noun} ${ids} ` +\n \"exists, but no renderable files were saved, so I cannot return it as a completed artifact.\"\n );\n}\n\nexport function appendA2AArtifactLinks(\n responseText: string,\n toolResults: A2AToolResultSummary[],\n options: A2AArtifactResponseOptions = {},\n): string {\n const baseUrl = normalizeBaseUrl(options.baseUrl);\n const { documents, designShells, generatedDesigns } =\n collectArtifacts(toolResults);\n const generatedDesignIds = new Set(\n generatedDesigns.map((design) => design.id),\n );\n const incompleteShells = designShells.filter(\n (shell) => !generatedDesignIds.has(shell.id),\n );\n\n let text = responseText.trim() === \"(no response)\" ? \"\" : responseText.trim();\n\n if (\n generatedDesigns.length === 0 &&\n incompleteShells.length > 0 &&\n !responseAlreadyWarnsIncompleteDesign(text) &&\n (incompleteShells.some((shell) =>\n responseMentionsDesignShell(text, shell),\n ) ||\n /\\b(?:done|created|ready|here(?:'s| is)|complete|finished)\\b/i.test(text))\n ) {\n return formatIncompleteDesignMessage(incompleteShells);\n }\n\n const missingLines: string[] = [];\n for (const document of documents) {\n const path = `/page/${document.id}`;\n if (!responseAlreadyMentionsPath(text, path)) {\n missingLines.push(formatDocumentLine(document, baseUrl));\n }\n }\n for (const design of generatedDesigns) {\n const path = `/design/${design.id}`;\n if (!responseAlreadyMentionsPath(text, path)) {\n missingLines.push(formatDesignLine(design, baseUrl));\n }\n }\n\n if (missingLines.length === 0) return text;\n const artifactBlock = `Artifacts:\\n${missingLines.join(\"\\n\")}`;\n return text ? `${text}\\n\\n${artifactBlock}` : artifactBlock;\n}\n"]}
|
package/dist/cli/create.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/cli/create.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/cli/create.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAiCvE,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAkGD,iBAAe,qBAAqB,CAClC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAqCf;AAMD;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CAkCf;AA8HD;;;;;GAKG;AACH,iBAAe,mBAAmB,CAChC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAuCf;AAsCD;;;;GAIG;AACH,iBAAe,wBAAwB,CACrC,aAAa,EAAE,MAAM,EAAE,EACvB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CA2Ef;AAED;;;GAGG;AACH,iBAAS,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAoEpE;AAgHD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GACf;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkB7D;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,yCAAyC;AACzC,OAAO,EACL,qBAAqB,IAAI,sBAAsB,EAC/C,mBAAmB,IAAI,oBAAoB,EAC3C,wBAAwB,IAAI,yBAAyB,EACrD,qBAAqB,IAAI,sBAAsB,EAC/C,WAAW,IAAI,YAAY,EAC3B,kBAAkB,IAAI,mBAAmB,EACzC,eAAe,IAAI,gBAAgB,EACnC,kBAAkB,IAAI,mBAAmB,EACzC,wBAAwB,IAAI,yBAAyB,EACrD,oBAAoB,IAAI,qBAAqB,EAC7C,uBAAuB,IAAI,wBAAwB,GACpD,CAAC;AAkEF;;;;;GAKG;AACH,iBAAS,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+B7C;AASD,iBAAS,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAQ9D;AAED,iBAAS,wBAAwB,IAAI,MAAM,CAW1C;AAcD,iBAAS,oBAAoB,IAAI,MAAM,CAMtC;AAiID,iBAAS,kBAAkB,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,YAAY,GAAG,WAAW,GAC/B,IAAI,CA0CN;AA2BD,iBAAS,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAyED,iBAAS,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CA0BxE"}
|
package/dist/cli/create.js
CHANGED
|
@@ -9,6 +9,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
const REPO = "BuilderIO/agent-native";
|
|
11
11
|
const TEMPLATES_DIR = "templates";
|
|
12
|
+
const POSTGRES_DEPENDENCY_VERSION = "^3.4.9";
|
|
12
13
|
/**
|
|
13
14
|
* Move "starter" to the top of the list so it lines up with clack's default
|
|
14
15
|
* highlight on the first option — otherwise users have to scroll to see that
|
|
@@ -508,6 +509,8 @@ function postProcessStandalone(name, targetDir) {
|
|
|
508
509
|
// Ensure pnpm.onlyBuiltDependencies is set so native packages
|
|
509
510
|
// (better-sqlite3, esbuild, node-pty) compile their postinstall scripts
|
|
510
511
|
// under pnpm 10+ without prompting for `pnpm approve-builds`.
|
|
512
|
+
pkg.dependencies = pkg.dependencies ?? {};
|
|
513
|
+
pkg.dependencies.postgres ??= POSTGRES_DEPENDENCY_VERSION;
|
|
511
514
|
const requiredBuilt = ["better-sqlite3", "esbuild", "node-pty"];
|
|
512
515
|
if (!pkg.pnpm || typeof pkg.pnpm !== "object") {
|
|
513
516
|
pkg.pnpm = {};
|