@kingsoftcloud/agentkit-harness-node 0.0.22 → 0.0.23

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": "@kingsoftcloud/agentkit-harness-node",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Standalone Native Harness Node adapters: a durable SQLite run store, a one-request model HTTP port, and a minimal versioned JSON-RPC 2.0 over NDJSON process entry. Reuses the shared Native adapter implementations and externalizes @kingsoftcloud/agentkit-harness-core; depends on no Studio/DSH code at runtime.",
@@ -154,7 +154,7 @@
154
154
  "src/package-integrity.mjs"
155
155
  ],
156
156
  "dependencies": {
157
- "@kingsoftcloud/agentkit-harness-core": "0.0.22",
157
+ "@kingsoftcloud/agentkit-harness-core": "0.0.23",
158
158
  "@astral-sh/ruff-wasm-nodejs": "0.16.8",
159
159
  "parse5": "7.3.0",
160
160
  "playwright-core": "1.58.2",
@@ -0,0 +1,25 @@
1
+ /** Ephemeral presentation notification, scoped to a Run. The journal remains
2
+ * authoritative; a timeout still observes durable changes and other processes. */
3
+ export function createDisplayWakeup() {
4
+ const waiting = new Map();
5
+ return {
6
+ notify(runId) { for (const wake of [...waiting.get(runId) ?? []]) wake(); },
7
+ wait(runId, timeoutMs, signal) {
8
+ signal.throwIfAborted();
9
+ return new Promise((resolve, reject) => {
10
+ let settled = false;
11
+ const listeners = waiting.get(runId) ?? new Set(); waiting.set(runId, listeners);
12
+ const finish = error => {
13
+ if (settled) return;
14
+ settled = true;
15
+ clearTimeout(timer); signal.removeEventListener('abort', abort); listeners.delete(wake);
16
+ if (!listeners.size) waiting.delete(runId);
17
+ if (error) reject(error); else resolve();
18
+ };
19
+ const wake = () => finish(), abort = () => finish(signal.reason);
20
+ const timer = setTimeout(wake, timeoutMs);
21
+ listeners.add(wake); signal.addEventListener('abort', abort, { once: true });
22
+ });
23
+ },
24
+ };
25
+ }
@@ -40,6 +40,7 @@ import { ENGINE_HOST_EFFECT, RECEIPT_WAIT_MS, hostReceiptReply, hostReceiptSourc
40
40
  import { ENGINE_COMMAND_VERIFIER, ENGINE_VERIFICATION } from './engine-verification.mjs';
41
41
  import { nativeTodoPlan } from './activity-status.mjs';
42
42
  import { nativeModelStopMessage } from './native-terminal-failure.mjs';
43
+ import { createDisplayWakeup } from './engine-display-wakeup.mjs';
43
44
  export { ENGINE_VIEW_CONTRACT };
44
45
 
45
46
  export const ENGINE_PROTOCOL = 'agentkit.engine/v1';
@@ -205,6 +206,7 @@ export async function serveEngine({ input, output, log = () => {}, startup, env
205
206
  const handlersInFlight = new Set(), lifetime = new AbortController();
206
207
  const reportActivity = () => onActivity(handlersInFlight.size > 0 || active.size > 0);
207
208
  const liveModelDisplay = new Map();
209
+ const displayWakeup = createDisplayWakeup();
208
210
  function captureModelDisplay({ runId, operationKey }, event) {
209
211
  if (!['text', 'thinking', 'tool_delta'].includes(event.kind)) return;
210
212
  let current = liveModelDisplay.get(runId);
@@ -215,11 +217,13 @@ export async function serveEngine({ input, output, log = () => {}, startup, env
215
217
  if (event.kind === 'thinking') {
216
218
  current.end += event.text.length;
217
219
  current.text = (current.text + event.text).slice(-THINKING_HISTORY_CHARS);
220
+ displayWakeup.notify(runId);
218
221
  return;
219
222
  }
220
223
  if (event.kind === 'text') {
221
224
  current.bodyEnd += event.text.length;
222
225
  current.body = (current.body + event.text).slice(-THINKING_HISTORY_CHARS);
226
+ displayWakeup.notify(runId);
223
227
  return;
224
228
  }
225
229
  // A draft has no call ID, argument data, or authority to execute.
@@ -230,6 +234,7 @@ export async function serveEngine({ input, output, log = () => {}, startup, env
230
234
  if (current.tools.get(index) === label) return;
231
235
  current.tools.set(index, label);
232
236
  current.draftRevision++;
237
+ displayWakeup.notify(runId);
233
238
  }
234
239
  let host = null, runtime = null, runtimePromise, closing = false;
235
240
  const viewRef = viewStore ? viewStore.archive(engineView()) : null;
@@ -508,7 +513,7 @@ export async function serveEngine({ input, output, log = () => {}, startup, env
508
513
  ...(body ? { text: body } : {}),
509
514
  terminal: runtime.terminal(snapshot), running: active.has(runId) };
510
515
  }
511
- await wait(250, undefined, { signal: lifetime.signal });
516
+ await displayWakeup.wait(runId, Math.min(250, Math.max(1, deadline - Date.now())), lifetime.signal);
512
517
  }
513
518
  },
514
519
  async 'run/resume'(params) {