@kingsoftcloud/agentkit-personal-assistant 0.0.0-stage → 0.1.6
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 +7 -0
- package/README.md +38 -2
- package/cordis.patch.yml +6 -0
- package/dist/client.js +6 -0
- package/package.json +83 -4
- package/personal-assistant.plugin.json +31 -0
- package/personal-assistant.plugin.schema.json +43 -0
- package/runtime/assistant-runtime.mjs +317 -0
- package/runtime/check-manifest.mjs +21 -0
- package/runtime/cloud-browser-cdp.mjs +313 -0
- package/runtime/cloud-browser.mjs +972 -0
- package/runtime/cloud-execution.mjs +320 -0
- package/runtime/cloud-session-channel.mjs +45 -0
- package/runtime/computer-agentd.mjs +488 -0
- package/runtime/desktop-clipboard-limit.mjs +2 -0
- package/runtime/desktop-launcher.mjs +106 -0
- package/runtime/desktop-permit.mjs +42 -0
- package/runtime/desktop-session.mjs +840 -0
- package/runtime/desktop-ws.mjs +371 -0
- package/runtime/prepare-dsh-profile.mjs +17 -0
- package/runtime/welcome-server.mjs +144 -0
- package/scripts/assistant-runtime-launcher.sh +3 -0
- package/scripts/build-artifacts.mjs +81 -0
- package/scripts/build-client.mjs +82 -0
- package/scripts/computer-agentd-launcher.sh +3 -0
- package/scripts/deterministic_tar.py +21 -0
- package/scripts/install-local.mjs +262 -0
- package/scripts/scan-secrets.mjs +41 -0
- package/scripts/sync-public.mjs +52 -0
- package/scripts/verification/gateway-desktop-client.mjs +142 -0
- package/scripts/verification/verify-desktop-applications-linux.mjs +46 -0
- package/scripts/verification/verify-desktop-input-linux.mjs +127 -0
- package/scripts/verification/verify-desktop-pod-gateway.mjs +204 -0
- package/scripts/verify-cloud-turn.mjs +18 -0
- package/scripts/verify-computer-broker.mjs +10 -0
- package/src/automation-tools.mjs +18 -0
- package/src/bot-private-tools.mjs +23 -0
- package/src/bot-registry.mjs +157 -0
- package/src/bot-tool-policy.mjs +48 -0
- package/src/bot-tool-scope.mjs +40 -0
- package/src/client/bot-directory.mjs +23 -0
- package/src/client/components/desktop-clipboard.mjs +194 -0
- package/src/client/conversation.mjs +558 -0
- package/src/client/desktop-control.mjs +70 -0
- package/src/client/desktop-view.mjs +68 -0
- package/src/client/entry.mjs +8 -0
- package/src/client/index.mjs +693 -0
- package/src/client/markdown.mjs +130 -0
- package/src/client/native-workbench.mjs +62 -0
- package/src/cloud-computer-tools.mjs +245 -0
- package/src/cloud-files.mjs +57 -0
- package/src/cloud-model.mjs +10 -0
- package/src/cloud-session-transport.mjs +76 -0
- package/src/computer-broker-protocol.mjs +116 -0
- package/src/computer-broker.mjs +220 -0
- package/src/desktop-tools.mjs +64 -0
- package/src/dsh-session-bridge.mjs +207 -0
- package/src/dsh-web-bridge.mjs +127 -0
- package/src/host-gateway.mjs +228 -0
- package/src/host-session-channel.mjs +410 -0
- package/src/implementation-capabilities.mjs +10 -0
- package/src/index.mjs +148 -0
- package/src/persistent-state.mjs +201 -0
- package/src/platform-manifest.mjs +24 -0
- package/src/plugin-manifest.mjs +82 -0
- package/src/schedule-manager.mjs +88 -0
- package/src/system-fetch.mjs +72 -0
- package/src/workspace-tools.mjs +22 -0
- package/src/workspace.mjs +22 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Pure browser-side helpers for the Personal Assistant desktop view. */
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_DESKTOP_DISPLAY = Object.freeze({ width: 1280, height: 800 });
|
|
4
|
+
export const DESKTOP_STREAM_IDLE_MS = 10_000;
|
|
5
|
+
export const DESKTOP_ACTIVE_POLL_MS = 100;
|
|
6
|
+
export const DESKTOP_IDLE_POLL_MS = 1_000;
|
|
7
|
+
export const DESKTOP_MOUSE_HZ = 30;
|
|
8
|
+
|
|
9
|
+
export function normalizeDisplay(display = {}) {
|
|
10
|
+
const width = Number(display.width) || DEFAULT_DESKTOP_DISPLAY.width;
|
|
11
|
+
const height = Number(display.height) || DEFAULT_DESKTOP_DISPLAY.height;
|
|
12
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
13
|
+
return DEFAULT_DESKTOP_DISPLAY;
|
|
14
|
+
}
|
|
15
|
+
return Object.freeze({ width: Math.round(width), height: Math.round(height) });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Map client/canvas coordinates without stretching the 16:10 desktop. */
|
|
19
|
+
export function mapDisplayPoint({ clientX, clientY, rect, display = DEFAULT_DESKTOP_DISPLAY }) {
|
|
20
|
+
const target = normalizeDisplay(display);
|
|
21
|
+
const width = Number(rect?.width) || target.width;
|
|
22
|
+
const height = Number(rect?.height) || target.height;
|
|
23
|
+
const offsetX = Number(rect?.left) || 0;
|
|
24
|
+
const offsetY = Number(rect?.top) || 0;
|
|
25
|
+
const scale = Math.min(width / target.width, height / target.height);
|
|
26
|
+
const left = offsetX + (width - target.width * scale) / 2;
|
|
27
|
+
const top = offsetY + (height - target.height * scale) / 2;
|
|
28
|
+
const x = Math.max(0, Math.min(target.width - 1, Math.round((Number(clientX) - left) / scale)));
|
|
29
|
+
const y = Math.max(0, Math.min(target.height - 1, Math.round((Number(clientY) - top) / scale)));
|
|
30
|
+
return { x, y };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function framePayload(frame) {
|
|
34
|
+
if (!frame || typeof frame !== 'object') return null;
|
|
35
|
+
const seq = Number(frame.seq);
|
|
36
|
+
const data = String(frame.data || '');
|
|
37
|
+
if (!Number.isSafeInteger(seq) || seq < 0 || !data) return null;
|
|
38
|
+
const display = normalizeDisplay(frame);
|
|
39
|
+
const format = String(frame.format || 'image/jpeg').toLowerCase();
|
|
40
|
+
const mime = format === 'webp' || format === 'image/webp' ? 'image/webp' : 'image/jpeg';
|
|
41
|
+
const bytes = Number(frame.bytes);
|
|
42
|
+
if (Number.isFinite(bytes) && bytes > 300 * 1024) return null;
|
|
43
|
+
return Object.freeze({ seq, data, mime, width: display.width, height: display.height, bytes: Number.isFinite(bytes) ? bytes : undefined });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function frameDataUrl(frame) {
|
|
47
|
+
const value = framePayload(frame);
|
|
48
|
+
return value ? `data:${value.mime};base64,${value.data}` : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function nextPollDelay({ lastInputAt = 0, now = Date.now(), idleMs = DESKTOP_STREAM_IDLE_MS } = {}) {
|
|
52
|
+
return now - Number(lastInputAt || 0) >= idleMs ? DESKTOP_IDLE_POLL_MS : DESKTOP_ACTIVE_POLL_MS;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function shouldAcceptFrame(frame, lastSeq = -1) {
|
|
56
|
+
const value = framePayload(frame);
|
|
57
|
+
return value ? value.seq > Number(lastSeq) : false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isLeaseConflict(error) {
|
|
61
|
+
return Number(error?.status || error?.statusCode || error?.httpStatus) === 409
|
|
62
|
+
|| String(error?.code || error?.error || '').toUpperCase().includes('LEASE_CONFLICT')
|
|
63
|
+
|| String(error?.message || '').includes('409');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function isInputEventWritable({ connected, readOnly } = {}) {
|
|
67
|
+
return Boolean(connected && !readOnly);
|
|
68
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { apply, inject, setClientReactRuntime } from './index.mjs';
|
|
2
|
+
window.__ModuleLoader__.load({
|
|
3
|
+
id: '@kingsoftcloud/agentkit-personal-assistant',
|
|
4
|
+
factory: require => {
|
|
5
|
+
setClientReactRuntime(require('react'));
|
|
6
|
+
return { name: 'agentkit-personal-assistant', inject, apply };
|
|
7
|
+
},
|
|
8
|
+
});
|