@lightcone-ai/daemon 0.14.8 → 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/agent-manager.js +33 -7
package/package.json
CHANGED
package/src/agent-manager.js
CHANGED
|
@@ -1024,6 +1024,27 @@ 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
|
+
|
|
1027
1048
|
async _handlePublishJob(msg, connection) {
|
|
1028
1049
|
const job = normalizeObject(msg.job);
|
|
1029
1050
|
const jobId = String(job.id ?? '').trim();
|
|
@@ -1038,6 +1059,13 @@ export class AgentManager {
|
|
|
1038
1059
|
}
|
|
1039
1060
|
console.log(`${logPrefix} entry`);
|
|
1040
1061
|
|
|
1062
|
+
connection.send({
|
|
1063
|
+
type: 'publish:job_received',
|
|
1064
|
+
job_id: jobId,
|
|
1065
|
+
action_id: actionId,
|
|
1066
|
+
received_at: new Date().toISOString(),
|
|
1067
|
+
});
|
|
1068
|
+
|
|
1041
1069
|
connection.send({
|
|
1042
1070
|
type: 'publish:job_status',
|
|
1043
1071
|
job_id: jobId,
|
|
@@ -1048,7 +1076,7 @@ export class AgentManager {
|
|
|
1048
1076
|
|
|
1049
1077
|
try {
|
|
1050
1078
|
const workspaceDir = this._workspaceDir(agentId, workspaceId);
|
|
1051
|
-
const publishResult = await
|
|
1079
|
+
const publishResult = await this._runPublishJob({
|
|
1052
1080
|
serverUrl: this.serverUrl,
|
|
1053
1081
|
machineApiKey: this.machineApiKey,
|
|
1054
1082
|
agentId,
|
|
@@ -1074,9 +1102,8 @@ export class AgentManager {
|
|
|
1074
1102
|
});
|
|
1075
1103
|
|
|
1076
1104
|
console.log(`${logPrefix} completion-post ok=true`);
|
|
1077
|
-
await this.
|
|
1078
|
-
|
|
1079
|
-
actionId,
|
|
1105
|
+
await this._postInternalPublishJobComplete({
|
|
1106
|
+
jobId,
|
|
1080
1107
|
ok: true,
|
|
1081
1108
|
result: publishResult.completionResult,
|
|
1082
1109
|
error: null,
|
|
@@ -1096,9 +1123,8 @@ export class AgentManager {
|
|
|
1096
1123
|
console.error(`${logPrefix} failed error=${errorMessage}`);
|
|
1097
1124
|
try {
|
|
1098
1125
|
console.log(`${logPrefix} completion-post ok=false`);
|
|
1099
|
-
await this.
|
|
1100
|
-
|
|
1101
|
-
actionId,
|
|
1126
|
+
await this._postInternalPublishJobComplete({
|
|
1127
|
+
jobId,
|
|
1102
1128
|
ok: false,
|
|
1103
1129
|
result: null,
|
|
1104
1130
|
error: errorMessage,
|