livedesk 0.1.210 → 0.1.211

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.
@@ -2958,7 +2958,7 @@ export function createRemoteHub(options = {}) {
2958
2958
  return batch;
2959
2959
  }
2960
2960
 
2961
- item.ok = true;
2961
+ item.ok = task.status !== 'failed' && task.status !== 'cancelled';
2962
2962
  item.status = safeString(task.status, 40) || 'queued';
2963
2963
  item.stage = safeString(task.stage, 160) || (item.status === 'running' ? 'Working' : '');
2964
2964
  item.result = safeText(task.resultSummary, MAX_AGENT_TASK_RESULT_CHARS);
@@ -3109,15 +3109,19 @@ export function createRemoteHub(options = {}) {
3109
3109
  }
3110
3110
 
3111
3111
  const now = device.lastSeenAt || new Date().toISOString();
3112
- const status = error
3113
- ? 'failed'
3114
- : safeString(result?.status, 40) || 'completed';
3112
+ const resultFailed = Boolean(error)
3113
+ || result?.ok === false
3114
+ || safeString(result?.status, 40) === 'failed';
3115
+ const status = resultFailed ? 'failed' : safeString(result?.status, 40) || 'completed';
3116
+ const resultError = safeString(error, 500)
3117
+ || safeString(result?.error, 500)
3118
+ || (resultFailed ? safeString(result?.summary, 500) || 'agent-task-failed' : '');
3115
3119
  clearTaskTimeout(device, commandId);
3116
3120
  task.status = status;
3117
3121
  task.updatedAt = now;
3118
3122
  task.completedAt = safeString(result?.completedAt, 80) || now;
3119
- task.error = error;
3120
- task.resultSummary = error || summarizeTaskResult(result);
3123
+ task.error = resultError;
3124
+ task.resultSummary = resultError || summarizeTaskResult(result);
3121
3125
  task.resultData = safeTaskData(result?.data);
3122
3126
  task.resultKind = safeString(result?.kind || result?.mode || 'agent-task', 80);
3123
3127
  task.resultModel = safeString(result?.model || result?.aiModel || '', 120);
@@ -3125,7 +3129,7 @@ export function createRemoteHub(options = {}) {
3125
3129
  device.latestTask = task;
3126
3130
  device.pendingTaskCommands.delete(commandId);
3127
3131
  device.counters.taskResultsReceived += 1;
3128
- if (error) {
3132
+ if (status === 'failed') {
3129
3133
  device.counters.taskResultsFailed += 1;
3130
3134
  }
3131
3135
  syncTaskBatchFromTask(device, task);