@agentknight/client 0.9.52 → 0.9.53
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 +358 -360
- 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-FLU66YYO.js → chunk-HQX6KKVV.js} +1 -1
- package/dist/chunks/{client-home-LAKFDPXO.js → client-home-GPFY7NJP.js} +6 -101
- package/dist/chunks/{start-client-OBVH54YU.js → start-client-YUTN4EXF.js} +29 -72
- 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 +0 -1
- package/package.json +2 -2
|
@@ -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-HQX6KKVV.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-YUTN4EXF.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()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentknight/client",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.53",
|
|
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.53"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@tailwindcss/node": "4.3.3",
|