@agentknight/sdk 0.9.35 → 0.9.37

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.
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  latestPreviewItems
3
- } from "./chunk-MVUOCZFL.js";
3
+ } from "./chunk-QLGX7333.js";
4
4
  import {
5
5
  UnsupportedAgentOperationError
6
- } from "./chunk-SJHJER3B.js";
6
+ } from "./chunk-UJZPAP64.js";
7
7
  import {
8
8
  ConversationItemSchema,
9
9
  PromptImageAttachmentSchema,
10
10
  SESSION_TIMELINE_PAGE_SIZE,
11
11
  SessionSummarySchema
12
- } from "./chunk-ZKAN2FO7.js";
12
+ } from "./chunk-N2LIXMIM.js";
13
13
 
14
14
  // src/acp-adapter.ts
15
15
  import { spawn } from "node:child_process";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isContentfulAssistant
3
- } from "./chunk-MVUOCZFL.js";
3
+ } from "./chunk-QLGX7333.js";
4
4
  import {
5
5
  SessionOperationError
6
- } from "./chunk-SJHJER3B.js";
6
+ } from "./chunk-UJZPAP64.js";
7
7
  import {
8
8
  CONVERSATION_SOURCE_ID_LIMIT,
9
9
  SESSION_DIRECTORY_LIST_OPERATION,
@@ -21,7 +21,7 @@ import {
21
21
  WorkbenchInsightsSchema,
22
22
  WorkbenchQueueMutationResultSchema,
23
23
  WorkbenchQueueSnapshotSchema
24
- } from "./chunk-ZKAN2FO7.js";
24
+ } from "./chunk-N2LIXMIM.js";
25
25
 
26
26
  // src/operation-diagnostics.ts
27
27
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -831,6 +831,7 @@ var ConversationNormalizer = class {
831
831
  sourceMessageIds: [event.id]
832
832
  } : { kind: "human-message", actor: "human" },
833
833
  sourceEventIds: [event.id],
834
+ ...event.data.messageId === void 0 ? {} : { sourceMessageIds: [protocolId(event.data.messageId)] },
834
835
  ...event.data.interactionId === void 0 ? {} : { sourceInteractionIds: [protocolId(event.data.interactionId)] },
835
836
  content: limitSummary(event.data.content, 1e5),
836
837
  attachments: event.data.attachments?.slice(0, 100).map(projectAttachment).map(boundAttachment) ?? []
@@ -1594,6 +1595,7 @@ var SessionRuntime = class {
1594
1595
  initializingEvents: void 0
1595
1596
  };
1596
1597
  activity = {
1598
+ revision: 0,
1597
1599
  activeRootTurn: false,
1598
1600
  busy: false,
1599
1601
  turnEndIdleTimer: void 0
@@ -1646,6 +1648,7 @@ var SessionRuntime = class {
1646
1648
  this.live.initializingEvents = void 0;
1647
1649
  }
1648
1650
  prepareReload(preserveTimelineState) {
1651
+ this.activity.revision += 1;
1649
1652
  this.timelineReads.invalidate();
1650
1653
  this.connection.sendReady = false;
1651
1654
  this.stopFollower();
@@ -1658,6 +1661,7 @@ var SessionRuntime = class {
1658
1661
  this.live.initializingEvents = this.watched ? [] : void 0;
1659
1662
  }
1660
1663
  stopResources() {
1664
+ this.activity.revision += 1;
1661
1665
  this.timelineReads.invalidate();
1662
1666
  this.stopFollower();
1663
1667
  this.clearFollowerRecovery();
@@ -1908,6 +1912,7 @@ ${state.deltaContent}`).slice(0, 4096),
1908
1912
  }
1909
1913
  const runtime = this.ports.state(sessionId);
1910
1914
  if (event.type === "session.resume" && event.data.sessionWasActive === true) {
1915
+ runtime.activity.revision += 1;
1911
1916
  this.#clearTurnEndIdleTimer(sessionId);
1912
1917
  if (!runtime.activity.busy) {
1913
1918
  runtime.activity.busy = true;
@@ -1920,6 +1925,7 @@ ${state.deltaContent}`).slice(0, 4096),
1920
1925
  return;
1921
1926
  }
1922
1927
  if (event.type === "assistant.turn_start") {
1928
+ runtime.activity.revision += 1;
1923
1929
  this.#clearTurnEndIdleTimer(sessionId);
1924
1930
  runtime.activity.activeRootTurn = true;
1925
1931
  if (!runtime.activity.busy) {
@@ -1933,6 +1939,7 @@ ${state.deltaContent}`).slice(0, 4096),
1933
1939
  return;
1934
1940
  }
1935
1941
  if (event.type === "assistant.turn_end") {
1942
+ runtime.activity.revision += 1;
1936
1943
  runtime.activity.activeRootTurn = false;
1937
1944
  this.#scheduleTurnEndIdleFallback(sessionId, event.timestamp);
1938
1945
  return;
@@ -1959,6 +1966,7 @@ ${state.deltaContent}`).slice(0, 4096),
1959
1966
  markSessionIdle(sessionId, occurredAt) {
1960
1967
  this.#clearTurnEndIdleTimer(sessionId);
1961
1968
  const runtime = this.ports.state(sessionId);
1969
+ runtime.activity.revision += 1;
1962
1970
  if (runtime.activity.busy) {
1963
1971
  runtime.activity.busy = false;
1964
1972
  this.ports.callbacks()?.onSessionActivity?.(sessionId, "idle", occurredAt);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SessionOperationError
3
- } from "./chunk-SJHJER3B.js";
3
+ } from "./chunk-UJZPAP64.js";
4
4
 
5
5
  // src/adapters/copilot/runtime/session-identity.ts
6
6
  function assertMainSessionId(sessionId) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IdSchema
3
- } from "./chunk-ZKAN2FO7.js";
3
+ } from "./chunk-N2LIXMIM.js";
4
4
 
5
5
  // src/data-directory.ts
6
6
  import { randomUUID } from "node:crypto";
@@ -34,6 +34,7 @@ var SESSION_LIST_UPDATES_CAPABILITY = "session-list-updates";
34
34
  var SESSION_WORKTREE_CREATION_CAPABILITY = "session-worktree-creation";
35
35
  var MANAGED_SESSION_SELECTION_CAPABILITY = "coding-agent:managed";
36
36
  var AGENT_CONTROLS_CAPABILITY = "coding-agent-controls-v1";
37
+ var SESSION_OPTIONS_PARTIAL_CAPABILITY = "session-options-partial-v1";
37
38
  var GroupChatParticipantSchema = z3.object({
38
39
  sessionId: IdSchema,
39
40
  title: z3.string().trim().min(1).max(260)
@@ -238,7 +239,17 @@ var SessionOptionsResultSchema = z3.discriminatedUnion("ok", [
238
239
  requestId: IdSchema,
239
240
  machineId: IdSchema,
240
241
  sessionId: IdSchema.optional(),
241
- error: ProtocolFailureSchema
242
+ error: ProtocolFailureSchema,
243
+ failureStage: z3.enum(["models", "configuration", "workspaces"]).optional(),
244
+ models: z3.array(CopilotModelOptionSchema).min(1).optional(),
245
+ agentModes: z3.array(SessionAgentModeSchema).min(1).optional(),
246
+ reasoningEffortConfigurationSupported: z3.literal(true).optional(),
247
+ fileAttachmentsSupported: z3.boolean().optional(),
248
+ currentModelId: IdSchema.optional(),
249
+ currentAgentMode: SessionAgentModeSchema.optional(),
250
+ currentReasoningEffort: CurrentReasoningEffortSchema.optional(),
251
+ agentName: z3.string().trim().min(1).max(260).optional(),
252
+ configOptions: z3.array(AgentConfigurationOptionSchema).max(32).optional()
242
253
  })
243
254
  ]);
244
255
  var SessionCreateRequestSchema = z3.object({
@@ -2545,6 +2556,7 @@ export {
2545
2556
  SESSION_WORKTREE_CREATION_CAPABILITY,
2546
2557
  MANAGED_SESSION_SELECTION_CAPABILITY,
2547
2558
  AGENT_CONTROLS_CAPABILITY,
2559
+ SESSION_OPTIONS_PARTIAL_CAPABILITY,
2548
2560
  GroupChatParticipantSchema,
2549
2561
  GroupChatInfoSchema,
2550
2562
  SessionSummarySchema,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SessionAssistantPreviewSchema,
3
3
  SessionUserPreviewSchema
4
- } from "./chunk-ZKAN2FO7.js";
4
+ } from "./chunk-N2LIXMIM.js";
5
5
 
6
6
  // src/assistant-preview.ts
7
7
  function isContentfulAssistant(item) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SECURE_MESSAGE_MAX_CIPHERTEXT_LENGTH
3
- } from "./chunk-ZKAN2FO7.js";
3
+ } from "./chunk-N2LIXMIM.js";
4
4
 
5
5
  // src/agent-selection.ts
6
6
  import { z } from "zod";
@@ -3,7 +3,7 @@ import {
3
3
  SessionCommunicationDataSchema,
4
4
  SessionNameSchema,
5
5
  WorkbenchOperationStatusSchema
6
- } from "./chunk-ZKAN2FO7.js";
6
+ } from "./chunk-N2LIXMIM.js";
7
7
 
8
8
  // src/session-operations.ts
9
9
  import { createHash, randomUUID } from "node:crypto";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  AgentSessionRenameError,
3
3
  validateSessionName
4
- } from "./chunk-SJHJER3B.js";
4
+ } from "./chunk-UJZPAP64.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-ZKAN2FO7.js";
11
+ } from "./chunk-N2LIXMIM.js";
12
12
 
13
13
  // src/group-chat.ts
14
14
  import { createHash, randomUUID } from "node:crypto";
@@ -17,24 +17,24 @@ import {
17
17
  recordOperationTimelineRead,
18
18
  resolveGitProjectIdentity,
19
19
  sanitizeGitRemoteUrl
20
- } from "./chunk-JFHUAIRY.js";
20
+ } from "./chunk-7JRY2FRZ.js";
21
21
  import {
22
22
  assertMainSessionId,
23
23
  isResearchSessionId
24
- } from "./chunk-AHJSR7OY.js";
24
+ } from "./chunk-DSHLLGE2.js";
25
25
  import {
26
26
  GroupChatError,
27
27
  GroupChatMessageSchema,
28
28
  GroupChatRuntime
29
- } from "./chunk-ATMWDEPF.js";
29
+ } from "./chunk-VXZ25DKC.js";
30
30
  import {
31
31
  isContentfulAssistant
32
- } from "./chunk-MVUOCZFL.js";
32
+ } from "./chunk-QLGX7333.js";
33
33
  import {
34
34
  AgentSessionRenameError,
35
35
  SessionOperationError,
36
36
  validateSessionName
37
- } from "./chunk-SJHJER3B.js";
37
+ } from "./chunk-UJZPAP64.js";
38
38
  import {
39
39
  ConversationItemSchema,
40
40
  CopilotModelOptionSchema,
@@ -54,7 +54,7 @@ import {
54
54
  WorkbenchScheduleEntrySchema,
55
55
  WorkbenchScheduleProposalSchema,
56
56
  WorkbenchScheduleSnapshotSchema
57
- } from "./chunk-ZKAN2FO7.js";
57
+ } from "./chunk-N2LIXMIM.js";
58
58
 
59
59
  // src/copilot-adapter.ts
60
60
  import { createHash as createHash4, randomUUID as randomUUID6 } from "node:crypto";
@@ -888,7 +888,6 @@ var SessionConnections = class {
888
888
  reloadSession(sessionId, options = {}) {
889
889
  assertMainSessionId(sessionId);
890
890
  const explicit = options.activate === true || options.resumeForSend === true;
891
- this.ports.assertCanResume?.(sessionId, explicit);
892
891
  this.ports.owned(sessionId);
893
892
  const runtime = this.#sessionRuntimes.getOrCreate(sessionId);
894
893
  const inProgress = runtime.connection.reload;
@@ -905,14 +904,14 @@ var SessionConnections = class {
905
904
  this.ports.resetMetadata(sessionId);
906
905
  const reloaded = (async () => {
907
906
  if (previous === void 0 && explicit) {
908
- const sendReadySession = await this.resumeSession(sessionId, false, explicit, options.beforeResume);
907
+ const sendReadySession = await this.resumeSession(sessionId, false, options.beforeResume);
909
908
  if (runtime.connection.generation !== generation) {
910
909
  throw new Error("Copilot session connection was replaced");
911
910
  }
912
911
  runtime.connection.sendReady = true;
913
912
  return sendReadySession;
914
913
  }
915
- const staleSession = previous === void 0 ? await this.resumeSession(sessionId, true, explicit, options.beforeResume) : await previous;
914
+ const staleSession = previous === void 0 ? await this.resumeSession(sessionId, true, options.beforeResume) : await previous;
916
915
  if (runtime.connection.generation !== generation) {
917
916
  throw new Error("Copilot session connection was replaced");
918
917
  }
@@ -931,7 +930,6 @@ var SessionConnections = class {
931
930
  const resumed = await this.resumeSession(
932
931
  sessionId,
933
932
  options.resumeForSend !== true,
934
- explicit,
935
933
  options.beforeResume
936
934
  );
937
935
  if (runtime.connection.generation !== generation) {
@@ -973,11 +971,9 @@ var SessionConnections = class {
973
971
  );
974
972
  return reloaded;
975
973
  }
976
- async resumeSession(sessionId, suppressResumeEvent = true, explicit = false, beforeResume) {
974
+ async resumeSession(sessionId, suppressResumeEvent = true, beforeResume) {
977
975
  assertMainSessionId(sessionId);
978
- this.ports.assertCanResume?.(sessionId, explicit);
979
976
  await this.ports.runtime().awaitRuntime();
980
- this.ports.assertCanResume?.(sessionId, explicit);
981
977
  const restoreFailures = this.#restoreFailures;
982
978
  const rejected = restoreFailures.get(sessionId);
983
979
  if (suppressResumeEvent && rejected !== void 0 && rejected.until > Date.now()) {
@@ -1061,6 +1057,7 @@ var SessionConnections = class {
1061
1057
  throw new Error("Prompt or attachment is required");
1062
1058
  }
1063
1059
  const runtime = this.#sessionRuntimes.getOrCreate(sessionId);
1060
+ const generation = runtime.connection.generation;
1064
1061
  runtime.timelineReads.invalidate();
1065
1062
  runtime.connection.sendInProgressCount += 1;
1066
1063
  try {
@@ -1075,6 +1072,7 @@ var SessionConnections = class {
1075
1072
  const wasBusy = runtime.activity.busy;
1076
1073
  const sdkMode = mode === "immediate" && !wasBusy ? "enqueue" : mode;
1077
1074
  const submittedAt = this.ports.runtime().client.supportsLocalSubmissionTime === true ? (/* @__PURE__ */ new Date()).toISOString() : void 0;
1075
+ const activityRevision = runtime.activity.revision;
1078
1076
  onDispatch?.();
1079
1077
  const messageId = await measureOperationStage("session-send", () => session.send({
1080
1078
  prompt,
@@ -1082,7 +1080,7 @@ var SessionConnections = class {
1082
1080
  ...displayPrompt === void 0 ? {} : { displayPrompt },
1083
1081
  ...sdkAttachments.length === 0 ? {} : { attachments: sdkAttachments }
1084
1082
  }));
1085
- if (!wasBusy) {
1083
+ if (!wasBusy && !runtime.activity.busy && runtime.activity.revision === activityRevision && runtime.connection.generation === generation) {
1086
1084
  runtime.activity.busy = true;
1087
1085
  this.ports.activity?.(
1088
1086
  sessionId,
@@ -1110,7 +1108,7 @@ var SessionConnections = class {
1110
1108
  }
1111
1109
  }
1112
1110
  canRefreshSessionConnection(sessionId) {
1113
- if (this.ports.allowsPassiveResume?.() === false) return false;
1111
+ if (this.ports.canRefreshSession?.(sessionId) === false) return false;
1114
1112
  const runtime = this.#sessionRuntimes.peek(sessionId);
1115
1113
  return runtime?.activity.activeRootTurn !== true && runtime?.activity.busy !== true && (runtime?.connection.sendInProgressCount ?? 0) === 0;
1116
1114
  }
@@ -1537,7 +1535,7 @@ var PlanSnapshots = class {
1537
1535
  return [{
1538
1536
  id,
1539
1537
  title: title.slice(0, 1024),
1540
- ...row.description === void 0 ? {} : { description: row.description.slice(0, 4096) },
1538
+ ...row.description == null ? {} : { description: row.description.slice(0, 4096) },
1541
1539
  status: (row.status?.trim() || "pending").slice(0, 64),
1542
1540
  dependsOn: (dependencies.get(id) ?? []).filter(
1543
1541
  (dependsOn) => dependsOn.length > 0 && dependsOn.length <= 256
@@ -1667,7 +1665,7 @@ var PlanSnapshots = class {
1667
1665
  {
1668
1666
  id,
1669
1667
  title: title.slice(0, 1024),
1670
- ...row.description === void 0 ? {} : { description: row.description.slice(0, 4096) },
1668
+ ...row.description == null ? {} : { description: row.description.slice(0, 4096) },
1671
1669
  status: (row.status?.trim() || "pending").slice(0, 64),
1672
1670
  dependsOn: (dependencies.get(id) ?? []).filter(
1673
1671
  (dependsOn) => dependsOn.length > 0 && dependsOn.length <= 256
@@ -1722,6 +1720,7 @@ var EnvelopeSchema = z2.object({
1722
1720
  });
1723
1721
  var HumanSchema = z2.object({
1724
1722
  content: z2.string(),
1723
+ messageId: z2.string().optional(),
1725
1724
  interactionId: z2.string().optional(),
1726
1725
  source: z2.string().optional(),
1727
1726
  isAutopilotContinuation: z2.boolean().optional()
@@ -1791,6 +1790,7 @@ function metadataEvent(value, preview = false) {
1791
1790
  if (data.isAutopilotContinuation === true) return void 0;
1792
1791
  return { ...base, type: "user.message", data: {
1793
1792
  content: data.content,
1793
+ ...data.messageId === void 0 ? {} : { messageId: data.messageId },
1794
1794
  ...data.interactionId === void 0 ? {} : { interactionId: data.interactionId },
1795
1795
  ...data.source === void 0 ? {} : { source: data.source }
1796
1796
  } };
@@ -3820,7 +3820,7 @@ var GithubCopilotAdapter = class {
3820
3820
  this.#mcpAuth.clear();
3821
3821
  },
3822
3822
  restoreWatched: (sessionId) => {
3823
- if (this.#sessions.peek(sessionId)?.watched && this.#schedules === void 0) {
3823
+ if (this.#sessions.peek(sessionId)?.watched) {
3824
3824
  this.#sessions.reloadSession(sessionId, { preserveTimelineState: true });
3825
3825
  }
3826
3826
  }
@@ -3908,12 +3908,7 @@ var GithubCopilotAdapter = class {
3908
3908
  isGroup: (sessionId) => this.#groups?.has(sessionId) === true,
3909
3909
  isDeleted: (sessionId) => this.#deletingSessions.has(sessionId) || this.#deletedSessions.has(sessionId),
3910
3910
  assertOriginalAction: (sessionId) => this.#assertOriginalGroupAction(sessionId),
3911
- assertCanResume: (_sessionId, explicit) => {
3912
- if (this.#schedules !== void 0 && !explicit) {
3913
- throw new SessionOperationError("SCHEDULE_NEEDS_RESUME", "Continue the session before activating its native runtime");
3914
- }
3915
- },
3916
- allowsPassiveResume: () => this.#schedules === void 0,
3911
+ canRefreshSession: (sessionId) => this.#schedules?.hasPlans(sessionId) !== true,
3917
3912
  owned: (sessionId) => {
3918
3913
  this.#upgradeSessionIds.add(sessionId);
3919
3914
  this.#upgradeRevision += 1;
@@ -4966,7 +4961,6 @@ var GithubCopilotAdapter = class {
4966
4961
  if (watched) {
4967
4962
  const runtime = this.#sessions.getOrCreate(sessionId);
4968
4963
  this.#projection.watch(sessionId);
4969
- if (this.#schedules !== void 0 && this.#sessions.current(sessionId) === void 0) return;
4970
4964
  try {
4971
4965
  await this.#sessions.readWithRecovery(
4972
4966
  sessionId,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  AgentSelectionSchema,
3
3
  assertSelectionSnapshotFits
4
- } from "./chunk-C7XDS2KG.js";
4
+ } from "./chunk-U2HBI4SH.js";
5
5
  import {
6
6
  isResearchSessionId
7
- } from "./chunk-AHJSR7OY.js";
7
+ } from "./chunk-DSHLLGE2.js";
8
8
  import {
9
9
  GroupChatError
10
- } from "./chunk-ATMWDEPF.js";
10
+ } from "./chunk-VXZ25DKC.js";
11
11
  import {
12
12
  AgentModelListingError,
13
13
  AgentSessionRenameError,
@@ -15,11 +15,11 @@ import {
15
15
  UnsupportedAgentOperationError,
16
16
  captureWorkbenchAccess,
17
17
  validateSessionName
18
- } from "./chunk-SJHJER3B.js";
18
+ } from "./chunk-UJZPAP64.js";
19
19
  import {
20
20
  InteractionResponseSchema,
21
21
  SessionSummarySchema
22
- } from "./chunk-ZKAN2FO7.js";
22
+ } from "./chunk-N2LIXMIM.js";
23
23
 
24
24
  // src/managed-agent-adapter.ts
25
25
  import { createHash, randomUUID } from "node:crypto";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  latestPreviewItems
3
- } from "./chunk-MVUOCZFL.js";
3
+ } from "./chunk-QLGX7333.js";
4
4
  import {
5
5
  AgentSessionRenameError,
6
6
  UnsupportedAgentOperationError,
7
7
  validateSessionName
8
- } from "./chunk-SJHJER3B.js";
8
+ } from "./chunk-UJZPAP64.js";
9
9
  import {
10
10
  InteractionRequestSchema,
11
11
  REASONING_EFFORTS,
12
12
  SESSION_TIMELINE_PAGE_SIZE
13
- } from "./chunk-ZKAN2FO7.js";
13
+ } from "./chunk-N2LIXMIM.js";
14
14
 
15
15
  // src/pi-adapter.ts
16
16
  import { createHash as createHash2, randomUUID } from "node:crypto";
package/dist/index.js CHANGED
@@ -4,12 +4,12 @@ import {
4
4
  PeerChatRequestSchema,
5
5
  PeerChatResultSchema,
6
6
  validateDataDirectory
7
- } from "./chunks/chunk-W3PG2W3C.js";
7
+ } from "./chunks/chunk-IXV2BIUR.js";
8
8
  import {
9
9
  AgentSelectionSchema,
10
10
  assertSelectionSnapshotFits,
11
11
  supportsAgentSelection
12
- } from "./chunks/chunk-C7XDS2KG.js";
12
+ } from "./chunks/chunk-U2HBI4SH.js";
13
13
  import {
14
14
  ConversationNormalizer,
15
15
  LiveTimelineProjection,
@@ -30,16 +30,16 @@ import {
30
30
  resolveGitProjectIdentity,
31
31
  sessionRestoreFailure,
32
32
  validateOperationResponse
33
- } from "./chunks/chunk-JFHUAIRY.js";
33
+ } from "./chunks/chunk-7JRY2FRZ.js";
34
34
  import {
35
35
  GROUP_CHAT_MAX_TURNS,
36
36
  GroupChatError
37
- } from "./chunks/chunk-ATMWDEPF.js";
37
+ } from "./chunks/chunk-VXZ25DKC.js";
38
38
  import {
39
39
  assistantPreview,
40
40
  isContentfulAssistant,
41
41
  userPreview
42
- } from "./chunks/chunk-MVUOCZFL.js";
42
+ } from "./chunks/chunk-QLGX7333.js";
43
43
  import {
44
44
  AgentModelListingError,
45
45
  AgentSessionRenameError,
@@ -48,7 +48,7 @@ import {
48
48
  UnsupportedAgentOperationError,
49
49
  captureResearchAccess,
50
50
  captureWorkbenchAccess
51
- } from "./chunks/chunk-SJHJER3B.js";
51
+ } from "./chunks/chunk-UJZPAP64.js";
52
52
  import {
53
53
  A2aRelayRequestSchema,
54
54
  A2aRelayResponseSchema,
@@ -109,6 +109,7 @@ import {
109
109
  SESSION_FILE_READ_OPERATION,
110
110
  SESSION_FILE_READ_VERSION,
111
111
  SESSION_LIST_UPDATES_CAPABILITY,
112
+ SESSION_OPTIONS_PARTIAL_CAPABILITY,
112
113
  SESSION_PROJECT_IDENTITY_OPERATION,
113
114
  SESSION_PROJECT_IDENTITY_VERSION,
114
115
  SESSION_PROMPT_SUBMISSION_TIME_CAPABILITY,
@@ -196,7 +197,7 @@ import {
196
197
  sessionCommunicationError,
197
198
  sessionCommunicationOperationCapability,
198
199
  workbenchCapability
199
- } from "./chunks/chunk-ZKAN2FO7.js";
200
+ } from "./chunks/chunk-N2LIXMIM.js";
200
201
 
201
202
  // src/initialize.ts
202
203
  import { createHash as createHash13 } from "node:crypto";
@@ -274,7 +275,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
274
275
  switch (engine.kind) {
275
276
  case "managed": {
276
277
  if (owner === void 0) throw new Error("Managed coding agents require the PC owner identity");
277
- const { ManagedCodingAgentAdapter } = await import("./chunks/managed-agent-adapter-HP5VE3AH.js");
278
+ const { ManagedCodingAgentAdapter } = await import("./chunks/managed-agent-adapter-4W4HC67T.js");
278
279
  return new ManagedCodingAgentAdapter({
279
280
  dataDirectory: config.dataDirectory,
280
281
  owner,
@@ -313,7 +314,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
313
314
  });
314
315
  }
315
316
  case "copilot": {
316
- const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-CLIDIK2S.js");
317
+ const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-KM6RMGFR.js");
317
318
  if (owner !== void 0) {
318
319
  return new GithubCopilotAdapter(void 0, void 0, void 0, {
319
320
  dataDirectory: config.dataDirectory,
@@ -333,13 +334,13 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
333
334
  }
334
335
  case "pi": {
335
336
  assertPiRuntimeSupported();
336
- const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-GSDVA7EG.js");
337
+ const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-IFNN3F4N.js");
337
338
  return new PiCodingAgentAdapter(
338
339
  engine.agentDirectory === void 0 ? {} : { agentDirectory: resolve(engine.agentDirectory) }
339
340
  );
340
341
  }
341
342
  case "acp": {
342
- const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-4N2QCTAL.js");
343
+ const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-QK4MVTNN.js");
343
344
  return new AcpCodingAgentAdapter({
344
345
  command: engine.command,
345
346
  args: engine.args,
@@ -3105,6 +3106,7 @@ var SessionOptionsHandler = class {
3105
3106
  this.#planErrors = new RepeatedErrorDiagnostics(options.logger, "copilot.session.plan.unavailable");
3106
3107
  this.#modelErrors = new RepeatedErrorDiagnostics(options.logger, "agent.models.refresh.failed");
3107
3108
  this.#partialModelErrors = new RepeatedErrorDiagnostics(options.logger, "agent.models.refresh.partial");
3109
+ this.#capabilityErrors = new RepeatedErrorDiagnostics(options.logger, "agent.session.capabilities.unavailable");
3108
3110
  }
3109
3111
  options;
3110
3112
  #errors;
@@ -3112,10 +3114,14 @@ var SessionOptionsHandler = class {
3112
3114
  #planErrors;
3113
3115
  #modelErrors;
3114
3116
  #partialModelErrors;
3117
+ #capabilityErrors;
3115
3118
  async handle(request, scope) {
3116
3119
  const { adapter, config, machineId, logger, emit } = this.options;
3117
3120
  const diagnostics = new OperationDiagnostics();
3118
3121
  const errorKey = JSON.stringify([request.machineId, request.sessionId, request.workspaceId]);
3122
+ let availableModels;
3123
+ let configuration;
3124
+ let failureStage;
3119
3125
  try {
3120
3126
  if (scope.clientId !== void 0 && request.capabilities !== void 0) {
3121
3127
  this.options.negotiateAgentControls(scope.clientId, request.capabilities);
@@ -3159,7 +3165,7 @@ var SessionOptionsHandler = class {
3159
3165
  });
3160
3166
  return void 0;
3161
3167
  });
3162
- const [workspaces, models, current, environment] = await diagnostics.run(() => Promise.all([
3168
+ const [workspaceResult, modelResult, configurationResult] = await diagnostics.run(() => Promise.allSettled([
3163
3169
  sessionWorkingDirectories.then((workingDirectories) => listSelectableWorkspaces(workingDirectories, config.workspaceRoot)),
3164
3170
  adapter.listModels(request.sessionId).then((models2) => {
3165
3171
  if (models2.length > 0) {
@@ -3170,17 +3176,45 @@ var SessionOptionsHandler = class {
3170
3176
  }).catch((error) => {
3171
3177
  if (isSessionRestoreFailure(error)) throw error;
3172
3178
  modelRefreshError = toErrorDetails(error).message.slice(0, 4096) || "Coding-agent models are unavailable.";
3173
- const availableModels = error instanceof AgentModelListingError ? error.availableModels : [];
3174
- if (availableModels.length === 0) modelFailure = error;
3175
- (availableModels.length === 0 ? this.#modelErrors : this.#partialModelErrors).failure(errorKey, error, diagnosticRequest(request));
3176
- return availableModels;
3179
+ const availableModels2 = error instanceof AgentModelListingError ? error.availableModels : [];
3180
+ if (availableModels2.length === 0) modelFailure = error;
3181
+ (availableModels2.length === 0 ? this.#modelErrors : this.#partialModelErrors).failure(errorKey, error, diagnosticRequest(request));
3182
+ return availableModels2;
3177
3183
  }),
3178
- request.sessionId === void 0 ? Promise.resolve(void 0) : adapter.getSessionConfiguration(request.sessionId),
3179
- sessionEnvironment
3184
+ request.sessionId === void 0 ? Promise.resolve(void 0) : adapter.getSessionConfiguration(request.sessionId)
3180
3185
  ]));
3186
+ if (modelResult.status === "fulfilled" && modelResult.value.length > 0) availableModels = modelResult.value;
3187
+ if (configurationResult.status === "fulfilled") configuration = configurationResult.value;
3188
+ for (const [stage, result] of [
3189
+ ["configuration", configurationResult],
3190
+ ["models", modelResult],
3191
+ ["workspaces", workspaceResult]
3192
+ ]) {
3193
+ if (result.status === "rejected" && isSessionRestoreFailure(result.reason)) {
3194
+ failureStage = stage;
3195
+ throw result.reason;
3196
+ }
3197
+ }
3198
+ if (configurationResult.status === "rejected") {
3199
+ failureStage = "configuration";
3200
+ throw configurationResult.reason;
3201
+ }
3202
+ if (modelResult.status === "rejected") {
3203
+ failureStage = "models";
3204
+ throw modelResult.reason;
3205
+ }
3206
+ if (workspaceResult.status === "rejected") {
3207
+ failureStage = "workspaces";
3208
+ throw workspaceResult.reason;
3209
+ }
3210
+ const workspaces = workspaceResult.value;
3211
+ const models = modelResult.value;
3212
+ const current = configurationResult.value;
3181
3213
  if (models.length === 0) {
3214
+ failureStage = "models";
3182
3215
  throw modelFailure ?? new Error("No coding-agent models are available. Select an authenticated coding agent on the PC.");
3183
3216
  }
3217
+ const environment = await sessionEnvironment;
3184
3218
  const worktreeCreationSupported = request.sessionId === void 0 && request.capabilities?.includes(SESSION_WORKTREE_CREATION_CAPABILITY) === true;
3185
3219
  let worktreeChoices;
3186
3220
  if (worktreeCreationSupported && request.workspaceId !== void 0) {
@@ -3222,9 +3256,37 @@ var SessionOptionsHandler = class {
3222
3256
  } catch (error) {
3223
3257
  this.#errors.failure(errorKey, error, {
3224
3258
  ...diagnosticRequest(request),
3225
- ...diagnostics.details()
3259
+ ...diagnostics.details(),
3260
+ failureStage
3226
3261
  });
3262
+ const partial = {};
3263
+ const negotiatedPartial = request.capabilities?.includes(SESSION_OPTIONS_PARTIAL_CAPABILITY) === true;
3264
+ if (negotiatedPartial && failureStage !== void 0) partial.failureStage = failureStage;
3265
+ if (request.sessionId !== void 0 && !isSessionRestoreFailure(error)) {
3266
+ try {
3267
+ const capabilities = adapter.getSessionCapabilities?.(request.sessionId) ?? adapter;
3268
+ this.#capabilityErrors.recovered(errorKey);
3269
+ if (request.capabilities?.includes(SESSION_FILE_ATTACHMENTS_CAPABILITY) === true) {
3270
+ partial.fileAttachmentsSupported = (capabilities.supportsFileAttachments ?? adapter.supportsFileAttachments) === true;
3271
+ }
3272
+ if (negotiatedPartial) {
3273
+ if (availableModels !== void 0) partial.models = availableModels;
3274
+ if (configuration !== void 0) {
3275
+ partial.agentModes = [...capabilities.agentModes];
3276
+ if (capabilities.supportsReasoningEffort) partial.reasoningEffortConfigurationSupported = true;
3277
+ if (configuration.modelId !== void 0) partial.currentModelId = configuration.modelId;
3278
+ partial.currentAgentMode = configuration.agentMode;
3279
+ partial.currentReasoningEffort = configuration.reasoningEffort;
3280
+ if (configuration.configOptions !== void 0) partial.configOptions = configuration.configOptions;
3281
+ partial.agentName = "agentName" in capabilities && typeof capabilities.agentName === "string" ? capabilities.agentName : codingAgentPresentation(adapter.agentId).name;
3282
+ }
3283
+ }
3284
+ } catch (capabilityError) {
3285
+ this.#capabilityErrors.failure(errorKey, capabilityError, diagnosticRequest(request));
3286
+ }
3287
+ }
3227
3288
  emit("session.options.result", {
3289
+ ...partial,
3228
3290
  ok: false,
3229
3291
  requestId: request.requestId,
3230
3292
  machineId,
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-W3PG2W3C.js";
7
- import "./chunks/chunk-ZKAN2FO7.js";
6
+ } from "./chunks/chunk-IXV2BIUR.js";
7
+ import "./chunks/chunk-N2LIXMIM.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.35",
3
+ "version": "0.9.37",
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/protocol": "0.1.0",
53
- "@agentknight/shared": "0.1.0"
52
+ "@agentknight/shared": "0.1.0",
53
+ "@agentknight/protocol": "0.1.0"
54
54
  },
55
55
  "optionalDependencies": {
56
56
  "@earendil-works/pi-ai": "0.85.1",