dsh-github-copilot 0.4.0-alpha.111 → 0.4.0-alpha.113
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/AGENTS.md +7 -0
- package/CHANGELOG.md +13 -0
- package/README.md +10 -6
- package/README.zh.md +10 -6
- package/deployment-baseline.json +7 -1
- package/docs/account-management-experience.md +7 -0
- package/docs/copilot-compaction.md +7 -0
- package/docs/session-continuation.md +20 -5
- package/lib/client.js +3 -3
- package/lib/client.js.map +1 -1
- package/lib/index.js +71 -72
- package/lib/types/session-continuation-host.d.ts +1 -1
- package/lib/types/session-continuation.d.ts +5 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
19
19
|
import { channel } from "node:diagnostics_channel";
|
|
20
20
|
import * as dshLlm from "@deepseek-ai/dsh-llm";
|
|
21
21
|
import { CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, ReasoningEffortId, attributionHeaders, boundContextSummary, callConfigEquals, contentHasImage, createUserMessage, isAgentLoopRequest, resolveImageAttachmentAccess, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
22
|
+
import { setImmediate } from "node:timers/promises";
|
|
22
23
|
import { Config as Config$1, PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
|
|
23
24
|
import { estimateContextTokens, estimateMessageTokens } from "@earendil-works/pi-ai/utils/estimate";
|
|
24
25
|
//#region lib/types/dual-model-host.js
|
|
@@ -2395,22 +2396,26 @@ var ResponsesRetryReplay = class {
|
|
|
2395
2396
|
normalized = JSON.parse(eligible.normalized);
|
|
2396
2397
|
reused = true;
|
|
2397
2398
|
}
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2399
|
+
const complete = (finalPayload) => {
|
|
2400
|
+
if (this.disposed || signal?.aborted || finished) throw new CopilotResponsesReplayError();
|
|
2401
|
+
payloadBytes = cacheBytes(finalPayload);
|
|
2402
|
+
candidate = signal === void 0 || !sessionId || !modelId || contextBytes === void 0 || rawBytes === void 0 || payloadBytes === void 0 ? void 0 : {
|
|
2403
|
+
raw: JSON.parse(rawBytes),
|
|
2404
|
+
normalized: payloadBytes,
|
|
2405
|
+
context: contextBytes,
|
|
2406
|
+
signal,
|
|
2407
|
+
sessionId,
|
|
2408
|
+
modelId,
|
|
2409
|
+
at: Date.now()
|
|
2410
|
+
};
|
|
2411
|
+
if (reused && eligible) candidate = {
|
|
2412
|
+
...eligible,
|
|
2413
|
+
at: Date.now()
|
|
2414
|
+
};
|
|
2415
|
+
return finalPayload;
|
|
2412
2416
|
};
|
|
2413
|
-
|
|
2417
|
+
const transformed = transform === void 0 ? normalized : transform(normalized);
|
|
2418
|
+
return transformed instanceof Promise ? transformed.then(complete) : complete(transformed);
|
|
2414
2419
|
},
|
|
2415
2420
|
observe: (body, status) => {
|
|
2416
2421
|
observed = true;
|
|
@@ -2896,9 +2901,9 @@ function createAccountProvider(descriptors, guard, baseURL) {
|
|
|
2896
2901
|
if (lease.signal.aborted || options.signal?.aborted) throw new Error("COPILOT_MANAGED_ABORTED");
|
|
2897
2902
|
try {
|
|
2898
2903
|
const effective = replacement === void 0 ? payload : replacement;
|
|
2899
|
-
if (retry !== void 0) return retry.normalize(effective, guard.recoverReplay);
|
|
2904
|
+
if (retry !== void 0) return await retry.normalize(effective, guard.recoverReplay);
|
|
2900
2905
|
const normalized = normalizeCopilotResponsesPayload(effective);
|
|
2901
|
-
return guard.recoverReplay === void 0 ? normalized : guard.recoverReplay(normalized);
|
|
2906
|
+
return guard.recoverReplay === void 0 ? normalized : await guard.recoverReplay(normalized);
|
|
2902
2907
|
} catch (error) {
|
|
2903
2908
|
if (error instanceof CopilotResponsesReplayError) reportReplayFailure(error);
|
|
2904
2909
|
throw error;
|
|
@@ -2993,7 +2998,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
|
|
|
2993
2998
|
var package_default = {
|
|
2994
2999
|
name: "dsh-github-copilot",
|
|
2995
3000
|
description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
2996
|
-
version: "0.4.0-alpha.
|
|
3001
|
+
version: "0.4.0-alpha.113",
|
|
2997
3002
|
publishConfig: {
|
|
2998
3003
|
"access": "public",
|
|
2999
3004
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -9120,71 +9125,65 @@ function installReplayRecovery(ctx, proof) {
|
|
|
9120
9125
|
//#region lib/types/session-continuation.js
|
|
9121
9126
|
const SESSION_CONTINUATION_LIMITS = Object.freeze({
|
|
9122
9127
|
items: 4096,
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9128
|
+
inputItems: 65536,
|
|
9129
|
+
ciphertextCodeUnits: 67108864,
|
|
9130
|
+
chunkCodeUnits: 65536
|
|
9126
9131
|
});
|
|
9127
9132
|
function record$8(value) {
|
|
9128
9133
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9129
9134
|
}
|
|
9130
|
-
function fingerprint(item) {
|
|
9131
|
-
if (!record$8(item)) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
|
|
9132
|
-
if (item.type !== "reasoning") return void 0;
|
|
9133
|
-
if (typeof item.encrypted_content !== "string" || !item.encrypted_content || item.status !== void 0 && item.status !== "completed") throw new Error("COPILOT_CONTINUATION_UNSUPPORTED_REASONING");
|
|
9134
|
-
return createHash("sha256").update(item.encrypted_content).digest("hex");
|
|
9135
|
-
}
|
|
9136
9135
|
/** One admitted turn; fingerprints never become durable history or account provenance. */
|
|
9137
9136
|
var SessionContinuationTurn = class {
|
|
9138
9137
|
baseline;
|
|
9138
|
+
processing = false;
|
|
9139
9139
|
get initialized() {
|
|
9140
9140
|
return this.baseline !== void 0;
|
|
9141
9141
|
}
|
|
9142
|
-
transform(payload) {
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
if (pending.length + value.length > SESSION_CONTINUATION_LIMITS.values) throw new Error("COPILOT_CONTINUATION_WORK_LIMIT");
|
|
9155
|
-
for (const child of value) pending.push({
|
|
9156
|
-
value: child,
|
|
9157
|
-
depth: depth + 1
|
|
9158
|
-
});
|
|
9159
|
-
} else if (record$8(value)) {
|
|
9160
|
-
const entries = Object.entries(value);
|
|
9161
|
-
if (pending.length + entries.length > SESSION_CONTINUATION_LIMITS.values) throw new Error("COPILOT_CONTINUATION_WORK_LIMIT");
|
|
9162
|
-
for (const [key, child] of entries) {
|
|
9163
|
-
stringBytes += Buffer.byteLength(key);
|
|
9164
|
-
pending.push({
|
|
9165
|
-
value: child,
|
|
9166
|
-
depth: depth + 1
|
|
9167
|
-
});
|
|
9142
|
+
async transform(payload, assertCurrent = () => {}) {
|
|
9143
|
+
assertCurrent();
|
|
9144
|
+
if (this.processing) throw new Error("COPILOT_CONTINUATION_PROCESSING_OVERLAP");
|
|
9145
|
+
if (!record$8(payload) || !Array.isArray(payload.input) || payload.input.length > SESSION_CONTINUATION_LIMITS.inputItems) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
|
|
9146
|
+
this.processing = true;
|
|
9147
|
+
try {
|
|
9148
|
+
const hashes = /* @__PURE__ */ new Map();
|
|
9149
|
+
let codeUnits = 0;
|
|
9150
|
+
for (let index = 0; index < payload.input.length; index++) {
|
|
9151
|
+
if (index % 256 === 0) {
|
|
9152
|
+
await setImmediate();
|
|
9153
|
+
assertCurrent();
|
|
9168
9154
|
}
|
|
9155
|
+
const item = payload.input[index];
|
|
9156
|
+
if (!record$8(item)) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
|
|
9157
|
+
if (item.type !== "reasoning") continue;
|
|
9158
|
+
const ciphertext = item.encrypted_content;
|
|
9159
|
+
if (typeof ciphertext !== "string" || !ciphertext || item.status !== void 0 && item.status !== "completed") throw new Error("COPILOT_CONTINUATION_UNSUPPORTED_REASONING");
|
|
9160
|
+
if (hashes.size >= SESSION_CONTINUATION_LIMITS.items) throw new Error("COPILOT_CONTINUATION_ITEM_LIMIT");
|
|
9161
|
+
codeUnits += ciphertext.length;
|
|
9162
|
+
if (codeUnits > SESSION_CONTINUATION_LIMITS.ciphertextCodeUnits) throw new Error("COPILOT_CONTINUATION_REASONING_WORK_LIMIT");
|
|
9163
|
+
const hash = createHash("sha256");
|
|
9164
|
+
for (let start = 0; start < ciphertext.length;) {
|
|
9165
|
+
let end = Math.min(start + SESSION_CONTINUATION_LIMITS.chunkCodeUnits, ciphertext.length);
|
|
9166
|
+
const last = ciphertext.charCodeAt(end - 1);
|
|
9167
|
+
if (end < ciphertext.length && last >= 55296 && last <= 56319) end--;
|
|
9168
|
+
hash.update(ciphertext.slice(start, end));
|
|
9169
|
+
start = end;
|
|
9170
|
+
await setImmediate();
|
|
9171
|
+
assertCurrent();
|
|
9172
|
+
}
|
|
9173
|
+
hashes.set(index, hash.digest("hex"));
|
|
9169
9174
|
}
|
|
9170
|
-
|
|
9175
|
+
const baseline = this.baseline ?? new Set(hashes.values());
|
|
9176
|
+
const input = payload.input.filter((_, index) => !hashes.has(index) || !baseline.has(hashes.get(index)));
|
|
9177
|
+
const result = input.length === payload.input.length ? payload : {
|
|
9178
|
+
...payload,
|
|
9179
|
+
input
|
|
9180
|
+
};
|
|
9181
|
+
assertCurrent();
|
|
9182
|
+
this.baseline ??= baseline;
|
|
9183
|
+
return result;
|
|
9184
|
+
} finally {
|
|
9185
|
+
this.processing = false;
|
|
9171
9186
|
}
|
|
9172
|
-
let bytes;
|
|
9173
|
-
try {
|
|
9174
|
-
bytes = JSON.stringify(payload);
|
|
9175
|
-
} catch {
|
|
9176
|
-
throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
|
|
9177
|
-
}
|
|
9178
|
-
if (Buffer.byteLength(bytes) > SESSION_CONTINUATION_LIMITS.bytes) throw new Error("COPILOT_CONTINUATION_PAYLOAD_LIMIT");
|
|
9179
|
-
const hashes = payload.input.map(fingerprint);
|
|
9180
|
-
const present = new Set(hashes.filter((value) => value !== void 0));
|
|
9181
|
-
if (present.size > SESSION_CONTINUATION_LIMITS.items) throw new Error("COPILOT_CONTINUATION_ITEM_LIMIT");
|
|
9182
|
-
this.baseline ??= present;
|
|
9183
|
-
const input = payload.input.filter((_, index) => hashes[index] === void 0 || !this.baseline.has(hashes[index]));
|
|
9184
|
-
return input.length === payload.input.length ? payload : {
|
|
9185
|
-
...payload,
|
|
9186
|
-
input
|
|
9187
|
-
};
|
|
9188
9187
|
}
|
|
9189
9188
|
};
|
|
9190
9189
|
//#endregion
|
|
@@ -9514,10 +9513,10 @@ function installSessionContinuation(ctx) {
|
|
|
9514
9513
|
if (!admission.filter.initialized && admission.step !== 1) throw new Error("COPILOT_CONTINUATION_TURN_BOUNDARY_UNAVAILABLE");
|
|
9515
9514
|
const current = () => !disposed && !request.signal.aborted && active.get(session) === admission && admission.signal === request.signal;
|
|
9516
9515
|
if (!current()) throw new Error("COPILOT_CONTINUATION_REVOKED");
|
|
9517
|
-
|
|
9516
|
+
const assertCurrent = () => {
|
|
9518
9517
|
if (!current()) throw new Error("COPILOT_CONTINUATION_REVOKED");
|
|
9519
|
-
return admission.filter.transform(payload);
|
|
9520
9518
|
};
|
|
9519
|
+
return (payload) => admission.filter.transform(payload, assertCurrent);
|
|
9521
9520
|
},
|
|
9522
9521
|
dispose() {
|
|
9523
9522
|
disposed = true;
|
|
@@ -35,7 +35,7 @@ export declare class SessionContinuationController extends TypertRemoteService {
|
|
|
35
35
|
}
|
|
36
36
|
export declare function installSessionContinuation(ctx: Context): {
|
|
37
37
|
ready: Promise<void>;
|
|
38
|
-
prepare(request: GenerateOptions): ((payload: unknown) => unknown) | undefined;
|
|
38
|
+
prepare(request: GenerateOptions): ((payload: unknown) => Promise<unknown>) | undefined;
|
|
39
39
|
dispose(): void;
|
|
40
40
|
};
|
|
41
41
|
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export declare const SESSION_CONTINUATION_LIMITS: Readonly<{
|
|
2
2
|
items: 4096;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
inputItems: 65536;
|
|
4
|
+
ciphertextCodeUnits: number;
|
|
5
|
+
chunkCodeUnits: number;
|
|
6
6
|
}>;
|
|
7
7
|
/** One admitted turn; fingerprints never become durable history or account provenance. */
|
|
8
8
|
export declare class SessionContinuationTurn {
|
|
9
9
|
private baseline;
|
|
10
|
+
private processing;
|
|
10
11
|
get initialized(): boolean;
|
|
11
|
-
transform(payload: unknown): unknown
|
|
12
|
+
transform(payload: unknown, assertCurrent?: () => void): Promise<unknown>;
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=session-continuation.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-github-copilot",
|
|
3
3
|
"description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
4
|
-
"version": "0.4.0-alpha.
|
|
4
|
+
"version": "0.4.0-alpha.113",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|