@yeaft/webchat-agent 0.1.962 → 0.1.964

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": "0.1.962",
3
+ "version": "0.1.964",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/yeaft/engine.js CHANGED
@@ -960,7 +960,6 @@ export class Engine {
960
960
  parentVpId: vpCtx?.senderVpId || null,
961
961
  parentVpPersona: vpCtx?.vpPersona || null,
962
962
  parentSessionId: vpCtx?.sessionId || null,
963
- parentThreadId: vpCtx?.threadId || MAIN_THREAD_ID,
964
963
  onEvent: this.#subAgentEventSink || null,
965
964
  language: this.#config?.language || 'en',
966
965
  // Forward the session-shared ToolUsageStats so sub-agent
@@ -15,7 +15,7 @@
15
15
  * 1. WaitAgent (drains anything queued for this agent on terminal,
16
16
  * before returning).
17
17
  * 2. Engine.query() — when started with a user prompt, it asks
18
- * `consumePendingNotifications({ sessionId, parentVpId, threadId })` for any queued
18
+ * `consumePendingNotifications({ sessionId, parentVpId })` for any queued
19
19
  * terminal events from sub-agents that the parent hasn't yet
20
20
  * acknowledged, and prepends a short XML block to the user
21
21
  * message. The XML block is human-readable for the model and
@@ -28,7 +28,7 @@
28
28
  * long-term record.
29
29
  *
30
30
  * Keying:
31
- * Notifications are bucketed by `(sessionId, parentVpId, threadId)` when
31
+ * Notifications are bucketed by `(sessionId, parentVpId)` when
32
32
  * the parent runs inside a Yeaft Session. Legacy / test callers that
33
33
  * don't provide a sessionId still bucket by `parentVpId` (or
34
34
  * `'__no_vp__'`) so older in-process callers keep working. WaitAgent
@@ -41,7 +41,7 @@
41
41
  * us from emitting more than one terminal notification per agent.
42
42
  */
43
43
 
44
- /** @typedef {{ id: string, agentId: string, agentName: string, status: string, result: string, error: string|null, outputFile: string|null, turns: number, parentVpId: string|null, parentSessionId: string|null, parentThreadId: string|null, budgetExceeded: boolean, budgetReason: string|null, budgetUsage: object|null, createdAt: number }} SubAgentNotification */
44
+ /** @typedef {{ id: string, agentId: string, agentName: string, status: string, result: string, error: string|null, outputFile: string|null, turns: number, parentVpId: string|null, parentSessionId: string|null, budgetExceeded: boolean, budgetReason: string|null, budgetUsage: object|null, createdAt: number }} SubAgentNotification */
45
45
 
46
46
  /** Map<bucketKey, SubAgentNotification[]> */
47
47
  const byParent = new Map();
@@ -49,32 +49,29 @@ const byParent = new Map();
49
49
  const byAgent = new Map();
50
50
 
51
51
  const FALLBACK_BUCKET = '__no_vp__';
52
- const MAIN_THREAD_ID = 'main';
53
52
 
54
53
  function cleanString(value) {
55
54
  return (typeof value === 'string' && value.trim()) ? value.trim() : null;
56
55
  }
57
56
 
58
- function normalizeScope(input, sessionId, threadId) {
57
+ function normalizeScope(input, sessionId) {
59
58
  if (input && typeof input === 'object') {
60
59
  return {
61
60
  parentVpId: cleanString(input.parentVpId),
62
61
  sessionId: cleanString(input.sessionId ?? input.parentSessionId),
63
- threadId: cleanString(input.threadId ?? input.parentThreadId) || MAIN_THREAD_ID,
64
62
  };
65
63
  }
66
64
  return {
67
65
  parentVpId: cleanString(input),
68
66
  sessionId: cleanString(sessionId),
69
- threadId: cleanString(threadId) || MAIN_THREAD_ID,
70
67
  };
71
68
  }
72
69
 
73
- function bucketKey(scope, sessionId, threadId) {
74
- const s = normalizeScope(scope, sessionId, threadId);
70
+ function bucketKey(scope, sessionId) {
71
+ const s = normalizeScope(scope, sessionId);
75
72
  const vp = s.parentVpId || FALLBACK_BUCKET;
76
73
  if (!s.sessionId) return vp;
77
- return `${s.sessionId}::${vp}::${s.threadId || MAIN_THREAD_ID}`;
74
+ return `${s.sessionId}::${vp}`;
78
75
  }
79
76
 
80
77
  /**
@@ -82,7 +79,7 @@ function bucketKey(scope, sessionId, threadId) {
82
79
  * a second call with the same agentId is a no-op (we only emit one
83
80
  * terminal notice per child).
84
81
  *
85
- * @param {{ agentId: string, agentName: string, status: string, result?: string, error?: string|null, outputFile?: string|null, turns?: number, parentVpId?: string|null, parentSessionId?: string|null, sessionId?: string|null, parentThreadId?: string|null, threadId?: string|null, budgetExceeded?: boolean, budgetReason?: string|null, budgetUsage?: object|null }} input
82
+ * @param {{ agentId: string, agentName: string, status: string, result?: string, error?: string|null, outputFile?: string|null, turns?: number, parentVpId?: string|null, parentSessionId?: string|null, sessionId?: string|null, budgetExceeded?: boolean, budgetReason?: string|null, budgetUsage?: object|null }} input
86
83
  * @returns {SubAgentNotification|null} the queued record (null if a dup)
87
84
  */
88
85
  export function enqueueTerminalNotification(input) {
@@ -91,7 +88,6 @@ export function enqueueTerminalNotification(input) {
91
88
  const scope = normalizeScope({
92
89
  parentVpId: input.parentVpId,
93
90
  parentSessionId: input.parentSessionId ?? input.sessionId,
94
- parentThreadId: input.parentThreadId ?? input.threadId,
95
91
  });
96
92
  const rec = {
97
93
  id: `${input.agentId}:${input.status}:${Date.now()}`,
@@ -104,7 +100,6 @@ export function enqueueTerminalNotification(input) {
104
100
  turns: typeof input.turns === 'number' ? input.turns : 0,
105
101
  parentVpId: scope.parentVpId,
106
102
  parentSessionId: scope.sessionId,
107
- parentThreadId: scope.threadId,
108
103
  budgetExceeded: Boolean(input.budgetExceeded),
109
104
  budgetReason: input.budgetReason || null,
110
105
  budgetUsage: input.budgetUsage || null,
@@ -124,7 +119,7 @@ export function enqueueTerminalNotification(input) {
124
119
  * Engine calls this at the start of every user-driven turn so the
125
120
  * parent model sees terminal events that arrived while it was idle.
126
121
  *
127
- * @param {string|{parentVpId?: string|null, sessionId?: string|null, parentSessionId?: string|null, threadId?: string|null, parentThreadId?: string|null}|null} scope
122
+ * @param {string|{parentVpId?: string|null, sessionId?: string|null, parentSessionId?: string|null}|null} scope
128
123
  * @returns {SubAgentNotification[]}
129
124
  */
130
125
  export function consumePendingNotifications(scope) {
@@ -142,7 +137,7 @@ export function consumePendingNotifications(scope) {
142
137
  * while constructing a prompt; it acknowledges only after the parent turn
143
138
  * completes successfully so abort/error paths don't lose the notification.
144
139
  *
145
- * @param {string|{parentVpId?: string|null, sessionId?: string|null, parentSessionId?: string|null, threadId?: string|null, parentThreadId?: string|null}|null} scope
140
+ * @param {string|{parentVpId?: string|null, sessionId?: string|null, parentSessionId?: string|null}|null} scope
146
141
  * @returns {SubAgentNotification[]}
147
142
  */
148
143
  export function peekPendingNotifications(scope) {
@@ -155,7 +150,7 @@ export function peekPendingNotifications(scope) {
155
150
  * Acknowledge notifications previously returned by peekPendingNotifications.
156
151
  * Removes them from both parent and per-agent maps.
157
152
  *
158
- * @param {string|{parentVpId?: string|null, sessionId?: string|null, parentSessionId?: string|null, threadId?: string|null, parentThreadId?: string|null}|null} scope
153
+ * @param {string|{parentVpId?: string|null, sessionId?: string|null, parentSessionId?: string|null}|null} scope
159
154
  * @param {string[]} ids
160
155
  */
161
156
  export function acknowledgePendingNotifications(scope, ids = []) {
@@ -192,7 +187,6 @@ export function consumeNotificationForAgent(agentId) {
192
187
  const key = bucketKey({
193
188
  parentVpId: rec.parentVpId,
194
189
  sessionId: rec.parentSessionId,
195
- threadId: rec.parentThreadId,
196
190
  });
197
191
  const list = byParent.get(key);
198
192
  if (Array.isArray(list)) {