@agentknight/client 0.9.52 → 0.9.55
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 -201
- package/README.md +366 -360
- package/dist/chunks/{aad-relay-login-GDMN45AM.js → aad-relay-login-WQG3PP44.js} +2 -2
- package/dist/chunks/{chunk-FLU66YYO.js → chunk-BSOD4PLU.js} +1 -1
- package/dist/chunks/{chunk-KYTI7A5R.js → chunk-CG5LD6VF.js} +1 -1
- package/dist/chunks/{chunk-YNKNHR5K.js → chunk-CNWBK4LE.js} +0 -2
- package/dist/chunks/{chunk-Q3KK54IU.js → chunk-KW4VLCH7.js} +648 -633
- package/dist/chunks/{chunk-EQHABZEC.js → chunk-TB7CMFWU.js} +1 -1
- package/dist/chunks/{client-home-LAKFDPXO.js → client-home-GPFY7NJP.js} +6 -101
- package/dist/chunks/{local-sessions-BNYVWPDJ.js → local-sessions-FSIFD3QQ.js} +1 -1
- package/dist/chunks/{start-client-OBVH54YU.js → start-client-G55A6VKD.js} +33 -76
- package/dist/chunks/stop-client-PHRAMW5R.js +40 -0
- package/dist/chunks/{upgrade-T32WY4HC.js → upgrade-4IKPYFYS.js} +2 -2
- package/dist/cli.js +28 -8
- package/dist/upgrade-worker.js +14 -3
- package/package.json +4 -4
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
processExists,
|
|
4
|
+
readRuntimeDescriptor,
|
|
5
|
+
requestRuntime
|
|
6
|
+
} from "./chunk-WZIU4HVH.js";
|
|
7
|
+
import "./chunk-SPZWIFFP.js";
|
|
8
|
+
|
|
9
|
+
// src/stop-client.ts
|
|
10
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
11
|
+
async function stopClient(dataDirectory, expectedPid) {
|
|
12
|
+
const descriptor = await readRuntimeDescriptor(dataDirectory);
|
|
13
|
+
if (descriptor === void 0 || !processExists(descriptor.pid)) {
|
|
14
|
+
if (expectedPid !== void 0) throw new Error("The selected Agent has exited. Refresh its status.");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (expectedPid !== void 0 && descriptor.pid !== expectedPid) {
|
|
18
|
+
throw new Error("The running Agent changed. Refresh its status before stopping it.");
|
|
19
|
+
}
|
|
20
|
+
const status = await requestRuntime(descriptor, "status");
|
|
21
|
+
if (status === void 0) throw new Error("Could not verify the running Agent.");
|
|
22
|
+
if (status.busy || status.stopping) {
|
|
23
|
+
throw new Error("The Agent is busy or already stopping. Finish pending work and retry.");
|
|
24
|
+
}
|
|
25
|
+
await requestRuntime(descriptor, "stop", 65e3);
|
|
26
|
+
const deadline = Date.now() + 1e4;
|
|
27
|
+
do {
|
|
28
|
+
const current = await readRuntimeDescriptor(dataDirectory);
|
|
29
|
+
if (current === void 0) return;
|
|
30
|
+
if (current.instanceId !== descriptor.instanceId || current.pid !== descriptor.pid) {
|
|
31
|
+
throw new Error("Another Agent started while stopping. Refresh its status.");
|
|
32
|
+
}
|
|
33
|
+
if (!processExists(descriptor.pid)) return;
|
|
34
|
+
await delay(100);
|
|
35
|
+
} while (Date.now() < deadline);
|
|
36
|
+
throw new Error("The Agent has not finished stopping. Check its status before retrying.");
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
stopClient
|
|
40
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
readAppVersion,
|
|
4
4
|
toErrorDetails
|
|
5
|
-
} from "./chunks/chunk-
|
|
5
|
+
} from "./chunks/chunk-BSOD4PLU.js";
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -20,6 +20,7 @@ function parseCliOptions(args) {
|
|
|
20
20
|
let json = false;
|
|
21
21
|
let check = false;
|
|
22
22
|
let targetVersion;
|
|
23
|
+
let expectedPid;
|
|
23
24
|
const peerChat = {};
|
|
24
25
|
for (let index = 0; index < args.length; index += 1) {
|
|
25
26
|
const argument = args[index];
|
|
@@ -31,7 +32,7 @@ function parseCliOptions(args) {
|
|
|
31
32
|
version = true;
|
|
32
33
|
continue;
|
|
33
34
|
}
|
|
34
|
-
if (argument === "status" || argument === "upgrade" || argument === "login" || argument === "peer-chat") {
|
|
35
|
+
if (argument === "status" || argument === "stop" || argument === "upgrade" || argument === "login" || argument === "peer-chat") {
|
|
35
36
|
if (command !== void 0) throw new Error("Specify only one command.");
|
|
36
37
|
command = argument;
|
|
37
38
|
continue;
|
|
@@ -44,6 +45,15 @@ function parseCliOptions(args) {
|
|
|
44
45
|
check = true;
|
|
45
46
|
continue;
|
|
46
47
|
}
|
|
48
|
+
if (argument === "--pid") {
|
|
49
|
+
const value = args[index + 1];
|
|
50
|
+
if (expectedPid !== void 0 || value === void 0 || !/^[1-9]\d*$/u.test(value) || !Number.isSafeInteger(Number(value)) || Number(value) > 2147483647) {
|
|
51
|
+
throw new Error("--pid requires one positive process ID.");
|
|
52
|
+
}
|
|
53
|
+
expectedPid = Number(value);
|
|
54
|
+
index += 1;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
47
57
|
if (argument === "--session" || argument === "--peer-machine" || argument === "--peer-session" || argument === "--prompt") {
|
|
48
58
|
const value = args[index + 1];
|
|
49
59
|
if (value === void 0 || value.trim() === "" || value.startsWith("--")) {
|
|
@@ -86,7 +96,8 @@ function parseCliOptions(args) {
|
|
|
86
96
|
}
|
|
87
97
|
throw new Error(`Unknown option: ${argument}`);
|
|
88
98
|
}
|
|
89
|
-
if (json && command !== "status" && command !== "peer-chat") throw new Error("--json requires status or peer-chat.");
|
|
99
|
+
if (json && command !== "status" && command !== "stop" && command !== "peer-chat") throw new Error("--json requires status, stop or peer-chat.");
|
|
100
|
+
if (expectedPid !== void 0 && command !== "stop") throw new Error("--pid requires stop.");
|
|
90
101
|
if (noEnv && envFile !== void 0) throw new Error("--no-env cannot be combined with --env.");
|
|
91
102
|
if (check && command !== "upgrade") throw new Error("--check requires upgrade.");
|
|
92
103
|
if (agents !== void 0 && (command !== void 0 || version)) throw new Error("--agents is only valid when starting the Agent.");
|
|
@@ -108,6 +119,7 @@ function parseCliOptions(args) {
|
|
|
108
119
|
...json ? { json } : {},
|
|
109
120
|
...check ? { check } : {},
|
|
110
121
|
...targetVersion === void 0 ? {} : { targetVersion },
|
|
122
|
+
...expectedPid === void 0 ? {} : { expectedPid },
|
|
111
123
|
...parsedPeerChat?.success ? { peerChat: parsedPeerChat.data } : {}
|
|
112
124
|
};
|
|
113
125
|
}
|
|
@@ -118,6 +130,7 @@ Usage:
|
|
|
118
130
|
agentknight [--env <path>] [--agents <list|none>]
|
|
119
131
|
npx @agentknight/client [--env <path>] [--agents <list|none>]
|
|
120
132
|
agentknight status [--json] [--env <path>]
|
|
133
|
+
agentknight stop [--pid <id>] [--json] [--env <path>]
|
|
121
134
|
agentknight upgrade [version] [--check] [--env <path>]
|
|
122
135
|
agentknight login [--env <path>]
|
|
123
136
|
agentknight peer-chat --session <id> --peer-machine <id> --peer-session <id> --prompt <text> [--json] [--env <path>]
|
|
@@ -132,9 +145,10 @@ Options:
|
|
|
132
145
|
|
|
133
146
|
AGENTKNIGHT_HOME defaults to ~/.ak; configuration is <home>/agentknight.env.
|
|
134
147
|
--env ignores inherited PC settings; external provider/OS variables are retained.
|
|
135
|
-
COPILOT_REMOTE_HOME is a deprecated input alias for AGENTKNIGHT_HOME.
|
|
136
148
|
Upgrade prepares both versions before stopping the Agent and restores the
|
|
137
149
|
previous version if startup fails. Busy agents are not interrupted.
|
|
150
|
+
stop requests a safe shutdown without deleting configuration or pairing.
|
|
151
|
+
--pid refuses to stop a different Agent if the selected process has changed.
|
|
138
152
|
|
|
139
153
|
--agents uses managed mode and overrides saved selection and
|
|
140
154
|
AGENTKNIGHT_CODING_AGENT for this start; it does not overwrite saved settings.
|
|
@@ -168,7 +182,7 @@ async function main() {
|
|
|
168
182
|
`);
|
|
169
183
|
return;
|
|
170
184
|
}
|
|
171
|
-
const { resolveClientEnvironment } = await import("./chunks/client-home-
|
|
185
|
+
const { resolveClientEnvironment } = await import("./chunks/client-home-GPFY7NJP.js");
|
|
172
186
|
const resolved = await resolveClientEnvironment({
|
|
173
187
|
...cliOptions.envFile === void 0 ? {} : { envFile: cliOptions.envFile },
|
|
174
188
|
...cliOptions.noEnv ? { noEnv: true } : {},
|
|
@@ -199,6 +213,13 @@ async function main() {
|
|
|
199
213
|
}
|
|
200
214
|
return;
|
|
201
215
|
}
|
|
216
|
+
if (cliOptions.command === "stop") {
|
|
217
|
+
const { stopClient } = await import("./chunks/stop-client-PHRAMW5R.js");
|
|
218
|
+
await stopClient(resolved.dataDirectory, cliOptions.expectedPid);
|
|
219
|
+
process.stdout.write(cliOptions.json ? `${JSON.stringify({ state: "stopped" })}
|
|
220
|
+
` : "PC Agent stopped.\n");
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
202
223
|
if (cliOptions.command === "status") {
|
|
203
224
|
const [{ processExists, readRuntimeDescriptor, requestRuntime }, { readLastUpgrade, readUpgradeState }] = await Promise.all([import("./chunks/runtime-CTACRJCK.js"), import("./chunks/upgrade-state-QXZT3TTS.js")]);
|
|
204
225
|
const descriptor = await readRuntimeDescriptor(resolved.dataDirectory);
|
|
@@ -214,7 +235,6 @@ async function main() {
|
|
|
214
235
|
configPath: runtime?.configPath ?? resolved.envFile ?? null,
|
|
215
236
|
relayUrl: runtime?.relayUrl ?? null,
|
|
216
237
|
dataDirectory: resolved.dataDirectory,
|
|
217
|
-
migrationPending: resolved.migrationPending ?? false,
|
|
218
238
|
upgradedAt: lastUpgrade?.upgradedAt ?? null,
|
|
219
239
|
upgrade: state ?? null
|
|
220
240
|
};
|
|
@@ -224,7 +244,7 @@ async function main() {
|
|
|
224
244
|
return;
|
|
225
245
|
}
|
|
226
246
|
if (cliOptions.command === "upgrade") {
|
|
227
|
-
const { upgrade } = await import("./chunks/upgrade-
|
|
247
|
+
const { upgrade } = await import("./chunks/upgrade-4IKPYFYS.js");
|
|
228
248
|
await upgrade({
|
|
229
249
|
dataDirectory: resolved.dataDirectory,
|
|
230
250
|
currentVersion: appVersion,
|
|
@@ -235,7 +255,7 @@ async function main() {
|
|
|
235
255
|
});
|
|
236
256
|
return;
|
|
237
257
|
}
|
|
238
|
-
const { startClient } = await import("./chunks/start-client-
|
|
258
|
+
const { startClient } = await import("./chunks/start-client-G55A6VKD.js");
|
|
239
259
|
await startClient(appVersion, cliOptions, resolved, fileURLToPath(import.meta.url));
|
|
240
260
|
}
|
|
241
261
|
await main().catch((error) => {
|
package/dist/upgrade-worker.js
CHANGED
|
@@ -19699,7 +19699,6 @@ import { homedir } from "node:os";
|
|
|
19699
19699
|
import { join, resolve } from "node:path";
|
|
19700
19700
|
import { fileURLToPath } from "node:url";
|
|
19701
19701
|
var directoryAliases = [
|
|
19702
|
-
["COPILOT_REMOTE_HOME", "AGENTKNIGHT_HOME"],
|
|
19703
19702
|
["AGENTKNIGHT_PI_DIRECTORY", "PI_CODING_AGENT_DIR"]
|
|
19704
19703
|
];
|
|
19705
19704
|
function sameClientPath(left, right, cwd = process.cwd()) {
|
|
@@ -20193,7 +20192,7 @@ async function installPreparedPackage(options) {
|
|
|
20193
20192
|
import { createConnection, createServer } from "node:net";
|
|
20194
20193
|
import { join as join5, resolve as resolve3 } from "node:path";
|
|
20195
20194
|
|
|
20196
|
-
// ../../shared/sdk/dist/chunks/chunk-
|
|
20195
|
+
// ../../shared/sdk/dist/chunks/chunk-K5CMKBW6.js
|
|
20197
20196
|
var IdSchema = external_exports.string().trim().min(1).max(256);
|
|
20198
20197
|
var IsoDateSchema = external_exports.iso.datetime({ offset: true });
|
|
20199
20198
|
var Base64UrlKeyIdSchema = external_exports.string().regex(/^[A-Za-z0-9_-]{22}$/u, "Expected a 16-byte base64url key ID");
|
|
@@ -21954,6 +21953,16 @@ var BrowserOpenUrlParamsSchema = external_exports.strictObject({
|
|
|
21954
21953
|
}, "Expected an absolute HTTP(S) URL without credentials or whitespace")
|
|
21955
21954
|
});
|
|
21956
21955
|
var BrowserOpenUrlResultSchema = external_exports.strictObject({ opened: external_exports.literal(true) });
|
|
21956
|
+
var DEVICE_TEXT_INPUT_MAX_LENGTH = 1e5;
|
|
21957
|
+
var DeviceTextInputDataSchema = external_exports.object({
|
|
21958
|
+
text: external_exports.string().min(1).max(DEVICE_TEXT_INPUT_MAX_LENGTH).refine((value) => value.trim().length > 0 && !value.includes("\0")),
|
|
21959
|
+
expiresAt: external_exports.number().int().nonnegative()
|
|
21960
|
+
}).strict();
|
|
21961
|
+
var DeviceTextInputResultSchema = external_exports.object({
|
|
21962
|
+
clipboardUpdated: external_exports.boolean(),
|
|
21963
|
+
pasteAttempted: external_exports.boolean(),
|
|
21964
|
+
pasteShortcutSent: external_exports.boolean()
|
|
21965
|
+
}).strict().refine((result) => (!result.pasteAttempted || result.clipboardUpdated) && (!result.pasteShortcutSent || result.pasteAttempted));
|
|
21957
21966
|
var SessionCommunicationIdSchema = external_exports.string().min(1).max(256).refine((value) => value === value.trim(), "Expected an unpadded identity");
|
|
21958
21967
|
var SessionCommunicationIdentityShape = {
|
|
21959
21968
|
requestId: SessionCommunicationIdSchema,
|
|
@@ -22855,6 +22864,8 @@ var AndroidProtocolSchemas = {
|
|
|
22855
22864
|
MobileAuthorizationResult: MobileAuthorizationResultSchema,
|
|
22856
22865
|
BrowserOpenUrlParams: BrowserOpenUrlParamsSchema,
|
|
22857
22866
|
BrowserOpenUrlResult: BrowserOpenUrlResultSchema,
|
|
22867
|
+
DeviceTextInputData: DeviceTextInputDataSchema,
|
|
22868
|
+
DeviceTextInputResult: DeviceTextInputResultSchema,
|
|
22858
22869
|
TimelineImageBlobRequest: TimelineImageBlobRequestSchema,
|
|
22859
22870
|
TimelineImageBlobResult: TimelineImageBlobResultSchema,
|
|
22860
22871
|
SessionImageUploadRequest: SessionImageUploadRequestSchema,
|
|
@@ -22972,7 +22983,7 @@ var AndroidProtocolSchemas = {
|
|
|
22972
22983
|
ProtocolError: ProtocolErrorSchema
|
|
22973
22984
|
};
|
|
22974
22985
|
|
|
22975
|
-
// ../../shared/sdk/dist/chunks/chunk-
|
|
22986
|
+
// ../../shared/sdk/dist/chunks/chunk-Z5STULMQ.js
|
|
22976
22987
|
var OwnerSchema = external_exports.object({ pid: external_exports.number().int().positive(), instanceId: external_exports.uuid().optional() });
|
|
22977
22988
|
var PeerChatRequestSchema = external_exports.object({
|
|
22978
22989
|
sessionId: IdSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentknight/client",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.55",
|
|
4
4
|
"description": "AgentKnight PC Agent CLI for remote coding sessions",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"qrcode": "1.5.4",
|
|
46
46
|
"qrcode-terminal": "0.12.0",
|
|
47
47
|
"zod": "4.6.5",
|
|
48
|
-
"@agentknight/sdk": "0.9.
|
|
48
|
+
"@agentknight/sdk": "0.9.55"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@tailwindcss/node": "4.3.3",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"sharp": "0.35.5",
|
|
58
58
|
"socket.io-client": "4.8.4",
|
|
59
59
|
"tailwindcss": "4.3.3",
|
|
60
|
-
"@agentknight/
|
|
61
|
-
"@agentknight/
|
|
60
|
+
"@agentknight/shared": "0.1.0",
|
|
61
|
+
"@agentknight/protocol": "0.1.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|