@contentful/experience-design-system-generation 2.26.7-dev-build-cdb420a.0 → 2.26.7-dev-build-6d2ed6d.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-generation",
3
- "version": "2.26.7-dev-build-cdb420a.0",
3
+ "version": "2.26.7-dev-build-6d2ed6d.0",
4
4
  "description": "Agent-invocation and skill-prompt engine for the Contentful Experience Design System SDK",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,24 +1,68 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  export { AGENT_NAMES, DEFAULT_AGENT_NAME, isAgentName } from './agent-names.js';
3
3
  const VALID_SELECT_TOOL_NAMES = new Set(['select_component', 'reject_component']);
4
- export function parseSelectToolCallLines(stdout) {
5
- const calls = [];
4
+ function findJsonObjectEnd(line) {
5
+ let depth = 0;
6
+ let inString = false;
7
+ let escaped = false;
8
+ for (let i = 0; i < line.length; i++) {
9
+ const ch = line[i];
10
+ if (escaped) {
11
+ escaped = false;
12
+ }
13
+ else if (ch === '\\' && inString) {
14
+ escaped = true;
15
+ }
16
+ else if (ch === '"') {
17
+ inString = !inString;
18
+ }
19
+ else if (!inString && ch === '{') {
20
+ depth++;
21
+ }
22
+ else if (!inString && ch === '}' && --depth === 0) {
23
+ return i;
24
+ }
25
+ }
26
+ return -1;
27
+ }
28
+ /**
29
+ * Reads an agent's stdout into the tool-call objects it carries. Lines that do
30
+ * not start with `{` are the agent's prose and are skipped silently, as before.
31
+ */
32
+ function readToolCallObjects(stdout) {
33
+ const objects = [];
6
34
  const warnings = [];
7
35
  for (const raw of stdout.split('\n')) {
8
36
  const line = raw.trim();
9
37
  if (!line.startsWith('{'))
10
38
  continue;
11
- let obj;
39
+ const end = findJsonObjectEnd(line);
40
+ if (end === -1) {
41
+ warnings.push(`unparseable line: ${line.slice(0, 120)}`);
42
+ continue;
43
+ }
44
+ let parsed;
12
45
  try {
13
- obj = JSON.parse(line);
46
+ parsed = JSON.parse(line.slice(0, end + 1));
14
47
  }
15
48
  catch {
16
49
  warnings.push(`unparseable line: ${line.slice(0, 120)}`);
17
50
  continue;
18
51
  }
19
- if (typeof obj !== 'object' || obj === null || !('tool' in obj))
20
- continue;
21
- const rec = obj;
52
+ const trailing = line.slice(end + 1);
53
+ if (trailing.trim()) {
54
+ warnings.push(`ignored trailing content after JSON: ${trailing.trim().slice(0, 120)}`);
55
+ }
56
+ if (typeof parsed === 'object' && parsed !== null && 'tool' in parsed) {
57
+ objects.push(parsed);
58
+ }
59
+ }
60
+ return { objects, warnings };
61
+ }
62
+ export function parseSelectToolCallLines(stdout) {
63
+ const calls = [];
64
+ const { objects, warnings } = readToolCallObjects(stdout);
65
+ for (const rec of objects) {
22
66
  if (!VALID_SELECT_TOOL_NAMES.has(rec.tool))
23
67
  continue;
24
68
  if (typeof rec.name !== 'string' || !rec.name) {
@@ -49,22 +93,8 @@ const VALID_CDF_TYPES = new Set(['string', 'richtext', 'media', 'enum', 'token',
49
93
  const VALID_CATEGORIES = new Set(['content', 'design', 'state']);
50
94
  export function parseToolCallLines(stdout) {
51
95
  const calls = [];
52
- const warnings = [];
53
- for (const raw of stdout.split('\n')) {
54
- const line = raw.trim();
55
- if (!line.startsWith('{'))
56
- continue;
57
- let obj;
58
- try {
59
- obj = JSON.parse(line);
60
- }
61
- catch {
62
- warnings.push(`unparseable line: ${line.slice(0, 120)}`);
63
- continue;
64
- }
65
- if (typeof obj !== 'object' || obj === null || !('tool' in obj))
66
- continue;
67
- const rec = obj;
96
+ const { objects, warnings } = readToolCallObjects(stdout);
97
+ for (const rec of objects) {
68
98
  if (!VALID_TOOL_NAMES.has(rec.tool)) {
69
99
  warnings.push(`unknown tool: ${String(rec.tool)}`);
70
100
  continue;
@@ -155,22 +185,8 @@ export function parseToolCallLines(stdout) {
155
185
  }
156
186
  export function parseTokenToolCallLines(stdout) {
157
187
  const calls = [];
158
- const warnings = [];
159
- for (const raw of stdout.split('\n')) {
160
- const line = raw.trim();
161
- if (!line.startsWith('{'))
162
- continue;
163
- let obj;
164
- try {
165
- obj = JSON.parse(line);
166
- }
167
- catch {
168
- warnings.push(`unparseable line: ${line.slice(0, 120)}`);
169
- continue;
170
- }
171
- if (typeof obj !== 'object' || obj === null || !('tool' in obj))
172
- continue;
173
- const rec = obj;
188
+ const { objects, warnings } = readToolCallObjects(stdout);
189
+ for (const rec of objects) {
174
190
  if (!VALID_TOKEN_TOOL_NAMES.has(rec.tool))
175
191
  continue; // not a token call — skip silently
176
192
  if (rec.tool === 'set_token') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-generation",
3
- "version": "2.26.7-dev-build-cdb420a.0",
3
+ "version": "2.26.7-dev-build-6d2ed6d.0",
4
4
  "description": "Agent-invocation and skill-prompt engine for the Contentful Experience Design System SDK",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "skills/"
23
23
  ],
24
24
  "dependencies": {
25
- "@contentful/experience-design-system-types": "2.26.7-dev-build-cdb420a.0"
25
+ "@contentful/experience-design-system-types": "2.26.7-dev-build-6d2ed6d.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@tsconfig/node24": "^24.0.4",