@github/copilot-sdk 1.0.15-preview.2 → 1.0.15-preview.4
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/README.md +53 -25
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +21 -6
- package/dist/cjs/extension.js +1 -12
- package/dist/cjs/generated/rpc.js +307 -177
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/installationConfirmation.js +98 -0
- package/dist/cjs/session.js +15 -524
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +23 -6
- package/dist/extension.d.ts +10 -24
- package/dist/extension.js +1 -13
- package/dist/generated/rpc.d.ts +4455 -2788
- package/dist/generated/rpc.js +307 -177
- package/dist/generated/session-events.d.ts +211 -120
- package/dist/index.d.ts +2 -4
- package/dist/index.js +0 -4
- package/dist/installationConfirmation.d.ts +19 -0
- package/dist/installationConfirmation.js +77 -0
- package/dist/session.d.ts +3 -25
- package/dist/session.js +15 -529
- package/dist/types.d.ts +31 -66
- package/dist/workflow.d.ts +5 -2
- package/docs/extensions.md +0 -1
- package/docs/workflows.md +2 -4
- package/package.json +10 -10
- package/dist/cjs/factory.js +0 -134
- package/dist/factory.d.ts +0 -327
- package/dist/factory.js +0 -106
- package/docs/factories.md +0 -296
- package/docs/factory-patterns.md +0 -194
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var installationConfirmation_exports = {};
|
|
20
|
+
__export(installationConfirmation_exports, {
|
|
21
|
+
createInstallationConfirmationAdapter: () => createInstallationConfirmationAdapter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(installationConfirmation_exports);
|
|
24
|
+
var import_node = require("vscode-jsonrpc/node.js");
|
|
25
|
+
function createInstallationConfirmationAdapter(connection, handler) {
|
|
26
|
+
const closed = new import_node.CancellationTokenSource();
|
|
27
|
+
const closeSubscription = connection.onClose(() => closed.cancel());
|
|
28
|
+
const disposeSubscription = connection.onDispose(() => {
|
|
29
|
+
closed.cancel();
|
|
30
|
+
closed.dispose();
|
|
31
|
+
closeSubscription.dispose();
|
|
32
|
+
disposeSubscription.dispose();
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
async confirm(request, token) {
|
|
36
|
+
if (!token) {
|
|
37
|
+
throw new Error("Installation confirmation request cancellation is unavailable");
|
|
38
|
+
}
|
|
39
|
+
const { confirmationId, reviewFingerprint } = request;
|
|
40
|
+
const combined = new import_node.CancellationTokenSource();
|
|
41
|
+
const subscriptions = [];
|
|
42
|
+
const cancelRequest = () => combined.cancel();
|
|
43
|
+
const cancelConnection = () => combined.cancel();
|
|
44
|
+
const checkCancellation = () => {
|
|
45
|
+
if (closed.token.isCancellationRequested) {
|
|
46
|
+
throw new Error("Installation confirmation connection closed");
|
|
47
|
+
}
|
|
48
|
+
if (token.isCancellationRequested) {
|
|
49
|
+
throw new import_node.ResponseError(-32800, "Installation confirmation request cancelled");
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
try {
|
|
53
|
+
subscriptions.push(
|
|
54
|
+
token.onCancellationRequested(cancelRequest),
|
|
55
|
+
closed.token.onCancellationRequested(cancelConnection)
|
|
56
|
+
);
|
|
57
|
+
if (token.isCancellationRequested || closed.token.isCancellationRequested) {
|
|
58
|
+
combined.cancel();
|
|
59
|
+
}
|
|
60
|
+
checkCancellation();
|
|
61
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
62
|
+
subscriptions.push(
|
|
63
|
+
token.onCancellationRequested(
|
|
64
|
+
() => reject(
|
|
65
|
+
new import_node.ResponseError(
|
|
66
|
+
-32800,
|
|
67
|
+
"Installation confirmation request cancelled"
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
),
|
|
71
|
+
closed.token.onCancellationRequested(
|
|
72
|
+
() => reject(new Error("Installation confirmation connection closed"))
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
const decision = await Promise.race([
|
|
77
|
+
Promise.resolve().then(() => {
|
|
78
|
+
checkCancellation();
|
|
79
|
+
return handler(request, combined.token);
|
|
80
|
+
}),
|
|
81
|
+
cancelled
|
|
82
|
+
]);
|
|
83
|
+
checkCancellation();
|
|
84
|
+
if (decision !== "confirm" && decision !== "decline" && decision !== "cancel") {
|
|
85
|
+
throw new Error("Invalid installation confirmation decision");
|
|
86
|
+
}
|
|
87
|
+
return { confirmationId, reviewFingerprint, decision };
|
|
88
|
+
} finally {
|
|
89
|
+
for (const subscription of subscriptions) subscription.dispose();
|
|
90
|
+
combined.dispose();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
createInstallationConfirmationAdapter
|
|
98
|
+
});
|