@agentknight/sdk 0.9.39 → 0.9.40
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/dist/chunks/{acp-adapter-BWVM6WIF.js → acp-adapter-TVAW7EHK.js} +3 -3
- package/dist/chunks/{chunk-KPRPUIXR.js → chunk-6RWWNR37.js} +1 -1
- package/dist/chunks/{chunk-BM6T2DLH.js → chunk-AJ4YL22H.js} +4 -1
- package/dist/chunks/{chunk-UE4QYZCG.js → chunk-CVWUKZX7.js} +1 -1
- package/dist/chunks/{chunk-N4MN54CD.js → chunk-D6HWUCVM.js} +5 -4
- package/dist/chunks/{chunk-E3XCZWRK.js → chunk-OV77TRIH.js} +13 -1
- package/dist/chunks/{chunk-VCNYBWYE.js → chunk-Q3TQPONK.js} +2 -2
- package/dist/chunks/{chunk-45FBONW3.js → chunk-SDAEMVSD.js} +1 -1
- package/dist/chunks/{chunk-QGPX4UDW.js → chunk-ULJMR33R.js} +10 -8
- package/dist/chunks/{copilot-adapter-N5B7BNWO.js → copilot-adapter-KH6NXHGK.js} +141 -62
- package/dist/chunks/{managed-agent-adapter-T3FVUJHA.js → managed-agent-adapter-F7U26CH2.js} +21 -6
- package/dist/chunks/{pi-adapter-PHEFFJVF.js → pi-adapter-G4GQ5ULV.js} +3 -3
- package/dist/index.d.ts +34 -9
- package/dist/index.js +177 -86
- package/dist/runtime.js +2 -2
- package/package.json +3 -3
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-CVWUKZX7.js";
|
|
8
8
|
import {
|
|
9
9
|
AgentSelectionSchema,
|
|
10
10
|
assertSelectionSnapshotFits,
|
|
11
11
|
supportsAgentSelection
|
|
12
|
-
} from "./chunks/chunk-
|
|
12
|
+
} from "./chunks/chunk-6RWWNR37.js";
|
|
13
13
|
import {
|
|
14
14
|
ConversationNormalizer,
|
|
15
15
|
LiveTimelineProjection,
|
|
@@ -31,25 +31,26 @@ import {
|
|
|
31
31
|
resolveGitProjectIdentity,
|
|
32
32
|
sessionRestoreFailure,
|
|
33
33
|
validateOperationResponse
|
|
34
|
-
} from "./chunks/chunk-
|
|
34
|
+
} from "./chunks/chunk-ULJMR33R.js";
|
|
35
35
|
import {
|
|
36
36
|
GROUP_CHAT_MAX_TURNS,
|
|
37
37
|
GroupChatError
|
|
38
|
-
} from "./chunks/chunk-
|
|
38
|
+
} from "./chunks/chunk-Q3TQPONK.js";
|
|
39
39
|
import {
|
|
40
40
|
assistantPreview,
|
|
41
41
|
isContentfulAssistant,
|
|
42
42
|
userPreview
|
|
43
|
-
} from "./chunks/chunk-
|
|
43
|
+
} from "./chunks/chunk-D6HWUCVM.js";
|
|
44
44
|
import {
|
|
45
45
|
AgentModelListingError,
|
|
46
46
|
AgentSessionRenameError,
|
|
47
47
|
SessionOperationError,
|
|
48
48
|
SessionOperations,
|
|
49
|
+
TimelinePageBudgetError,
|
|
49
50
|
UnsupportedAgentOperationError,
|
|
50
51
|
captureResearchAccess,
|
|
51
52
|
captureWorkbenchAccess
|
|
52
|
-
} from "./chunks/chunk-
|
|
53
|
+
} from "./chunks/chunk-AJ4YL22H.js";
|
|
53
54
|
import {
|
|
54
55
|
A2aRelayRequestSchema,
|
|
55
56
|
A2aRelayResponseSchema,
|
|
@@ -95,6 +96,7 @@ import {
|
|
|
95
96
|
SECURE_MESSAGE_MAX_CIPHERTEXT_LENGTH,
|
|
96
97
|
SECURE_SOCKET_IO_NAMESPACE,
|
|
97
98
|
SESSION_ASSISTANT_PREVIEW_CAPABILITY,
|
|
99
|
+
SESSION_AVATAR_PERSONA_CAPABILITY,
|
|
98
100
|
SESSION_COMMUNICATION_CAPABILITY,
|
|
99
101
|
SESSION_DELETE_CAPABILITY,
|
|
100
102
|
SESSION_DIRECTORY_LIST_OPERATION,
|
|
@@ -124,6 +126,7 @@ import {
|
|
|
124
126
|
SESSION_IMAGE_MAX_PIXELS,
|
|
125
127
|
SESSION_LIST_UPDATES_CAPABILITY,
|
|
126
128
|
SESSION_OPTIONS_PARTIAL_CAPABILITY,
|
|
129
|
+
SESSION_OPTIONS_PROGRESSIVE_CAPABILITY,
|
|
127
130
|
SESSION_PROJECT_IDENTITY_OPERATION,
|
|
128
131
|
SESSION_PROJECT_IDENTITY_VERSION,
|
|
129
132
|
SESSION_PROMPT_SUBMISSION_TIME_CAPABILITY,
|
|
@@ -223,7 +226,7 @@ import {
|
|
|
223
226
|
sessionCommunicationError,
|
|
224
227
|
sessionCommunicationOperationCapability,
|
|
225
228
|
workbenchCapability
|
|
226
|
-
} from "./chunks/chunk-
|
|
229
|
+
} from "./chunks/chunk-OV77TRIH.js";
|
|
227
230
|
|
|
228
231
|
// src/initialize.ts
|
|
229
232
|
import { createHash as createHash16 } from "node:crypto";
|
|
@@ -301,7 +304,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
301
304
|
switch (engine.kind) {
|
|
302
305
|
case "managed": {
|
|
303
306
|
if (owner === void 0) throw new Error("Managed coding agents require the PC owner identity");
|
|
304
|
-
const { ManagedCodingAgentAdapter } = await import("./chunks/managed-agent-adapter-
|
|
307
|
+
const { ManagedCodingAgentAdapter } = await import("./chunks/managed-agent-adapter-F7U26CH2.js");
|
|
305
308
|
return new ManagedCodingAgentAdapter({
|
|
306
309
|
dataDirectory: config.dataDirectory,
|
|
307
310
|
owner,
|
|
@@ -340,7 +343,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
340
343
|
});
|
|
341
344
|
}
|
|
342
345
|
case "copilot": {
|
|
343
|
-
const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-
|
|
346
|
+
const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-KH6NXHGK.js");
|
|
344
347
|
if (owner !== void 0) {
|
|
345
348
|
return new GithubCopilotAdapter(void 0, void 0, void 0, {
|
|
346
349
|
dataDirectory: config.dataDirectory,
|
|
@@ -360,13 +363,13 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
360
363
|
}
|
|
361
364
|
case "pi": {
|
|
362
365
|
assertPiRuntimeSupported();
|
|
363
|
-
const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-
|
|
366
|
+
const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-G4GQ5ULV.js");
|
|
364
367
|
return new PiCodingAgentAdapter(
|
|
365
368
|
engine.agentDirectory === void 0 ? {} : { agentDirectory: resolve(engine.agentDirectory) }
|
|
366
369
|
);
|
|
367
370
|
}
|
|
368
371
|
case "acp": {
|
|
369
|
-
const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-
|
|
372
|
+
const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-TVAW7EHK.js");
|
|
370
373
|
return new AcpCodingAgentAdapter({
|
|
371
374
|
command: engine.command,
|
|
372
375
|
args: engine.args,
|
|
@@ -2324,11 +2327,21 @@ function researchAwareCodingAgentAdapter(inner, research) {
|
|
|
2324
2327
|
},
|
|
2325
2328
|
readSessionTimelinePage: (id, options) => route(id, () => research.timeline(id, options), () => inner.readSessionTimelinePage(id, options)),
|
|
2326
2329
|
watchSession: (id, watched) => route(id, () => research.watch(id, watched), () => inner.watchSession(id, watched)),
|
|
2327
|
-
sendPrompt: (id, prompt, mode, attachments, persist, files, operationId) => route(id, () => {
|
|
2330
|
+
sendPrompt: (id, prompt, mode, attachments, persist, files, operationId, avatarPersona) => route(id, () => {
|
|
2331
|
+
if (avatarPersona !== void 0) return deny();
|
|
2328
2332
|
if (attachments?.length || files?.length) return deny();
|
|
2329
2333
|
if (operationId === void 0) throw new SessionOperationError("OPERATION_ID_REQUIRED", "A stable operation ID is required");
|
|
2330
2334
|
return research.sendPrompt(id, prompt, mode, operationId);
|
|
2331
|
-
}, () => inner.sendPrompt(
|
|
2335
|
+
}, () => inner.sendPrompt(
|
|
2336
|
+
id,
|
|
2337
|
+
prompt,
|
|
2338
|
+
mode,
|
|
2339
|
+
attachments,
|
|
2340
|
+
persist,
|
|
2341
|
+
files,
|
|
2342
|
+
operationId,
|
|
2343
|
+
...avatarPersona === void 0 ? [] : [avatarPersona]
|
|
2344
|
+
)),
|
|
2332
2345
|
abortSession: (id) => route(id, () => research.abort(id), () => inner.abortSession(id)),
|
|
2333
2346
|
getSessionConfiguration: (id) => route(id, () => research.configuration(id), () => inner.getSessionConfiguration(id)),
|
|
2334
2347
|
getSessionCapabilities: (id) => id !== void 0 && owned(id) ? { agentModes: ["interactive"], supportsReasoningEffort: false, supportsFileAttachments: false, supportsPlanRead: false, agentName: "Side chat" } : inner.getSessionCapabilities?.(id) ?? inner,
|
|
@@ -2403,8 +2416,25 @@ function toErrorDetails(error) {
|
|
|
2403
2416
|
};
|
|
2404
2417
|
}
|
|
2405
2418
|
|
|
2406
|
-
// src/
|
|
2419
|
+
// src/service/transport/relay-socket.ts
|
|
2407
2420
|
import { io } from "socket.io-client";
|
|
2421
|
+
function createRelaySocket(uri, options) {
|
|
2422
|
+
const socket = io(uri, { ...options, autoConnect: false });
|
|
2423
|
+
socket.on("connect_error", (error) => {
|
|
2424
|
+
const manager = socket.io;
|
|
2425
|
+
const transports = manager.opts.transports;
|
|
2426
|
+
if (error.message !== "timeout" || manager.engine.readyState !== "opening" || !manager.opts.tryAllTransports || transports === void 0 || transports.length < 2 || !transports.every((transport) => typeof transport === "string")) return;
|
|
2427
|
+
const failedTransport = manager.engine.transport.name;
|
|
2428
|
+
const failedIndex = transports.findIndex((transport) => transport === failedTransport);
|
|
2429
|
+
if (failedIndex < 0) return;
|
|
2430
|
+
manager.opts.transports = [
|
|
2431
|
+
...transports.slice(failedIndex + 1),
|
|
2432
|
+
...transports.slice(0, failedIndex + 1)
|
|
2433
|
+
];
|
|
2434
|
+
});
|
|
2435
|
+
if (options.autoConnect !== false) socket.connect();
|
|
2436
|
+
return socket;
|
|
2437
|
+
}
|
|
2408
2438
|
|
|
2409
2439
|
// src/service/requests/session-communication.ts
|
|
2410
2440
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -2793,7 +2823,7 @@ var Work = class {
|
|
|
2793
2823
|
GIT_DIR: join6(cwd, "no-repository"),
|
|
2794
2824
|
GIT_CONFIG_NOSYSTEM: "1",
|
|
2795
2825
|
GIT_ATTR_NOSYSTEM: "1",
|
|
2796
|
-
GIT_CONFIG_GLOBAL:
|
|
2826
|
+
GIT_CONFIG_GLOBAL: join6(cwd, "gitconfig")
|
|
2797
2827
|
} : {}
|
|
2798
2828
|
}
|
|
2799
2829
|
}, (error, output2, stderr) => {
|
|
@@ -3122,6 +3152,7 @@ async function patch(context, change, work, scratchDirectory) {
|
|
|
3122
3152
|
await writeFile2(file, content, { flag: "wx", mode: 384 });
|
|
3123
3153
|
if (process.platform !== "win32") await chmod(file, mode === "100755" ? 448 : 384);
|
|
3124
3154
|
}
|
|
3155
|
+
await writeFile2(join6(scratch, "gitconfig"), "", { flag: "wx", mode: 384 });
|
|
3125
3156
|
text = decode(await work.git(scratch, [
|
|
3126
3157
|
"-c",
|
|
3127
3158
|
"core.quotePath=false",
|
|
@@ -3302,10 +3333,10 @@ var TimelineImageCache = class {
|
|
|
3302
3333
|
get bytes() {
|
|
3303
3334
|
return this.#bytes;
|
|
3304
3335
|
}
|
|
3305
|
-
referenceItem(sessionId, item) {
|
|
3336
|
+
referenceItem = (sessionId, item) => {
|
|
3306
3337
|
if (!("attachments" in item) || item.attachments === void 0) return item;
|
|
3307
3338
|
return { ...item, attachments: item.attachments.map((attachment) => this.#reference(sessionId, attachment)) };
|
|
3308
|
-
}
|
|
3339
|
+
};
|
|
3309
3340
|
read(sessionId, request) {
|
|
3310
3341
|
const key = JSON.stringify([sessionId, request.sha256]);
|
|
3311
3342
|
const asset = this.#assets.get(key);
|
|
@@ -4576,14 +4607,14 @@ var SessionOptionsHandler = class {
|
|
|
4576
4607
|
]));
|
|
4577
4608
|
if (modelResult.status === "fulfilled" && modelResult.value.length > 0) availableModels = modelResult.value;
|
|
4578
4609
|
if (configurationResult.status === "fulfilled") configuration = configurationResult.value;
|
|
4579
|
-
for (const [stage,
|
|
4610
|
+
for (const [stage, result2] of [
|
|
4580
4611
|
["configuration", configurationResult],
|
|
4581
4612
|
["models", modelResult],
|
|
4582
4613
|
["workspaces", workspaceResult]
|
|
4583
4614
|
]) {
|
|
4584
|
-
if (
|
|
4615
|
+
if (result2.status === "rejected" && isSessionRestoreFailure(result2.reason)) {
|
|
4585
4616
|
failureStage = stage;
|
|
4586
|
-
throw
|
|
4617
|
+
throw result2.reason;
|
|
4587
4618
|
}
|
|
4588
4619
|
}
|
|
4589
4620
|
if (configurationResult.status === "rejected") {
|
|
@@ -4605,7 +4636,8 @@ var SessionOptionsHandler = class {
|
|
|
4605
4636
|
failureStage = "models";
|
|
4606
4637
|
throw modelFailure ?? new Error("No coding-agent models are available. Select an authenticated coding agent on the PC.");
|
|
4607
4638
|
}
|
|
4608
|
-
const
|
|
4639
|
+
const progressive = request.sessionId !== void 0 && request.capabilities?.includes(SESSION_OPTIONS_PROGRESSIVE_CAPABILITY) === true;
|
|
4640
|
+
const environment2 = progressive ? void 0 : await sessionEnvironment;
|
|
4609
4641
|
const worktreeCreationSupported = request.sessionId === void 0 && request.capabilities?.includes(SESSION_WORKTREE_CREATION_CAPABILITY) === true;
|
|
4610
4642
|
let worktreeChoices;
|
|
4611
4643
|
if (worktreeCreationSupported && request.workspaceId !== void 0) {
|
|
@@ -4617,7 +4649,7 @@ var SessionOptionsHandler = class {
|
|
|
4617
4649
|
}
|
|
4618
4650
|
const capabilities = adapter.getSessionCapabilities?.(request.sessionId) ?? adapter;
|
|
4619
4651
|
this.#errors.recovered(errorKey);
|
|
4620
|
-
|
|
4652
|
+
const result = {
|
|
4621
4653
|
ok: true,
|
|
4622
4654
|
requestId: request.requestId,
|
|
4623
4655
|
machineId,
|
|
@@ -4639,7 +4671,21 @@ var SessionOptionsHandler = class {
|
|
|
4639
4671
|
...environment2 === void 0 ? {} : { environment: environment2 },
|
|
4640
4672
|
agentName: "agentName" in capabilities && typeof capabilities.agentName === "string" ? capabilities.agentName : codingAgentPresentation(adapter.agentId).name,
|
|
4641
4673
|
...current?.configOptions === void 0 ? {} : { configOptions: current.configOptions }
|
|
4674
|
+
};
|
|
4675
|
+
if (!scope.isCurrent()) return;
|
|
4676
|
+
emit("session.options.result", {
|
|
4677
|
+
...result,
|
|
4678
|
+
...progressive ? { environmentPending: true } : {}
|
|
4642
4679
|
});
|
|
4680
|
+
if (progressive) {
|
|
4681
|
+
const environment3 = await sessionEnvironment;
|
|
4682
|
+
if (!scope.isCurrent()) return;
|
|
4683
|
+
adapter.getSessionCapabilities?.(request.sessionId);
|
|
4684
|
+
emit("session.options.result", {
|
|
4685
|
+
...result,
|
|
4686
|
+
...environment3 === void 0 ? {} : { environment: environment3 }
|
|
4687
|
+
});
|
|
4688
|
+
}
|
|
4643
4689
|
const plan = await sessionPlan;
|
|
4644
4690
|
if (plan !== void 0 && scope.isCurrent()) {
|
|
4645
4691
|
emit("conversation.item.upsert", plan);
|
|
@@ -5023,11 +5069,15 @@ var SessionCommandsHandler = class {
|
|
|
5023
5069
|
// src/service/requests/session-prompt.ts
|
|
5024
5070
|
import { createHash as createHash10 } from "node:crypto";
|
|
5025
5071
|
function promptOperationFingerprint(request) {
|
|
5026
|
-
|
|
5072
|
+
const fingerprint = createHash10("sha256").update(request.sessionId).update("\0").update(request.mode).update("\0").update(request.prompt).update("\0").update(request.attachments?.map((attachment) => attachment.sha256).join(",") ?? "").update("\0").update(JSON.stringify(request.fileAttachments?.map(({ name, mimeType, sha256 }) => ({
|
|
5027
5073
|
name,
|
|
5028
5074
|
mimeType,
|
|
5029
5075
|
sha256
|
|
5030
|
-
})) ?? []))
|
|
5076
|
+
})) ?? []));
|
|
5077
|
+
if (request.avatarPersona !== void 0) {
|
|
5078
|
+
fingerprint.update("\0").update(JSON.stringify(request.avatarPersona));
|
|
5079
|
+
}
|
|
5080
|
+
return fingerprint.digest("base64url");
|
|
5031
5081
|
}
|
|
5032
5082
|
var SessionPromptHandler = class {
|
|
5033
5083
|
constructor(options) {
|
|
@@ -5049,6 +5099,9 @@ var SessionPromptHandler = class {
|
|
|
5049
5099
|
if (adapter.isSessionVisible?.(request.sessionId) === false) {
|
|
5050
5100
|
throw new Error("This session's coding agent is not shared or is unavailable on the PC");
|
|
5051
5101
|
}
|
|
5102
|
+
if (request.avatarPersona !== void 0 && adapter.agentId !== "copilot" && adapter.agentId !== "managed") {
|
|
5103
|
+
throw new Error("Avatar personas require Copilot; nothing was submitted");
|
|
5104
|
+
}
|
|
5052
5105
|
const accepted = await diagnostics.run(() => this.#operations.run({
|
|
5053
5106
|
operationId: request.operationId,
|
|
5054
5107
|
fingerprint: promptOperationFingerprint(request),
|
|
@@ -5067,7 +5120,8 @@ var SessionPromptHandler = class {
|
|
|
5067
5120
|
request.attachments,
|
|
5068
5121
|
this.options.supportsPersistentInteractions(context.clientId),
|
|
5069
5122
|
request.fileAttachments,
|
|
5070
|
-
request.operationId
|
|
5123
|
+
request.operationId,
|
|
5124
|
+
...request.avatarPersona === void 0 ? [] : [request.avatarPersona]
|
|
5071
5125
|
)
|
|
5072
5126
|
}));
|
|
5073
5127
|
emit("session.prompt.result", {
|
|
@@ -5186,63 +5240,95 @@ var SessionTimelinePageHandler = class {
|
|
|
5186
5240
|
if (request.metadataOnly === true && request.assistantPreview !== true && adapter.supportsSessionListUpdates !== true) {
|
|
5187
5241
|
throw new Error("Passive session metadata is not supported by this runtime");
|
|
5188
5242
|
}
|
|
5189
|
-
const
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5243
|
+
const references = request.imageReferences === true && config.timelineIncrementalEnabled !== false && this.options.imageReferencesEnabled();
|
|
5244
|
+
let pageSize = request.pageSize;
|
|
5245
|
+
while (true) {
|
|
5246
|
+
let itemCount;
|
|
5247
|
+
try {
|
|
5248
|
+
phase = "read";
|
|
5249
|
+
const page = await diagnostics.run(() => measureOperationPhase("read", () => adapter.readSessionTimelinePage(
|
|
5250
|
+
request.sessionId,
|
|
5251
|
+
{
|
|
5252
|
+
pageSize,
|
|
5253
|
+
...request.cursor === void 0 ? {} : { cursor: request.cursor },
|
|
5254
|
+
...request.metadataOnly === true ? {
|
|
5255
|
+
metadataOnly: true,
|
|
5256
|
+
...request.assistantPreview === true ? { assistantPreview: true } : {}
|
|
5257
|
+
} : {
|
|
5258
|
+
...references || request.cursor !== void 0 || pageSize !== request.pageSize ? { readOnly: true } : {},
|
|
5259
|
+
...references ? {
|
|
5260
|
+
imageProjection: { sessionId: request.sessionId, referenceItem: this.options.referenceItem }
|
|
5261
|
+
} : {}
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
5264
|
+
)));
|
|
5265
|
+
itemCount = page.items.length;
|
|
5266
|
+
if (diagnostics.activeMs >= 1e3) {
|
|
5267
|
+
logger.info({
|
|
5268
|
+
...diagnosticRequest(request),
|
|
5269
|
+
...diagnostics.details(),
|
|
5270
|
+
metadataOnly: request.metadataOnly === true
|
|
5271
|
+
}, "session.timeline.page.read-slow");
|
|
5272
|
+
}
|
|
5273
|
+
if (!publications.isCurrent(request.sessionId, publication)) throw new SessionNotSharedError();
|
|
5274
|
+
const latestAssistant = request.assistantPreview === true ? [...page.items].reverse().find(isContentfulAssistant) : void 0;
|
|
5275
|
+
const preview = latestAssistant === void 0 ? void 0 : assistantPreview(
|
|
5276
|
+
latestAssistant,
|
|
5277
|
+
(item) => this.options.referenceItem(request.sessionId, item)
|
|
5278
|
+
);
|
|
5279
|
+
const latestUser = request.assistantPreview === true ? [...page.items].reverse().find((item) => item.kind === "human-message" && item.actor === "human") : void 0;
|
|
5280
|
+
const humanPreview = latestUser === void 0 ? void 0 : userPreview(latestUser);
|
|
5281
|
+
const responsePage = {
|
|
5282
|
+
...page,
|
|
5283
|
+
...preview === void 0 ? {} : { assistantPreview: preview },
|
|
5284
|
+
...humanPreview === void 0 ? {} : { userPreview: humanPreview },
|
|
5285
|
+
...request.assistantPreview === true ? { previewsComplete: !page.hasMore } : {},
|
|
5286
|
+
items: request.metadataOnly === true && request.assistantPreview === true ? page.items.map((item) => {
|
|
5287
|
+
if (item.kind === "assistant-message" || item.kind === "human-message") {
|
|
5288
|
+
return { ...item, content: "", attachments: [] };
|
|
5289
|
+
}
|
|
5290
|
+
return isContentfulAssistant(item) ? { ...item, content: "" } : item;
|
|
5291
|
+
}) : page.items
|
|
5292
|
+
};
|
|
5293
|
+
const result = {
|
|
5294
|
+
ok: true,
|
|
5295
|
+
requestId: request.requestId,
|
|
5296
|
+
machineId,
|
|
5297
|
+
sessionId: request.sessionId,
|
|
5298
|
+
page: references ? { ...responsePage, items: responsePage.items.map((item) => this.options.referenceItem(request.sessionId, item)) } : responsePage
|
|
5299
|
+
};
|
|
5300
|
+
logger.debug({
|
|
5301
|
+
requestId: request.requestId,
|
|
5302
|
+
sessionId: request.sessionId,
|
|
5303
|
+
itemCount: page.items.length
|
|
5304
|
+
}, "session.timeline.page.ready");
|
|
5305
|
+
phase = "encode";
|
|
5306
|
+
const { message, metrics } = await this.options.encoder.seal(result, request, {
|
|
5307
|
+
enabled: config.timelineCompressionEnabled === true,
|
|
5308
|
+
...scope.clientId === void 0 ? {} : { recipientClientId: scope.clientId },
|
|
5309
|
+
...config.secureMessagePacketBudget === void 0 ? {} : { packetBudget: config.secureMessagePacketBudget }
|
|
5310
|
+
});
|
|
5311
|
+
if (!scope.isCurrent()) return;
|
|
5312
|
+
if (!publications.isCurrent(request.sessionId, publication)) throw new SessionNotSharedError();
|
|
5313
|
+
phase = "emit";
|
|
5314
|
+
this.options.sendSealed(message);
|
|
5315
|
+
this.options.trafficMetrics.record(message, metrics.plaintextBytes, metrics.sealDurationMs);
|
|
5316
|
+
this.#errors.recovered(errorKey);
|
|
5317
|
+
const timingLevel = metrics.encodeDurationMs + metrics.sealDurationMs >= 1e3 ? "info" : "debug";
|
|
5318
|
+
logger[timingLevel](metrics, "transport.timeline.encoding");
|
|
5319
|
+
return;
|
|
5320
|
+
} catch (error) {
|
|
5321
|
+
if (!scope.isCurrent()) return;
|
|
5322
|
+
if (!publications.isCurrent(request.sessionId, publication)) throw new SessionNotSharedError();
|
|
5323
|
+
if (phase === "emit" || request.metadataOnly === true || request.assistantPreview === true || pageSize <= 25 || !(error instanceof TimelinePageBudgetError || error instanceof SecureMessageBudgetError) || itemCount !== void 0 && itemCount <= 1) throw error;
|
|
5324
|
+
const nextPageSize = Math.max(25, Math.floor(pageSize / 2));
|
|
5325
|
+
logger.info(
|
|
5326
|
+
{ ...diagnosticRequest(request), pageSize, nextPageSize, phase },
|
|
5327
|
+
"session.timeline.page.resized"
|
|
5328
|
+
);
|
|
5329
|
+
pageSize = nextPageSize;
|
|
5330
|
+
}
|
|
5331
|
+
}
|
|
5246
5332
|
} catch (error) {
|
|
5247
5333
|
if (!scope.isCurrent()) return;
|
|
5248
5334
|
this.#errors.failure(errorKey, error, {
|
|
@@ -5256,7 +5342,7 @@ var SessionTimelinePageHandler = class {
|
|
|
5256
5342
|
machineId,
|
|
5257
5343
|
sessionId: request.sessionId,
|
|
5258
5344
|
error: sessionRestoreFailure(error) ?? {
|
|
5259
|
-
code: error instanceof SecureMessageBudgetError ? "TRANSPORT_BUDGET_EXCEEDED" : operationErrorCode(adapter.agentId, "TIMELINE_PAGE", error),
|
|
5345
|
+
code: error instanceof SecureMessageBudgetError || error instanceof TimelinePageBudgetError ? "TRANSPORT_BUDGET_EXCEEDED" : operationErrorCode(adapter.agentId, "TIMELINE_PAGE", error),
|
|
5260
5346
|
message: toErrorDetails(error).message
|
|
5261
5347
|
}
|
|
5262
5348
|
});
|
|
@@ -7786,7 +7872,7 @@ var INVENTORY_REFRESH_DEBOUNCE_MS = 100;
|
|
|
7786
7872
|
var SESSION_LIST_REFRESH_RETRIES = 2;
|
|
7787
7873
|
var TRAFFIC_METRICS_INTERVAL_MS = 6e4;
|
|
7788
7874
|
var PcAgent = class {
|
|
7789
|
-
constructor(config, identity2, appVersion, adapter, logger, pairingProvider, contentCipher, research, createSocket =
|
|
7875
|
+
constructor(config, identity2, appVersion, adapter, logger, pairingProvider, contentCipher, research, createSocket = createRelaySocket, onPairing) {
|
|
7790
7876
|
this.config = config;
|
|
7791
7877
|
this.identity = identity2;
|
|
7792
7878
|
this.appVersion = appVersion;
|
|
@@ -7832,7 +7918,10 @@ var PcAgent = class {
|
|
|
7832
7918
|
stopSynchronizing: (clientId, sessionId) => this.#conversationAudience.stopSynchronizing(clientId, sessionId)
|
|
7833
7919
|
});
|
|
7834
7920
|
this.#timelineIncremental = new TimelineIncrementalTransport({
|
|
7835
|
-
readHead: (sessionId) => this.adapter.readSessionTimelinePage(sessionId, {
|
|
7921
|
+
readHead: (sessionId) => this.adapter.readSessionTimelinePage(sessionId, {
|
|
7922
|
+
pageSize: 100,
|
|
7923
|
+
imageProjection: { sessionId, referenceItem: this.#timelineIncremental.images.referenceItem }
|
|
7924
|
+
})
|
|
7836
7925
|
});
|
|
7837
7926
|
const imageSettings = config.sessionImages === void 0 ? void 0 : SessionImagesConfigSchema.parse(config.sessionImages);
|
|
7838
7927
|
this.#imageBlob = imageSettings === void 0 ? void 0 : new TimelineImageBlobPublisher(this.#timelineIncremental.images, new SessionImageUploader({
|
|
@@ -7902,7 +7991,7 @@ var PcAgent = class {
|
|
|
7902
7991
|
trafficMetrics: this.#trafficMetrics,
|
|
7903
7992
|
sendSealed: (message) => this.#socket.emit("secure.message", message),
|
|
7904
7993
|
imageReferencesEnabled: () => this.#communicationNegotiated && this.#conversationAudience.confirmed,
|
|
7905
|
-
referenceItem:
|
|
7994
|
+
referenceItem: this.#timelineIncremental.images.referenceItem
|
|
7906
7995
|
});
|
|
7907
7996
|
this.#secureRequestRouter = createPcSecureRequestRouter({
|
|
7908
7997
|
configuredMachineId: identity2.machineId,
|
|
@@ -8828,6 +8917,7 @@ var PcAgent = class {
|
|
|
8828
8917
|
}
|
|
8829
8918
|
#machineCapabilities() {
|
|
8830
8919
|
return [
|
|
8920
|
+
...this.adapter.agentId === "copilot" || this.adapter.agentId === "managed" ? [SESSION_AVATAR_PERSONA_CAPABILITY] : [],
|
|
8831
8921
|
SESSION_COMMUNICATION_CAPABILITY,
|
|
8832
8922
|
...this.#peerChatEnabled && this.adapter.runPeerTurn !== void 0 ? [PC_PEER_CHAT_CAPABILITY] : [],
|
|
8833
8923
|
...this.adapter.runPeerTurn !== void 0 ? [PC_A2A_CAPABILITY] : [],
|
|
@@ -10680,6 +10770,7 @@ export {
|
|
|
10680
10770
|
SessionImageUploadError,
|
|
10681
10771
|
SessionImageUploader,
|
|
10682
10772
|
SessionImagesConfigSchema,
|
|
10773
|
+
TimelinePageBudgetError,
|
|
10683
10774
|
assertPiRuntimeSupported,
|
|
10684
10775
|
buildPairingUri,
|
|
10685
10776
|
codingAgentPresentation,
|
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-CVWUKZX7.js";
|
|
7
|
+
import "./chunks/chunk-OV77TRIH.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.40",
|
|
4
4
|
"description": "AgentKnight runtime SDK for local and remote coding sessions",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"esbuild": "0.28.2",
|
|
50
50
|
"rollup": "4.63.1",
|
|
51
51
|
"rollup-plugin-dts": "6.3.0",
|
|
52
|
-
"@agentknight/
|
|
53
|
-
"@agentknight/
|
|
52
|
+
"@agentknight/protocol": "0.1.0",
|
|
53
|
+
"@agentknight/shared": "0.1.0"
|
|
54
54
|
},
|
|
55
55
|
"optionalDependencies": {
|
|
56
56
|
"@earendil-works/pi-ai": "0.85.1",
|