@agentknight/sdk 0.9.45 → 0.9.47
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-IH6MP7JE.js} +1 -1
- package/dist/chunks/{chunk-WAY4EXDI.js → chunk-MUKGV7IE.js} +1 -1
- package/dist/chunks/{claude-adapter-CBEKRKPT.js → claude-adapter-YHNFRQLV.js} +1 -1
- package/dist/chunks/{copilot-adapter-6PV52BVH.js → copilot-adapter-JXWQKOIV.js} +22 -11
- package/dist/chunks/{pi-adapter-5PZT5YQN.js → pi-adapter-XLQHILYF.js} +3 -5
- package/dist/index.js +37 -10
- package/package.json +7 -7
|
@@ -85,7 +85,7 @@ async function bounded(promise, timeout, operation) {
|
|
|
85
85
|
}
|
|
86
86
|
var AcpCodingAgentAdapter = class {
|
|
87
87
|
agentId = "acp";
|
|
88
|
-
sdkVersion = "1.
|
|
88
|
+
sdkVersion = "1.9.0";
|
|
89
89
|
agentModes = ["interactive"];
|
|
90
90
|
supportsReasoningEffort = false;
|
|
91
91
|
supportsSessionListUpdates = false;
|
|
@@ -515,7 +515,7 @@ function isDisplayableHumanMessage(event) {
|
|
|
515
515
|
return false;
|
|
516
516
|
}
|
|
517
517
|
const source = event.data.source;
|
|
518
|
-
return event.data.isAutopilotContinuation !== true && (source === void 0 || source === "user" || source === "mobile");
|
|
518
|
+
return event.data.isAutopilotContinuation !== true && (source === void 0 || source === "user" || source === "mobile" || /^schedule-[1-9]\d*$/.test(source));
|
|
519
519
|
}
|
|
520
520
|
function projectAttachment(attachment) {
|
|
521
521
|
switch (attachment.type) {
|
|
@@ -475,7 +475,7 @@ var MessageSchema = z4.object({
|
|
|
475
475
|
}).passthrough();
|
|
476
476
|
var ClaudeCodingAgentAdapter = class {
|
|
477
477
|
agentId = "claude";
|
|
478
|
-
sdkVersion = "0.3.
|
|
478
|
+
sdkVersion = "0.3.310";
|
|
479
479
|
agentModes = ["interactive"];
|
|
480
480
|
supportsReasoningEffort = false;
|
|
481
481
|
supportsSessionListUpdates = true;
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
recordTimelineSyncDiagnostic,
|
|
19
19
|
resolveGitProjectIdentity,
|
|
20
20
|
sanitizeGitRemoteUrl
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-MUKGV7IE.js";
|
|
22
22
|
import {
|
|
23
23
|
assertMainSessionId,
|
|
24
24
|
isResearchSessionId
|
|
@@ -2340,6 +2340,12 @@ var Event = z4.object({
|
|
|
2340
2340
|
source: z4.string().optional(),
|
|
2341
2341
|
content: z4.string().optional(),
|
|
2342
2342
|
interactionId: z4.string().optional(),
|
|
2343
|
+
turnId: z4.string().optional(),
|
|
2344
|
+
messageId: z4.string().optional(),
|
|
2345
|
+
originatingMessageId: z4.string().optional(),
|
|
2346
|
+
apiCallId: z4.string().optional(),
|
|
2347
|
+
chunkIndex: z4.number().int().nonnegative().optional(),
|
|
2348
|
+
chunkCount: z4.number().int().positive().optional(),
|
|
2343
2349
|
parentToolCallId: z4.string().optional(),
|
|
2344
2350
|
delivery: z4.string().optional(),
|
|
2345
2351
|
toolRequests: z4.array(z4.unknown()).optional()
|
|
@@ -2372,12 +2378,17 @@ function projectScheduleHistory(input) {
|
|
|
2372
2378
|
const previousBoundary = events.slice(0, index).reverse().find((event) => ["session.idle", "session.start", "user.message", "assistant.turn_start"].includes(event.type));
|
|
2373
2379
|
const idleDelivery = trigger.data.delivery === "idle" || trigger.data.delivery === void 0 && ["session.idle", "session.start"].includes(previousBoundary?.type ?? "");
|
|
2374
2380
|
const associated = !merged && idleDelivery && inputs.length === 1 && inputs[0]?.id === trigger.id;
|
|
2375
|
-
const replies = associated ? span.filter((event) => event.type === "assistant.message"
|
|
2376
|
-
const
|
|
2381
|
+
const replies = associated ? span.filter((event) => event.type === "assistant.message") : [];
|
|
2382
|
+
const lastMessage = replies.at(-1);
|
|
2377
2383
|
const lastErrorIndex = span.reduce((last, event, position) => event.type === "session.error" ? position : last, -1);
|
|
2378
|
-
const lastReplyIndex =
|
|
2379
|
-
const
|
|
2380
|
-
const
|
|
2384
|
+
const lastReplyIndex = lastMessage === void 0 ? -1 : span.indexOf(lastMessage);
|
|
2385
|
+
const responseId = lastMessage?.data.apiCallId ?? lastMessage?.data.messageId;
|
|
2386
|
+
const response = responseId === void 0 ? replies.slice(-1) : replies.filter((event) => (event.data.apiCallId ?? event.data.messageId) === responseId);
|
|
2387
|
+
const chunkCount = lastMessage?.data.chunkCount;
|
|
2388
|
+
const complete = chunkCount === void 0 ? lastMessage?.data.chunkIndex === void 0 : lastMessage?.data.chunkIndex === chunkCount - 1 && new Set(response.map((event) => event.data.chunkIndex).filter((index2) => index2 !== void 0 && index2 < chunkCount)).size === chunkCount;
|
|
2389
|
+
const finished = span.some((event, position) => position > lastReplyIndex && (event.type === "session.idle" || event.type === "assistant.turn_end" && lastMessage?.data.turnId !== void 0 && event.data.turnId === lastMessage.data.turnId));
|
|
2390
|
+
const finalResponse = lastMessage !== void 0 && complete && finished && response.every((event) => event.data.interactionId === trigger.data.interactionId && (event.data.originatingMessageId === void 0 || event.data.originatingMessageId === trigger.data.messageId)) && response.every((event) => (event.data.toolRequests?.length ?? 0) === 0) && response.some((event) => event.data.content?.trim()) && lastReplyIndex > lastErrorIndex && !span.some((event, position) => position > lastReplyIndex && (event.type === "tool.execution_start" || event.type === "assistant.turn_start"));
|
|
2391
|
+
const explicitError = associated && lastErrorIndex >= 0 && !finalResponse;
|
|
2381
2392
|
const idle = span.some((event) => event.type === "session.idle");
|
|
2382
2393
|
const newerInput = span.some((event) => event.type === "user.message" && !event.data.source?.startsWith("skill-"));
|
|
2383
2394
|
return {
|
|
@@ -2386,10 +2397,10 @@ function projectScheduleHistory(input) {
|
|
|
2386
2397
|
triggerEventId: trigger.id,
|
|
2387
2398
|
time: trigger.timestamp,
|
|
2388
2399
|
prompt: (trigger.data.content ?? "").slice(0, 16e3),
|
|
2389
|
-
status: merged ? "merged" : explicitError ? "error" :
|
|
2390
|
-
|
|
2391
|
-
reply:
|
|
2392
|
-
replyEventId:
|
|
2400
|
+
status: merged ? "merged" : explicitError ? "error" : finalResponse ? "reply" : idle || newerInput || !associated ? "unknown" : "pending",
|
|
2401
|
+
...!finalResponse || lastMessage === void 0 ? {} : {
|
|
2402
|
+
reply: response.map((event) => event.data.content ?? "").filter(Boolean).join("\n\n").slice(0, 16e3),
|
|
2403
|
+
replyEventId: lastMessage.id
|
|
2393
2404
|
},
|
|
2394
2405
|
// Native error bodies can contain paths, credentials, or tool arguments.
|
|
2395
2406
|
...explicitError ? { error: "The session reported an error. Open the chat for details." } : {}
|
|
@@ -4103,7 +4114,7 @@ var GithubCopilotAdapter = class {
|
|
|
4103
4114
|
resolveImages: (sessionId, session, normalizer, readOnly) => this.#images.resolveTimelineImageAssets(sessionId, session, normalizer, readOnly)
|
|
4104
4115
|
});
|
|
4105
4116
|
agentId = "copilot";
|
|
4106
|
-
sdkVersion = "1.0.
|
|
4117
|
+
sdkVersion = "1.0.26";
|
|
4107
4118
|
agentModes = ["interactive", "plan", "autopilot"];
|
|
4108
4119
|
supportsReasoningEffort = true;
|
|
4109
4120
|
#upgradeSessionIds = /* @__PURE__ */ new Set();
|
|
@@ -113,6 +113,7 @@ var PiTimeline = class {
|
|
|
113
113
|
return `pi:${key(`${this.sessionId}:${signature}:${index}`)}`;
|
|
114
114
|
}
|
|
115
115
|
#message(message, id, final) {
|
|
116
|
+
if (message.role === "system") return;
|
|
116
117
|
const timestamp = new Date(message.timestamp).toISOString();
|
|
117
118
|
if (message.role === "user") this.#turnId = id;
|
|
118
119
|
if (message.role === "user" || message.role === "assistant") {
|
|
@@ -771,6 +772,7 @@ var PiCodingAgentAdapter = class {
|
|
|
771
772
|
this.#assertOpening(sessionId);
|
|
772
773
|
const cancellation = (pi) => {
|
|
773
774
|
const cancelled = () => this.#stopping || this.#cancelledOpenings.has(sessionId) || this.#runtimes.get(sessionId)?.aborting === true;
|
|
775
|
+
pi.on("input", () => cancelled() ? { action: "handled" } : void 0);
|
|
774
776
|
pi.on("session_before_compact", () => cancelled() ? { cancel: true } : void 0);
|
|
775
777
|
pi.on("session_before_tree", () => cancelled() ? { cancel: true } : void 0);
|
|
776
778
|
};
|
|
@@ -924,11 +926,7 @@ var PiCodingAgentAdapter = class {
|
|
|
924
926
|
runtime.primarySource = prompt;
|
|
925
927
|
return runtime.session.prompt(prompt.text, {
|
|
926
928
|
expandPromptTemplates: false,
|
|
927
|
-
source: "rpc"
|
|
928
|
-
// PI awaits compaction/extensions before Agent.prompt; cancellation must survive preflight.
|
|
929
|
-
preflightResult: (accepted) => {
|
|
930
|
-
if (accepted && (runtime.aborting || this.#stopping)) throw new Error("PI prompt was aborted before execution.");
|
|
931
|
-
}
|
|
929
|
+
source: "rpc"
|
|
932
930
|
});
|
|
933
931
|
}).catch((error) => {
|
|
934
932
|
this.#error(runtime, error);
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
resolveGitProjectIdentity,
|
|
32
32
|
sessionRestoreFailure,
|
|
33
33
|
validateOperationResponse
|
|
34
|
-
} from "./chunks/chunk-
|
|
34
|
+
} from "./chunks/chunk-MUKGV7IE.js";
|
|
35
35
|
import {
|
|
36
36
|
GROUP_CHAT_MAX_TURNS,
|
|
37
37
|
GroupChatError
|
|
@@ -336,7 +336,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
338
|
case "copilot": {
|
|
339
|
-
const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-
|
|
339
|
+
const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-JXWQKOIV.js");
|
|
340
340
|
if (owner !== void 0) {
|
|
341
341
|
return new GithubCopilotAdapter(void 0, void 0, void 0, {
|
|
342
342
|
dataDirectory: config.dataDirectory,
|
|
@@ -356,7 +356,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
356
356
|
}
|
|
357
357
|
case "pi": {
|
|
358
358
|
assertPiRuntimeSupported();
|
|
359
|
-
const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-
|
|
359
|
+
const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-XLQHILYF.js");
|
|
360
360
|
return new PiCodingAgentAdapter(
|
|
361
361
|
engine.agentDirectory === void 0 ? {} : { agentDirectory: resolve(engine.agentDirectory) }
|
|
362
362
|
);
|
|
@@ -370,14 +370,14 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
case "claude": {
|
|
373
|
-
const { ClaudeCodingAgentAdapter } = await import("./chunks/claude-adapter-
|
|
373
|
+
const { ClaudeCodingAgentAdapter } = await import("./chunks/claude-adapter-YHNFRQLV.js");
|
|
374
374
|
return new ClaudeCodingAgentAdapter({
|
|
375
375
|
dataDirectory: resolve(config.dataDirectory, "coding-agents"),
|
|
376
376
|
...onDiagnostic === void 0 ? {} : { onDiagnostic }
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
case "acp": {
|
|
380
|
-
const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-
|
|
380
|
+
const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-IH6MP7JE.js");
|
|
381
381
|
return new AcpCodingAgentAdapter({
|
|
382
382
|
command: engine.command,
|
|
383
383
|
args: engine.args,
|
|
@@ -2677,6 +2677,17 @@ import { createHash as createHash5, randomUUID as randomUUID3 } from "node:crypt
|
|
|
2677
2677
|
import { constants as constants2 } from "node:fs";
|
|
2678
2678
|
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
2679
|
import { dirname, isAbsolute as isAbsolute4, join as join5, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
2680
|
+
|
|
2681
|
+
// src/git-repository-error.ts
|
|
2682
|
+
function isGitRepositoryUnavailableError(error) {
|
|
2683
|
+
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)))) {
|
|
2684
|
+
return false;
|
|
2685
|
+
}
|
|
2686
|
+
const stderr = typeof error.stderr === "string" ? error.stderr : error.stderr.toString("utf8");
|
|
2687
|
+
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);
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
// src/session-git-diff.ts
|
|
2680
2691
|
var SESSION_GIT_DIFF_CONCURRENCY = 4;
|
|
2681
2692
|
var SESSION_GIT_DIFF_TIMEOUT_MS = 15e3;
|
|
2682
2693
|
var SESSION_GIT_DIFF_MAX_SOURCE_BYTES = 8 * 1024 * 1024;
|
|
@@ -3335,8 +3346,12 @@ var SessionGitDiffReader = class {
|
|
|
3335
3346
|
repository = await realpath4(top);
|
|
3336
3347
|
} catch (error) {
|
|
3337
3348
|
if (error instanceof SessionGitDiffError) throw error;
|
|
3338
|
-
if (
|
|
3339
|
-
throw new SessionGitDiffError(
|
|
3349
|
+
if (isGitRepositoryUnavailableError(error)) {
|
|
3350
|
+
throw new SessionGitDiffError(
|
|
3351
|
+
"DIFF_NOT_REPOSITORY",
|
|
3352
|
+
"The session directory is not a Git repository or its .git metadata is invalid",
|
|
3353
|
+
{ cause: error }
|
|
3354
|
+
);
|
|
3340
3355
|
}
|
|
3341
3356
|
throw error;
|
|
3342
3357
|
}
|
|
@@ -4548,9 +4563,22 @@ async function git(env, ...args) {
|
|
|
4548
4563
|
], { env, encoding: "utf8", windowsHide: true, timeout: 6e4, maxBuffer: 1024 * 1024 });
|
|
4549
4564
|
return stdout.replace(/\r?\n$/, "");
|
|
4550
4565
|
}
|
|
4566
|
+
async function sourceIdentity(sourceDirectory, env) {
|
|
4567
|
+
try {
|
|
4568
|
+
return await resolveGitProjectIdentity(sourceDirectory, env);
|
|
4569
|
+
} catch (cause) {
|
|
4570
|
+
if (isGitRepositoryUnavailableError(cause)) {
|
|
4571
|
+
throw new Error(
|
|
4572
|
+
"The source directory is not a Git repository or its .git metadata is invalid. Choose a valid repository.",
|
|
4573
|
+
{ cause }
|
|
4574
|
+
);
|
|
4575
|
+
}
|
|
4576
|
+
throw cause;
|
|
4577
|
+
}
|
|
4578
|
+
}
|
|
4551
4579
|
async function listSessionWorktreeBranches(sourceDirectory) {
|
|
4552
4580
|
const env = creationEnvironment();
|
|
4553
|
-
const identity2 = await
|
|
4581
|
+
const identity2 = await sourceIdentity(sourceDirectory, env);
|
|
4554
4582
|
const output2 = await git(
|
|
4555
4583
|
env,
|
|
4556
4584
|
"-C",
|
|
@@ -4577,7 +4605,7 @@ async function listSessionWorktreeBranches(sourceDirectory) {
|
|
|
4577
4605
|
}
|
|
4578
4606
|
async function createSessionWorktree(sourceDirectory, requestedBranchName, requestedBaseBranch) {
|
|
4579
4607
|
const env = creationEnvironment();
|
|
4580
|
-
const identity2 = await
|
|
4608
|
+
const identity2 = await sourceIdentity(sourceDirectory, env);
|
|
4581
4609
|
const baseBranch = requestedBaseBranch?.trim();
|
|
4582
4610
|
const baseRef = baseBranch === void 0 ? "HEAD" : `refs/heads/${baseBranch}`;
|
|
4583
4611
|
if (baseBranch !== void 0) {
|
|
@@ -9916,7 +9944,6 @@ function researchSessionPolicy(privateDirectory, tools) {
|
|
|
9916
9944
|
skipEmbeddingRetrieval: true,
|
|
9917
9945
|
embeddingCacheStorage: "in-memory",
|
|
9918
9946
|
memory: { enabled: false },
|
|
9919
|
-
remoteSession: "off",
|
|
9920
9947
|
additionalDirectories: [],
|
|
9921
9948
|
enableExperimentalMode: false,
|
|
9922
9949
|
enableFileChangeTracking: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentknight/sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.47",
|
|
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",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"@agentknight/shared": "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})\"",
|