@agentknight/sdk 0.9.41 → 0.9.43

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.
@@ -18,25 +18,25 @@ import {
18
18
  recordTimelineSyncDiagnostic,
19
19
  resolveGitProjectIdentity,
20
20
  sanitizeGitRemoteUrl
21
- } from "./chunk-SHOE7YAU.js";
21
+ } from "./chunk-CWJENQ3O.js";
22
22
  import {
23
23
  assertMainSessionId,
24
24
  isResearchSessionId
25
- } from "./chunk-J52FWJU4.js";
25
+ } from "./chunk-NYSZHHBS.js";
26
26
  import {
27
27
  GroupChatError,
28
28
  GroupChatMessageSchema,
29
29
  GroupChatRuntime
30
- } from "./chunk-VDC4G7ZG.js";
30
+ } from "./chunk-C2VUD77E.js";
31
31
  import {
32
32
  isContentfulAssistant
33
- } from "./chunk-RBULXS7T.js";
33
+ } from "./chunk-DB3EAMYS.js";
34
34
  import {
35
35
  AgentSessionRenameError,
36
36
  SessionOperationError,
37
37
  TimelinePageBudgetError,
38
38
  validateSessionName
39
- } from "./chunk-LQIW4ARE.js";
39
+ } from "./chunk-ULM5KUJ7.js";
40
40
  import {
41
41
  ConversationItemSchema,
42
42
  CopilotModelOptionSchema,
@@ -57,7 +57,7 @@ import {
57
57
  WorkbenchScheduleEntrySchema,
58
58
  WorkbenchScheduleProposalSchema,
59
59
  WorkbenchScheduleSnapshotSchema
60
- } from "./chunk-QTBB2U7G.js";
60
+ } from "./chunk-7QOBDG6R.js";
61
61
 
62
62
  // src/copilot-adapter.ts
63
63
  import { createHash as createHash4, randomUUID as randomUUID6 } from "node:crypto";
@@ -547,11 +547,14 @@ var SessionConfiguration = class {
547
547
  }
548
548
  forget(sessionId) {
549
549
  this.#sessionReasoningEfforts.delete(sessionId);
550
+ this.#pendingModels.delete(sessionId);
550
551
  }
551
552
  clear() {
552
553
  this.#sessionReasoningEfforts.clear();
554
+ this.#pendingModels.clear();
553
555
  }
554
556
  #sessionReasoningEfforts = /* @__PURE__ */ new Map();
557
+ #pendingModels = /* @__PURE__ */ new Map();
555
558
  async serializeSessionConfiguration(sessionId, operation) {
556
559
  const runtime = this.ports.state(sessionId);
557
560
  const previous = runtime.configuration.transition;
@@ -578,15 +581,21 @@ var SessionConfiguration = class {
578
581
  if (agentMode === "autopilot") {
579
582
  await this.ensureAutopilotPermissions(session);
580
583
  }
584
+ const pending = this.#pendingModels.get(sessionId);
585
+ if (pending !== void 0 && model.modelId === pending.modelId && (pending.reasoningEffort === "default" && model.modelId !== pending.previousModelId || model.reasoningEffort === pending.reasoningEffort || pending.reasoningEffort === "default" && model.reasoningEffort !== pending.previousEffort)) {
586
+ this.#pendingModels.delete(sessionId);
587
+ }
588
+ const selected = this.#pendingModels.get(sessionId);
589
+ const selectedModelId = selected?.modelId ?? model.modelId;
581
590
  const reasoningEffort = model.reasoningEffort === void 0 ? this.#sessionReasoningEfforts.get(sessionId) ?? "default" : CurrentReasoningEffortSchema.parse(model.reasoningEffort);
582
591
  const configurableEffort = SessionReasoningEffortSchema.safeParse(reasoningEffort);
583
592
  if (configurableEffort.success) {
584
593
  this.#sessionReasoningEfforts.set(sessionId, configurableEffort.data);
585
594
  }
586
595
  return {
587
- ...model.modelId === void 0 ? {} : { modelId: model.modelId },
596
+ ...selectedModelId === void 0 ? {} : { modelId: selectedModelId },
588
597
  agentMode,
589
- reasoningEffort
598
+ reasoningEffort: selected?.reasoningEffort ?? reasoningEffort
590
599
  };
591
600
  }
592
601
  async setAgentMode(session, mode) {
@@ -671,32 +680,37 @@ var SessionConfiguration = class {
671
680
  this.ports.assertOriginalAction(sessionId);
672
681
  if (options.modelId !== void 0 || options.reasoningEffort !== void 0) {
673
682
  const currentModel = await session.rpc.model.getCurrent();
674
- const modelId = options.modelId ?? currentModel.modelId;
683
+ const pending = this.#pendingModels.get(sessionId);
684
+ const modelId = options.modelId ?? pending?.modelId ?? currentModel.modelId;
675
685
  if (modelId === void 0) {
676
686
  throw new Error(
677
687
  "Copilot did not report the current model for reasoning effort configuration"
678
688
  );
679
689
  }
680
690
  const currentReasoningEffort = currentModel.reasoningEffort ?? this.#sessionReasoningEfforts.get(sessionId) ?? "default";
681
- const reasoningEffort = options.reasoningEffort ?? (modelId === currentModel.modelId ? currentReasoningEffort : "default");
682
- if (modelId !== currentModel.modelId || reasoningEffort !== currentReasoningEffort) {
683
- if ((await session.rpc.metadata?.isProcessing?.())?.processing) {
684
- throw new Error("Copilot session is busy; wait before changing its model");
685
- }
691
+ const reasoningEffort = options.reasoningEffort ?? (modelId === pending?.modelId ? pending.reasoningEffort : modelId === currentModel.modelId ? currentReasoningEffort : "default");
692
+ if (!(pending?.modelId === modelId && pending.reasoningEffort === reasoningEffort) && (modelId !== currentModel.modelId || reasoningEffort !== currentReasoningEffort || pending !== void 0)) {
686
693
  const result = await session.rpc.model.switchTo({
687
694
  modelId,
688
695
  ...reasoningEffort === "default" ? {} : { reasoningEffort },
689
696
  deferIfModelChangeQueued: true
690
697
  });
691
- if (result.deferred) {
692
- throw new Error("Copilot queued the model change; it has not been applied yet");
693
- }
694
- if (result.modelId !== modelId) {
698
+ if (!result.deferred && result.modelId !== modelId) {
695
699
  throw new Error(`Copilot did not apply the requested model: ${modelId}`);
696
700
  }
697
- const parsedEffort = SessionReasoningEffortSchema.safeParse(reasoningEffort);
698
- if (parsedEffort.success) {
699
- this.#sessionReasoningEfforts.set(sessionId, parsedEffort.data);
701
+ if (result.deferred) {
702
+ this.#pendingModels.set(sessionId, {
703
+ modelId,
704
+ reasoningEffort,
705
+ previousModelId: currentModel.modelId,
706
+ previousEffort: currentReasoningEffort
707
+ });
708
+ } else {
709
+ this.#pendingModels.delete(sessionId);
710
+ const parsedEffort = SessionReasoningEffortSchema.safeParse(reasoningEffort);
711
+ if (parsedEffort.success) {
712
+ this.#sessionReasoningEfforts.set(sessionId, parsedEffort.data);
713
+ }
700
714
  }
701
715
  }
702
716
  }
@@ -2767,10 +2781,10 @@ function permissionSessionApproval(request) {
2767
2781
  }
2768
2782
  };
2769
2783
  }
2770
- if (request.kind === "factory" && request.canPersistApproval && request.approvalKey.trim()) {
2784
+ if (request.kind === "workflow" && request.canPersistApproval && request.approvalKey.trim()) {
2771
2785
  return {
2772
2786
  kind: "approve-for-session",
2773
- approval: { kind: "factory", approvalKey: request.approvalKey }
2787
+ approval: { kind: "workflow", approvalKey: request.approvalKey }
2774
2788
  };
2775
2789
  }
2776
2790
  if (request.kind === "url" && URL.canParse(request.url)) {
@@ -3543,7 +3557,7 @@ var McpAuthCoordinator = class {
3543
3557
  const staticConfig = event.data.staticClientConfig;
3544
3558
  const result = await oauth.login({
3545
3559
  serverName,
3546
- clientName: "BluePaw",
3560
+ clientName: "AgentKnight",
3547
3561
  ...event.data.reason === "reauth" || event.data.reason === "upscope" ? { forceReauth: true } : {},
3548
3562
  ...staticConfig?.clientId === void 0 ? {} : { clientId: staticConfig.clientId },
3549
3563
  ...staticConfig?.clientSecret === void 0 ? {} : { clientSecret: staticConfig.clientSecret },
@@ -1,32 +1,34 @@
1
1
  import {
2
2
  AgentSelectionSchema,
3
3
  assertSelectionSnapshotFits
4
- } from "./chunk-ASHXZ46V.js";
4
+ } from "./chunk-YZ2GB3DD.js";
5
5
  import {
6
6
  isResearchSessionId
7
- } from "./chunk-J52FWJU4.js";
7
+ } from "./chunk-NYSZHHBS.js";
8
8
  import {
9
9
  GroupChatError
10
- } from "./chunk-VDC4G7ZG.js";
10
+ } from "./chunk-C2VUD77E.js";
11
11
  import {
12
12
  AgentModelListingError,
13
13
  AgentSessionRenameError,
14
+ CODING_AGENT_IDS,
14
15
  SessionOperationError,
15
16
  UnsupportedAgentOperationError,
16
17
  captureWorkbenchAccess,
17
18
  validateSessionName
18
- } from "./chunk-LQIW4ARE.js";
19
+ } from "./chunk-ULM5KUJ7.js";
19
20
  import {
20
21
  InteractionResponseSchema,
21
22
  SessionSummarySchema
22
- } from "./chunk-QTBB2U7G.js";
23
+ } from "./chunk-7QOBDG6R.js";
23
24
 
24
25
  // src/managed-agent-adapter.ts
25
26
  import { createHash, randomUUID } from "node:crypto";
26
27
  import { mkdir, open, readFile, rename, rm } from "node:fs/promises";
27
28
  import { join } from "node:path";
28
29
  import { z } from "zod";
29
- var ManagedSessionIdSchema = z.string().regex(/^managed:(copilot|pi|acp):session:[a-f0-9]{64}$/);
30
+ var managedSessionIdPattern = new RegExp(`^managed:(${CODING_AGENT_IDS.join("|")}):session:[a-f0-9]{64}$`);
31
+ var ManagedSessionIdSchema = z.string().regex(managedSessionIdPattern);
30
32
  var StoredSelectionSchema = AgentSelectionSchema.extend({ version: z.literal(1) });
31
33
  var LegacySelectionSchema = AgentSelectionSchema.extend({
32
34
  sessionIds: z.array(ManagedSessionIdSchema).max(2e3).refine((ids) => new Set(ids).size === ids.length, "Duplicate managed session selection")
@@ -108,7 +110,7 @@ var ManagedCodingAgentAdapter = class {
108
110
  this.#localOwner = SessionSummarySchema.pick({ userId: true, machineId: true }).parse(options.owner);
109
111
  const ids = /* @__PURE__ */ new Set();
110
112
  this.#providers = options.candidates.map((candidate) => {
111
- if (!["copilot", "pi", "acp"].includes(candidate.id) || ids.has(candidate.id)) {
113
+ if (!CODING_AGENT_IDS.includes(candidate.id) || ids.has(candidate.id)) {
112
114
  throw new Error(`Invalid or duplicate managed agent: ${candidate.id}`);
113
115
  }
114
116
  ids.add(candidate.id);
@@ -833,7 +835,7 @@ var ManagedCodingAgentAdapter = class {
833
835
  return join(this.#directory, "managed-session-deletions.json");
834
836
  }
835
837
  #owner(id) {
836
- const match = /^managed:(copilot|pi|acp):session:[a-f0-9]{64}$/.exec(id);
838
+ const match = managedSessionIdPattern.exec(id);
837
839
  return match ? this.#providers.find((provider) => provider.candidate.id === match[1]) : void 0;
838
840
  }
839
841
  #validateSelection(input) {
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  latestPreviewItems
3
- } from "./chunk-RBULXS7T.js";
3
+ } from "./chunk-DB3EAMYS.js";
4
4
  import {
5
5
  AgentSessionRenameError,
6
6
  UnsupportedAgentOperationError,
7
7
  validateSessionName
8
- } from "./chunk-LQIW4ARE.js";
8
+ } from "./chunk-ULM5KUJ7.js";
9
9
  import {
10
10
  InteractionRequestSchema,
11
11
  REASONING_EFFORTS,
12
12
  SESSION_TIMELINE_PAGE_SIZE
13
- } from "./chunk-QTBB2U7G.js";
13
+ } from "./chunk-7QOBDG6R.js";
14
14
 
15
15
  // src/pi-adapter.ts
16
16
  import { createHash as createHash2, randomUUID } from "node:crypto";