@lightcone-ai/daemon 0.14.7 → 0.14.8
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 +31 -33
- 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
|
@@ -1024,45 +1024,19 @@ export class AgentManager {
|
|
|
1024
1024
|
return res.json();
|
|
1025
1025
|
}
|
|
1026
1026
|
|
|
1027
|
-
async _postInternalPublishJobComplete({ jobId, ok, result, error }) {
|
|
1028
|
-
const url = `${this.serverUrl.replace(/\/$/, '')}/internal/agent/publish-jobs/${encodeURIComponent(jobId)}/complete`;
|
|
1029
|
-
const res = await fetch(url, {
|
|
1030
|
-
method: 'POST',
|
|
1031
|
-
headers: {
|
|
1032
|
-
'Content-Type': 'application/json',
|
|
1033
|
-
Authorization: `Bearer ${this.machineApiKey}`,
|
|
1034
|
-
},
|
|
1035
|
-
body: JSON.stringify({ ok, result, error }),
|
|
1036
|
-
});
|
|
1037
|
-
if (!res.ok) {
|
|
1038
|
-
const text = await res.text();
|
|
1039
|
-
throw new Error(`publish job complete failed (${res.status}): ${text}`);
|
|
1040
|
-
}
|
|
1041
|
-
return res.json();
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
async _runPublishJob(args) {
|
|
1045
|
-
return runPublishJob(args);
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
1027
|
async _handlePublishJob(msg, connection) {
|
|
1049
1028
|
const job = normalizeObject(msg.job);
|
|
1050
1029
|
const jobId = String(job.id ?? '').trim();
|
|
1051
1030
|
const actionId = String(job.approval_action_id ?? '').trim();
|
|
1052
1031
|
const agentId = String(job.agent_id ?? '').trim();
|
|
1053
1032
|
const workspaceId = String(job.workspace_id ?? '').trim() || null;
|
|
1033
|
+
const logPrefix = `[AgentManager] publish:job job=${jobId || 'unknown'} action=${actionId || 'unknown'} agent=${agentId || 'unknown'} workspace=${workspaceId ?? 'none'}`;
|
|
1054
1034
|
|
|
1055
1035
|
if (!jobId || !actionId || !agentId) {
|
|
1056
1036
|
console.warn('[AgentManager] publish:job missing required fields (id, approval_action_id, agent_id)');
|
|
1057
1037
|
return;
|
|
1058
1038
|
}
|
|
1059
|
-
|
|
1060
|
-
connection.send({
|
|
1061
|
-
type: 'publish:job_received',
|
|
1062
|
-
job_id: jobId,
|
|
1063
|
-
action_id: actionId,
|
|
1064
|
-
received_at: new Date().toISOString(),
|
|
1065
|
-
});
|
|
1039
|
+
console.log(`${logPrefix} entry`);
|
|
1066
1040
|
|
|
1067
1041
|
connection.send({
|
|
1068
1042
|
type: 'publish:job_status',
|
|
@@ -1074,20 +1048,40 @@ export class AgentManager {
|
|
|
1074
1048
|
|
|
1075
1049
|
try {
|
|
1076
1050
|
const workspaceDir = this._workspaceDir(agentId, workspaceId);
|
|
1077
|
-
const publishResult = await
|
|
1051
|
+
const publishResult = await runPublishJob({
|
|
1078
1052
|
serverUrl: this.serverUrl,
|
|
1079
1053
|
machineApiKey: this.machineApiKey,
|
|
1080
1054
|
agentId,
|
|
1081
1055
|
workspaceDir,
|
|
1082
1056
|
job,
|
|
1057
|
+
onProgress: (stage, payload = {}) => {
|
|
1058
|
+
if (stage === 'precheck_done') {
|
|
1059
|
+
console.log(
|
|
1060
|
+
`${logPrefix} precheck-done ok=${payload.ok === true} blockers=${payload.blockerCount ?? 0} warnings=${payload.warningCount ?? 0}`
|
|
1061
|
+
);
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
if (stage === 'publish_action_start') {
|
|
1065
|
+
console.log(
|
|
1066
|
+
`${logPrefix} publish-action-start platform=${payload.platform ?? 'unknown'} content_type=${payload.contentType ?? 'unknown'}`
|
|
1067
|
+
);
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
if (stage === 'precheck_error') {
|
|
1071
|
+
console.error(`${logPrefix} precheck-error error=${payload.error ?? 'unknown_error'}`);
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1083
1074
|
});
|
|
1084
1075
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1076
|
+
console.log(`${logPrefix} completion-post ok=true`);
|
|
1077
|
+
await this._postInternalActionComplete({
|
|
1078
|
+
agentId,
|
|
1079
|
+
actionId,
|
|
1087
1080
|
ok: true,
|
|
1088
1081
|
result: publishResult.completionResult,
|
|
1089
1082
|
error: null,
|
|
1090
1083
|
});
|
|
1084
|
+
console.log(`${logPrefix} completion-post posted ok=true`);
|
|
1091
1085
|
|
|
1092
1086
|
connection.send({
|
|
1093
1087
|
type: 'publish:job_status',
|
|
@@ -1099,13 +1093,17 @@ export class AgentManager {
|
|
|
1099
1093
|
});
|
|
1100
1094
|
} catch (err) {
|
|
1101
1095
|
const errorMessage = err?.message ?? String(err);
|
|
1096
|
+
console.error(`${logPrefix} failed error=${errorMessage}`);
|
|
1102
1097
|
try {
|
|
1103
|
-
|
|
1104
|
-
|
|
1098
|
+
console.log(`${logPrefix} completion-post ok=false`);
|
|
1099
|
+
await this._postInternalActionComplete({
|
|
1100
|
+
agentId,
|
|
1101
|
+
actionId,
|
|
1105
1102
|
ok: false,
|
|
1106
1103
|
result: null,
|
|
1107
1104
|
error: errorMessage,
|
|
1108
1105
|
});
|
|
1106
|
+
console.log(`${logPrefix} completion-post posted ok=false`);
|
|
1109
1107
|
} catch (completeErr) {
|
|
1110
1108
|
console.error(
|
|
1111
1109
|
`[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,
|