@lightcone-ai/daemon 0.14.7 → 0.14.9
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/src/_vendor/mcp/registry.js +1 -1
- package/src/agent-manager.js +24 -0
- package/src/publish-job-runner.js +32 -7
package/package.json
CHANGED
|
@@ -262,7 +262,7 @@ function buildRegistry({ repoRoot }) {
|
|
|
262
262
|
|
|
263
263
|
function defaultRepoRoot() {
|
|
264
264
|
const currentFile = fileURLToPath(import.meta.url);
|
|
265
|
-
return path.resolve(path.dirname(currentFile), '..', '..');
|
|
265
|
+
return path.resolve(path.dirname(currentFile), '..', '..', '..');
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
export function loadMcpServerRegistry({
|
package/src/agent-manager.js
CHANGED
|
@@ -1051,11 +1051,13 @@ export class AgentManager {
|
|
|
1051
1051
|
const actionId = String(job.approval_action_id ?? '').trim();
|
|
1052
1052
|
const agentId = String(job.agent_id ?? '').trim();
|
|
1053
1053
|
const workspaceId = String(job.workspace_id ?? '').trim() || null;
|
|
1054
|
+
const logPrefix = `[AgentManager] publish:job job=${jobId || 'unknown'} action=${actionId || 'unknown'} agent=${agentId || 'unknown'} workspace=${workspaceId ?? 'none'}`;
|
|
1054
1055
|
|
|
1055
1056
|
if (!jobId || !actionId || !agentId) {
|
|
1056
1057
|
console.warn('[AgentManager] publish:job missing required fields (id, approval_action_id, agent_id)');
|
|
1057
1058
|
return;
|
|
1058
1059
|
}
|
|
1060
|
+
console.log(`${logPrefix} entry`);
|
|
1059
1061
|
|
|
1060
1062
|
connection.send({
|
|
1061
1063
|
type: 'publish:job_received',
|
|
@@ -1080,14 +1082,33 @@ export class AgentManager {
|
|
|
1080
1082
|
agentId,
|
|
1081
1083
|
workspaceDir,
|
|
1082
1084
|
job,
|
|
1085
|
+
onProgress: (stage, payload = {}) => {
|
|
1086
|
+
if (stage === 'precheck_done') {
|
|
1087
|
+
console.log(
|
|
1088
|
+
`${logPrefix} precheck-done ok=${payload.ok === true} blockers=${payload.blockerCount ?? 0} warnings=${payload.warningCount ?? 0}`
|
|
1089
|
+
);
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
if (stage === 'publish_action_start') {
|
|
1093
|
+
console.log(
|
|
1094
|
+
`${logPrefix} publish-action-start platform=${payload.platform ?? 'unknown'} content_type=${payload.contentType ?? 'unknown'}`
|
|
1095
|
+
);
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
if (stage === 'precheck_error') {
|
|
1099
|
+
console.error(`${logPrefix} precheck-error error=${payload.error ?? 'unknown_error'}`);
|
|
1100
|
+
}
|
|
1101
|
+
},
|
|
1083
1102
|
});
|
|
1084
1103
|
|
|
1104
|
+
console.log(`${logPrefix} completion-post ok=true`);
|
|
1085
1105
|
await this._postInternalPublishJobComplete({
|
|
1086
1106
|
jobId,
|
|
1087
1107
|
ok: true,
|
|
1088
1108
|
result: publishResult.completionResult,
|
|
1089
1109
|
error: null,
|
|
1090
1110
|
});
|
|
1111
|
+
console.log(`${logPrefix} completion-post posted ok=true`);
|
|
1091
1112
|
|
|
1092
1113
|
connection.send({
|
|
1093
1114
|
type: 'publish:job_status',
|
|
@@ -1099,13 +1120,16 @@ export class AgentManager {
|
|
|
1099
1120
|
});
|
|
1100
1121
|
} catch (err) {
|
|
1101
1122
|
const errorMessage = err?.message ?? String(err);
|
|
1123
|
+
console.error(`${logPrefix} failed error=${errorMessage}`);
|
|
1102
1124
|
try {
|
|
1125
|
+
console.log(`${logPrefix} completion-post ok=false`);
|
|
1103
1126
|
await this._postInternalPublishJobComplete({
|
|
1104
1127
|
jobId,
|
|
1105
1128
|
ok: false,
|
|
1106
1129
|
result: null,
|
|
1107
1130
|
error: errorMessage,
|
|
1108
1131
|
});
|
|
1132
|
+
console.log(`${logPrefix} completion-post posted ok=false`);
|
|
1109
1133
|
} catch (completeErr) {
|
|
1110
1134
|
console.error(
|
|
1111
1135
|
`[AgentManager] Failed to report publish job completion for action=${actionId}: ${completeErr.message}`
|
|
@@ -327,7 +327,16 @@ function buildJobInput(job = {}) {
|
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
function emitPublishJobProgress(onProgress, stage, payload = {}) {
|
|
331
|
+
if (typeof onProgress !== 'function') return;
|
|
332
|
+
try {
|
|
333
|
+
onProgress(stage, payload);
|
|
334
|
+
} catch (error) {
|
|
335
|
+
console.warn(`[publish-job-runner] failed to emit progress for ${stage}: ${error.message}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export async function runPublishJob({ serverUrl, machineApiKey, agentId, workspaceDir, job, onProgress }) {
|
|
331
340
|
if (!serverUrl || !machineApiKey || !agentId) {
|
|
332
341
|
throw new Error('runPublishJob requires serverUrl, machineApiKey, and agentId');
|
|
333
342
|
}
|
|
@@ -352,13 +361,28 @@ export async function runPublishJob({ serverUrl, machineApiKey, agentId, workspa
|
|
|
352
361
|
const resolvedWorkspaceDir = workspaceDir ?? process.cwd();
|
|
353
362
|
const workspaceRootDir = path.dirname(resolvedWorkspaceDir);
|
|
354
363
|
|
|
355
|
-
|
|
364
|
+
let precheck = null;
|
|
365
|
+
try {
|
|
366
|
+
precheck = await runPublishPrecheck({
|
|
367
|
+
platform,
|
|
368
|
+
title,
|
|
369
|
+
text,
|
|
370
|
+
tags,
|
|
371
|
+
payload,
|
|
372
|
+
callTool: callOfficialTool,
|
|
373
|
+
});
|
|
374
|
+
} catch (error) {
|
|
375
|
+
emitPublishJobProgress(onProgress, 'precheck_error', {
|
|
376
|
+
platform,
|
|
377
|
+
error: error.message ?? String(error),
|
|
378
|
+
});
|
|
379
|
+
throw error;
|
|
380
|
+
}
|
|
381
|
+
emitPublishJobProgress(onProgress, 'precheck_done', {
|
|
356
382
|
platform,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
payload,
|
|
361
|
-
callTool: callOfficialTool,
|
|
383
|
+
ok: precheck.ok,
|
|
384
|
+
blockerCount: precheck.blockers.length,
|
|
385
|
+
warningCount: precheck.warnings.length,
|
|
362
386
|
});
|
|
363
387
|
if (!precheck.ok) {
|
|
364
388
|
const blockerSummary = precheck.blockers.map(item => `${item.code}: ${item.message}`).join(' | ');
|
|
@@ -378,6 +402,7 @@ export async function runPublishJob({ serverUrl, machineApiKey, agentId, workspa
|
|
|
378
402
|
const staticAdapter = createStaticAdapter(platform);
|
|
379
403
|
const req = staticAdapter.getRequirements(contentType);
|
|
380
404
|
if (!req) throw new Error(`INPUT_UNSUPPORTED_CONTENT_TYPE: ${platform} does not support ${contentType}`);
|
|
405
|
+
emitPublishJobProgress(onProgress, 'publish_action_start', { platform, contentType });
|
|
381
406
|
|
|
382
407
|
const media = validateMedia({
|
|
383
408
|
platform,
|