@lightcone-ai/daemon 0.14.4 → 0.14.6
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/src/connection.js +29 -3
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/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();
|
|
@@ -1036,6 +1057,13 @@ export class AgentManager {
|
|
|
1036
1057
|
return;
|
|
1037
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
|
+
});
|
|
1066
|
+
|
|
1039
1067
|
connection.send({
|
|
1040
1068
|
type: 'publish:job_status',
|
|
1041
1069
|
job_id: jobId,
|
|
@@ -1046,7 +1074,7 @@ export class AgentManager {
|
|
|
1046
1074
|
|
|
1047
1075
|
try {
|
|
1048
1076
|
const workspaceDir = this._workspaceDir(agentId, workspaceId);
|
|
1049
|
-
const publishResult = await
|
|
1077
|
+
const publishResult = await this._runPublishJob({
|
|
1050
1078
|
serverUrl: this.serverUrl,
|
|
1051
1079
|
machineApiKey: this.machineApiKey,
|
|
1052
1080
|
agentId,
|
|
@@ -1054,9 +1082,8 @@ export class AgentManager {
|
|
|
1054
1082
|
job,
|
|
1055
1083
|
});
|
|
1056
1084
|
|
|
1057
|
-
await this.
|
|
1058
|
-
|
|
1059
|
-
actionId,
|
|
1085
|
+
await this._postInternalPublishJobComplete({
|
|
1086
|
+
jobId,
|
|
1060
1087
|
ok: true,
|
|
1061
1088
|
result: publishResult.completionResult,
|
|
1062
1089
|
error: null,
|
|
@@ -1073,9 +1100,8 @@ export class AgentManager {
|
|
|
1073
1100
|
} catch (err) {
|
|
1074
1101
|
const errorMessage = err?.message ?? String(err);
|
|
1075
1102
|
try {
|
|
1076
|
-
await this.
|
|
1077
|
-
|
|
1078
|
-
actionId,
|
|
1103
|
+
await this._postInternalPublishJobComplete({
|
|
1104
|
+
jobId,
|
|
1079
1105
|
ok: false,
|
|
1080
1106
|
result: null,
|
|
1081
1107
|
error: errorMessage,
|
package/src/connection.js
CHANGED
|
@@ -32,6 +32,18 @@ function detectRuntimes() {
|
|
|
32
32
|
return runtimes;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function parseOptionalDeviceHints() {
|
|
36
|
+
const raw = String(process.env.LIGHTCONE_DEVICE_HINTS ?? '').trim();
|
|
37
|
+
if (!raw) return {};
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(raw);
|
|
40
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
41
|
+
} catch {
|
|
42
|
+
console.warn('[Connection] Ignoring invalid LIGHTCONE_DEVICE_HINTS (must be JSON object)');
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
export class DaemonConnection {
|
|
36
48
|
constructor({ serverUrl, machineApiKey, onMessage }) {
|
|
37
49
|
this.serverUrl = serverUrl.replace(/^http/, 'ws');
|
|
@@ -86,13 +98,27 @@ export class DaemonConnection {
|
|
|
86
98
|
|
|
87
99
|
_sendReady() {
|
|
88
100
|
const runtimes = detectRuntimes();
|
|
89
|
-
|
|
101
|
+
const hostname = os.hostname();
|
|
102
|
+
const platform = os.platform();
|
|
103
|
+
const arch = os.arch();
|
|
104
|
+
const release = os.release();
|
|
105
|
+
const envDeviceType = String(process.env.LIGHTCONE_DEVICE_TYPE ?? '').trim();
|
|
106
|
+
const deviceHints = {
|
|
107
|
+
platform,
|
|
108
|
+
arch,
|
|
109
|
+
release,
|
|
110
|
+
...(envDeviceType ? { deviceType: envDeviceType } : {}),
|
|
111
|
+
...parseOptionalDeviceHints(),
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
console.log(`[Connection] Ready — host=${hostname} runtimes=[${runtimes.join(',')}] v${DAEMON_VERSION}`);
|
|
90
115
|
this.send({
|
|
91
116
|
type: 'ready',
|
|
92
|
-
hostname
|
|
93
|
-
os: `${
|
|
117
|
+
hostname,
|
|
118
|
+
os: `${platform} ${arch}`,
|
|
94
119
|
runtimes,
|
|
95
120
|
daemonVersion: DAEMON_VERSION,
|
|
121
|
+
deviceHints,
|
|
96
122
|
});
|
|
97
123
|
}
|
|
98
124
|
|