dsh-github-copilot 0.4.0-alpha.52 → 0.4.0-alpha.54
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 +6 -4
- package/CHANGELOG.md +12 -0
- package/README.md +24 -42
- package/README.zh.md +25 -43
- package/deployment-baseline.json +3 -2
- package/docs/agent-readiness.md +2 -2
- package/docs/automatic-model-routing.md +71 -29
- package/docs/images/copilot-search-routing.png +0 -0
- package/docs/single-route-migration.md +2 -2
- package/lib/client.js +9 -3
- package/lib/client.js.map +1 -1
- package/lib/index.js +194 -30
- package/lib/types/auto-model-host.d.ts +2 -0
- package/lib/types/auto-model-presentation.d.ts +4 -0
- package/lib/types/auto-model-routing.d.ts +20 -3
- package/package.json +3 -1
- package/docs/images/copilot-auth-card-signed-in.png +0 -0
- package/docs/images/copilot-device-code-copy.png +0 -0
- package/docs/images/copilot-model-freshness.png +0 -0
- package/docs/images/copilot-model-refreshing.png +0 -0
- package/docs/images/copilot-provider-authorization.png +0 -0
- package/docs/images/copilot-provider-entry.png +0 -0
- package/docs/images/github-copilot-auth-flow.gif +0 -0
package/lib/index.js
CHANGED
|
@@ -1622,7 +1622,7 @@ let GitHubCopilotUsageController = (() => {
|
|
|
1622
1622
|
//#endregion
|
|
1623
1623
|
//#region package.json
|
|
1624
1624
|
var name$1 = "dsh-github-copilot";
|
|
1625
|
-
var version = "0.4.0-alpha.
|
|
1625
|
+
var version = "0.4.0-alpha.54";
|
|
1626
1626
|
//#endregion
|
|
1627
1627
|
//#region lib/types/probe.js
|
|
1628
1628
|
/**
|
|
@@ -6164,22 +6164,180 @@ function reasonFor(features) {
|
|
|
6164
6164
|
if (features.taskClass === "strong") return "large-structured-turn";
|
|
6165
6165
|
return "standard-turn";
|
|
6166
6166
|
}
|
|
6167
|
+
function estimateTurnInputTokens(messages) {
|
|
6168
|
+
let fresh = 0;
|
|
6169
|
+
for (const message of messages) if (typeof message === "object" && message !== null) try {
|
|
6170
|
+
fresh += estimateMessageTokens(message);
|
|
6171
|
+
} catch {}
|
|
6172
|
+
let contextTokens = 0;
|
|
6173
|
+
try {
|
|
6174
|
+
contextTokens = estimateContextTokens(messages).tokens;
|
|
6175
|
+
} catch {}
|
|
6176
|
+
const estimated = Math.max(fresh, contextTokens);
|
|
6177
|
+
if (estimated > 0) return estimated;
|
|
6178
|
+
let charCount = 0;
|
|
6179
|
+
for (const message of messages) if (record$1(message) && Array.isArray(message.content)) {
|
|
6180
|
+
for (const block of message.content) if (record$1(block) && typeof block.text === "string") charCount += block.text.length;
|
|
6181
|
+
}
|
|
6182
|
+
return charCount > 0 ? Math.ceil(charCount / 4) : 0;
|
|
6183
|
+
}
|
|
6184
|
+
function latestUserTurnTokens(messages) {
|
|
6185
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
6186
|
+
const message = messages[index];
|
|
6187
|
+
if (userMessage(message)) {
|
|
6188
|
+
try {
|
|
6189
|
+
const est = estimateMessageTokens(message);
|
|
6190
|
+
if (est > 0) return est;
|
|
6191
|
+
} catch {}
|
|
6192
|
+
if (Array.isArray(message.content)) {
|
|
6193
|
+
let chars = 0;
|
|
6194
|
+
for (const block of message.content) if (record$1(block) && typeof block.text === "string") chars += block.text.length;
|
|
6195
|
+
if (chars > 0) return Math.ceil(chars / 4);
|
|
6196
|
+
}
|
|
6197
|
+
}
|
|
6198
|
+
}
|
|
6199
|
+
return 0;
|
|
6200
|
+
}
|
|
6201
|
+
function candidateInputLimit(model, requestedMaxTokens, policy = DEFAULT_REQUEST_BUDGET_POLICY) {
|
|
6202
|
+
const result = calculateRequestBudget(model, requestedMaxTokens, policy);
|
|
6203
|
+
return result.ok ? result.budget.hardInputLimit : 0;
|
|
6204
|
+
}
|
|
6205
|
+
function fnv1a(str) {
|
|
6206
|
+
let hash = 2166136261;
|
|
6207
|
+
for (let i = 0; i < str.length; i++) {
|
|
6208
|
+
hash ^= str.charCodeAt(i);
|
|
6209
|
+
hash = Math.imul(hash, 16777619);
|
|
6210
|
+
}
|
|
6211
|
+
return hash >>> 0;
|
|
6212
|
+
}
|
|
6213
|
+
function resolveSeed(messages, context) {
|
|
6214
|
+
if (typeof context?.seed === "number" && Number.isSafeInteger(context.seed)) return Math.abs(context.seed);
|
|
6215
|
+
if (typeof context?.seed === "string" && context.seed.length > 0) return fnv1a(context.seed);
|
|
6216
|
+
if (context?.sessionId !== void 0) return fnv1a(`${context.sessionId}:${context.turn ?? 1}`);
|
|
6217
|
+
let text = "";
|
|
6218
|
+
for (const block of latestUserContent(messages)) if (record$1(block) && typeof block.text === "string") text += block.text;
|
|
6219
|
+
return fnv1a(text || "default-auto-seed");
|
|
6220
|
+
}
|
|
6221
|
+
function pickBandIndex(n, taskClass, preference, seed) {
|
|
6222
|
+
if (n <= 1) return 0;
|
|
6223
|
+
const middle = Math.floor((n - 1) / 2);
|
|
6224
|
+
if (n === 2) {
|
|
6225
|
+
if (taskClass === "fast") return preference === "intelligence" ? 1 : 0;
|
|
6226
|
+
if (taskClass === "strong") return 1;
|
|
6227
|
+
return preference === "efficiency" ? 0 : 1;
|
|
6228
|
+
}
|
|
6229
|
+
let start;
|
|
6230
|
+
let end;
|
|
6231
|
+
let bias;
|
|
6232
|
+
if (taskClass === "fast") {
|
|
6233
|
+
if (preference === "intelligence") {
|
|
6234
|
+
start = Math.max(0, middle - 1);
|
|
6235
|
+
end = Math.min(n - 1, Math.max(1, middle));
|
|
6236
|
+
bias = "high";
|
|
6237
|
+
} else {
|
|
6238
|
+
start = 0;
|
|
6239
|
+
end = 0;
|
|
6240
|
+
bias = "low";
|
|
6241
|
+
}
|
|
6242
|
+
} else if (taskClass === "strong") {
|
|
6243
|
+
if (preference === "efficiency") {
|
|
6244
|
+
start = Math.min(n - 1, Math.max(1, middle));
|
|
6245
|
+
end = start;
|
|
6246
|
+
bias = "center";
|
|
6247
|
+
} else if (preference === "balance") {
|
|
6248
|
+
start = Math.min(n - 1, Math.max(1, middle));
|
|
6249
|
+
end = n - 1;
|
|
6250
|
+
bias = "high";
|
|
6251
|
+
} else {
|
|
6252
|
+
const upperCount = Math.max(2, Math.min(3, Math.ceil(n / 2)));
|
|
6253
|
+
start = Math.max(1, n - upperCount);
|
|
6254
|
+
end = n - 1;
|
|
6255
|
+
bias = "high";
|
|
6256
|
+
}
|
|
6257
|
+
} else if (preference === "efficiency") {
|
|
6258
|
+
const lowerCount = Math.max(1, Math.min(2, Math.floor(n / 3)));
|
|
6259
|
+
start = 0;
|
|
6260
|
+
end = lowerCount - 1;
|
|
6261
|
+
bias = "low";
|
|
6262
|
+
} else if (preference === "intelligence") {
|
|
6263
|
+
const upperCount = Math.max(2, Math.min(3, Math.ceil(n / 2)));
|
|
6264
|
+
start = Math.max(1, n - upperCount);
|
|
6265
|
+
end = n - 1;
|
|
6266
|
+
bias = "high";
|
|
6267
|
+
} else {
|
|
6268
|
+
const spread = n >= 5 ? 1 : 0;
|
|
6269
|
+
start = Math.max(0, middle - spread);
|
|
6270
|
+
end = Math.min(n - 1, middle + spread);
|
|
6271
|
+
bias = "center";
|
|
6272
|
+
}
|
|
6273
|
+
const bandSize = end - start + 1;
|
|
6274
|
+
if (bandSize <= 1) return start;
|
|
6275
|
+
const weights = [];
|
|
6276
|
+
for (let i = 0; i < bandSize; i++) if (bias === "high") weights.push(i + 1);
|
|
6277
|
+
else if (bias === "low") weights.push(bandSize - i);
|
|
6278
|
+
else {
|
|
6279
|
+
const dist = Math.abs(i - Math.floor((bandSize - 1) / 2));
|
|
6280
|
+
weights.push(bandSize - dist);
|
|
6281
|
+
}
|
|
6282
|
+
const offset = seed % weights.reduce((sum, w) => sum + w, 0);
|
|
6283
|
+
let accumulated = 0;
|
|
6284
|
+
for (let i = 0; i < bandSize; i++) {
|
|
6285
|
+
accumulated += weights[i];
|
|
6286
|
+
if (offset < accumulated) return start + i;
|
|
6287
|
+
}
|
|
6288
|
+
return end;
|
|
6289
|
+
}
|
|
6167
6290
|
/**
|
|
6168
|
-
*
|
|
6169
|
-
*
|
|
6291
|
+
* Filter by hard capabilities and input headroom before soft preference.
|
|
6292
|
+
* Soft preferences distribute across capacity bands using in-memory deterministic seeds.
|
|
6293
|
+
* Preserves Core compaction ownership if no candidate currently fits.
|
|
6170
6294
|
*/
|
|
6171
|
-
function selectAutoModel(models, messages, preference = "balance") {
|
|
6295
|
+
function selectAutoModel(models, messages, preference = "balance", context) {
|
|
6172
6296
|
const features = classifyAutoModelTurn(messages);
|
|
6173
6297
|
const eligible = models.filter((model) => autoModelPreference(model.id) === void 0 && model.input.includes("text") && (!features.requiresImage || model.input.includes("image"))).toSorted(compareCapacity);
|
|
6174
6298
|
if (eligible.length === 0) throw new AutoModelRoutingError("COPILOT_AUTO_NO_ELIGIBLE_MODEL");
|
|
6175
|
-
const
|
|
6176
|
-
const
|
|
6299
|
+
const estimatedInputTokens = estimateTurnInputTokens(messages);
|
|
6300
|
+
const requestedMaxTokens = context?.requestedMaxTokens;
|
|
6301
|
+
const policy = context?.requestBudgetPolicy ?? DEFAULT_REQUEST_BUDGET_POLICY;
|
|
6302
|
+
const fitting = eligible.filter((model) => {
|
|
6303
|
+
const limit = candidateInputLimit(model, requestedMaxTokens, policy);
|
|
6304
|
+
return limit > 0 && estimatedInputTokens <= limit;
|
|
6305
|
+
});
|
|
6306
|
+
const seed = resolveSeed(messages, context);
|
|
6307
|
+
let selectedModel;
|
|
6308
|
+
let inputFitDiagnostic;
|
|
6309
|
+
let selectedInputBudget;
|
|
6310
|
+
if (fitting.length > 0) {
|
|
6311
|
+
selectedModel = fitting[pickBandIndex(fitting.length, features.taskClass, preference, seed)];
|
|
6312
|
+
selectedInputBudget = candidateInputLimit(selectedModel, requestedMaxTokens, policy);
|
|
6313
|
+
inputFitDiagnostic = "fitting-candidate-selected";
|
|
6314
|
+
} else {
|
|
6315
|
+
let maxModel = eligible[0];
|
|
6316
|
+
let maxLimit = candidateInputLimit(maxModel, requestedMaxTokens, policy);
|
|
6317
|
+
for (let i = 1; i < eligible.length; i++) {
|
|
6318
|
+
const limit = candidateInputLimit(eligible[i], requestedMaxTokens, policy);
|
|
6319
|
+
if (limit > maxLimit) {
|
|
6320
|
+
maxLimit = limit;
|
|
6321
|
+
maxModel = eligible[i];
|
|
6322
|
+
}
|
|
6323
|
+
}
|
|
6324
|
+
selectedModel = maxModel;
|
|
6325
|
+
selectedInputBudget = maxLimit;
|
|
6326
|
+
if (latestUserTurnTokens(messages) > maxLimit) inputFitDiagnostic = "fixed-content-cannot-fit";
|
|
6327
|
+
else if (context?.compactionAvailable === false) inputFitDiagnostic = "compaction-unavailable";
|
|
6328
|
+
else if (context?.hasCompactionSummary === true) inputFitDiagnostic = "attempted-but-still-oversized";
|
|
6329
|
+
else inputFitDiagnostic = "compaction-eligible";
|
|
6330
|
+
}
|
|
6177
6331
|
return Object.freeze({
|
|
6178
|
-
model:
|
|
6332
|
+
model: selectedModel,
|
|
6179
6333
|
preference,
|
|
6180
6334
|
taskClass: features.taskClass,
|
|
6181
6335
|
reason: reasonFor(features),
|
|
6182
|
-
candidateCount: eligible.length
|
|
6336
|
+
candidateCount: eligible.length,
|
|
6337
|
+
fittingCandidateCount: fitting.length,
|
|
6338
|
+
estimatedInputTokens,
|
|
6339
|
+
selectedInputBudget,
|
|
6340
|
+
inputFitDiagnostic
|
|
6183
6341
|
});
|
|
6184
6342
|
}
|
|
6185
6343
|
function autoModelInputModalities(models) {
|
|
@@ -6190,9 +6348,9 @@ function autoModelInputModalities(models) {
|
|
|
6190
6348
|
function failure$1(code) {
|
|
6191
6349
|
return new LlmError(code, "INVALID_REQUEST");
|
|
6192
6350
|
}
|
|
6193
|
-
async function decide(dependencies, signal, messages, preference) {
|
|
6351
|
+
async function decide(dependencies, signal, messages, preference, context) {
|
|
6194
6352
|
try {
|
|
6195
|
-
return selectAutoModel(await dependencies.loadModels(signal), messages, preference);
|
|
6353
|
+
return selectAutoModel(await dependencies.loadModels(signal), messages, preference, context);
|
|
6196
6354
|
} catch (cause) {
|
|
6197
6355
|
if (cause instanceof AutoModelRoutingError) throw failure$1(cause.code);
|
|
6198
6356
|
throw cause;
|
|
@@ -6201,6 +6359,21 @@ async function decide(dependencies, signal, messages, preference) {
|
|
|
6201
6359
|
function record(value) {
|
|
6202
6360
|
return typeof value === "object" && value !== null;
|
|
6203
6361
|
}
|
|
6362
|
+
function buildRoutingContext(ctx, agent, turn, messages, budgetPolicyConfig) {
|
|
6363
|
+
const sessionId = typeof agent.session?.id === "string" ? agent.session.id : void 0;
|
|
6364
|
+
const compaction = ctx.get("compaction");
|
|
6365
|
+
const compactionConfig = record(compaction) && record(compaction.config) ? compaction.config : void 0;
|
|
6366
|
+
const compactionAvailable = compaction !== void 0 && compactionConfig?.auto !== false && (typeof compactionConfig?.maxOverflowRetries !== "number" || compactionConfig.maxOverflowRetries > 0);
|
|
6367
|
+
const hasCompactionSummary = messages.some((m) => record(m) && (record(m.source) && m.source.kind === "compaction" || typeof m.surfaceOp === "object"));
|
|
6368
|
+
return {
|
|
6369
|
+
sessionId,
|
|
6370
|
+
turn,
|
|
6371
|
+
requestedMaxTokens: (typeof agent.session?.requestHeader === "function" ? agent.session.requestHeader() : void 0)?.config.maxTokens,
|
|
6372
|
+
requestBudgetPolicy: budgetPolicyConfig ? resolveRequestBudgetPolicy(budgetPolicyConfig) : DEFAULT_REQUEST_BUDGET_POLICY,
|
|
6373
|
+
compactionAvailable,
|
|
6374
|
+
hasCompactionSummary
|
|
6375
|
+
};
|
|
6376
|
+
}
|
|
6204
6377
|
function pendingAuto(ctx, agent) {
|
|
6205
6378
|
const candidate = ctx.get("sessionProjections");
|
|
6206
6379
|
if (!record(candidate) || typeof candidate.stateOf !== "function") return void 0;
|
|
@@ -6231,9 +6404,6 @@ function actualNotice(agent, model) {
|
|
|
6231
6404
|
}
|
|
6232
6405
|
});
|
|
6233
6406
|
}
|
|
6234
|
-
function appendAutoModelDecision(agent, event) {
|
|
6235
|
-
Reflect.apply(agent.session.append, agent.session, ["github-copilot/auto-model-decision", event]);
|
|
6236
|
-
}
|
|
6237
6407
|
/** Resolve virtual Auto once per Core turn before request/header persistence. */
|
|
6238
6408
|
function installAutoModelRouting(ctx, dependencies) {
|
|
6239
6409
|
const captured = /* @__PURE__ */ new WeakMap();
|
|
@@ -6255,7 +6425,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
6255
6425
|
}
|
|
6256
6426
|
};
|
|
6257
6427
|
}, { prepend: true });
|
|
6258
|
-
const removePreStep = agent.ctx.on("agent/pre-step", async ({ messages, turn,
|
|
6428
|
+
const removePreStep = agent.ctx.on("agent/pre-step", async ({ messages, turn, signal }, next) => {
|
|
6259
6429
|
const result = await next();
|
|
6260
6430
|
const entered = result.kind === "enter" ? result.messages : messages;
|
|
6261
6431
|
captured.set(agent, {
|
|
@@ -6269,7 +6439,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
6269
6439
|
if (state?.turn !== turn) {
|
|
6270
6440
|
state = {
|
|
6271
6441
|
turn,
|
|
6272
|
-
decision: await decide(dependencies, signal, entered, preference),
|
|
6442
|
+
decision: await decide(dependencies, signal, entered, preference, buildRoutingContext(ctx, agent, turn, entered, dependencies.budgetPolicy?.())),
|
|
6273
6443
|
recorded: false
|
|
6274
6444
|
};
|
|
6275
6445
|
routed.set(agent, state);
|
|
@@ -6302,7 +6472,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
6302
6472
|
captured.delete(agent);
|
|
6303
6473
|
routed.delete(agent);
|
|
6304
6474
|
});
|
|
6305
|
-
const removeRequest = ctx.on("agent/request", async ({ agent, turn,
|
|
6475
|
+
const removeRequest = ctx.on("agent/request", async ({ agent, turn, signal }, next) => {
|
|
6306
6476
|
const resolved = await next();
|
|
6307
6477
|
const pending = pendingAuto(ctx, agent);
|
|
6308
6478
|
const virtualPreference = resolved.provider === "github-copilot-preview" ? autoModelPreference(resolved.model) : void 0;
|
|
@@ -6321,9 +6491,10 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
6321
6491
|
if (input?.turn !== turn) throw failure$1("COPILOT_AUTO_TURN_CONTEXT_UNAVAILABLE");
|
|
6322
6492
|
const preference = virtualPreference ?? (pending === void 0 ? void 0 : autoModelPreference(pending));
|
|
6323
6493
|
if (preference === void 0) throw failure$1("COPILOT_AUTO_PREFERENCE_UNAVAILABLE");
|
|
6494
|
+
const routingContext = buildRoutingContext(ctx, agent, turn, input.messages, dependencies.budgetPolicy?.());
|
|
6324
6495
|
state = {
|
|
6325
6496
|
turn,
|
|
6326
|
-
decision: await decide(dependencies, signal, input.messages, preference),
|
|
6497
|
+
decision: await decide(dependencies, signal, input.messages, preference, routingContext),
|
|
6327
6498
|
recorded: false
|
|
6328
6499
|
};
|
|
6329
6500
|
routed.set(agent, state);
|
|
@@ -6337,16 +6508,6 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
6337
6508
|
model: resolved.model
|
|
6338
6509
|
}]);
|
|
6339
6510
|
}
|
|
6340
|
-
appendAutoModelDecision(agent, {
|
|
6341
|
-
turn,
|
|
6342
|
-
step,
|
|
6343
|
-
provider: GITHUB_COPILOT_PREVIEW_PROVIDER_ID,
|
|
6344
|
-
model: state.decision.model.id,
|
|
6345
|
-
preference: state.decision.preference,
|
|
6346
|
-
taskClass: state.decision.taskClass,
|
|
6347
|
-
reason: state.decision.reason,
|
|
6348
|
-
candidateCount: state.decision.candidateCount
|
|
6349
|
-
});
|
|
6350
6511
|
state.recorded = true;
|
|
6351
6512
|
}
|
|
6352
6513
|
return {
|
|
@@ -6995,9 +7156,12 @@ function apply$1(ctx, config = {}) {
|
|
|
6995
7156
|
resolveImageAccess: (attachments, ref) => resolveImageAttachmentAccess(attachments, (hostPath) => ctx.get("fs")?.processPathFromHostPath(hostPath), ref)
|
|
6996
7157
|
};
|
|
6997
7158
|
};
|
|
6998
|
-
const removeAutoRoute = installAutoModelRouting(ctx, {
|
|
6999
|
-
|
|
7000
|
-
|
|
7159
|
+
const removeAutoRoute = installAutoModelRouting(ctx, {
|
|
7160
|
+
async loadModels(signal) {
|
|
7161
|
+
return (await discoverSnapshot({ signal })).models;
|
|
7162
|
+
},
|
|
7163
|
+
budgetPolicy: () => budgetSettings()
|
|
7164
|
+
});
|
|
7001
7165
|
const registration = ctx.llm.registerAdapter([GITHUB_COPILOT_PREVIEW_PROVIDER_ID], new PreviewAdapter(lifetime, optionsFor, discoverSnapshot, refreshRejected, budgetSettings));
|
|
7002
7166
|
installCopilotCompactionPressure(ctx, { resolve(request) {
|
|
7003
7167
|
const snapshot = source.readSnapshot();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { AccountModelDescriptor } from './account-model-catalog.ts';
|
|
3
|
+
import type { RequestBudgetPolicy } from './request-budget.ts';
|
|
3
4
|
export interface AutoModelHostDependencies {
|
|
4
5
|
loadModels(signal: AbortSignal): Promise<readonly AccountModelDescriptor[]>;
|
|
6
|
+
budgetPolicy?: () => Partial<RequestBudgetPolicy>;
|
|
5
7
|
}
|
|
6
8
|
/** Resolve virtual Auto once per Core turn before request/header persistence. */
|
|
7
9
|
export declare function installAutoModelRouting(ctx: Context, dependencies: AutoModelHostDependencies): () => void;
|
|
@@ -8,6 +8,10 @@ export interface AutoModelAttribution {
|
|
|
8
8
|
readonly taskClass: 'fast' | 'balanced' | 'strong';
|
|
9
9
|
readonly reason: 'short-text-turn' | 'standard-turn' | 'large-structured-turn' | 'image-capability';
|
|
10
10
|
readonly candidateCount: number;
|
|
11
|
+
readonly fittingCandidateCount?: number;
|
|
12
|
+
readonly estimatedInputTokens?: number;
|
|
13
|
+
readonly selectedInputBudget?: number;
|
|
14
|
+
readonly inputFitDiagnostic?: 'fitting-candidate-selected' | 'compaction-eligible' | 'compaction-unavailable' | 'attempted-but-still-oversized' | 'fixed-content-cannot-fit';
|
|
11
15
|
}
|
|
12
16
|
interface AttributionState {
|
|
13
17
|
readonly turn: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AccountModelDescriptor } from './account-model-catalog.ts';
|
|
2
2
|
import type { AutoModelPreference } from './copilot-identity.ts';
|
|
3
|
+
import type { RequestBudgetPolicy } from './request-budget.ts';
|
|
3
4
|
export type AutoModelClass = 'fast' | 'balanced' | 'strong';
|
|
4
5
|
export interface AutoModelFeatures {
|
|
5
6
|
readonly taskClass: AutoModelClass;
|
|
@@ -7,22 +8,38 @@ export interface AutoModelFeatures {
|
|
|
7
8
|
readonly codeFenceCount: number;
|
|
8
9
|
readonly requiresImage: boolean;
|
|
9
10
|
}
|
|
11
|
+
export type AutoModelInputFitDiagnostic = 'fitting-candidate-selected' | 'compaction-eligible' | 'compaction-unavailable' | 'attempted-but-still-oversized' | 'fixed-content-cannot-fit';
|
|
10
12
|
export interface AutoModelDecision {
|
|
11
13
|
readonly model: AccountModelDescriptor;
|
|
12
14
|
readonly preference: AutoModelPreference;
|
|
13
15
|
readonly taskClass: AutoModelClass;
|
|
14
16
|
readonly reason: 'short-text-turn' | 'standard-turn' | 'large-structured-turn' | 'image-capability';
|
|
15
17
|
readonly candidateCount: number;
|
|
18
|
+
readonly fittingCandidateCount: number;
|
|
19
|
+
readonly estimatedInputTokens: number;
|
|
20
|
+
readonly selectedInputBudget: number;
|
|
21
|
+
readonly inputFitDiagnostic: AutoModelInputFitDiagnostic;
|
|
22
|
+
}
|
|
23
|
+
export interface AutoModelRoutingContext {
|
|
24
|
+
readonly sessionId?: string;
|
|
25
|
+
readonly turn?: number;
|
|
26
|
+
readonly requestedMaxTokens?: number;
|
|
27
|
+
readonly requestBudgetPolicy?: Readonly<RequestBudgetPolicy>;
|
|
28
|
+
readonly seed?: string | number;
|
|
29
|
+
readonly compactionAvailable?: boolean;
|
|
30
|
+
readonly hasCompactionSummary?: boolean;
|
|
16
31
|
}
|
|
17
32
|
export declare class AutoModelRoutingError extends Error {
|
|
18
33
|
readonly code: 'COPILOT_AUTO_NO_ELIGIBLE_MODEL';
|
|
19
34
|
constructor(code: 'COPILOT_AUTO_NO_ELIGIBLE_MODEL');
|
|
20
35
|
}
|
|
21
36
|
export declare function classifyAutoModelTurn(messages: readonly unknown[]): AutoModelFeatures;
|
|
37
|
+
export declare function estimateTurnInputTokens(messages: readonly unknown[]): number;
|
|
22
38
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
39
|
+
* Filter by hard capabilities and input headroom before soft preference.
|
|
40
|
+
* Soft preferences distribute across capacity bands using in-memory deterministic seeds.
|
|
41
|
+
* Preserves Core compaction ownership if no candidate currently fits.
|
|
25
42
|
*/
|
|
26
|
-
export declare function selectAutoModel(models: readonly AccountModelDescriptor[], messages: readonly unknown[], preference?: AutoModelPreference): AutoModelDecision;
|
|
43
|
+
export declare function selectAutoModel(models: readonly AccountModelDescriptor[], messages: readonly unknown[], preference?: AutoModelPreference, context?: AutoModelRoutingContext): AutoModelDecision;
|
|
27
44
|
export declare function autoModelInputModalities(models: readonly AccountModelDescriptor[]): readonly ('text' | 'image')[];
|
|
28
45
|
//# sourceMappingURL=auto-model-routing.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.54",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -149,6 +149,8 @@
|
|
|
149
149
|
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
150
150
|
"@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
|
|
151
151
|
"@deepseek-ai/dsh-scope": "0.2.0-rc.2",
|
|
152
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
153
|
+
"@deepseek-ai/dsh-session-format-catalog": "0.2.0-rc.2",
|
|
152
154
|
"@deepseek-ai/dsh-settings": "0.2.0-rc.2",
|
|
153
155
|
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
154
156
|
"@deepseek-ai/dsh-tool-web": "0.2.0-rc.2",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|