@crewx/shared 0.0.2 → 0.0.3
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 +1 -1
- package/skill-tracer.js +5 -1
package/package.json
CHANGED
package/skill-tracer.js
CHANGED
|
@@ -299,6 +299,10 @@ function trace(skillName, command, options = {}) {
|
|
|
299
299
|
// crewx skill x로 실행된 경우 → spans 테이블에 child span으로 기록
|
|
300
300
|
const parentTaskId = process.env.CREWX_TASK_ID;
|
|
301
301
|
if (parentTaskId && parentTaskId.trim() !== '') {
|
|
302
|
+
// Verify FK target exists before INSERT to avoid constraint error
|
|
303
|
+
const taskExists = db.prepare('SELECT 1 FROM tasks WHERE id = ?').get(parentTaskId);
|
|
304
|
+
const safeTaskId = taskExists ? parentTaskId : null;
|
|
305
|
+
|
|
302
306
|
const spanId = randomUUID();
|
|
303
307
|
const attributes = JSON.stringify({
|
|
304
308
|
skill: skillName,
|
|
@@ -309,7 +313,7 @@ function trace(skillName, command, options = {}) {
|
|
|
309
313
|
db.prepare(`
|
|
310
314
|
INSERT INTO spans (id, task_id, name, kind, status, started_at, input, attributes)
|
|
311
315
|
VALUES (?, ?, ?, 'internal', 'ok', ?, ?, ?)
|
|
312
|
-
`).run(spanId,
|
|
316
|
+
`).run(spanId, safeTaskId, `[skill:${skillName}] ${command}`, now, command, attributes);
|
|
313
317
|
|
|
314
318
|
return {
|
|
315
319
|
taskId: parentTaskId,
|