@hienlh/ppm 0.9.11 → 0.9.12
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/package.json
CHANGED
|
@@ -168,14 +168,30 @@ function inferMemberStatus(messages: unknown[], agentName: string): string {
|
|
|
168
168
|
return "active";
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
/** Extract team name from TeamCreate tool_result output
|
|
171
|
+
/** Extract team name from TeamCreate tool_result output.
|
|
172
|
+
* Output may be plain JSON, or a content-block array like:
|
|
173
|
+
* [{"type":"text","text":"{ \"team_name\": \"foo\" }"}] */
|
|
172
174
|
export function extractTeamName(output: string): string | null {
|
|
173
175
|
try {
|
|
174
176
|
const parsed = JSON.parse(output);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
// Direct JSON object: { team_name: "foo" }
|
|
178
|
+
if (parsed && !Array.isArray(parsed)) {
|
|
179
|
+
return parsed.team_name ?? parsed.name ?? null;
|
|
180
|
+
}
|
|
181
|
+
// Content-block array: [{"type":"text","text":"..."}]
|
|
182
|
+
if (Array.isArray(parsed)) {
|
|
183
|
+
for (const block of parsed) {
|
|
184
|
+
if (block?.type === "text" && typeof block.text === "string") {
|
|
185
|
+
try {
|
|
186
|
+
const inner = JSON.parse(block.text);
|
|
187
|
+
if (inner?.team_name) return inner.team_name;
|
|
188
|
+
if (inner?.name) return inner.name;
|
|
189
|
+
} catch { /* not JSON, try next block */ }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
} catch { /* not valid JSON at all */ }
|
|
194
|
+
// Fallback regex
|
|
195
|
+
const match = output.match(/"team_name"\s*:\s*"([^"]+)"/);
|
|
196
|
+
return match?.[1] ?? null;
|
|
181
197
|
}
|