@kingsoftcloud/agentkit-harness-node 0.0.5 → 0.0.7
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/dist/rpc-entry.mjs
CHANGED
|
@@ -5333,12 +5333,12 @@ function createNativeRpcServer({ startup, store, ledger, owner = startup.owner,
|
|
|
5333
5333
|
const row = ledger.lookupByRunKey(key);
|
|
5334
5334
|
if (row) ledger.complete(row.requestId, compactResponse(snap), key);
|
|
5335
5335
|
} catch (e) {
|
|
5336
|
-
process.stderr.write(`complete failed for ${runId}: ${e
|
|
5336
|
+
process.stderr.write(`complete failed for ${runId}: ${publicErrorMessage(e)}
|
|
5337
5337
|
`);
|
|
5338
5338
|
}
|
|
5339
5339
|
}
|
|
5340
5340
|
} catch (e) {
|
|
5341
|
-
process.stderr.write(`drive failed for ${runId}: ${e
|
|
5341
|
+
process.stderr.write(`drive failed for ${runId}: ${publicErrorMessage(e)}
|
|
5342
5342
|
`);
|
|
5343
5343
|
} finally {
|
|
5344
5344
|
resolveDone();
|
|
@@ -5380,7 +5380,7 @@ function createNativeRpcServer({ startup, store, ledger, owner = startup.owner,
|
|
|
5380
5380
|
if (e.code !== "run_not_found") throw e;
|
|
5381
5381
|
}
|
|
5382
5382
|
if (existing) {
|
|
5383
|
-
if (terminal3(existing.snapshot)) {
|
|
5383
|
+
if (terminal3(existing.snapshot.phase)) {
|
|
5384
5384
|
const response = compactResponse(existing.snapshot);
|
|
5385
5385
|
try {
|
|
5386
5386
|
ledger.complete(ledgerId(requestId), response, key);
|
|
@@ -5600,7 +5600,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
5600
5600
|
try {
|
|
5601
5601
|
startup = buildStartup(args);
|
|
5602
5602
|
} catch (e) {
|
|
5603
|
-
process.stderr.write(`startup error: ${e
|
|
5603
|
+
process.stderr.write(`startup error: ${publicErrorMessage(e)}
|
|
5604
5604
|
`);
|
|
5605
5605
|
return process.exit(2);
|
|
5606
5606
|
}
|
|
@@ -5614,7 +5614,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
5614
5614
|
try {
|
|
5615
5615
|
await server.dispose();
|
|
5616
5616
|
} catch (e) {
|
|
5617
|
-
process.stderr.write(`dispose error: ${e
|
|
5617
|
+
process.stderr.write(`dispose error: ${publicErrorMessage(e)}
|
|
5618
5618
|
`);
|
|
5619
5619
|
}
|
|
5620
5620
|
await Promise.allSettled(handlers);
|
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.7",
|
|
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.",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"src/package-integrity.mjs"
|
|
138
138
|
],
|
|
139
139
|
"dependencies": {
|
|
140
|
-
"@kingsoftcloud/agentkit-harness-core": "0.0.
|
|
140
|
+
"@kingsoftcloud/agentkit-harness-core": "0.0.7",
|
|
141
141
|
"@astral-sh/ruff-wasm-nodejs": "0.16.8",
|
|
142
142
|
"parse5": "7.3.0",
|
|
143
143
|
"playwright-core": "1.58.2",
|
|
@@ -138,7 +138,17 @@ export function tryLock(path, busyTimeoutMs = 0) {
|
|
|
138
138
|
try { createPrivate(path); } catch (error) { if (error.code !== 'EEXIST') throw error; }
|
|
139
139
|
}
|
|
140
140
|
const before = privateFile(path);
|
|
141
|
-
for (const suffix of ['-journal', '-wal', '-shm'])
|
|
141
|
+
for (const suffix of ['-journal', '-wal', '-shm']) {
|
|
142
|
+
try { privateFile(path + suffix, true); }
|
|
143
|
+
catch (error) {
|
|
144
|
+
// SQLite may unlink a sidecar while another owner checks its lstat.
|
|
145
|
+
// No lock has been acquired or effect dispatched: treat this transient
|
|
146
|
+
// tombstone as contention, then verify the next acquisition afresh.
|
|
147
|
+
// Main database drift, links and unsafe permissions remain hard errors.
|
|
148
|
+
if (error.code === 'background_state_changed') return null;
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
142
152
|
let db;
|
|
143
153
|
try {
|
|
144
154
|
db = new DatabaseSync(path);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { publicErrorMessage, publicErrorCode } from '@kingsoftcloud/agentkit-harness-core/error-presentation';
|
|
1
|
+
import { publicErrorMessage, publicErrorCode, publicFailureContent } from '@kingsoftcloud/agentkit-harness-core/error-presentation';
|
|
2
2
|
/**
|
|
3
3
|
* Native Node workspace tools for the AgentKit Harness.
|
|
4
4
|
*
|
|
@@ -476,7 +476,7 @@ export function createNativeWorkspaceTools({
|
|
|
476
476
|
if (e.code === 'EEXIST') {
|
|
477
477
|
return { ok: false, path: rel, error_type: 'file_exists', error_message: 'workspace file was created before publication', suggested_action: 'Read the new file before proposing an overwrite.' };
|
|
478
478
|
}
|
|
479
|
-
return { ok: false, path: rel, error_type: e.code
|
|
479
|
+
return { ok: false, path: rel, error_type: typeof e.code === 'string' && e.code.startsWith('checkpoint_') ? publicErrorCode(e, 'publish_failed') : 'publish_failed', error_message: publicErrorMessage(e) };
|
|
480
480
|
}
|
|
481
481
|
const stat = statSync(t, { bigint: true });
|
|
482
482
|
refreshReadState(rel, stat, content, t);
|
|
@@ -790,7 +790,7 @@ export function createNativeWorkspaceTools({
|
|
|
790
790
|
try {
|
|
791
791
|
publish(target, Buffer.from(updated, 'utf-8'));
|
|
792
792
|
} catch (e) {
|
|
793
|
-
return { stat: null, error: { ok: false, path: rel, error_type: e.code
|
|
793
|
+
return { stat: null, error: { ok: false, path: rel, error_type: typeof e.code === 'string' && e.code.startsWith('checkpoint_') ? publicErrorCode(e, 'publish_failed') : 'publish_failed', error_message: publicErrorMessage(e) } };
|
|
794
794
|
}
|
|
795
795
|
const stat = statSync(target, { bigint: true });
|
|
796
796
|
refreshReadState(rel, stat, updated, target);
|
|
@@ -832,7 +832,7 @@ export function createNativeWorkspaceTools({
|
|
|
832
832
|
try {
|
|
833
833
|
JSON.parse(text ?? '');
|
|
834
834
|
} catch (e) {
|
|
835
|
-
issues.push({ severity: 'error', ...jsonErrorPosition(e.message, text), message: e
|
|
835
|
+
issues.push({ severity: 'error', ...jsonErrorPosition(e.message, text), message: publicErrorMessage(e) });
|
|
836
836
|
}
|
|
837
837
|
} else {
|
|
838
838
|
genericTextChecks(text, issues);
|
|
@@ -923,7 +923,7 @@ export function createNativeWorkspaceTools({
|
|
|
923
923
|
try {
|
|
924
924
|
pattern = new RegExp(isRegex ? needle : escapeRegex(needle), caseSensitive ? '' : 'i');
|
|
925
925
|
} catch (e) {
|
|
926
|
-
return { ok: false, error_code: 'invalid_search_pattern', error_message: e
|
|
926
|
+
return { ok: false, error_code: 'invalid_search_pattern', error_message: publicErrorMessage(e) };
|
|
927
927
|
}
|
|
928
928
|
const limit = Math.max(1, Math.min(maxResults || 100, 5000));
|
|
929
929
|
const contextLimit = Math.max(0, Math.min(contextLines || 0, 20));
|
|
@@ -983,7 +983,7 @@ export function createNativeWorkspaceTools({
|
|
|
983
983
|
}
|
|
984
984
|
activeMutations?.add(relativeOf(target));
|
|
985
985
|
} catch (e) {
|
|
986
|
-
return { ok: false, error_message: `workspace delete failed: ${e
|
|
986
|
+
return { ok: false, error_message: `workspace delete failed: ${publicErrorMessage(e)}` };
|
|
987
987
|
}
|
|
988
988
|
return { ok: true, deleted: relativeOf(target) };
|
|
989
989
|
}
|
|
@@ -1047,7 +1047,18 @@ export function createNativeWorkspaceTools({
|
|
|
1047
1047
|
|
|
1048
1048
|
// ---- execute --------------------------------------------------------------
|
|
1049
1049
|
|
|
1050
|
-
|
|
1050
|
+
// One public failure boundary also covers helper results and parser diagnostics.
|
|
1051
|
+
// Successful file/media data and Host effect evidence must not be rewritten.
|
|
1052
|
+
async function execute(request, options) {
|
|
1053
|
+
try {
|
|
1054
|
+
const result = await executeWorkspace(request, options);
|
|
1055
|
+
return result.status === 'ok' ? result : { ...result, content: publicFailureContent(result.content) };
|
|
1056
|
+
} catch (error) {
|
|
1057
|
+
throw Object.assign(new Error(publicErrorMessage(error)), { code: publicErrorCode(error, 'internal_error') });
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
async function executeWorkspace(request, { assertCurrent, checkpointCommitted } = {}) {
|
|
1051
1062
|
if (!request || typeof request !== 'object') {
|
|
1052
1063
|
return { status: 'error', content: { code: 'invalid_request', message: 'request object required' } };
|
|
1053
1064
|
}
|
|
@@ -1072,7 +1083,7 @@ export function createNativeWorkspaceTools({
|
|
|
1072
1083
|
try { checkRootBoundary(); }
|
|
1073
1084
|
catch (e) {
|
|
1074
1085
|
if (e instanceof RootBoundaryError) {
|
|
1075
|
-
return { status: 'error', content: { code: e
|
|
1086
|
+
return { status: 'error', content: { code: publicErrorCode(e, 'workspace_root_changed'), message: publicErrorMessage(e) } };
|
|
1076
1087
|
}
|
|
1077
1088
|
throw e;
|
|
1078
1089
|
}
|
|
@@ -1085,14 +1096,14 @@ export function createNativeWorkspaceTools({
|
|
|
1085
1096
|
} else {
|
|
1086
1097
|
let decision;
|
|
1087
1098
|
try { decision = await authorizeFn(request); } catch (e) {
|
|
1088
|
-
return { status: 'error', content: { code: 'authorize_failed', message: e
|
|
1099
|
+
return { status: 'error', content: { code: 'authorize_failed', message: publicErrorMessage(e) } };
|
|
1089
1100
|
}
|
|
1090
1101
|
// Re-check the boundary after the authorization await: the root could
|
|
1091
1102
|
// have been swapped while the caller was deciding approval.
|
|
1092
1103
|
try { checkRootBoundary(); }
|
|
1093
1104
|
catch (e) {
|
|
1094
1105
|
if (e instanceof RootBoundaryError) {
|
|
1095
|
-
return { status: 'error', content: { code: e
|
|
1106
|
+
return { status: 'error', content: { code: publicErrorCode(e, 'workspace_root_changed'), message: publicErrorMessage(e) } };
|
|
1096
1107
|
}
|
|
1097
1108
|
throw e;
|
|
1098
1109
|
}
|
|
@@ -1178,19 +1189,19 @@ export function createNativeWorkspaceTools({
|
|
|
1178
1189
|
try {
|
|
1179
1190
|
compensateRewind(preparedRewind, publications, checkpoint, guard);
|
|
1180
1191
|
return { status: 'error', workspaceChangedPaths: [...mutations], content: { ok: false,
|
|
1181
|
-
error_type: 'checkpoint_rewind_compensated', cause: e
|
|
1192
|
+
error_type: 'checkpoint_rewind_compensated', cause: publicErrorCode(e, 'rewind_failed'), compensated: true, executed: true, paths: [...mutations] } };
|
|
1182
1193
|
} catch (error) { compensationError = error; }
|
|
1183
1194
|
}
|
|
1184
1195
|
if (checkpoint && !mutations.size) { try { checkpoint.fail(); } catch {} }
|
|
1185
1196
|
if (signal?.aborted && !mutations.size) return canceled();
|
|
1186
1197
|
if (e instanceof WorkspacePathError && !mutations.size) {
|
|
1187
|
-
return { status: 'error', content: { ok: false, error_type: 'path_escape', error_message: e
|
|
1198
|
+
return { status: 'error', content: { ok: false, error_type: 'path_escape', error_message: publicErrorMessage(e) } };
|
|
1188
1199
|
}
|
|
1189
1200
|
if (mutations.size) return { status: 'uncertain', workspaceChangedPaths: [...mutations],
|
|
1190
1201
|
content: { ok: false, error_type: compensationError ? 'checkpoint_compensation_incomplete'
|
|
1191
1202
|
: name === 'apply_workspace_patch' ? 'patch_publication_incomplete' : 'state_persist_failed',
|
|
1192
|
-
...(compensationError ? { compensation_reason: compensationError
|
|
1193
|
-
return { status: 'error', content: { ok: false, error_type: e
|
|
1203
|
+
...(compensationError ? { compensation_reason: publicErrorCode(compensationError, 'compensation_failed') } : {}), executed: true, paths: [...mutations] } };
|
|
1204
|
+
return { status: 'error', content: { ok: false, error_type: publicErrorCode(e, 'internal_error'), error_message: publicErrorMessage(e) } };
|
|
1194
1205
|
} finally { activeMutations = previousMutations; activeGuard = previousGuard; activeCheckpoint = previousCheckpoint; activeDisplayChanges = previousDisplayChanges;
|
|
1195
1206
|
activePublications = previousPublications; activeReads = previousReads; release?.(); }
|
|
1196
1207
|
// The only asynchronous implementation parses captured read-only bytes.
|