@kingsoftcloud/agentkit-harness-node 0.0.0-stage → 0.0.1
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/LICENSE +201 -0
- package/NOTICE +1 -0
- package/README.md +124 -2
- package/THIRD_PARTY_NOTICES.md +66 -0
- package/ZCode-LICENSE +202 -0
- package/dist/index.mjs +4871 -0
- package/dist/native-command-plan.LICENSE.txt +221 -0
- package/dist/native-command-plan.json +16 -0
- package/dist/native-command-plan.mjs +8 -0
- package/dist/rpc-entry.mjs +5682 -0
- package/package.json +169 -4
- package/src/native/a2a-receipt-source.mjs +19 -0
- package/src/native/a2a-tools.mjs +517 -0
- package/src/native/activity-status.mjs +30 -0
- package/src/native/artifact-codec.mjs +481 -0
- package/src/native/artifact-store.mjs +1162 -0
- package/src/native/assistant-stream.mjs +76 -0
- package/src/native/background-command-port.mjs +95 -0
- package/src/native/browser-action-observation.mjs +43 -0
- package/src/native/browser-availability.mjs +22 -0
- package/src/native/browser-canvas-metrics.mjs +71 -0
- package/src/native/browser-dom.mjs +193 -0
- package/src/native/browser-playwright.mjs +1249 -0
- package/src/native/browser-vision.mjs +369 -0
- package/src/native/browser-workspace-policy.mjs +22 -0
- package/src/native/browser-workspace-protocol.mjs +95 -0
- package/src/native/browser-workspace-server.mjs +164 -0
- package/src/native/browser-workspace.mjs +355 -0
- package/src/native/captured-source.mjs +3 -0
- package/src/native/child-budget-allocation.mjs +87 -0
- package/src/native/child-capabilities.mjs +35 -0
- package/src/native/child-command-resource.mjs +20 -0
- package/src/native/child-history.mjs +188 -0
- package/src/native/child-merge.mjs +98 -0
- package/src/native/child-model-surface.mjs +19 -0
- package/src/native/child-observation.mjs +100 -0
- package/src/native/child-owner.mjs +620 -0
- package/src/native/child-publication.mjs +76 -0
- package/src/native/child-readers.mjs +366 -0
- package/src/native/child-tools.mjs +46 -0
- package/src/native/child-workspace-binding.mjs +29 -0
- package/src/native/child-workspace-tools.mjs +1 -0
- package/src/native/child-workspaces.mjs +655 -0
- package/src/native/children.mjs +365 -0
- package/src/native/command-plan-worker.mjs +14 -0
- package/src/native/command-plan.mjs +31 -0
- package/src/native/command-progress.mjs +64 -0
- package/src/native/command-shell.mjs +9 -0
- package/src/native/command-workspace-observation.mjs +36 -0
- package/src/native/component-tools.mjs +280 -0
- package/src/native/context-counter.mjs +133 -0
- package/src/native/context-markers.mjs +51 -0
- package/src/native/context-profile.mjs +72 -0
- package/src/native/context-status.mjs +27 -0
- package/src/native/conversation-command-control.mjs +133 -0
- package/src/native/delivery-timeline.mjs +39 -0
- package/src/native/dsh-background-ownership.mjs +102 -0
- package/src/native/dsh-managed-ownership.mjs +23 -0
- package/src/native/dsh-turn-contract.mjs +3 -0
- package/src/native/dsh-turn-ownership.mjs +54 -0
- package/src/native/dsh-turn-runtime.mjs +498 -0
- package/src/native/e2b-background-supervisor.mjs +347 -0
- package/src/native/e2b-background.mjs +368 -0
- package/src/native/e2b-command-state.mjs +40 -0
- package/src/native/e2b-command-tools.mjs +486 -0
- package/src/native/e2b-sandbox-owner.mjs +227 -0
- package/src/native/hook-executor.mjs +249 -0
- package/src/native/instruction-assembly.mjs +60 -0
- package/src/native/instruction-context.mjs +54 -0
- package/src/native/local-background-supervisor.mjs +108 -0
- package/src/native/local-background.mjs +207 -0
- package/src/native/local-command-evidence.mjs +57 -0
- package/src/native/local-command-policy-worker.mjs +197 -0
- package/src/native/local-command-policy.mjs +46 -0
- package/src/native/local-command-state.mjs +177 -0
- package/src/native/local-command-tools.mjs +302 -0
- package/src/native/local-execution-profile.mjs +36 -0
- package/src/native/local-output-policy.mjs +92 -0
- package/src/native/local-process-bin/darwin-arm64/launcher +0 -0
- package/src/native/local-process-bin/darwin-x64/launcher +0 -0
- package/src/native/local-process-bin/linux-arm64/launcher +0 -0
- package/src/native/local-process-bin/linux-x64/launcher +0 -0
- package/src/native/local-process-launcher.c +183 -0
- package/src/native/local-process-licenses/GCC-COPYING.RUNTIME +72 -0
- package/src/native/local-process-licenses/GCC-COPYING3 +674 -0
- package/src/native/local-process-licenses/NOTICE +21 -0
- package/src/native/local-process-licenses/musl-COPYRIGHT +193 -0
- package/src/native/local-process-manifest.json +32 -0
- package/src/native/local-process.mjs +246 -0
- package/src/native/local-resource-profile.mjs +32 -0
- package/src/native/memory-candidate.mjs +121 -0
- package/src/native/memory-extraction-run.mjs +60 -0
- package/src/native/memory-extraction-tools.mjs +116 -0
- package/src/native/memory-recall.mjs +65 -0
- package/src/native/memory-store.mjs +334 -0
- package/src/native/memory-tools.mjs +329 -0
- package/src/native/model-anthropic-cache.mjs +49 -0
- package/src/native/model-anthropic-tool-search.mjs +85 -0
- package/src/native/model-anthropic.mjs +753 -0
- package/src/native/model-chat-usage.mjs +24 -0
- package/src/native/model-inline-reasoning.mjs +111 -0
- package/src/native/model-media.mjs +174 -0
- package/src/native/model-normalize.mjs +228 -0
- package/src/native/model-openai-chat.mjs +561 -0
- package/src/native/model-port.mjs +361 -0
- package/src/native/model-provider-compat.mjs +129 -0
- package/src/native/model-replay.mjs +153 -0
- package/src/native/model-request.mjs +15 -0
- package/src/native/model-responses.mjs +1205 -0
- package/src/native/model-sse.mjs +171 -0
- package/src/native/model-surface-host.mjs +27 -0
- package/src/native/model-tool-search-policy.mjs +16 -0
- package/src/native/model-transport-observation.mjs +27 -0
- package/src/native/owned-child.mjs +114 -0
- package/src/native/owned-command.mjs +106 -0
- package/src/native/python-syntax-worker.mjs +60 -0
- package/src/native/python-syntax.mjs +50 -0
- package/src/native/read-interruption.mjs +16 -0
- package/src/native/result-stream.mjs +63 -0
- package/src/native/ruff-ast.mjs +95 -0
- package/src/native/run-observation.mjs +128 -0
- package/src/native/session-delivery-journal.mjs +96 -0
- package/src/native/session-delivery.mjs +434 -0
- package/src/native/shell-analysis.mjs +50 -0
- package/src/native/skill-disclosure.mjs +404 -0
- package/src/native/skill-events.mjs +164 -0
- package/src/native/skill-tools.mjs +813 -0
- package/src/native/source-page.mjs +73 -0
- package/src/native/sqlite-session-inbox.mjs +42 -0
- package/src/native/sqlite-store.mjs +617 -0
- package/src/native/tool-authority.mjs +99 -0
- package/src/native/tool-guidance.mjs +12 -0
- package/src/native/tool-observation.mjs +75 -0
- package/src/native/tool-states.mjs +14 -0
- package/src/native/verification-authority.mjs +37 -0
- package/src/native/web-tools.mjs +643 -0
- package/src/native/workspace-checkpoints.mjs +312 -0
- package/src/native/workspace-context.mjs +61 -0
- package/src/native/workspace-display.mjs +39 -0
- package/src/native/workspace-edit-match.mjs +19 -0
- package/src/native/workspace-edit-worker.mjs +15 -0
- package/src/native/workspace-editing.mjs +447 -0
- package/src/native/workspace-image.mjs +72 -0
- package/src/native/workspace-instructions.mjs +107 -0
- package/src/native/workspace-mutation-lock.mjs +74 -0
- package/src/native/workspace-patch-worker.mjs +17 -0
- package/src/native/workspace-patch.mjs +17 -0
- package/src/native/workspace-paths.mjs +225 -0
- package/src/native/workspace-state.mjs +272 -0
- package/src/native/workspace-subject-observer.mjs +84 -0
- package/src/native/workspace-tools.mjs +1740 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { canonical, invariant, workspaceSourceModelReply, archivedSourceObservation } from '@kingsoftcloud/agentkit-harness-core';
|
|
2
|
+
import { estimateNativeText, NATIVE_CONTEXT_COUNTER_ID } from './context-counter.mjs';
|
|
3
|
+
|
|
4
|
+
export function validateSourcePageBudget(budget) {
|
|
5
|
+
invariant(budget?.policy === 'agentkit.source-page-budget/v1' && budget.counterId === NATIVE_CONTEXT_COUNTER_ID
|
|
6
|
+
&& typeof budget.quoteDigest === 'string' && budget.quoteDigest && typeof budget.tokenizerDigest === 'string' && budget.tokenizerDigest
|
|
7
|
+
&& ['maxSourceUnits', 'maxResultUnits', 'maxResultBytes', 'sourceGroupSize'].every(key => Number.isSafeInteger(budget[key]) && budget[key] > 0)
|
|
8
|
+
&& budget.maxResultBytes >= 1024, 'source_read_budget_unavailable');
|
|
9
|
+
return budget;
|
|
10
|
+
}
|
|
11
|
+
const maximumUri = 'artifact://' + 'a'.repeat(245);
|
|
12
|
+
const modelBytes = text => Buffer.byteLength(canonical({ content: text, media: [], additionalContexts: [] }));
|
|
13
|
+
|
|
14
|
+
/** Shape the exact bytes already selected by the filesystem reader. No I/O,
|
|
15
|
+
* artifact publication, read-state grant or secondary source read occurs here. */
|
|
16
|
+
export function budgetWorkspaceSourcePage(info, content, requestedLimit, inputBudget) {
|
|
17
|
+
const budget = validateSourcePageBudget(inputBudget), chars = Array.from(content);
|
|
18
|
+
const requested = Math.max(1000, Math.min(Number(requestedLimit ?? 20000), 100000));
|
|
19
|
+
const carrier = { path: info.path, read_range: { start: info.start_line, end: info.end_line }, content };
|
|
20
|
+
const fullCount = info.line_count;
|
|
21
|
+
let low = 0, high = Math.min(chars.length, requested);
|
|
22
|
+
while (low < high) {
|
|
23
|
+
const mid = Math.ceil((low + high) / 2);
|
|
24
|
+
if (estimateNativeText(chars.slice(0, mid).join('')) <= budget.maxSourceUnits) low = mid; else high = mid - 1;
|
|
25
|
+
}
|
|
26
|
+
const prefix = chars.slice(0, low).join('');
|
|
27
|
+
let visible = prefix, count = fullCount, truncated = low < chars.length;
|
|
28
|
+
if (truncated) {
|
|
29
|
+
const complete = chars[low] === '\n', boundary = prefix.lastIndexOf('\n');
|
|
30
|
+
count = complete ? prefix.split('\n').length : boundary >= 0 ? prefix.slice(0, boundary).split('\n').length : 0;
|
|
31
|
+
visible = complete || !count ? prefix : prefix.slice(0, boundary);
|
|
32
|
+
}
|
|
33
|
+
const window = (returned, text) => {
|
|
34
|
+
const last = returned ? info.start_line + returned - 1 : null;
|
|
35
|
+
return { content: text, preview_chars: Array.from(text).length, end_line: last, line_count: returned,
|
|
36
|
+
read_range: last === null ? null : { start: info.start_line, end: last },
|
|
37
|
+
source_read_range: carrier.read_range, next_start_line: last === null ? null : last + 1,
|
|
38
|
+
suggested_action: last === null
|
|
39
|
+
? 'The source line or result metadata exceeds the output window. Use bound search or another permitted inspection tool; the unread remainder cannot be skipped.'
|
|
40
|
+
: `Continue with read_workspace_file(path='${info.path}', start_line=${last + 1}); the remaining lines were not returned.`,
|
|
41
|
+
...(returned ? {} : { partial_line: info.start_line }) };
|
|
42
|
+
};
|
|
43
|
+
let result = { ...info, content: visible, preview_chars: Array.from(visible).length, original_chars: chars.length,
|
|
44
|
+
truncated, partial: info.partial || truncated, requested_source: carrier,
|
|
45
|
+
source_output_budget: { version: 'host-source-page/v2', counter_id: budget.counterId,
|
|
46
|
+
max_units: budget.maxSourceUnits, max_result_units: budget.maxResultUnits },
|
|
47
|
+
...(truncated ? window(count, visible) : {}) };
|
|
48
|
+
const fits = page => {
|
|
49
|
+
const projected = workspaceSourceModelReply(page) ?? canonical({ status: 'ok', content: page });
|
|
50
|
+
const text = archivedSourceObservation(projected, maximumUri);
|
|
51
|
+
return estimateNativeText(canonical(text)) <= budget.maxResultUnits && modelBytes(text) <= budget.maxResultBytes;
|
|
52
|
+
};
|
|
53
|
+
let sourceLines;
|
|
54
|
+
const candidate = returned => ({ ...result, ...window(returned, (sourceLines ??= content.split('\n')).slice(0, returned).join('\n')),
|
|
55
|
+
truncated: true, partial: true, ...(returned ? {} : { artifact_only: true }) });
|
|
56
|
+
if (!fits(result)) {
|
|
57
|
+
if (!content) return { ok: false, path: info.path, error_message: 'source_read_envelope_over_budget' };
|
|
58
|
+
low = 0; high = count;
|
|
59
|
+
if (!fits(candidate(0))) return { ok: false, path: info.path, error_message: 'source_read_envelope_over_budget' };
|
|
60
|
+
while (low < high) {
|
|
61
|
+
const mid = Math.ceil((low + high) / 2);
|
|
62
|
+
if (fits(candidate(mid))) low = mid; else high = mid - 1;
|
|
63
|
+
}
|
|
64
|
+
result = candidate(low);
|
|
65
|
+
}
|
|
66
|
+
if (content && result.line_count === 0) {
|
|
67
|
+
// Retaining a source, including a partial first line, is not evidence of a
|
|
68
|
+
// live read. The latest reference policy returns a saved-unread envelope.
|
|
69
|
+
result = { ...result, ...window(0, ''), artifact_only: true, truncated: true, partial: true };
|
|
70
|
+
if (!fits(result)) return { ok: false, path: info.path, error_message: 'source_read_envelope_over_budget' };
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { appendSessionInjection, canonical, invariant, parseNativeJson } from '@kingsoftcloud/agentkit-harness-core';
|
|
2
|
+
|
|
3
|
+
/** Uses the RunStore connection: assigning inbox rows and creating a Run commit together. */
|
|
4
|
+
export function createSqliteSessionInbox(db, open) {
|
|
5
|
+
db.exec(`CREATE TABLE IF NOT EXISTS native_session_inbox (
|
|
6
|
+
scope TEXT NOT NULL, session_id TEXT NOT NULL, injection_id TEXT NOT NULL,
|
|
7
|
+
seq INTEGER NOT NULL, data TEXT NOT NULL, consumed_by TEXT,
|
|
8
|
+
PRIMARY KEY(scope,session_id,injection_id), UNIQUE(scope,session_id,seq));
|
|
9
|
+
CREATE INDEX IF NOT EXISTS native_session_inbox_pending ON native_session_inbox(scope,session_id,consumed_by,seq);`);
|
|
10
|
+
const pending = (scope, sessionId) => db.prepare(`SELECT data FROM native_session_inbox
|
|
11
|
+
WHERE scope=? AND session_id=? AND consumed_by IS NULL ORDER BY seq`)
|
|
12
|
+
.all(canonical(scope), sessionId).map(row => parseNativeJson(row.data));
|
|
13
|
+
return {
|
|
14
|
+
pendingSessionInjections: pending,
|
|
15
|
+
enqueueSessionInjection(scope, sessionId, input) {
|
|
16
|
+
open(); db.exec('BEGIN IMMEDIATE');
|
|
17
|
+
try {
|
|
18
|
+
const key = canonical(scope);
|
|
19
|
+
const duplicate = db.prepare('SELECT data,consumed_by FROM native_session_inbox WHERE scope=? AND session_id=? AND injection_id=?')
|
|
20
|
+
.get(key, sessionId, input.injectionId);
|
|
21
|
+
const entries = duplicate ? [{ ...parseNativeJson(duplicate.data), consumedBy: duplicate.consumed_by }] : pending(scope, sessionId);
|
|
22
|
+
const nextSequence = db.prepare('SELECT COALESCE(MAX(seq),0)+1 AS seq FROM native_session_inbox WHERE scope=? AND session_id=?')
|
|
23
|
+
.get(key, sessionId).seq;
|
|
24
|
+
const result = appendSessionInjection({ entries, nextSequence }, input);
|
|
25
|
+
if (!duplicate) {
|
|
26
|
+
const row = result.state.entries.at(-1);
|
|
27
|
+
db.prepare('INSERT INTO native_session_inbox VALUES (?,?,?,?,?,NULL)').run(key, sessionId,
|
|
28
|
+
row.injectionId, row.sequence, canonical(row));
|
|
29
|
+
}
|
|
30
|
+
db.exec('COMMIT'); return result.receipt;
|
|
31
|
+
} catch (error) { db.exec('ROLLBACK'); throw error; }
|
|
32
|
+
},
|
|
33
|
+
consume(snapshot) {
|
|
34
|
+
for (const row of snapshot.sessionInjections ?? []) {
|
|
35
|
+
const result = db.prepare(`UPDATE native_session_inbox SET consumed_by=?
|
|
36
|
+
WHERE scope=? AND session_id=? AND injection_id=? AND seq=? AND consumed_by IS NULL`)
|
|
37
|
+
.run(snapshot.runId, canonical(snapshot.scope), snapshot.sessionId, row.injectionId, row.sequence);
|
|
38
|
+
invariant(result.changes === 1, 'session_injection_admission_conflict');
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|