@kingsoftcloud/agentkit-harness-node 0.0.3 → 0.0.4
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 +3 -2
- package/package.json +4 -3
- package/src/native/skill-tools.mjs +17 -16
- package/src/native/workspace-tools.mjs +10 -9
package/dist/rpc-entry.mjs
CHANGED
|
@@ -5145,6 +5145,7 @@ function createWorkspaceToolExecutor({ workspaceDir, workspaceReal, granted, exe
|
|
|
5145
5145
|
}
|
|
5146
5146
|
|
|
5147
5147
|
// packages/agentkit-harness-node/src/rpc-entry.mjs
|
|
5148
|
+
import { publicErrorMessage } from "@kingsoftcloud/agentkit-harness-core/error-presentation";
|
|
5148
5149
|
var RPC_PROTOCOL_VERSION = "agentkit.native-rpc/v1";
|
|
5149
5150
|
var ERR = {
|
|
5150
5151
|
parse_error: { code: -32700, message: "Parse error" },
|
|
@@ -5517,7 +5518,7 @@ function createNativeRpcServer({ startup, store, ledger, owner = startup.owner,
|
|
|
5517
5518
|
try {
|
|
5518
5519
|
await dispatch(req);
|
|
5519
5520
|
} catch (e) {
|
|
5520
|
-
process.stderr.write(`notification error: ${e
|
|
5521
|
+
process.stderr.write(`notification error: ${publicErrorMessage(e)}
|
|
5521
5522
|
`);
|
|
5522
5523
|
}
|
|
5523
5524
|
return null;
|
|
@@ -5651,7 +5652,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
5651
5652
|
if (res) writeLine(res);
|
|
5652
5653
|
},
|
|
5653
5654
|
(e) => {
|
|
5654
|
-
process.stderr.write(`handler error: ${e
|
|
5655
|
+
process.stderr.write(`handler error: ${publicErrorMessage(e)}
|
|
5655
5656
|
`);
|
|
5656
5657
|
writeLine(errorResponse(req?.id ?? null, ERR.internalError));
|
|
5657
5658
|
}
|
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.4",
|
|
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.",
|
|
@@ -120,7 +120,8 @@
|
|
|
120
120
|
"./native/a2a-receipt-source": "./src/native/a2a-receipt-source.mjs",
|
|
121
121
|
"./native/children": "./src/native/children.mjs",
|
|
122
122
|
"./native/run-observation": "./src/native/run-observation.mjs",
|
|
123
|
-
"./native/tool-states": "./src/native/tool-states.mjs"
|
|
123
|
+
"./native/tool-states": "./src/native/tool-states.mjs",
|
|
124
|
+
"./package-integrity": "./src/package-integrity.mjs"
|
|
124
125
|
},
|
|
125
126
|
"bin": {
|
|
126
127
|
"agentkit-native-rpc": "./dist/rpc-entry.mjs"
|
|
@@ -135,7 +136,7 @@
|
|
|
135
136
|
"THIRD_PARTY_NOTICES.md"
|
|
136
137
|
],
|
|
137
138
|
"dependencies": {
|
|
138
|
-
"@kingsoftcloud/agentkit-harness-core": "0.0.
|
|
139
|
+
"@kingsoftcloud/agentkit-harness-core": "0.0.4",
|
|
139
140
|
"@astral-sh/ruff-wasm-nodejs": "0.16.8",
|
|
140
141
|
"parse5": "7.3.0",
|
|
141
142
|
"playwright-core": "1.58.2",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { publicErrorMessage, publicErrorCode, publicFailureContent } from '@kingsoftcloud/agentkit-harness-core/error-presentation';
|
|
1
2
|
// Native Skills builtin tools — bounded formal definitions and ToolPort.
|
|
2
3
|
//
|
|
3
4
|
// Security contract: the internal definition map is deep-cloned from the
|
|
@@ -18,7 +19,7 @@ import { join, relative, sep } from 'node:path';
|
|
|
18
19
|
export const SKILL_TOOL_CONTRACT = 'agentkit.native-skill-tools/v3';
|
|
19
20
|
|
|
20
21
|
function uncertainOutcome(content) {
|
|
21
|
-
const result = { ...content, uncertain: true };
|
|
22
|
+
const result = { ...publicFailureContent(content), uncertain: true };
|
|
22
23
|
delete result.executed;
|
|
23
24
|
return { status: 'uncertain', content: result };
|
|
24
25
|
}
|
|
@@ -330,9 +331,9 @@ export function createNativeSkillTools({
|
|
|
330
331
|
if (effectStarted) {
|
|
331
332
|
return { ...runtimeLocator, ok: false, status: 'uncertain', uncertain: true,
|
|
332
333
|
error_type: error.code === 'approval_required' || error.approvalRequired ? 'invalid_skill_approval' : 'skill_runtime_uncertain',
|
|
333
|
-
error_message: error
|
|
334
|
+
error_message: publicErrorMessage(error, 'Skill runtime outcome is unknown; the workflow may have side effects.') };
|
|
334
335
|
}
|
|
335
|
-
return { ok: false, error_type: error
|
|
336
|
+
return { ok: false, error_type: publicErrorCode(error, 'TOOL_OPERATION_FAILED'), error_message: publicErrorMessage(error) };
|
|
336
337
|
}
|
|
337
338
|
|
|
338
339
|
// Post-workflow guard: if the request drifted after the workflow completed,
|
|
@@ -460,15 +461,15 @@ export function createNativeSkillTools({
|
|
|
460
461
|
decision = await raceAbort(guard.signal, () => authorize(call.name, { call, signal: guard.signal, scope, runId, sessionId, turnId, buildId, parentRunId, taskChainId, operationKey, executionFence, definition: internalDef }));
|
|
461
462
|
} catch (error) {
|
|
462
463
|
if (guard.signal.aborted) return { status: 'error', content: { code: 'REQUEST_CANCELLED', executed: false, message: 'Cancelled during authorization' } };
|
|
463
|
-
return { status: 'error', content: { code: error
|
|
464
|
+
return { status: 'error', content: { code: publicErrorCode(error, 'NATIVE_SKILL_ERROR'), executed: false, message: publicErrorMessage(error) } };
|
|
464
465
|
}
|
|
465
466
|
const g = guard.check();
|
|
466
467
|
if (g) return { status: 'error', content: { code: g.code, executed: false, message: g.message } };
|
|
467
468
|
if (decision !== 'allow') {
|
|
468
469
|
if (decision?.status === 'approval_required' && typeof decision.interactionId === 'string' && decision.interactionId.trim())
|
|
469
470
|
return { status: 'approval_required', interactionId: decision.interactionId, content: { executed: false } };
|
|
470
|
-
const code = decision
|
|
471
|
-
const message = decision
|
|
471
|
+
const code = publicErrorCode(decision, 'STUDIO_NATIVE_SKILL_PERMISSION_DENIED');
|
|
472
|
+
const message = publicErrorMessage(decision, 'Skill tool not authorized');
|
|
472
473
|
return { status: 'error', content: { code, executed: false, message } };
|
|
473
474
|
}
|
|
474
475
|
|
|
@@ -507,12 +508,12 @@ export function createNativeSkillTools({
|
|
|
507
508
|
}
|
|
508
509
|
// content.ok === false → status 'error'.
|
|
509
510
|
if (result && typeof result === 'object' && result.ok === false) {
|
|
510
|
-
return { status: 'error', content: { ...result, executed: result.executed ?? ctx.effectStarted } };
|
|
511
|
+
return { status: 'error', content: { ...publicFailureContent(result), executed: result.executed ?? ctx.effectStarted } };
|
|
511
512
|
}
|
|
512
513
|
return { status: 'ok', content: result };
|
|
513
514
|
} catch (error) {
|
|
514
515
|
if (ctx.effectStarted) return { status: 'uncertain', content: { ...locator,
|
|
515
|
-
uncertain: true, error_type: 'skill_runtime_uncertain', error_message:
|
|
516
|
+
uncertain: true, error_type: 'skill_runtime_uncertain', error_message: publicErrorMessage(error) } };
|
|
516
517
|
if (guard.signal.aborted) {
|
|
517
518
|
// Fix #4: if effectStarted was set by executeSkills, the abort
|
|
518
519
|
// after side effects is uncertain. For read-only tools, it's
|
|
@@ -521,7 +522,7 @@ export function createNativeSkillTools({
|
|
|
521
522
|
// read-only tool after abort is a clean cancel.
|
|
522
523
|
return { status: 'error', content: { code: 'REQUEST_CANCELLED', executed: false, message: 'Cancelled during execution' } };
|
|
523
524
|
}
|
|
524
|
-
return { status: 'error', content: { code: error
|
|
525
|
+
return { status: 'error', content: { code: publicErrorCode(error, 'NATIVE_SKILL_ERROR'), executed: false, message: publicErrorMessage(error) } };
|
|
525
526
|
}
|
|
526
527
|
},
|
|
527
528
|
},
|
|
@@ -668,7 +669,7 @@ export function createSkillReadTransport({ serviceClient, loadSkillFn, skillSpac
|
|
|
668
669
|
}
|
|
669
670
|
return { ok: true, skills, truncated: pairs.length > skills.length, skill_space_ids: spaceIds, space_id: spaceId ?? null };
|
|
670
671
|
} catch (error) {
|
|
671
|
-
return { ok: false, error_type: error
|
|
672
|
+
return { ok: false, error_type: publicErrorCode(error, 'TOOL_OPERATION_FAILED'), error_message: publicErrorMessage(error), skill_space_ids: spaceIds, space_id: spaceId ?? null };
|
|
672
673
|
}
|
|
673
674
|
}
|
|
674
675
|
|
|
@@ -724,7 +725,7 @@ export function createSkillReadTransport({ serviceClient, loadSkillFn, skillSpac
|
|
|
724
725
|
cache_hit: !!loaded.cacheHit, root_dir: rootDir, has_scripts_dir: hasScripts, script_files: files,
|
|
725
726
|
instructions: loaded.content, usage: "Read these instructions and complete the user's task in the outer agent unless the skill explicitly requires isolated execution." };
|
|
726
727
|
} catch (error) {
|
|
727
|
-
return { ok: false, error_type: error
|
|
728
|
+
return { ok: false, error_type: publicErrorCode(error, 'TOOL_OPERATION_FAILED'), error_message: publicErrorMessage(error) };
|
|
728
729
|
}
|
|
729
730
|
}
|
|
730
731
|
|
|
@@ -743,7 +744,7 @@ export function createSkillReadTransport({ serviceClient, loadSkillFn, skillSpac
|
|
|
743
744
|
cache_hit: false, has_scripts_dir: false, script_files: [], instructions: skill.description || '',
|
|
744
745
|
usage: 'Manifest-level preview. For full SKILL.md instructions, use load_skill.' };
|
|
745
746
|
} catch (error) {
|
|
746
|
-
return { ok: false, error_type: error
|
|
747
|
+
return { ok: false, error_type: publicErrorCode(error, 'TOOL_OPERATION_FAILED'), error_message: publicErrorMessage(error) };
|
|
747
748
|
}
|
|
748
749
|
}
|
|
749
750
|
|
|
@@ -771,7 +772,7 @@ export function createSkillReadTransport({ serviceClient, loadSkillFn, skillSpac
|
|
|
771
772
|
}));
|
|
772
773
|
return { ok: true, query: queryText, space_id: spaceId ?? null, results };
|
|
773
774
|
} catch (error) {
|
|
774
|
-
return { ok: false, error_type: error
|
|
775
|
+
return { ok: false, error_type: publicErrorCode(error, 'TOOL_OPERATION_FAILED'), error_message: publicErrorMessage(error) };
|
|
775
776
|
}
|
|
776
777
|
}
|
|
777
778
|
|
|
@@ -797,7 +798,7 @@ export function createSkillReadTransport({ serviceClient, loadSkillFn, skillSpac
|
|
|
797
798
|
stable(); const verdict = assertCurrent();
|
|
798
799
|
if (verdict && typeof verdict.then === 'function') Promise.resolve(verdict).catch(() => {});
|
|
799
800
|
invariant(verdict === true, 'skill_read_authority_expired'); stable(); return null;
|
|
800
|
-
} catch (error) { return { code: signal.aborted ? 'REQUEST_CANCELLED' : error
|
|
801
|
+
} catch (error) { return { code: signal.aborted ? 'REQUEST_CANCELLED' : publicErrorCode(error, 'skill_read_authority_expired'),
|
|
801
802
|
message: signal.aborted ? 'Skill read cancelled' : 'Skill read authority or identity changed' }; }
|
|
802
803
|
}, assertCurrent() {
|
|
803
804
|
const failure = this.check(); if (failure) throw new SkillToolError(failure.code, failure.message); return true;
|
|
@@ -805,8 +806,8 @@ export function createSkillReadTransport({ serviceClient, loadSkillFn, skillSpac
|
|
|
805
806
|
try {
|
|
806
807
|
guard.assertCurrent();
|
|
807
808
|
const result = await raceAbort(signal, () => handlers[request.call.name](copy(request.call.arguments ?? {}), { guard }));
|
|
808
|
-
guard.assertCurrent(); return result;
|
|
809
|
-
} catch (error) { return { ok: false, error_type: signal.aborted ? 'REQUEST_CANCELLED' : error
|
|
809
|
+
guard.assertCurrent(); return result?.ok === false ? publicFailureContent(result) : result;
|
|
810
|
+
} catch (error) { return { ok: false, error_type: signal.aborted ? 'REQUEST_CANCELLED' : publicErrorCode(error, 'SKILL_READ_FAILED'), executed: false }; }
|
|
810
811
|
} };
|
|
811
812
|
}
|
|
812
813
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { publicErrorMessage, publicErrorCode } from '@kingsoftcloud/agentkit-harness-core/error-presentation';
|
|
1
2
|
/**
|
|
2
3
|
* Native Node workspace tools for the AgentKit Harness.
|
|
3
4
|
*
|
|
@@ -527,8 +528,8 @@ export function createNativeWorkspaceTools({
|
|
|
527
528
|
if (!absent(target)) return stalePreparedEdit(rel);
|
|
528
529
|
const createdText = preparedEdit.createdText;
|
|
529
530
|
try { publish(target, Buffer.from(createdText, 'utf-8'), { createOnly: true }); }
|
|
530
|
-
catch (error) { return { ok: false, path: rel, error_type: error.code === 'EEXIST' ? 'file_modified_since_read' : error
|
|
531
|
-
error_message: error
|
|
531
|
+
catch (error) { return { ok: false, path: rel, error_type: error.code === 'EEXIST' ? 'file_modified_since_read' : publicErrorCode(error, 'publish_failed'),
|
|
532
|
+
error_message: publicErrorMessage(error), suggested_action: 'Read the current file and retry.' }; }
|
|
532
533
|
const stat = statSync(target, { bigint: true }); refreshReadState(rel, stat, createdText, target);
|
|
533
534
|
const diff = buildDiff(rel, '', createdText);
|
|
534
535
|
return { ok: true, path: rel, absolute_path: target, replacements: 1, used_quote_normalization: false,
|
|
@@ -694,7 +695,7 @@ export function createNativeWorkspaceTools({
|
|
|
694
695
|
if (typeof patch !== 'string' || patch.length > 262144) return { error: patchFailure('apply_patch_invalid_patch', 'patch_text must be a string of at most 262144 characters') };
|
|
695
696
|
let sections;
|
|
696
697
|
try { sections = parseStructuredPatch(patch); }
|
|
697
|
-
catch (error) { return { error: patchFailure('apply_patch_invalid_patch', error
|
|
698
|
+
catch (error) { return { error: patchFailure('apply_patch_invalid_patch', publicErrorMessage(error)) }; }
|
|
698
699
|
if (!sections.length) return { error: patchFailure('apply_patch_empty_patch', 'Patch has no file changes') };
|
|
699
700
|
if (sections.length > 64) return { error: patchFailure('patch_budget_exceeded', 'At most 64 file sections are allowed') };
|
|
700
701
|
const changes = [], paths = new Set(); let bytes = 0;
|
|
@@ -1062,7 +1063,7 @@ export function createNativeWorkspaceTools({
|
|
|
1062
1063
|
const mutating = MUTATING.has(name);
|
|
1063
1064
|
let guard;
|
|
1064
1065
|
try { guard = workspaceMutationGuard(request, mutating ? assertCurrent : undefined, checkRootBoundary); }
|
|
1065
|
-
catch (error) { return { status: 'error', content: { code: error
|
|
1066
|
+
catch (error) { return { status: 'error', content: { code: publicErrorCode(error, 'invalid_request') } }; }
|
|
1066
1067
|
|
|
1067
1068
|
// The root boundary is pinned at factory creation. Re-check it on every
|
|
1068
1069
|
// execute: a symlink swap (or parent rewrite) that changes the live
|
|
@@ -1128,7 +1129,7 @@ export function createNativeWorkspaceTools({
|
|
|
1128
1129
|
if (preparedPatch.error) return { status: 'error', content: preparedPatch.error };
|
|
1129
1130
|
} catch (error) {
|
|
1130
1131
|
if (signal?.aborted) return canceled();
|
|
1131
|
-
return { status: 'error', content: { ok: false, error_type: error
|
|
1132
|
+
return { status: 'error', content: { ok: false, error_type: publicErrorCode(error, 'apply_patch_verification_failed'), error_message: publicErrorMessage(error), executed: false } };
|
|
1132
1133
|
}
|
|
1133
1134
|
}
|
|
1134
1135
|
// Matching runs before the publication lock, with strings only. The locked
|
|
@@ -1141,8 +1142,8 @@ export function createNativeWorkspaceTools({
|
|
|
1141
1142
|
if (preparedEdit.error) return { status: 'error', content: preparedEdit.error };
|
|
1142
1143
|
} catch (error) {
|
|
1143
1144
|
if (signal?.aborted) return canceled();
|
|
1144
|
-
return { status: 'error', content: { ok: false, error_type: error instanceof WorkspacePathError ? 'path_escape' : error
|
|
1145
|
-
error_message: error
|
|
1145
|
+
return { status: 'error', content: { ok: false, error_type: error instanceof WorkspacePathError ? 'path_escape' : publicErrorCode(error, 'edit_match_failed'),
|
|
1146
|
+
error_message: publicErrorMessage(error), executed: false } };
|
|
1146
1147
|
}
|
|
1147
1148
|
}
|
|
1148
1149
|
const mutations = new Set(), publications = new Map(), reads = new Map(), displayChanges = new Map(), previousDisplayChanges = activeDisplayChanges,
|
|
@@ -1199,8 +1200,8 @@ export function createNativeWorkspaceTools({
|
|
|
1199
1200
|
try { result = await result; }
|
|
1200
1201
|
catch (error) {
|
|
1201
1202
|
if (signal?.aborted) return canceled();
|
|
1202
|
-
return { status: 'error', content: { ok: false, error_type: error
|
|
1203
|
-
error_message: error
|
|
1203
|
+
return { status: 'error', content: { ok: false, error_type: publicErrorCode(error, 'python_syntax_unavailable'),
|
|
1204
|
+
error_message: publicErrorMessage(error) } };
|
|
1204
1205
|
}
|
|
1205
1206
|
}
|
|
1206
1207
|
if (signal?.aborted && !(result && result.ok)) return canceled();
|