@kingsoftcloud/agentkit-harness-node 0.0.21 → 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.
|
|
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.
|
|
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
|
+
}
|
|
@@ -29,6 +29,7 @@ import { nativeLocalExecutionMethods } from './local-execution-profile.mjs';
|
|
|
29
29
|
import { bindNativeModelSurface } from './model-surface-host.mjs';
|
|
30
30
|
import { nativeToolModelGuidance } from './tool-guidance.mjs';
|
|
31
31
|
import { createNativeWebTools } from './web-tools.mjs';
|
|
32
|
+
import { engineWebConfig } from './engine-web-config.mjs';
|
|
32
33
|
import { createNativeChildren, nativeChildRoles } from './children.mjs';
|
|
33
34
|
import { nativeChildToolDefinitions } from './child-tools.mjs';
|
|
34
35
|
import { nativeChildReaderDefinitions } from './child-readers.mjs';
|
|
@@ -235,7 +236,11 @@ export async function createEngineRuntime({ workspaceRoot, stateDir, sessionId,
|
|
|
235
236
|
artifacts, authorize: (request, info) => decide(request, true, info?.readOnlyCommand),
|
|
236
237
|
classifyApproval: true, captureWorkspace: request => workspace.capture(request),
|
|
237
238
|
resolveOwnedCommand: createOwnedCommandResolver({ scope, store }) });
|
|
238
|
-
const
|
|
239
|
+
const search = engineWebConfig(sourceEnv);
|
|
240
|
+
const web = createNativeWebTools({ fetch: fetchImpl, providerConfig: search.providerConfig, authorize: decide, sessionId, inlineMaxChars: 6000 });
|
|
241
|
+
// Do not advertise a search which can only return provider_not_configured.
|
|
242
|
+
// Public page fetching remains available independently of search credentials.
|
|
243
|
+
if (!search.configured) web.definitions = web.definitions.filter(tool => tool.name !== 'web_search');
|
|
239
244
|
const owners = [workspace, commands, web];
|
|
240
245
|
const route = new Map(owners.flatMap(port => port.definitions.map(definition => [definition.name, port])));
|
|
241
246
|
// Anything a Run advertises that the engine does not own was admitted as a host tool.
|
|
@@ -447,6 +452,7 @@ export async function createEngineRuntime({ workspaceRoot, stateDir, sessionId,
|
|
|
447
452
|
description: 'Verify the requested result using the bound host owner.' }] } : {}) },
|
|
448
453
|
...(media.length || scopedCallbacks || originalInput ? { inputMessages } : {}), ...preset.policies,
|
|
449
454
|
hostBindingDigest: digest({ contract: ENGINE_RUNTIME_CONTRACT, workspaceRoot: root, description, tools: runtimeTools, instructions,
|
|
455
|
+
webBinding: digest(search.providerConfig),
|
|
450
456
|
...(commandSandbox ? { commandSandbox } : {}), ...(durableApprovals && roles.length ? { roles } : {}),
|
|
451
457
|
...(contextSources.length ? { contextSources } : {}),
|
|
452
458
|
...(hooks.definitions.length ? { hooks: hooks.definitions, ...hooks.configuration } : {}),
|
|
@@ -482,6 +488,7 @@ export async function createEngineRuntime({ workspaceRoot, stateDir, sessionId,
|
|
|
482
488
|
model: { name: description.modelName, protocol: description.protocol, contextWindow: description.contextWindow,
|
|
483
489
|
requestOutputTokens: description.maxOutputTokens, images: supportsImages },
|
|
484
490
|
tools: bound.map(tool => tool.name),
|
|
491
|
+
webSearch: { available: search.configured, reason: search.configured ? null : 'provider_not_configured' },
|
|
485
492
|
// Every name a host tool may not use: engine tools plus the control tools the preset or discovery can add.
|
|
486
493
|
reservedToolNames: [...new Set([...[...bound, ...childDefinitions, ...enginePresetToolDefinitions(resolveEnginePreset()), ...toolDiscoveryDefinitions(),
|
|
487
494
|
...todoToolDefinitions(true), ...todoToolDefinitions(false)].map(tool => tool.name), ...KERNEL_TOOL_NAMES])].sort(),
|
|
@@ -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,
|
|
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) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Search configuration belongs to the independent engine, not to its UI host.
|
|
2
|
+
// Resolve once at startup; credentials must never be returned by info().
|
|
3
|
+
export function engineWebConfig(env = {}) {
|
|
4
|
+
const read = (...names) => names.map(name => String(env[name] ?? '').trim()).find(Boolean) || '';
|
|
5
|
+
const provider = read('AGENTKIT_ENGINE_WEB_SEARCH_PROVIDER', 'KSADK_WEB_SEARCH_PROVIDER', 'OPENCLAW_WEB_SEARCH_PROVIDER').toLowerCase();
|
|
6
|
+
const baseUrl = read('AGENTKIT_ENGINE_WEB_SEARCH_BASE_URL', 'KSADK_WEB_SEARCH_BASE_URL', 'OPENCLAW_WEB_SEARCH_BASE_URL');
|
|
7
|
+
const apiKey = read('AGENTKIT_ENGINE_WEB_SEARCH_API_KEY', 'KSADK_WEB_SEARCH_API_KEY', 'OPENCLAW_WEB_SEARCH_API_KEY',
|
|
8
|
+
...(provider === 'ksyun' ? ['KSADK_MCP_KEY', 'KSC_AIPRO_API_KEY', 'KSC_AIPRO_APIKEY', 'AIPRO_API_KEY'] : []));
|
|
9
|
+
const scope = read('AGENTKIT_ENGINE_WEB_SEARCH_SCOPE', 'KSADK_WEB_SEARCH_SCOPE') || 'webpage';
|
|
10
|
+
const validUrl = value => {
|
|
11
|
+
try { const url = new URL(value); return ['http:', 'https:'].includes(url.protocol) && !url.username && !url.password; }
|
|
12
|
+
catch { return false; }
|
|
13
|
+
};
|
|
14
|
+
const configured = provider === 'http' && validUrl(baseUrl)
|
|
15
|
+
|| provider === 'ksyun' && Boolean(apiKey) && (!baseUrl || validUrl(baseUrl));
|
|
16
|
+
return { configured, providerConfig: configured ? { provider, baseUrl, apiKey, scope } : { provider: '' } };
|
|
17
|
+
}
|