@yeaft/webchat-agent 1.0.207 → 1.0.208

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.207",
3
+ "version": "1.0.208",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -33,6 +33,18 @@ function currentAction(detail) {
33
33
  return detail.actions.find(action => action.id === detail.currentActionId) || null;
34
34
  }
35
35
 
36
+ function projectCurrentActionSummary(action, projectedAction = action) {
37
+ if (!projectedAction?.id) return null;
38
+ return {
39
+ id: projectedAction.id,
40
+ type: projectedAction.type,
41
+ stageId: projectedAction.stageId,
42
+ assignmentMode: projectedAction.assignmentPolicy?.mode || (projectedAction.requiredRole ? 'fixed' : null),
43
+ status: projectedAction.status,
44
+ objective: truncateUtf8(action?.brief?.objective, 1_000) || null,
45
+ };
46
+ }
47
+
36
48
  function count(value) {
37
49
  return Math.max(0, Number(value) || 0);
38
50
  }
@@ -652,7 +664,9 @@ export function projectWorkItemSummary(detail) {
652
664
  activeActionIds: Array.isArray(detail.activeActionIds) ? detail.activeActionIds : undefined,
653
665
  attentionActionIds: Array.isArray(detail.attentionActionIds) ? detail.attentionActionIds : undefined,
654
666
  currentActionId: detail.currentActionId || null,
655
- currentAction: null,
667
+ currentAction: projectCurrentActionSummary(detail.currentAction),
668
+ actionCount: count(detail.actionCount),
669
+ completedActionCount: count(detail.completedActionCount),
656
670
  executionStats: executionStats(detail.executionStats),
657
671
  origin: detail.origin?.sessionId ? { sessionId: detail.origin.sessionId } : null,
658
672
  linkedSessionIds: Array.isArray(detail.linkedSessionIds) ? detail.linkedSessionIds : [],
@@ -677,18 +691,14 @@ export function projectWorkItemSummary(detail) {
677
691
  activeActionIds: Array.isArray(detail.activeActionIds) ? detail.activeActionIds : undefined,
678
692
  attentionActionIds: Array.isArray(detail.attentionActionIds) ? detail.attentionActionIds : undefined,
679
693
  currentActionId: detail.currentActionId || null,
694
+ actionCount: detail.actions.filter(item => !['superseded', 'cancelled'].includes(item?.status)).length,
695
+ completedActionCount: detail.actions.filter(item => item?.status === 'completed').length,
680
696
  executionStats: Array.isArray(detail.runs)
681
697
  ? sumExecutionStats(detail.runs)
682
698
  : executionStats(detail.executionStats),
683
699
  failureReason: workItemFailureReason(detail),
684
700
 
685
- currentAction: projectedAction ? {
686
- id: projectedAction.id,
687
- type: projectedAction.type,
688
- stageId: projectedAction.stageId,
689
- assignmentMode: projectedAction.assignmentPolicy?.mode || (projectedAction.requiredRole ? 'fixed' : null),
690
- status: projectedAction.status,
691
- } : null,
701
+ currentAction: projectCurrentActionSummary(action, projectedAction),
692
702
  origin: detail.origin?.sessionId ? { sessionId: detail.origin.sessionId } : null,
693
703
  linkedSessionIds: Array.isArray(detail.linkedSessionIds) ? detail.linkedSessionIds : [],
694
704
  attachmentCount: Array.isArray(detail.attachments) ? detail.attachments.length : 0,
@@ -70,12 +70,21 @@ function mapWorkItem(row) {
70
70
  workflowSnapshot: parseJson(row.workflow_snapshot, null),
71
71
  status: row.status,
72
72
  currentActionId: row.current_action_id || null,
73
+ currentAction: row.current_action_type ? {
74
+ id: row.current_action_id,
75
+ type: row.current_action_type,
76
+ stageId: row.current_action_stage_id || row.current_action_type,
77
+ status: row.current_action_status || null,
78
+ brief: parseJson(row.current_action_brief, null),
79
+ } : null,
73
80
  currentRunId: row.current_run_id || null,
74
81
  workDir: row.work_dir || '',
75
82
  workspaceKey: row.workspace_key || '',
76
83
  reuseMemory: row.reuse_memory !== 0,
77
84
  origin: parseJson(row.origin, null),
78
85
  linkedSessionIds: parseJson(row.linked_session_ids, []),
86
+ actionCount: Math.max(0, Number(row.action_count) || 0),
87
+ completedActionCount: Math.max(0, Number(row.completed_action_count) || 0),
79
88
  sessionContext: parseJson(row.session_context, []),
80
89
  messages: parseJson(row.messages, []),
81
90
  attachments: parseJson(row.attachments, []),
@@ -1190,6 +1199,14 @@ export class WorkItemStore {
1190
1199
  }
1191
1200
  const limit = Math.min(Math.max(Number(filters.limit) || 100, 1), 500);
1192
1201
  const sql = `SELECT w.*,
1202
+ current_action.type AS current_action_type,
1203
+ current_action.stage_id AS current_action_stage_id,
1204
+ current_action.status AS current_action_status,
1205
+ current_action.brief AS current_action_brief,
1206
+ (SELECT COUNT(*) FROM actions a WHERE a.work_item_id = w.id
1207
+ AND a.status NOT IN ('superseded', 'cancelled')) AS action_count,
1208
+ (SELECT COUNT(*) FROM actions a WHERE a.work_item_id = w.id
1209
+ AND a.status = 'completed') AS completed_action_count,
1193
1210
  COALESCE(SUM(r.llm_request_count), 0) AS usage_llm_request_count,
1194
1211
  COALESCE(SUM(r.loop_count), 0) AS usage_loop_count,
1195
1212
  COALESCE(SUM(r.tool_count), 0) AS usage_tool_count,
@@ -1198,7 +1215,9 @@ export class WorkItemStore {
1198
1215
  COALESCE(SUM(r.cache_read_tokens), 0) AS usage_cache_read_tokens,
1199
1216
  COALESCE(SUM(r.cache_write_tokens), 0) AS usage_cache_write_tokens,
1200
1217
  COALESCE(SUM(r.total_tokens), 0) AS usage_total_tokens
1201
- FROM work_items w LEFT JOIN runs r ON r.work_item_id = w.id
1218
+ FROM work_items w
1219
+ LEFT JOIN actions current_action ON current_action.id = w.current_action_id
1220
+ LEFT JOIN runs r ON r.work_item_id = w.id
1202
1221
  ${where.length ? `WHERE ${where.join(' AND ')}` : ''}
1203
1222
  GROUP BY w.id ORDER BY w.updated_at DESC LIMIT ?`;
1204
1223
  return this.db.prepare(sql).all(...values, limit).map(mapWorkItem).map(workItem => {