@agentknight/sdk 0.9.46 → 0.9.48
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/chunks/{acp-adapter-3CQCDP5H.js → acp-adapter-2ZBDMHA3.js} +4 -4
- package/dist/chunks/{chunk-TKIZWXMQ.js → chunk-2QHOQXOR.js} +1 -1
- package/dist/chunks/{chunk-QBKKQQCB.js → chunk-6VEMXJW4.js} +1 -1
- package/dist/chunks/{chunk-GRXWNM6S.js → chunk-7HZ5UZSC.js} +1 -1
- package/dist/chunks/{chunk-DUMC5F2D.js → chunk-BDKVGENQ.js} +3 -0
- package/dist/chunks/{chunk-OPUBIQCO.js → chunk-H6FG5CCS.js} +2 -2
- package/dist/chunks/{chunk-7A2SQAZ7.js → chunk-R5LSWHRH.js} +1 -1
- package/dist/chunks/{chunk-MUKGV7IE.js → chunk-RX7VGB3T.js} +3 -3
- package/dist/chunks/{chunk-EIFNERXM.js → chunk-T6226JFS.js} +1 -1
- package/dist/chunks/{chunk-DCY33KQC.js → chunk-YFLDTX2W.js} +2 -2
- package/dist/chunks/{claude-adapter-CBEKRKPT.js → claude-adapter-WCIDCXOP.js} +214 -18
- package/dist/chunks/{codex-adapter-IR5E7AMV.js → codex-adapter-5XC3CAAT.js} +151 -19
- package/dist/chunks/{copilot-adapter-7IACBBQ6.js → copilot-adapter-RSL5GJYO.js} +7 -7
- package/dist/chunks/{managed-agent-adapter-UYLBGRNG.js → managed-agent-adapter-GTFFRVMM.js} +5 -5
- package/dist/chunks/{pi-adapter-5PZT5YQN.js → pi-adapter-WGHEJ5WA.js} +6 -8
- package/dist/index.d.ts +4 -2
- package/dist/index.js +133 -28
- package/dist/runtime.js +2 -2
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
PeerChatRequestSchema,
|
|
5
5
|
PeerChatResultSchema,
|
|
6
6
|
validateDataDirectory
|
|
7
|
-
} from "./chunks/chunk-
|
|
7
|
+
} from "./chunks/chunk-7HZ5UZSC.js";
|
|
8
8
|
import {
|
|
9
9
|
AgentSelectionSchema,
|
|
10
10
|
assertSelectionSnapshotFits,
|
|
11
11
|
supportsAgentSelection
|
|
12
|
-
} from "./chunks/chunk-
|
|
12
|
+
} from "./chunks/chunk-YFLDTX2W.js";
|
|
13
13
|
import {
|
|
14
14
|
ConversationNormalizer,
|
|
15
15
|
LiveTimelineProjection,
|
|
@@ -31,22 +31,22 @@ import {
|
|
|
31
31
|
resolveGitProjectIdentity,
|
|
32
32
|
sessionRestoreFailure,
|
|
33
33
|
validateOperationResponse
|
|
34
|
-
} from "./chunks/chunk-
|
|
34
|
+
} from "./chunks/chunk-RX7VGB3T.js";
|
|
35
35
|
import {
|
|
36
36
|
GROUP_CHAT_MAX_TURNS,
|
|
37
37
|
GroupChatError
|
|
38
|
-
} from "./chunks/chunk-
|
|
38
|
+
} from "./chunks/chunk-H6FG5CCS.js";
|
|
39
39
|
import {
|
|
40
40
|
detectClaude,
|
|
41
41
|
detectCopilot,
|
|
42
42
|
detectPi,
|
|
43
43
|
hasLocalExecutable
|
|
44
|
-
} from "./chunks/chunk-
|
|
44
|
+
} from "./chunks/chunk-T6226JFS.js";
|
|
45
45
|
import {
|
|
46
46
|
assistantPreview,
|
|
47
47
|
isContentfulAssistant,
|
|
48
48
|
userPreview
|
|
49
|
-
} from "./chunks/chunk-
|
|
49
|
+
} from "./chunks/chunk-6VEMXJW4.js";
|
|
50
50
|
import {
|
|
51
51
|
AgentModelListingError,
|
|
52
52
|
AgentSessionRenameError,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
UnsupportedAgentOperationError,
|
|
58
58
|
captureResearchAccess,
|
|
59
59
|
captureWorkbenchAccess
|
|
60
|
-
} from "./chunks/chunk-
|
|
60
|
+
} from "./chunks/chunk-R5LSWHRH.js";
|
|
61
61
|
import {
|
|
62
62
|
A2aRelayRequestSchema,
|
|
63
63
|
A2aRelayResponseSchema,
|
|
@@ -98,6 +98,8 @@ import {
|
|
|
98
98
|
PeerMessageSchema,
|
|
99
99
|
PermissionRequestPayloadSchema,
|
|
100
100
|
PermissionRespondRequestSchema,
|
|
101
|
+
ProtocolErrorSchema,
|
|
102
|
+
RELAY_DISCONNECT_EVENT,
|
|
101
103
|
RESEARCH_CHAT_CAPABILITY,
|
|
102
104
|
SCHEDULES_CAPABILITY,
|
|
103
105
|
SCHEDULE_OPERATIONS,
|
|
@@ -241,7 +243,7 @@ import {
|
|
|
241
243
|
sessionCommunicationError,
|
|
242
244
|
sessionCommunicationOperationCapability,
|
|
243
245
|
workbenchCapability
|
|
244
|
-
} from "./chunks/chunk-
|
|
246
|
+
} from "./chunks/chunk-BDKVGENQ.js";
|
|
245
247
|
|
|
246
248
|
// src/initialize.ts
|
|
247
249
|
import { createHash as createHash16 } from "node:crypto";
|
|
@@ -279,7 +281,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
279
281
|
switch (engine.kind) {
|
|
280
282
|
case "managed": {
|
|
281
283
|
if (owner === void 0) throw new Error("Managed coding agents require the PC owner identity");
|
|
282
|
-
const { ManagedCodingAgentAdapter } = await import("./chunks/managed-agent-adapter-
|
|
284
|
+
const { ManagedCodingAgentAdapter } = await import("./chunks/managed-agent-adapter-GTFFRVMM.js");
|
|
283
285
|
return new ManagedCodingAgentAdapter({
|
|
284
286
|
dataDirectory: config.dataDirectory,
|
|
285
287
|
owner,
|
|
@@ -315,13 +317,13 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
315
317
|
kind: "codex",
|
|
316
318
|
...engine.codexCommand === void 0 ? {} : { command: engine.codexCommand }
|
|
317
319
|
}
|
|
318
|
-
}, onDiagnostic)
|
|
320
|
+
}, onDiagnostic, owner)
|
|
319
321
|
},
|
|
320
322
|
{
|
|
321
323
|
id: "claude",
|
|
322
324
|
name: codingAgentPresentation("claude").name,
|
|
323
325
|
detect: detectClaude,
|
|
324
|
-
create: () => createCodingAgentAdapter({ ...config, codingAgent: { kind: "claude" } }, onDiagnostic)
|
|
326
|
+
create: () => createCodingAgentAdapter({ ...config, codingAgent: { kind: "claude" } }, onDiagnostic, owner)
|
|
325
327
|
},
|
|
326
328
|
{
|
|
327
329
|
id: "acp",
|
|
@@ -336,7 +338,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
336
338
|
});
|
|
337
339
|
}
|
|
338
340
|
case "copilot": {
|
|
339
|
-
const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-
|
|
341
|
+
const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-RSL5GJYO.js");
|
|
340
342
|
if (owner !== void 0) {
|
|
341
343
|
return new GithubCopilotAdapter(void 0, void 0, void 0, {
|
|
342
344
|
dataDirectory: config.dataDirectory,
|
|
@@ -356,28 +358,30 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
356
358
|
}
|
|
357
359
|
case "pi": {
|
|
358
360
|
assertPiRuntimeSupported();
|
|
359
|
-
const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-
|
|
361
|
+
const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-WGHEJ5WA.js");
|
|
360
362
|
return new PiCodingAgentAdapter(
|
|
361
363
|
engine.agentDirectory === void 0 ? {} : { agentDirectory: resolve(engine.agentDirectory) }
|
|
362
364
|
);
|
|
363
365
|
}
|
|
364
366
|
case "codex": {
|
|
365
|
-
const { CodexCodingAgentAdapter } = await import("./chunks/codex-adapter-
|
|
367
|
+
const { CodexCodingAgentAdapter } = await import("./chunks/codex-adapter-5XC3CAAT.js");
|
|
366
368
|
return new CodexCodingAgentAdapter({
|
|
367
369
|
dataDirectory: resolve(config.dataDirectory, "coding-agents"),
|
|
370
|
+
...owner === void 0 ? {} : { nativeSessionOwner: owner },
|
|
368
371
|
...engine.command === void 0 ? {} : { command: engine.command },
|
|
369
372
|
...onDiagnostic === void 0 ? {} : { onDiagnostic }
|
|
370
373
|
});
|
|
371
374
|
}
|
|
372
375
|
case "claude": {
|
|
373
|
-
const { ClaudeCodingAgentAdapter } = await import("./chunks/claude-adapter-
|
|
376
|
+
const { ClaudeCodingAgentAdapter } = await import("./chunks/claude-adapter-WCIDCXOP.js");
|
|
374
377
|
return new ClaudeCodingAgentAdapter({
|
|
375
378
|
dataDirectory: resolve(config.dataDirectory, "coding-agents"),
|
|
379
|
+
...owner === void 0 ? {} : { nativeSessionOwner: owner },
|
|
376
380
|
...onDiagnostic === void 0 ? {} : { onDiagnostic }
|
|
377
381
|
});
|
|
378
382
|
}
|
|
379
383
|
case "acp": {
|
|
380
|
-
const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-
|
|
384
|
+
const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-2ZBDMHA3.js");
|
|
381
385
|
return new AcpCodingAgentAdapter({
|
|
382
386
|
command: engine.command,
|
|
383
387
|
args: engine.args,
|
|
@@ -2677,6 +2681,17 @@ import { createHash as createHash5, randomUUID as randomUUID3 } from "node:crypt
|
|
|
2677
2681
|
import { constants as constants2 } from "node:fs";
|
|
2678
2682
|
import { chmod, lstat as lstat4, mkdir as mkdir2, open as open2, readlink, realpath as realpath4, rm, stat as stat4, writeFile as writeFile2 } from "node:fs/promises";
|
|
2679
2683
|
import { dirname, isAbsolute as isAbsolute4, join as join5, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
2684
|
+
|
|
2685
|
+
// src/git-repository-error.ts
|
|
2686
|
+
function isGitRepositoryUnavailableError(error) {
|
|
2687
|
+
if (!(error instanceof Error && "code" in error && error.code === 128 && "stdout" in error && (typeof error.stdout === "string" || Buffer.isBuffer(error.stdout)) && "stderr" in error && (typeof error.stderr === "string" || Buffer.isBuffer(error.stderr)))) {
|
|
2688
|
+
return false;
|
|
2689
|
+
}
|
|
2690
|
+
const stderr = typeof error.stderr === "string" ? error.stderr : error.stderr.toString("utf8");
|
|
2691
|
+
return error.stdout.length === 0 && /^fatal: (?:not a git repository(?: \(or any of the parent directories\))?|gitfile does not point to a valid repository|invalid gitfile format): [^\r\n]+\r?\n?$/.test(stderr);
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
// src/session-git-diff.ts
|
|
2680
2695
|
var SESSION_GIT_DIFF_CONCURRENCY = 4;
|
|
2681
2696
|
var SESSION_GIT_DIFF_TIMEOUT_MS = 15e3;
|
|
2682
2697
|
var SESSION_GIT_DIFF_MAX_SOURCE_BYTES = 8 * 1024 * 1024;
|
|
@@ -3335,8 +3350,12 @@ var SessionGitDiffReader = class {
|
|
|
3335
3350
|
repository = await realpath4(top);
|
|
3336
3351
|
} catch (error) {
|
|
3337
3352
|
if (error instanceof SessionGitDiffError) throw error;
|
|
3338
|
-
if (
|
|
3339
|
-
throw new SessionGitDiffError(
|
|
3353
|
+
if (isGitRepositoryUnavailableError(error)) {
|
|
3354
|
+
throw new SessionGitDiffError(
|
|
3355
|
+
"DIFF_NOT_REPOSITORY",
|
|
3356
|
+
"The session directory is not a Git repository or its .git metadata is invalid",
|
|
3357
|
+
{ cause: error }
|
|
3358
|
+
);
|
|
3340
3359
|
}
|
|
3341
3360
|
throw error;
|
|
3342
3361
|
}
|
|
@@ -4548,9 +4567,22 @@ async function git(env, ...args) {
|
|
|
4548
4567
|
], { env, encoding: "utf8", windowsHide: true, timeout: 6e4, maxBuffer: 1024 * 1024 });
|
|
4549
4568
|
return stdout.replace(/\r?\n$/, "");
|
|
4550
4569
|
}
|
|
4570
|
+
async function sourceIdentity(sourceDirectory, env) {
|
|
4571
|
+
try {
|
|
4572
|
+
return await resolveGitProjectIdentity(sourceDirectory, env);
|
|
4573
|
+
} catch (cause) {
|
|
4574
|
+
if (isGitRepositoryUnavailableError(cause)) {
|
|
4575
|
+
throw new Error(
|
|
4576
|
+
"The source directory is not a Git repository or its .git metadata is invalid. Choose a valid repository.",
|
|
4577
|
+
{ cause }
|
|
4578
|
+
);
|
|
4579
|
+
}
|
|
4580
|
+
throw cause;
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4551
4583
|
async function listSessionWorktreeBranches(sourceDirectory) {
|
|
4552
4584
|
const env = creationEnvironment();
|
|
4553
|
-
const identity2 = await
|
|
4585
|
+
const identity2 = await sourceIdentity(sourceDirectory, env);
|
|
4554
4586
|
const output2 = await git(
|
|
4555
4587
|
env,
|
|
4556
4588
|
"-C",
|
|
@@ -4577,7 +4609,7 @@ async function listSessionWorktreeBranches(sourceDirectory) {
|
|
|
4577
4609
|
}
|
|
4578
4610
|
async function createSessionWorktree(sourceDirectory, requestedBranchName, requestedBaseBranch) {
|
|
4579
4611
|
const env = creationEnvironment();
|
|
4580
|
-
const identity2 = await
|
|
4612
|
+
const identity2 = await sourceIdentity(sourceDirectory, env);
|
|
4581
4613
|
const baseBranch = requestedBaseBranch?.trim();
|
|
4582
4614
|
const baseRef = baseBranch === void 0 ? "HEAD" : `refs/heads/${baseBranch}`;
|
|
4583
4615
|
if (baseBranch !== void 0) {
|
|
@@ -7997,6 +8029,7 @@ var BUFFERED_INTERACTION_RETENTION_MS = 5 * 60 * 1e3;
|
|
|
7997
8029
|
var INVENTORY_REFRESH_DEBOUNCE_MS = 100;
|
|
7998
8030
|
var SESSION_LIST_REFRESH_RETRIES = 2;
|
|
7999
8031
|
var TRAFFIC_METRICS_INTERVAL_MS = 6e4;
|
|
8032
|
+
var RELAY_RECONNECT_INTERVAL_MS = 15 * 6e4;
|
|
8000
8033
|
var PcAgent = class {
|
|
8001
8034
|
constructor(config, identity2, appVersion, adapter, logger, pairingProvider, contentCipher, research, createSocket = createRelaySocket, onPairing) {
|
|
8002
8035
|
this.config = config;
|
|
@@ -8432,6 +8465,10 @@ var PcAgent = class {
|
|
|
8432
8465
|
#refreshTimer;
|
|
8433
8466
|
#inventoryRefreshTimer;
|
|
8434
8467
|
#trafficMetricsTimer;
|
|
8468
|
+
#relayReconnectTimer;
|
|
8469
|
+
#relayDisconnected = false;
|
|
8470
|
+
#relayDisconnectCode;
|
|
8471
|
+
#started = false;
|
|
8435
8472
|
#machineRegistered = false;
|
|
8436
8473
|
#initialSyncGeneration;
|
|
8437
8474
|
#connecting = 0;
|
|
@@ -8491,7 +8528,10 @@ var PcAgent = class {
|
|
|
8491
8528
|
try {
|
|
8492
8529
|
await this.adapter.start();
|
|
8493
8530
|
this.logger.info({ codingAgent: this.adapter.agentId }, "coding-agent.started");
|
|
8494
|
-
if (!this.#stopping)
|
|
8531
|
+
if (!this.#stopping) {
|
|
8532
|
+
this.#started = true;
|
|
8533
|
+
this.#socket.connect();
|
|
8534
|
+
}
|
|
8495
8535
|
} finally {
|
|
8496
8536
|
this.#starting = false;
|
|
8497
8537
|
}
|
|
@@ -8499,6 +8539,49 @@ var PcAgent = class {
|
|
|
8499
8539
|
waitUntilStopped() {
|
|
8500
8540
|
return this.#stopped;
|
|
8501
8541
|
}
|
|
8542
|
+
reconnectRelay() {
|
|
8543
|
+
if (!this.#started || this.#stopping || this.#upgradeAdmissionClosed) {
|
|
8544
|
+
throw new Error("PC Agent is not available for Relay reconnection.");
|
|
8545
|
+
}
|
|
8546
|
+
if (this.#relayRegistrationStatus.state === "connecting" || this.#socket.connected && this.#machineRegistered) return;
|
|
8547
|
+
this.#connectRelay("manual");
|
|
8548
|
+
}
|
|
8549
|
+
disconnectRelay() {
|
|
8550
|
+
if (!this.#started || this.#stopping || this.#upgradeAdmissionClosed) {
|
|
8551
|
+
throw new Error("PC Agent is not available for Relay disconnection.");
|
|
8552
|
+
}
|
|
8553
|
+
if (this.#relayDisconnected) return;
|
|
8554
|
+
this.#relayDisconnected = true;
|
|
8555
|
+
this.#clearRelayReconnect();
|
|
8556
|
+
this.#connectionGeneration += 1;
|
|
8557
|
+
this.#socket.disconnect();
|
|
8558
|
+
this.#relayRegistrationStatus = { state: "disconnected", message: "\u5DF2\u65AD\u5F00 Relay \u8FDE\u63A5\u3002" };
|
|
8559
|
+
this.logger.info("relay.disconnect.requested");
|
|
8560
|
+
}
|
|
8561
|
+
#connectRelay(source) {
|
|
8562
|
+
this.#clearRelayReconnect();
|
|
8563
|
+
this.#relayDisconnected = false;
|
|
8564
|
+
if (this.#socket.connected) this.#socket.disconnect();
|
|
8565
|
+
this.#relayDisconnectCode = void 0;
|
|
8566
|
+
this.#relayRegistrationStatus = { state: "connecting", message: "\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5 Relay\u3002" };
|
|
8567
|
+
this.logger.info({ source }, "relay.reconnect.requested");
|
|
8568
|
+
this.#socket.connect();
|
|
8569
|
+
}
|
|
8570
|
+
#scheduleRelayReconnect() {
|
|
8571
|
+
if (this.#stopping || this.#relayDisconnected || this.#socket.active || this.#socket.connected || this.#relayReconnectTimer !== void 0) return;
|
|
8572
|
+
this.logger.info({ delayMs: RELAY_RECONNECT_INTERVAL_MS }, "relay.reconnect.scheduled");
|
|
8573
|
+
this.#relayReconnectTimer = setTimeout(() => {
|
|
8574
|
+
this.#relayReconnectTimer = void 0;
|
|
8575
|
+
if (this.#stopping || this.#relayDisconnected || this.#socket.active || this.#socket.connected) return;
|
|
8576
|
+
if (this.#upgradeAdmissionClosed) this.#scheduleRelayReconnect();
|
|
8577
|
+
else this.#connectRelay("automatic");
|
|
8578
|
+
}, RELAY_RECONNECT_INTERVAL_MS);
|
|
8579
|
+
this.#relayReconnectTimer.unref();
|
|
8580
|
+
}
|
|
8581
|
+
#clearRelayReconnect() {
|
|
8582
|
+
clearTimeout(this.#relayReconnectTimer);
|
|
8583
|
+
this.#relayReconnectTimer = void 0;
|
|
8584
|
+
}
|
|
8502
8585
|
runPeerChat(request, signal) {
|
|
8503
8586
|
if (this.#peerChatEnabled && !this.#a2aNegotiated) {
|
|
8504
8587
|
return Promise.reject(new Error("Relay has not negotiated A2A support; upgrade Relay before starting a peer conversation."));
|
|
@@ -8697,6 +8780,7 @@ var PcAgent = class {
|
|
|
8697
8780
|
this.#a2aNegotiated = false;
|
|
8698
8781
|
this.#connectionGeneration += 1;
|
|
8699
8782
|
this.#cancelSnapshotSync();
|
|
8783
|
+
this.#clearRelayReconnect();
|
|
8700
8784
|
this.#clearTimers();
|
|
8701
8785
|
this.#socket.disconnect();
|
|
8702
8786
|
this.#prompts.reset();
|
|
@@ -8732,11 +8816,13 @@ var PcAgent = class {
|
|
|
8732
8816
|
}
|
|
8733
8817
|
#bindSocketEvents() {
|
|
8734
8818
|
this.#socket.on("connect", () => {
|
|
8735
|
-
if (this.#stopping) {
|
|
8819
|
+
if (this.#stopping || this.#relayDisconnected) {
|
|
8736
8820
|
this.#socket.disconnect();
|
|
8737
8821
|
return;
|
|
8738
8822
|
}
|
|
8739
8823
|
const generation = ++this.#connectionGeneration;
|
|
8824
|
+
this.#clearRelayReconnect();
|
|
8825
|
+
this.#relayDisconnectCode = void 0;
|
|
8740
8826
|
this.#machineRegistered = false;
|
|
8741
8827
|
this.#initialSyncGeneration = void 0;
|
|
8742
8828
|
this.#relayRegistrationStatus = {
|
|
@@ -8746,9 +8832,11 @@ var PcAgent = class {
|
|
|
8746
8832
|
void this.#onConnected(generation);
|
|
8747
8833
|
});
|
|
8748
8834
|
this.#socket.on("connect_error", (error) => {
|
|
8835
|
+
if (this.#stopping || this.#relayDisconnected) return;
|
|
8836
|
+
this.#clearRelayReconnect();
|
|
8749
8837
|
this.#relayRegistrationStatus = {
|
|
8750
8838
|
state: "error",
|
|
8751
|
-
message: error.message
|
|
8839
|
+
message: error.message === "Unauthorized" ? "Relay \u6388\u6743\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002" : error.message === "Authentication service unavailable" ? "Relay \u6388\u6743\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\u3002" : "\u65E0\u6CD5\u8FDE\u63A5 Relay\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u548C Relay \u670D\u52A1\u3002"
|
|
8752
8840
|
};
|
|
8753
8841
|
this.logger.error(
|
|
8754
8842
|
{
|
|
@@ -8758,6 +8846,7 @@ var PcAgent = class {
|
|
|
8758
8846
|
},
|
|
8759
8847
|
"relay.connect.failed"
|
|
8760
8848
|
);
|
|
8849
|
+
if (error.message === "Authentication service unavailable") this.#scheduleRelayReconnect();
|
|
8761
8850
|
});
|
|
8762
8851
|
this.#socket.on("disconnect", (reason, details) => {
|
|
8763
8852
|
const diagnostics = this.#relayDiagnostics.disconnected(reason, details);
|
|
@@ -8779,10 +8868,14 @@ var PcAgent = class {
|
|
|
8779
8868
|
this.#researchChatClients.clear();
|
|
8780
8869
|
this.#assistantPreviewClients.clear();
|
|
8781
8870
|
this.#agentControlClients.clear();
|
|
8782
|
-
this.#relayRegistrationStatus = {
|
|
8871
|
+
this.#relayRegistrationStatus = this.#relayDisconnected ? {
|
|
8872
|
+
state: "disconnected",
|
|
8873
|
+
message: "\u5DF2\u65AD\u5F00 Relay \u8FDE\u63A5\u3002"
|
|
8874
|
+
} : {
|
|
8783
8875
|
state: "error",
|
|
8784
|
-
message:
|
|
8876
|
+
message: this.#relayDisconnectCode === "MACHINE_REPLACED" ? "\u53E6\u4E00 PC \u8FDE\u63A5\u5DF2\u6CE8\u518C\u6B64\u7535\u8111\uFF0C\u81EA\u52A8\u91CD\u8FDE\u5DF2\u6682\u505C\u3002" : this.#relayDisconnectCode === "AUTHORIZATION_REVOKED" ? "Relay \u6388\u6743\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002" : this.#relayDisconnectCode === "AUTH_SERVICE_UNAVAILABLE" ? "Relay \u6388\u6743\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u5C06\u7A0D\u540E\u91CD\u8FDE\u3002" : "Relay \u8FDE\u63A5\u5DF2\u65AD\u5F00\u3002"
|
|
8785
8877
|
};
|
|
8878
|
+
this.#clearRelayReconnect();
|
|
8786
8879
|
this.#clearTimers();
|
|
8787
8880
|
void this.#watches.releaseAll().catch((error) => {
|
|
8788
8881
|
this.logger.error(
|
|
@@ -8794,10 +8887,23 @@ var PcAgent = class {
|
|
|
8794
8887
|
...diagnostics,
|
|
8795
8888
|
transport: relayTransport(this.#socket.io.engine?.transport?.name),
|
|
8796
8889
|
socketActive: this.#socket.active,
|
|
8797
|
-
stopping: this.#stopping
|
|
8890
|
+
stopping: this.#stopping,
|
|
8891
|
+
...this.#relayDisconnectCode === void 0 ? {} : { disconnectCode: this.#relayDisconnectCode }
|
|
8798
8892
|
}, "relay.disconnected");
|
|
8893
|
+
if (reason === "io server disconnect" && this.#relayDisconnectCode === "AUTH_SERVICE_UNAVAILABLE") {
|
|
8894
|
+
this.#scheduleRelayReconnect();
|
|
8895
|
+
}
|
|
8799
8896
|
});
|
|
8800
8897
|
this.#socket.on("protocol.error", (error) => {
|
|
8898
|
+
const parsed = ProtocolErrorSchema.safeParse(error);
|
|
8899
|
+
if (parsed.success && parsed.data.event === RELAY_DISCONNECT_EVENT) {
|
|
8900
|
+
const code = parsed.data.code;
|
|
8901
|
+
if (code === "AUTH_SERVICE_UNAVAILABLE" || code === "AUTHORIZATION_REVOKED" || code === "MACHINE_REPLACED") {
|
|
8902
|
+
this.#relayDisconnectCode = code;
|
|
8903
|
+
this.logger.error({ code }, "relay.protocol.error");
|
|
8904
|
+
return;
|
|
8905
|
+
}
|
|
8906
|
+
}
|
|
8801
8907
|
this.logger.error(error, "relay.protocol.error");
|
|
8802
8908
|
});
|
|
8803
8909
|
this.#socket.on("peer.message", (delivery) => {
|
|
@@ -9916,7 +10022,6 @@ function researchSessionPolicy(privateDirectory, tools) {
|
|
|
9916
10022
|
skipEmbeddingRetrieval: true,
|
|
9917
10023
|
embeddingCacheStorage: "in-memory",
|
|
9918
10024
|
memory: { enabled: false },
|
|
9919
|
-
remoteSession: "off",
|
|
9920
10025
|
additionalDirectories: [],
|
|
9921
10026
|
enableExperimentalMode: false,
|
|
9922
10027
|
enableFileChangeTracking: false,
|
|
@@ -10854,7 +10959,7 @@ async function initialize(options) {
|
|
|
10854
10959
|
}
|
|
10855
10960
|
async getStatus() {
|
|
10856
10961
|
const { ready, busy } = await this.getUpgradeStatus();
|
|
10857
|
-
const state = this.isStopping ? "stopped" : this.#started === void 0 ? "initialized" : ready ? "ready" : this.relayRegistrationStatus.state === "error" ? "error" : "connecting";
|
|
10962
|
+
const state = this.isStopping ? "stopped" : this.#started === void 0 ? "initialized" : ready ? "ready" : this.relayRegistrationStatus.state === "disconnected" ? "disconnected" : this.relayRegistrationStatus.state === "error" ? "error" : "connecting";
|
|
10858
10963
|
return { state, busy };
|
|
10859
10964
|
}
|
|
10860
10965
|
}
|
package/dist/runtime.js
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
PEER_CHAT_TIMEOUT_MS,
|
|
4
4
|
PeerChatRequestSchema,
|
|
5
5
|
PeerChatResultSchema
|
|
6
|
-
} from "./chunks/chunk-
|
|
7
|
-
import "./chunks/chunk-
|
|
6
|
+
} from "./chunks/chunk-7HZ5UZSC.js";
|
|
7
|
+
import "./chunks/chunk-BDKVGENQ.js";
|
|
8
8
|
export {
|
|
9
9
|
DataDirectoryLease,
|
|
10
10
|
PEER_CHAT_TIMEOUT_MS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentknight/sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.48",
|
|
4
4
|
"description": "AgentKnight runtime SDK for local and remote coding sessions",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@a2a-js/sdk": "1.2.1",
|
|
40
|
-
"@agentclientprotocol/sdk": "1.
|
|
41
|
-
"@github/copilot": "1.0.
|
|
42
|
-
"@github/copilot-sdk": "1.0.
|
|
40
|
+
"@agentclientprotocol/sdk": "1.9.0",
|
|
41
|
+
"@github/copilot": "1.0.103",
|
|
42
|
+
"@github/copilot-sdk": "1.0.26",
|
|
43
43
|
"file-type": "22.2.0",
|
|
44
44
|
"pino": "10.3.1",
|
|
45
45
|
"sharp": "0.35.5",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"esbuild": "0.28.2",
|
|
52
52
|
"rollup": "4.63.5",
|
|
53
53
|
"rollup-plugin-dts": "6.5.1",
|
|
54
|
-
"@agentknight/
|
|
55
|
-
"@agentknight/
|
|
54
|
+
"@agentknight/shared": "0.1.0",
|
|
55
|
+
"@agentknight/protocol": "0.1.0"
|
|
56
56
|
},
|
|
57
57
|
"optionalDependencies": {
|
|
58
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
59
|
-
"@earendil-works/pi-ai": "
|
|
60
|
-
"@earendil-works/pi-coding-agent": "
|
|
58
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.310",
|
|
59
|
+
"@earendil-works/pi-ai": "1.4.0",
|
|
60
|
+
"@earendil-works/pi-coding-agent": "1.4.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|