@agentknight/sdk 0.9.68 → 0.9.69

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.
Files changed (27) hide show
  1. package/dist/chunks/{acp-adapter-RZX5SUB3.js → acp-adapter-VJ2OUSBS.js} +41 -4
  2. package/dist/chunks/{chunk-FY4XTWUF.js → chunk-2D34UDII.js} +4 -13
  3. package/dist/chunks/{chunk-AWVC5NX4.js → chunk-5QYL6NKJ.js} +1 -1
  4. package/dist/chunks/{chunk-B777YB6E.js → chunk-ES2N66EH.js} +1 -1
  5. package/dist/chunks/{chunk-DWTXWVIA.js → chunk-F5YCEWE4.js} +3 -0
  6. package/dist/chunks/{chunk-CFQQOAQV.js → chunk-IRYEOV62.js} +2 -2
  7. package/dist/chunks/{chunk-UHRUQM4D.js → chunk-J63A5OLO.js} +1 -1
  8. package/dist/chunks/{chunk-Y6NCJB55.js → chunk-LA6A4TUM.js} +3 -3
  9. package/dist/chunks/{chunk-EDYVCZIR.js → chunk-LU73CEHE.js} +2 -2
  10. package/dist/chunks/chunk-MB34W52S.js +78 -0
  11. package/dist/chunks/{chunk-Q5OUZJCZ.js → chunk-MH7FDSTY.js} +1 -1
  12. package/dist/chunks/{chunk-MB3H6HEI.js → chunk-Q5NNNSU2.js} +2 -2
  13. package/dist/chunks/chunk-UTF7KLMJ.js +11 -0
  14. package/dist/chunks/{chunk-4XT65OSG.js → chunk-WAPJZKUK.js} +46 -3
  15. package/dist/chunks/{chunk-LCA2MWOQ.js → chunk-ZAU2MYQI.js} +2 -2
  16. package/dist/chunks/{claude-adapter-FQSQIYUY.js → claude-adapter-FZNLF5XN.js} +240 -27
  17. package/dist/chunks/{codex-adapter-TOXSRT2W.js → codex-adapter-5ZVOAT6O.js} +249 -66
  18. package/dist/chunks/{copilot-adapter-KUCX7XQW.js → copilot-adapter-V6RAQ4WK.js} +13 -12
  19. package/dist/chunks/{managed-agent-adapter-LGBRXDGP.js → managed-agent-adapter-THUSTKRW.js} +9 -7
  20. package/dist/chunks/{pi-adapter-RXNZSE4F.js → pi-adapter-EHCSR5I2.js} +6 -8
  21. package/dist/configuration.js +4 -4
  22. package/dist/index.d.ts +15 -8
  23. package/dist/index.js +35 -22
  24. package/dist/runtime.js +2 -2
  25. package/dist/session-analytics-worker.js +5 -6
  26. package/package.json +3 -3
  27. package/dist/chunks/chunk-IXGVSREH.js +0 -48
@@ -1,16 +1,22 @@
1
+ import {
2
+ projectNativeImage
3
+ } from "./chunk-MB34W52S.js";
4
+ import "./chunk-UTF7KLMJ.js";
5
+ import "./chunk-ES2N66EH.js";
6
+ import "./chunk-35OF2ZNS.js";
1
7
  import {
2
8
  latestPreviewItems
3
- } from "./chunk-IXGVSREH.js";
9
+ } from "./chunk-WAPJZKUK.js";
4
10
  import {
5
11
  UnsupportedAgentOperationError
6
- } from "./chunk-CFQQOAQV.js";
7
- import "./chunk-UHRUQM4D.js";
12
+ } from "./chunk-IRYEOV62.js";
13
+ import "./chunk-J63A5OLO.js";
8
14
  import {
9
15
  ConversationItemSchema,
10
16
  PromptImageAttachmentSchema,
11
17
  SESSION_TIMELINE_PAGE_SIZE,
12
18
  SessionSummarySchema
13
- } from "./chunk-DWTXWVIA.js";
19
+ } from "./chunk-F5YCEWE4.js";
14
20
 
15
21
  // src/acp-adapter.ts
16
22
  import { spawn } from "node:child_process";
@@ -131,6 +137,9 @@ var AcpCodingAgentAdapter = class {
131
137
  get supportsSessionDelete() {
132
138
  return this.#capabilities.sessionCapabilities?.delete != null;
133
139
  }
140
+ get supportsImageAttachments() {
141
+ return this.#capabilities.promptCapabilities?.image === true;
142
+ }
134
143
  async canUpgrade() {
135
144
  return this.#started && !this.#stopping && this.#fatalError === void 0 && this.#permissions.size === 0 && [...this.#sessions.values()].every((session) => session.active === void 0 && session.queue.length === 0 && session.loading === void 0 && !session.writeInProgress && session.persistenceError === void 0 && !session.items.some((item) => item.kind === "activity-group" && item.status === "running"));
136
145
  }
@@ -719,6 +728,10 @@ var AcpCodingAgentAdapter = class {
719
728
  const turnId = session.active?.id;
720
729
  if (!turnId) return;
721
730
  if (update.sessionUpdate === "agent_message_chunk") {
731
+ if (update.content.type === "image") {
732
+ this.#projectImage(session, turnId, update.messageId ?? "message", update.content);
733
+ return;
734
+ }
722
735
  if (update.content.type !== "text") {
723
736
  this.#notice(session, turnId, "warning", "Unsupported agent content", update.content.type);
724
737
  return;
@@ -757,6 +770,13 @@ var AcpCodingAgentAdapter = class {
757
770
  timestamp: step?.timestamp ?? previous?.timestamp ?? base.timestamp
758
771
  }]
759
772
  });
773
+ if (status === "completed") {
774
+ for (const block of update.content ?? []) {
775
+ if (block.type === "content" && block.content.type === "image") {
776
+ this.#projectImage(session, turnId, update.toolCallId, block.content);
777
+ }
778
+ }
779
+ }
760
780
  } else if (update.sessionUpdate === "plan") {
761
781
  const id = hash(`${session.summary.sessionId}:plan`);
762
782
  const previous = session.items.find((item) => item.id === id);
@@ -775,6 +795,23 @@ var AcpCodingAgentAdapter = class {
775
795
  });
776
796
  }
777
797
  }
798
+ #projectImage(session, turnId, source, image) {
799
+ const attachment = projectNativeImage(image.data, image.mimeType);
800
+ if (!attachment) {
801
+ this.#notice(session, turnId, "warning", "Unsupported agent image", "The image format or size is not supported");
802
+ return;
803
+ }
804
+ const id = hash(`${turnId}:image:${source}:${attachment.sha256}`);
805
+ if (session.items.some((item) => item.id === id)) return;
806
+ this.#upsert(session, {
807
+ ...this.#base(id, turnId),
808
+ kind: "assistant-message",
809
+ actor: "assistant",
810
+ content: "",
811
+ final: true,
812
+ attachments: [attachment]
813
+ });
814
+ }
778
815
  #permission(request, signal) {
779
816
  const session = this.#sessions.get(request.sessionId);
780
817
  if (!session?.active || session.active.cancelled || this.#stopping || signal.aborted) {
@@ -6,13 +6,13 @@ import {
6
6
  ConversationNormalizer,
7
7
  ConversationToolLifecycles,
8
8
  assistantMessageId
9
- } from "./chunk-EDYVCZIR.js";
9
+ } from "./chunk-LU73CEHE.js";
10
10
  import {
11
11
  isContentfulAssistant
12
- } from "./chunk-IXGVSREH.js";
12
+ } from "./chunk-WAPJZKUK.js";
13
13
  import {
14
14
  SessionOperationError
15
- } from "./chunk-UHRUQM4D.js";
15
+ } from "./chunk-J63A5OLO.js";
16
16
  import {
17
17
  IdSchema,
18
18
  SESSION_DIRECTORY_LIST_OPERATION,
@@ -48,7 +48,7 @@ import {
48
48
  WorkbenchReasoningPageSchema,
49
49
  WorkbenchReasoningRequestSchema,
50
50
  isSafeSessionDirectoryPath
51
- } from "./chunk-DWTXWVIA.js";
51
+ } from "./chunk-F5YCEWE4.js";
52
52
 
53
53
  // src/session-image-uploader.ts
54
54
  import { createHash } from "node:crypto";
@@ -1611,14 +1611,6 @@ async function resolveGitProjectIdentity(workingDirectory, env = gitEnvironment(
1611
1611
  };
1612
1612
  }
1613
1613
 
1614
- // src/prompt-preparation-error.ts
1615
- var PromptPreparationError = class extends Error {
1616
- constructor(cause) {
1617
- super(cause instanceof Error ? cause.message : "Prompt preparation failed", { cause });
1618
- this.name = "PromptPreparationError";
1619
- }
1620
- };
1621
-
1622
1614
  // src/session-project-identity.ts
1623
1615
  import { realpath as realpath3, stat as stat2 } from "node:fs/promises";
1624
1616
  import { isAbsolute as isAbsolute3 } from "node:path";
@@ -2371,7 +2363,6 @@ export {
2371
2363
  sanitizeGitRemoteUrl,
2372
2364
  NotGitDirectoryError,
2373
2365
  resolveGitProjectIdentity,
2374
- PromptPreparationError,
2375
2366
  SESSION_PROJECT_IDENTITY_CONCURRENCY,
2376
2367
  SessionProjectIdentityError,
2377
2368
  SessionProjectIdentityReader,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SessionOperationError
3
- } from "./chunk-UHRUQM4D.js";
3
+ } from "./chunk-J63A5OLO.js";
4
4
 
5
5
  // src/adapters/copilot/runtime/session-identity.ts
6
6
  function assertMainSessionId(sessionId) {
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  PromptFileAttachmentSchema,
6
6
  PromptImageAttachmentSchema
7
- } from "./chunk-DWTXWVIA.js";
7
+ } from "./chunk-F5YCEWE4.js";
8
8
 
9
9
  // src/prompt-attachments.ts
10
10
  import { createHash, randomUUID } from "node:crypto";
@@ -66,6 +66,9 @@ var SessionSummarySchema = z4.object({
66
66
  machineId: IdSchema,
67
67
  summary: z4.string().max(4096).optional(),
68
68
  renameSupported: z4.boolean().optional(),
69
+ deleteSupported: z4.boolean().optional(),
70
+ imageAttachmentsSupported: z4.boolean().optional(),
71
+ fileAttachmentsSupported: z4.boolean().optional(),
69
72
  workingDirectory: z4.string().max(32768).optional(),
70
73
  gitRoot: z4.string().max(32768).optional(),
71
74
  repository: z4.string().max(1024).optional(),
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  SessionOperationError
3
- } from "./chunk-UHRUQM4D.js";
3
+ } from "./chunk-J63A5OLO.js";
4
4
  import {
5
5
  SESSION_NAME_MAX_LENGTH,
6
6
  SessionNameSchema
7
- } from "./chunk-DWTXWVIA.js";
7
+ } from "./chunk-F5YCEWE4.js";
8
8
 
9
9
  // src/coding-agent-adapter.ts
10
10
  var CODING_AGENT_IDS = ["copilot", "pi", "codex", "claude", "acp"];
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SessionCommunicationDataSchema,
3
3
  WorkbenchOperationStatusSchema
4
- } from "./chunk-DWTXWVIA.js";
4
+ } from "./chunk-F5YCEWE4.js";
5
5
 
6
6
  // src/session-operations.ts
7
7
  import { createHash, randomUUID } from "node:crypto";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  ConversationNormalizer
3
- } from "./chunk-EDYVCZIR.js";
3
+ } from "./chunk-LU73CEHE.js";
4
4
  import {
5
5
  resolveCopilotSessionDirectory
6
6
  } from "./chunk-35OF2ZNS.js";
7
7
  import {
8
8
  isContentfulAssistant
9
- } from "./chunk-IXGVSREH.js";
9
+ } from "./chunk-WAPJZKUK.js";
10
10
  import {
11
11
  SessionAnalyticsRequestSchema,
12
12
  SessionTimelinePageSchema
13
- } from "./chunk-DWTXWVIA.js";
13
+ } from "./chunk-F5YCEWE4.js";
14
14
 
15
15
  // src/session-analytics-messages.ts
16
16
  import { z } from "zod";
@@ -2,10 +2,10 @@ import {
2
2
  decodeTimelineImage,
3
3
  normalizeImageMimeType,
4
4
  splitTimelineImages
5
- } from "./chunk-4XT65OSG.js";
5
+ } from "./chunk-WAPJZKUK.js";
6
6
  import {
7
7
  CONVERSATION_SOURCE_ID_LIMIT
8
- } from "./chunk-DWTXWVIA.js";
8
+ } from "./chunk-F5YCEWE4.js";
9
9
 
10
10
  // src/conversation-normalizer.ts
11
11
  import { createHash } from "node:crypto";
@@ -0,0 +1,78 @@
1
+ import {
2
+ PromptPreparationError
3
+ } from "./chunk-UTF7KLMJ.js";
4
+ import {
5
+ stagePromptAttachments,
6
+ validatePromptAttachments
7
+ } from "./chunk-ES2N66EH.js";
8
+ import {
9
+ decodeTimelineImage,
10
+ normalizeImageMimeType
11
+ } from "./chunk-WAPJZKUK.js";
12
+ import {
13
+ SessionPromptRequestSchema
14
+ } from "./chunk-F5YCEWE4.js";
15
+
16
+ // src/adapters/prompt-media.ts
17
+ import { join } from "node:path";
18
+ async function prepareNativePrompt(root, sessionKey, text, images, files) {
19
+ try {
20
+ if (images.length || files.length) {
21
+ SessionPromptRequestSchema.parse({
22
+ machineId: "local",
23
+ sessionId: sessionKey,
24
+ requestId: "prepare",
25
+ operationId: "prepare",
26
+ prompt: text,
27
+ attachments: images,
28
+ fileAttachments: files
29
+ });
30
+ }
31
+ const validated = validatePromptAttachments(images, files);
32
+ for (const image of images) {
33
+ if ("failure" in decodeTimelineImage(image.data, image.mimeType, "content")) throw new Error("Invalid prompt image");
34
+ }
35
+ const staged = await stagePromptAttachments(
36
+ sessionKey,
37
+ { images: [], files: validated.files },
38
+ join(root, "uploads", sessionKey)
39
+ );
40
+ const fileParts = staged.flatMap((item) => item.type === "file" ? [item] : []);
41
+ const attachments = [
42
+ ...images.map(({ name, mimeType, byteLength, data, sha256 }) => ({ kind: "image", name, mimeType, byteLength, data, sha256 })),
43
+ ...fileParts.map((item, index) => {
44
+ const file = validated.files[index]?.attachment;
45
+ if (!file) throw new Error("Missing staged attachment");
46
+ return { kind: "file", name: file.name, mimeType: file.mimeType, uri: item.path };
47
+ })
48
+ ];
49
+ return {
50
+ attachments,
51
+ text: fileParts.length ? `${text}
52
+
53
+ Uploaded files (name and local path):
54
+ ${fileParts.map(
55
+ (file) => JSON.stringify({ name: file.displayName, path: file.path })
56
+ ).join("\n")}` : text,
57
+ images
58
+ };
59
+ } catch (error) {
60
+ throw new PromptPreparationError(error);
61
+ }
62
+ }
63
+ function projectNativeImage(data, type, name = "Image") {
64
+ const mimeType = normalizeImageMimeType(type);
65
+ const image = decodeTimelineImage(data, mimeType, "content");
66
+ return "failure" in image ? void 0 : { kind: "image", name, mimeType, ...image };
67
+ }
68
+ function projectNativeImageUrl(url) {
69
+ if (typeof url !== "string") return void 0;
70
+ const match = /^data:(image\/[a-z]+);base64,/iu.exec(url);
71
+ return match?.[1] === void 0 ? void 0 : projectNativeImage(url, match[1]);
72
+ }
73
+
74
+ export {
75
+ prepareNativePrompt,
76
+ projectNativeImage,
77
+ projectNativeImageUrl
78
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IdSchema
3
- } from "./chunk-DWTXWVIA.js";
3
+ } from "./chunk-F5YCEWE4.js";
4
4
 
5
5
  // src/data-directory.ts
6
6
  import { randomUUID } from "node:crypto";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  AgentSessionRenameError,
3
3
  validateSessionName
4
- } from "./chunk-CFQQOAQV.js";
4
+ } from "./chunk-IRYEOV62.js";
5
5
  import {
6
6
  ConversationItemSchema,
7
7
  GroupChatInfoSchema,
8
8
  GroupChatParticipantSchema,
9
9
  SESSION_TIMELINE_PAGE_SIZE,
10
10
  SessionSummarySchema
11
- } from "./chunk-DWTXWVIA.js";
11
+ } from "./chunk-F5YCEWE4.js";
12
12
 
13
13
  // src/group-chat.ts
14
14
  import { createHash, randomUUID } from "node:crypto";
@@ -0,0 +1,11 @@
1
+ // src/prompt-preparation-error.ts
2
+ var PromptPreparationError = class extends Error {
3
+ constructor(cause) {
4
+ super(cause instanceof Error ? cause.message : "Prompt preparation failed", { cause });
5
+ this.name = "PromptPreparationError";
6
+ }
7
+ };
8
+
9
+ export {
10
+ PromptPreparationError
11
+ };
@@ -1,6 +1,45 @@
1
1
  import {
2
- INLINE_IMAGE_MAX_BYTES
3
- } from "./chunk-DWTXWVIA.js";
2
+ INLINE_IMAGE_MAX_BYTES,
3
+ SessionAssistantPreviewSchema,
4
+ SessionUserPreviewSchema
5
+ } from "./chunk-F5YCEWE4.js";
6
+
7
+ // src/assistant-preview.ts
8
+ function isContentfulAssistant(item) {
9
+ return item.actor === "assistant" && (item.kind === "notice" && item.severity === "success" && item.title === "Task completed" && item.content.trim().length > 0 || item.kind === "assistant-message" && (item.content.trim().length > 0 || (item.attachments ?? []).some((attachment) => attachment.kind === "image")));
10
+ }
11
+ function userPreview(item) {
12
+ if (item.kind !== "human-message" || item.actor !== "human") return void 0;
13
+ return SessionUserPreviewSchema.parse({
14
+ id: item.id,
15
+ revision: item.revision,
16
+ timestamp: item.timestamp,
17
+ text: item.content.slice(0, 4096)
18
+ });
19
+ }
20
+ function latestPreviewItems(items) {
21
+ const latest = [...items].reverse();
22
+ return [
23
+ latest.find((item) => item.kind === "human-message" && item.actor === "human"),
24
+ latest.find(isContentfulAssistant)
25
+ ].filter((item) => item !== void 0);
26
+ }
27
+ function assistantPreview(item, referenceItem) {
28
+ if (!isContentfulAssistant(item)) return void 0;
29
+ const referenced = referenceItem(item);
30
+ const attachments = referenced.kind === "assistant-message" ? (referenced.attachments ?? []).filter((attachment) => attachment.kind === "image" && attachment.imageRef === "sha256").slice(0, 4) : [];
31
+ if (item.content.trim().length === 0 && attachments.length === 0) return void 0;
32
+ return SessionAssistantPreviewSchema.parse({
33
+ id: item.id,
34
+ revision: item.revision,
35
+ timestamp: item.timestamp,
36
+ sourceEventIds: item.sourceEventIds.slice(-1),
37
+ text: item.content.trim().slice(0, 4096),
38
+ final: item.kind === "assistant-message" ? item.final : true,
39
+ ...item.kind === "notice" ? { kind: "task-completion" } : {},
40
+ attachments
41
+ });
42
+ }
4
43
 
5
44
  // src/timeline-image-content.ts
6
45
  import { createHash } from "node:crypto";
@@ -68,5 +107,9 @@ export {
68
107
  normalizeImageMimeType,
69
108
  hasImageSignature,
70
109
  decodeTimelineImage,
71
- splitTimelineImages
110
+ splitTimelineImages,
111
+ isContentfulAssistant,
112
+ userPreview,
113
+ latestPreviewItems,
114
+ assistantPreview
72
115
  };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  CODING_AGENT_IDS
3
- } from "./chunk-CFQQOAQV.js";
3
+ } from "./chunk-IRYEOV62.js";
4
4
  import {
5
5
  BYTES_PER_KIB,
6
6
  LEGACY_SECURE_MESSAGE_MAX_CIPHERTEXT_LENGTH
7
- } from "./chunk-DWTXWVIA.js";
7
+ } from "./chunk-F5YCEWE4.js";
8
8
 
9
9
  // src/agent-selection.ts
10
10
  import { z } from "zod";