@github/copilot-language-server 1.560.0 → 1.562.0
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/main.js +1020 -973
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/cliVersion.js +1 -1
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/client.js +165 -23
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/copilotRequestHandler.js +17 -9
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/ffiRuntimeHost.js +24 -0
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/generated/rpc.js +1063 -258
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/host.js +17 -1
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/session.js +219 -29
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/types.js +2 -2
- package/dist/node_modules/@github/copilot-sdk/package.json +28 -18
- package/package.json +20 -20
|
@@ -23,10 +23,12 @@ __export(host_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(host_exports);
|
|
24
24
|
class AhpHost {
|
|
25
25
|
/** @internal */
|
|
26
|
-
constructor(info, disposeHost, publishHostSession, listHostSessions) {
|
|
26
|
+
constructor(info, disposeHost, publishHostSession, listHostSessions, unpublishHostSession, updateCreationPolicy) {
|
|
27
27
|
this.disposeHost = disposeHost;
|
|
28
28
|
this.publishHostSession = publishHostSession;
|
|
29
29
|
this.listHostSessions = listHostSessions;
|
|
30
|
+
this.unpublishHostSession = unpublishHostSession;
|
|
31
|
+
this.updateCreationPolicy = updateCreationPolicy;
|
|
30
32
|
this.hostId = info.hostId;
|
|
31
33
|
this.url = info.url;
|
|
32
34
|
this.environmentId = info.environmentId;
|
|
@@ -36,6 +38,8 @@ class AhpHost {
|
|
|
36
38
|
disposeHost;
|
|
37
39
|
publishHostSession;
|
|
38
40
|
listHostSessions;
|
|
41
|
+
unpublishHostSession;
|
|
42
|
+
updateCreationPolicy;
|
|
39
43
|
hostId;
|
|
40
44
|
/** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
|
|
41
45
|
url;
|
|
@@ -49,10 +53,22 @@ class AhpHost {
|
|
|
49
53
|
dispose() {
|
|
50
54
|
return this.disposeHost();
|
|
51
55
|
}
|
|
56
|
+
/** Change subsequent remote admissions without disconnecting clients; admitted creation may finish. */
|
|
57
|
+
setAllowCreatingNewSessions(allowed) {
|
|
58
|
+
return this.updateCreationPolicy(allowed);
|
|
59
|
+
}
|
|
52
60
|
/** Publish an attached application session into the durable compute-scoped host catalog. */
|
|
53
61
|
publishSession(sessionId) {
|
|
54
62
|
return this.publishHostSession(sessionId);
|
|
55
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Withdraw a live or dormant application publication and revoke AHP attachments.
|
|
66
|
+
* Preserves local history, worktrees and ongoing work; returns false when already absent.
|
|
67
|
+
* Rejects nonapplication publications. Does not stop the host.
|
|
68
|
+
*/
|
|
69
|
+
unpublishSession(sessionId) {
|
|
70
|
+
return this.unpublishHostSession(sessionId);
|
|
71
|
+
}
|
|
56
72
|
/** List all live and dormant catalog sessions advertised by this host. */
|
|
57
73
|
listSessions() {
|
|
58
74
|
return this.listHostSessions();
|
|
@@ -47,7 +47,8 @@ function toToolDefinition(tool) {
|
|
|
47
47
|
skipPermission: tool.skipPermission,
|
|
48
48
|
defer: tool.defer,
|
|
49
49
|
metadata: tool.metadata,
|
|
50
|
-
isTerminal: tool.isTerminal
|
|
50
|
+
isTerminal: tool.isTerminal,
|
|
51
|
+
namespace: tool.namespace
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
const workflowExecutionStore = new import_node_async_hooks.AsyncLocalStorage();
|
|
@@ -75,6 +76,20 @@ function deserializeHookInput(raw) {
|
|
|
75
76
|
...stop_hook_active === void 0 ? {} : { stopHookActive: stop_hook_active }
|
|
76
77
|
};
|
|
77
78
|
}
|
|
79
|
+
function normalizeHookError(hookType, input) {
|
|
80
|
+
if (hookType !== "errorOccurred" && hookType !== "sessionEnd") {
|
|
81
|
+
return input;
|
|
82
|
+
}
|
|
83
|
+
if (!input || typeof input !== "object" || !("error" in input)) {
|
|
84
|
+
return input;
|
|
85
|
+
}
|
|
86
|
+
const { error } = input;
|
|
87
|
+
if (!error || typeof error !== "object" || Array.isArray(error)) {
|
|
88
|
+
return input;
|
|
89
|
+
}
|
|
90
|
+
const { message } = error;
|
|
91
|
+
return { ...input, error: typeof message === "string" ? message : JSON.stringify(error) };
|
|
92
|
+
}
|
|
78
93
|
function isOpenCanvasInstance(value) {
|
|
79
94
|
if (!value || typeof value !== "object") {
|
|
80
95
|
return false;
|
|
@@ -296,6 +311,7 @@ class CopilotSession {
|
|
|
296
311
|
disconnected = false;
|
|
297
312
|
pendingResponseWaits = /* @__PURE__ */ new Set();
|
|
298
313
|
pendingStructuredWaits = /* @__PURE__ */ new Set();
|
|
314
|
+
completionRpcUnsupported = false;
|
|
299
315
|
disconnecting = false;
|
|
300
316
|
onDisconnected;
|
|
301
317
|
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
@@ -497,9 +513,22 @@ class CopilotSession {
|
|
|
497
513
|
}
|
|
498
514
|
async send(optionsOrPrompt) {
|
|
499
515
|
const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
|
|
516
|
+
return this.sendMessage(options);
|
|
517
|
+
}
|
|
518
|
+
async sendMessage(options, cancelled) {
|
|
519
|
+
const message = await this.createSendParams(options);
|
|
520
|
+
if (cancelled?.()) {
|
|
521
|
+
throw new Error("Completion wait cancelled");
|
|
522
|
+
}
|
|
500
523
|
const response = await this.connection.sendRequest("session.send", {
|
|
501
|
-
...await (0, import_telemetry.getTraceContext)(this.traceContextProvider),
|
|
502
524
|
sessionId: this.sessionId,
|
|
525
|
+
...message
|
|
526
|
+
});
|
|
527
|
+
return response.messageId;
|
|
528
|
+
}
|
|
529
|
+
async createSendParams(options) {
|
|
530
|
+
return {
|
|
531
|
+
...await (0, import_telemetry.getTraceContext)(this.traceContextProvider),
|
|
503
532
|
prompt: options.prompt,
|
|
504
533
|
source: options.source,
|
|
505
534
|
displayPrompt: options.displayPrompt,
|
|
@@ -517,8 +546,7 @@ class CopilotSession {
|
|
|
517
546
|
}
|
|
518
547
|
}
|
|
519
548
|
} : {}
|
|
520
|
-
}
|
|
521
|
-
return response.messageId;
|
|
549
|
+
};
|
|
522
550
|
}
|
|
523
551
|
async sendAndWait(optionsOrPrompt, schemaOrTimeout, timeout) {
|
|
524
552
|
const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
|
|
@@ -539,10 +567,39 @@ class CopilotSession {
|
|
|
539
567
|
"Structured output cannot be requested on an immediate steering message."
|
|
540
568
|
);
|
|
541
569
|
}
|
|
570
|
+
const startedAt = Date.now();
|
|
571
|
+
const completion = await this.sendWithCompletion(
|
|
572
|
+
typedSchema ? { ...options, responseSchema: typedSchema } : options,
|
|
573
|
+
effectiveTimeout
|
|
574
|
+
);
|
|
575
|
+
if (completion !== void 0) {
|
|
576
|
+
const message = completion.response;
|
|
577
|
+
if (message !== void 0 && (message.type !== "assistant.message" || message.agentId)) {
|
|
578
|
+
throw new Error("The runtime returned a non-assistant response.");
|
|
579
|
+
}
|
|
580
|
+
if (typedSchema || options.responseSchema) {
|
|
581
|
+
if (completion.aborted) {
|
|
582
|
+
throw new Error(
|
|
583
|
+
"The requested run was aborted before a structured result was completed."
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
if (!message || message.data.toolRequests?.length || !message.data.content.trim()) {
|
|
587
|
+
throw new Error(
|
|
588
|
+
"The requested run completed without a structured assistant response."
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
return typedSchema ? typedSchema.parse(JSON.parse(message.data.content)) : message;
|
|
592
|
+
}
|
|
593
|
+
if (completion.aborted) {
|
|
594
|
+
throw new Error("The requested run was aborted before completion.");
|
|
595
|
+
}
|
|
596
|
+
return message;
|
|
597
|
+
}
|
|
598
|
+
const remainingTimeout = Math.max(0, effectiveTimeout - (Date.now() - startedAt));
|
|
542
599
|
if (typedSchema || options.responseSchema) {
|
|
543
600
|
const message = await this.sendAndWaitForStructuredMessage(
|
|
544
601
|
typedSchema ? { ...options, responseSchema: typedSchema } : options,
|
|
545
|
-
|
|
602
|
+
remainingTimeout
|
|
546
603
|
);
|
|
547
604
|
if (typedSchema) {
|
|
548
605
|
if (!message) {
|
|
@@ -559,46 +616,173 @@ class CopilotSession {
|
|
|
559
616
|
resolveOutcome = resolve;
|
|
560
617
|
});
|
|
561
618
|
let lastAssistantMessage;
|
|
562
|
-
|
|
619
|
+
let messageId;
|
|
620
|
+
let requestStarted = false;
|
|
621
|
+
let admitted = false;
|
|
622
|
+
const buffered = [];
|
|
623
|
+
const observe = (event) => {
|
|
563
624
|
if (event.agentId) return;
|
|
564
|
-
if (event.type === "
|
|
625
|
+
if (event.type === "user.message" && event.data.messageId === messageId) {
|
|
626
|
+
requestStarted = true;
|
|
627
|
+
} else if (event.type === "session.warning" && event.data.warningType === "policy_blocked" && event.data.originatingMessageId === messageId) {
|
|
628
|
+
requestStarted = true;
|
|
629
|
+
} else if (event.type === "assistant.message" && (event.data.originatingMessageId === messageId || !event.data.originatingMessageId && requestStarted)) {
|
|
565
630
|
lastAssistantMessage = event;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
631
|
+
if (event.data.originatingMessageId === messageId) requestStarted = true;
|
|
632
|
+
} else if (event.type === "session.idle" && requestStarted && event.data.mode !== "autopilot") {
|
|
633
|
+
resolveOutcome(
|
|
634
|
+
event.data.aborted ? {
|
|
635
|
+
kind: "error",
|
|
636
|
+
error: new Error("The requested run was aborted before completion.")
|
|
637
|
+
} : { kind: "idle", message: lastAssistantMessage }
|
|
638
|
+
);
|
|
639
|
+
} else if (event.type === "session.autopilot_stopped" && messageId && event.data.requestId === messageId) {
|
|
640
|
+
if (event.data.reason === "error") {
|
|
641
|
+
resolveOutcome({
|
|
642
|
+
kind: "error",
|
|
643
|
+
error: new Error("Autopilot request failed")
|
|
644
|
+
});
|
|
645
|
+
} else if (event.data.reason === "aborted") {
|
|
646
|
+
resolveOutcome({
|
|
647
|
+
kind: "error",
|
|
648
|
+
error: new Error("The requested run was aborted before completion.")
|
|
649
|
+
});
|
|
650
|
+
} else {
|
|
651
|
+
resolveOutcome({ kind: "idle", message: lastAssistantMessage });
|
|
652
|
+
}
|
|
653
|
+
} else if (event.type === "session.error" && (!event.data.originatingMessageId || event.data.originatingMessageId === messageId)) {
|
|
569
654
|
const error = new Error(event.data.message);
|
|
570
655
|
error.stack = event.data.stack;
|
|
571
656
|
resolveOutcome({ kind: "error", error });
|
|
572
657
|
}
|
|
658
|
+
};
|
|
659
|
+
const unsubscribe = this.on((event) => {
|
|
660
|
+
if (event.agentId || event.type !== "assistant.message" && event.type !== "user.message" && event.type !== "session.warning" && event.type !== "session.idle" && event.type !== "session.autopilot_stopped" && event.type !== "session.error") {
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
if (!admitted) buffered.push(event);
|
|
664
|
+
else observe(event);
|
|
573
665
|
});
|
|
574
|
-
const fail = (error) =>
|
|
666
|
+
const fail = (error) => {
|
|
667
|
+
if (!admitted) buffered.push(error);
|
|
668
|
+
else resolveOutcome({ kind: "error", error });
|
|
669
|
+
};
|
|
575
670
|
this.pendingResponseWaits.add(fail);
|
|
576
671
|
let timeoutId;
|
|
672
|
+
let waiting = true;
|
|
577
673
|
try {
|
|
578
|
-
await this.send(options);
|
|
579
674
|
const timeoutPromise = new Promise((_, reject) => {
|
|
580
675
|
timeoutId = setTimeout(
|
|
581
676
|
() => reject(
|
|
582
677
|
new Error(
|
|
583
|
-
`Timeout after ${effectiveTimeout}ms waiting for
|
|
678
|
+
`Timeout after ${effectiveTimeout}ms waiting for response completion`
|
|
584
679
|
)
|
|
585
680
|
),
|
|
586
|
-
|
|
681
|
+
remainingTimeout
|
|
587
682
|
);
|
|
588
683
|
});
|
|
589
|
-
const outcome = await Promise.race([
|
|
684
|
+
const outcome = await Promise.race([
|
|
685
|
+
this.sendMessage(options, () => !waiting).then((id) => {
|
|
686
|
+
messageId = id;
|
|
687
|
+
admitted = true;
|
|
688
|
+
for (const event of buffered) {
|
|
689
|
+
if (event instanceof Error) fail(event);
|
|
690
|
+
else observe(event);
|
|
691
|
+
}
|
|
692
|
+
buffered.length = 0;
|
|
693
|
+
return outcomePromise;
|
|
694
|
+
}),
|
|
695
|
+
timeoutPromise
|
|
696
|
+
]);
|
|
590
697
|
if (outcome.kind === "error") {
|
|
591
698
|
throw outcome.error;
|
|
592
699
|
}
|
|
593
|
-
return
|
|
700
|
+
return outcome.message;
|
|
594
701
|
} finally {
|
|
702
|
+
waiting = false;
|
|
595
703
|
if (timeoutId !== void 0) {
|
|
596
704
|
clearTimeout(timeoutId);
|
|
597
705
|
}
|
|
598
706
|
unsubscribe();
|
|
707
|
+
buffered.length = 0;
|
|
599
708
|
this.pendingResponseWaits.delete(fail);
|
|
600
709
|
}
|
|
601
710
|
}
|
|
711
|
+
async sendWithCompletion(options, timeout) {
|
|
712
|
+
if (this.completionRpcUnsupported) return void 0;
|
|
713
|
+
if (this.disconnected) throw new Error("Session is disconnected");
|
|
714
|
+
const cancellation = new import_node.CancellationTokenSource();
|
|
715
|
+
const dispatched = /* @__PURE__ */ new Set();
|
|
716
|
+
let completionEventId;
|
|
717
|
+
let resolveDispatched;
|
|
718
|
+
const dispatchCompleted = new Promise((resolve) => {
|
|
719
|
+
resolveDispatched = resolve;
|
|
720
|
+
});
|
|
721
|
+
const unsubscribe = this.on((event) => {
|
|
722
|
+
if (event.agentId || event.type !== "session.idle" && event.type !== "session.autopilot_stopped" && event.type !== "session.error") {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
dispatched.add(event.id);
|
|
726
|
+
if (event.id === completionEventId) resolveDispatched();
|
|
727
|
+
});
|
|
728
|
+
const drain = async (id) => {
|
|
729
|
+
if (id && !dispatched.has(id)) {
|
|
730
|
+
completionEventId = id;
|
|
731
|
+
await dispatchCompleted;
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
let fail;
|
|
735
|
+
const stopped = new Promise((_, reject) => {
|
|
736
|
+
fail = reject;
|
|
737
|
+
});
|
|
738
|
+
this.pendingResponseWaits.add(fail);
|
|
739
|
+
const timer = setTimeout(
|
|
740
|
+
() => fail(new Error(`Timeout after ${timeout}ms waiting for session.idle`)),
|
|
741
|
+
timeout
|
|
742
|
+
);
|
|
743
|
+
const operation = async () => {
|
|
744
|
+
try {
|
|
745
|
+
const message = await this.createSendParams(options);
|
|
746
|
+
if (cancellation.token.isCancellationRequested) {
|
|
747
|
+
throw new Error("Completion wait cancelled");
|
|
748
|
+
}
|
|
749
|
+
const result = await this.connection.sendRequest(
|
|
750
|
+
"session.sendAndWait",
|
|
751
|
+
{
|
|
752
|
+
sessionId: this.sessionId,
|
|
753
|
+
...message
|
|
754
|
+
},
|
|
755
|
+
cancellation.token
|
|
756
|
+
);
|
|
757
|
+
await drain(result.completionEventId);
|
|
758
|
+
return result;
|
|
759
|
+
} catch (error) {
|
|
760
|
+
if (error instanceof import_node.ResponseError && error.code === import_node.ErrorCodes.MethodNotFound) {
|
|
761
|
+
this.completionRpcUnsupported = true;
|
|
762
|
+
return void 0;
|
|
763
|
+
}
|
|
764
|
+
if (error instanceof import_node.ResponseError && typeof error.data === "object" && error.data !== null) {
|
|
765
|
+
if ("stack" in error.data && typeof error.data.stack === "string") {
|
|
766
|
+
error.stack = error.data.stack;
|
|
767
|
+
}
|
|
768
|
+
if ("completionEventId" in error.data && typeof error.data.completionEventId === "string") {
|
|
769
|
+
await drain(error.data.completionEventId);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
throw error;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
try {
|
|
776
|
+
return await Promise.race([operation(), stopped]);
|
|
777
|
+
} finally {
|
|
778
|
+
clearTimeout(timer);
|
|
779
|
+
unsubscribe();
|
|
780
|
+
this.pendingResponseWaits.delete(fail);
|
|
781
|
+
resolveDispatched();
|
|
782
|
+
cancellation.cancel();
|
|
783
|
+
cancellation.dispose();
|
|
784
|
+
}
|
|
785
|
+
}
|
|
602
786
|
async sendAndWaitForStructuredMessage(options, timeout) {
|
|
603
787
|
if (this.disconnected) {
|
|
604
788
|
throw new Error("Session is disconnected");
|
|
@@ -619,8 +803,10 @@ class CopilotSession {
|
|
|
619
803
|
} else if (event.type === "assistant.message" && event.data.originatingMessageId === messageId) {
|
|
620
804
|
consumed = true;
|
|
621
805
|
lastMessage = event.data.toolRequests?.length ? void 0 : event;
|
|
622
|
-
} else if (consumed && event.type === "session.idle" && event.data.mode !== "autopilot") {
|
|
623
|
-
if (event.data.
|
|
806
|
+
} else if (consumed && event.type === "session.idle" && event.data.mode !== "autopilot" || event.type === "session.autopilot_stopped" && event.data.requestId === messageId) {
|
|
807
|
+
if (event.type === "session.autopilot_stopped" && event.data.reason === "error") {
|
|
808
|
+
fail(new Error("Autopilot request failed"));
|
|
809
|
+
} else if (event.type === "session.idle" && event.data.aborted || event.type === "session.autopilot_stopped" && event.data.reason === "aborted") {
|
|
624
810
|
fail(
|
|
625
811
|
new Error(
|
|
626
812
|
"The requested run was aborted before a structured result was completed."
|
|
@@ -629,14 +815,14 @@ class CopilotSession {
|
|
|
629
815
|
} else {
|
|
630
816
|
resolveOutcome({ kind: "idle", message: lastMessage });
|
|
631
817
|
}
|
|
632
|
-
} else if (
|
|
818
|
+
} else if (event.type === "session.error" && (event.data.originatingMessageId ? event.data.originatingMessageId === messageId : consumed)) {
|
|
633
819
|
const error = new Error(event.data.message);
|
|
634
820
|
error.stack = event.data.stack;
|
|
635
821
|
fail(error);
|
|
636
822
|
}
|
|
637
823
|
};
|
|
638
824
|
const unsubscribe = this.on((event) => {
|
|
639
|
-
if (event.type !== "user.message" && event.type !== "assistant.message" && event.type !== "session.idle" && event.type !== "session.error") {
|
|
825
|
+
if (event.type !== "user.message" && event.type !== "assistant.message" && event.type !== "session.idle" && event.type !== "session.autopilot_stopped" && event.type !== "session.error") {
|
|
640
826
|
return;
|
|
641
827
|
}
|
|
642
828
|
if (messageId === void 0) {
|
|
@@ -646,12 +832,13 @@ class CopilotSession {
|
|
|
646
832
|
}
|
|
647
833
|
});
|
|
648
834
|
this.pendingStructuredWaits.add(fail);
|
|
835
|
+
let waiting = true;
|
|
649
836
|
const timer = setTimeout(
|
|
650
837
|
() => fail(new Error(`Timeout after ${timeout}ms waiting for the structured response`)),
|
|
651
838
|
timeout
|
|
652
839
|
);
|
|
653
840
|
try {
|
|
654
|
-
const sendOutcome = this.
|
|
841
|
+
const sendOutcome = this.sendMessage(options, () => !waiting).then(
|
|
655
842
|
(id) => {
|
|
656
843
|
if (!id) {
|
|
657
844
|
throw new Error(
|
|
@@ -672,6 +859,7 @@ class CopilotSession {
|
|
|
672
859
|
if (outcome.kind === "error") throw outcome.error;
|
|
673
860
|
return outcome.message;
|
|
674
861
|
} finally {
|
|
862
|
+
waiting = false;
|
|
675
863
|
clearTimeout(timer);
|
|
676
864
|
buffered.length = 0;
|
|
677
865
|
unsubscribe();
|
|
@@ -829,12 +1017,12 @@ class CopilotSession {
|
|
|
829
1017
|
}
|
|
830
1018
|
}
|
|
831
1019
|
} else if (event.type === "permission.requested") {
|
|
832
|
-
const { requestId, permissionRequest, resolvedByHook } = event.data;
|
|
1020
|
+
const { requestId, permissionRequest, promptRequest, resolvedByHook } = event.data;
|
|
833
1021
|
if (resolvedByHook) {
|
|
834
1022
|
return;
|
|
835
1023
|
}
|
|
836
1024
|
if (this.permissionHandler) {
|
|
837
|
-
void this._executePermissionAndRespond(requestId, permissionRequest);
|
|
1025
|
+
void this._executePermissionAndRespond(requestId, permissionRequest, promptRequest);
|
|
838
1026
|
}
|
|
839
1027
|
} else if (event.type === "mcp.oauth_required") {
|
|
840
1028
|
const data = event.data;
|
|
@@ -993,12 +1181,14 @@ class CopilotSession {
|
|
|
993
1181
|
* Executes a permission handler and sends the result back via RPC.
|
|
994
1182
|
* @internal
|
|
995
1183
|
*/
|
|
996
|
-
async _executePermissionAndRespond(requestId, permissionRequest) {
|
|
1184
|
+
async _executePermissionAndRespond(requestId, permissionRequest, promptRequest) {
|
|
997
1185
|
try {
|
|
998
|
-
const
|
|
1186
|
+
const invocation = {
|
|
999
1187
|
sessionId: this.sessionId,
|
|
1000
|
-
managedSettingsEnabled: this.managedSettingsEnabled
|
|
1001
|
-
|
|
1188
|
+
managedSettingsEnabled: this.managedSettingsEnabled,
|
|
1189
|
+
...promptRequest === void 0 ? {} : { promptRequest }
|
|
1190
|
+
};
|
|
1191
|
+
const handlerResult = await this.permissionHandler(permissionRequest, invocation);
|
|
1002
1192
|
const isAttributed = (0, import_types.isAttributedPermissionResult)(handlerResult);
|
|
1003
1193
|
const result = isAttributed ? handlerResult.result : handlerResult;
|
|
1004
1194
|
const decisionContext = isAttributed ? handlerResult.decisionContext : void 0;
|
|
@@ -1041,7 +1231,7 @@ class CopilotSession {
|
|
|
1041
1231
|
async _executeMcpAuthAndRespond(request) {
|
|
1042
1232
|
try {
|
|
1043
1233
|
const result = await this.mcpAuthHandler(request, { sessionId: this.sessionId });
|
|
1044
|
-
const response = result && "accessToken" in result ? { kind: "token"
|
|
1234
|
+
const response = result && "kind" in result && result.kind === "cancelled" ? { kind: "cancelled" } : result && "accessToken" in result && typeof result.accessToken === "string" && result.accessToken.length > 0 ? { ...result, kind: "token" } : result && "kind" in result && result.kind === "runtimeRefresh" && request.runtimeRefreshSupported === true ? { kind: "runtimeRefresh" } : { kind: "cancelled" };
|
|
1045
1235
|
await this.rpc.mcp.oauth.handlePendingRequest({
|
|
1046
1236
|
requestId: request.requestId,
|
|
1047
1237
|
result: response
|
|
@@ -1793,7 +1983,7 @@ class CopilotSession {
|
|
|
1793
1983
|
if (!this.hooks) {
|
|
1794
1984
|
return void 0;
|
|
1795
1985
|
}
|
|
1796
|
-
const normalized = deserializeHookInput(input);
|
|
1986
|
+
const normalized = normalizeHookError(hookType, deserializeHookInput(input));
|
|
1797
1987
|
const handlerMap = {
|
|
1798
1988
|
preToolUse: this.hooks.onPreToolUse,
|
|
1799
1989
|
preMcpToolCall: this.hooks.onPreMcpToolCall,
|
|
@@ -77,8 +77,8 @@ const RuntimeConnection = {
|
|
|
77
77
|
* corresponding environment variables on the host process instead. See
|
|
78
78
|
* https://github.com/github/copilot-sdk/issues/1934.
|
|
79
79
|
*/
|
|
80
|
-
forInProcess() {
|
|
81
|
-
return { kind: "inprocess" };
|
|
80
|
+
forInProcess(options = {}) {
|
|
81
|
+
return { kind: "inprocess", ...options };
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
function convertMcpCallToolResult(callResult) {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"url": "https://github.com/github/copilot-agent-runtime.git",
|
|
6
6
|
"directory": "src/sdk/nodejs"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.0.
|
|
9
|
-
"copilotCliVersion": "1.0.
|
|
8
|
+
"version": "1.0.26",
|
|
9
|
+
"copilotCliVersion": "1.0.103",
|
|
10
10
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
11
11
|
"main": "./dist/cjs/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"prepare:runtime": "tsx scripts/prepare-runtime.ts",
|
|
45
45
|
"test": "vitest run",
|
|
46
46
|
"test:unit": "vitest run --exclude=\"test/e2e/**\"",
|
|
47
|
+
"test:codegen": "vitest run --exclude=\"test/e2e/**\" codegen.test.ts legacy-parameters.test.ts",
|
|
47
48
|
"test:watch": "vitest",
|
|
48
49
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" --ignore-path .prettierignore",
|
|
49
50
|
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" --ignore-path .prettierignore",
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"generate": "cd ../scripts/codegen && npm run generate",
|
|
54
55
|
"set:cli-version": "node scripts/set-cli-version.js",
|
|
55
56
|
"update:protocol-version": "tsx scripts/update-protocol-version.ts",
|
|
57
|
+
"vendor:tools": "tsx scripts/vendor-build-tools.ts",
|
|
56
58
|
"prepublishOnly": "npm run build",
|
|
57
59
|
"package": "npm run clean && npm run build && node scripts/set-version.js && npm run pack:release && npm version 0.0.0-dev --no-git-tag-version --allow-same-version"
|
|
58
60
|
},
|
|
@@ -71,6 +73,7 @@
|
|
|
71
73
|
"zod": "4.3.6"
|
|
72
74
|
},
|
|
73
75
|
"devDependencies": {
|
|
76
|
+
"@hpke/core": "^1.9.0",
|
|
74
77
|
"@microsoft/agent-host-protocol-v09": "npm:@microsoft/agent-host-protocol@0.9.0",
|
|
75
78
|
"@platformatic/vfs": "^0.3.0",
|
|
76
79
|
"@types/node": "^25.2.0",
|
|
@@ -80,19 +83,26 @@
|
|
|
80
83
|
"@typescript-eslint/parser": "^8.54.0",
|
|
81
84
|
"esbuild": "^0.28.1",
|
|
82
85
|
"eslint": "^9.0.0",
|
|
86
|
+
"file-entry-cache": "file:./scripts/eslint-file-cache",
|
|
83
87
|
"glob": "^13.0.1",
|
|
84
|
-
"hpke-js": "^1.8.0",
|
|
85
88
|
"json-schema": "^0.4.0",
|
|
86
89
|
"json-schema-to-typescript": "^15.0.4",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
90
|
+
"jsonc-parser": "^3.3.1",
|
|
91
|
+
"prettier": "file:../../../third_party/build-tools/prettier-3.8.1",
|
|
89
92
|
"rimraf": "^6.1.2",
|
|
90
93
|
"semver": "^7.7.3",
|
|
91
94
|
"tar": "^7.5.22",
|
|
92
|
-
"tsx": "
|
|
95
|
+
"tsx": "file:../../../third_party/build-tools/tsx-4.23.13",
|
|
93
96
|
"typescript": "^5.0.0",
|
|
94
|
-
"
|
|
95
|
-
"
|
|
97
|
+
"vite": "file:../../../third_party/build-tools/vite-8.3.4",
|
|
98
|
+
"vitest": "^4.1.11",
|
|
99
|
+
"ws": "^8.21.0",
|
|
100
|
+
"yaml": "^2.8.3"
|
|
101
|
+
},
|
|
102
|
+
"overrides": {
|
|
103
|
+
"file-entry-cache": "$file-entry-cache",
|
|
104
|
+
"prettier": "$prettier",
|
|
105
|
+
"vite": "$vite"
|
|
96
106
|
},
|
|
97
107
|
"engines": {
|
|
98
108
|
"node": "^20.19.0 || >=22.12.0"
|
|
@@ -104,18 +114,18 @@
|
|
|
104
114
|
"README.md"
|
|
105
115
|
],
|
|
106
116
|
"copilotRuntime": {
|
|
107
|
-
"sourceSha": "
|
|
108
|
-
"version": "1.0.
|
|
117
|
+
"sourceSha": "131fc866123af5df4451497f183cadef4ddf20f2",
|
|
118
|
+
"version": "1.0.103",
|
|
109
119
|
"visibility": "public"
|
|
110
120
|
},
|
|
111
121
|
"optionalDependencies": {
|
|
112
|
-
"@github/copilot-sdk-darwin-arm64": "1.0.
|
|
113
|
-
"@github/copilot-sdk-darwin-x64": "1.0.
|
|
114
|
-
"@github/copilot-sdk-linux-arm64": "1.0.
|
|
115
|
-
"@github/copilot-sdk-linux-x64": "1.0.
|
|
116
|
-
"@github/copilot-sdk-linuxmusl-arm64": "1.0.
|
|
117
|
-
"@github/copilot-sdk-linuxmusl-x64": "1.0.
|
|
118
|
-
"@github/copilot-sdk-win32-arm64": "1.0.
|
|
119
|
-
"@github/copilot-sdk-win32-x64": "1.0.
|
|
122
|
+
"@github/copilot-sdk-darwin-arm64": "1.0.26",
|
|
123
|
+
"@github/copilot-sdk-darwin-x64": "1.0.26",
|
|
124
|
+
"@github/copilot-sdk-linux-arm64": "1.0.26",
|
|
125
|
+
"@github/copilot-sdk-linux-x64": "1.0.26",
|
|
126
|
+
"@github/copilot-sdk-linuxmusl-arm64": "1.0.26",
|
|
127
|
+
"@github/copilot-sdk-linuxmusl-x64": "1.0.26",
|
|
128
|
+
"@github/copilot-sdk-win32-arm64": "1.0.26",
|
|
129
|
+
"@github/copilot-sdk-win32-x64": "1.0.26"
|
|
120
130
|
}
|
|
121
131
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "git+https://github.com/github/copilot-language-server-release.git"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.562.0",
|
|
15
15
|
"bin": {
|
|
16
16
|
"copilot-language-server": "../dist/language-server.js"
|
|
17
17
|
},
|
|
@@ -40,25 +40,25 @@
|
|
|
40
40
|
"vscode-languageserver-protocol": "^3.17.5"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@github/copilot-language-server-win32-x64": "1.
|
|
44
|
-
"@github/copilot-language-server-win32-arm64": "1.
|
|
45
|
-
"@github/copilot-language-server-linux-x64": "1.
|
|
46
|
-
"@github/copilot-language-server-linux-arm64": "1.
|
|
47
|
-
"@github/copilot-language-server-darwin-x64": "1.
|
|
48
|
-
"@github/copilot-language-server-darwin-arm64": "1.
|
|
49
|
-
"@github/copilot-win32-x64": "1.0.
|
|
50
|
-
"@github/copilot-win32-arm64": "1.0.
|
|
51
|
-
"@github/copilot-linux-x64": "1.0.
|
|
52
|
-
"@github/copilot-linux-arm64": "1.0.
|
|
53
|
-
"@github/copilot-darwin-x64": "1.0.
|
|
54
|
-
"@github/copilot-darwin-arm64": "1.0.
|
|
55
|
-
"@github/copilot-sdk-win32-x64": "1.0.
|
|
56
|
-
"@github/copilot-sdk-win32-arm64": "1.0.
|
|
57
|
-
"@github/copilot-sdk-linux-x64": "1.0.
|
|
58
|
-
"@github/copilot-sdk-linux-arm64": "1.0.
|
|
59
|
-
"@github/copilot-sdk-darwin-x64": "1.0.
|
|
60
|
-
"@github/copilot-sdk-darwin-arm64": "1.0.
|
|
43
|
+
"@github/copilot-language-server-win32-x64": "1.562.0",
|
|
44
|
+
"@github/copilot-language-server-win32-arm64": "1.562.0",
|
|
45
|
+
"@github/copilot-language-server-linux-x64": "1.562.0",
|
|
46
|
+
"@github/copilot-language-server-linux-arm64": "1.562.0",
|
|
47
|
+
"@github/copilot-language-server-darwin-x64": "1.562.0",
|
|
48
|
+
"@github/copilot-language-server-darwin-arm64": "1.562.0",
|
|
49
|
+
"@github/copilot-win32-x64": "1.0.103",
|
|
50
|
+
"@github/copilot-win32-arm64": "1.0.103",
|
|
51
|
+
"@github/copilot-linux-x64": "1.0.103",
|
|
52
|
+
"@github/copilot-linux-arm64": "1.0.103",
|
|
53
|
+
"@github/copilot-darwin-x64": "1.0.103",
|
|
54
|
+
"@github/copilot-darwin-arm64": "1.0.103",
|
|
55
|
+
"@github/copilot-sdk-win32-x64": "1.0.26",
|
|
56
|
+
"@github/copilot-sdk-win32-arm64": "1.0.26",
|
|
57
|
+
"@github/copilot-sdk-linux-x64": "1.0.26",
|
|
58
|
+
"@github/copilot-sdk-linux-arm64": "1.0.26",
|
|
59
|
+
"@github/copilot-sdk-darwin-x64": "1.0.26",
|
|
60
|
+
"@github/copilot-sdk-darwin-arm64": "1.0.26"
|
|
61
61
|
},
|
|
62
62
|
"buildType": "prod",
|
|
63
|
-
"build": "
|
|
63
|
+
"build": "191"
|
|
64
64
|
}
|