dsh-github-copilot 0.4.0-alpha.121 → 0.4.0-alpha.123
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 +14 -5
- package/CHANGELOG.md +6 -0
- package/README.md +16 -7
- package/README.zh.md +14 -7
- package/deployment-baseline.json +28 -2
- package/docs/auto-high-cost.md +22 -0
- package/docs/manual-compaction-recovery.md +3 -1
- package/docs/plugin-diagnostics.md +388 -0
- package/docs/session-continuation.md +23 -4
- package/lib/client.js +1341 -404
- package/lib/client.js.map +1 -1
- package/lib/index.js +1737 -919
- package/lib/manual-compaction-recovery.js +15 -2
- package/lib/remote.js +211 -9
- package/lib/request-budget-Cui2hCi1.js +268 -0
- package/lib/routed-web.js +1 -1
- package/lib/{search-routing-CHyF6TbO.js → search-routing-CV2hs8as.js} +35 -35
- package/lib/types/client.d.ts +3 -0
- package/lib/types/compaction-continuation-ui.d.ts +11 -0
- package/lib/types/compaction-continuation.d.ts +48 -0
- package/lib/types/config.d.ts +6 -2
- package/lib/types/copilot-accounts-host.d.ts +1 -0
- package/lib/types/diagnostics-card.d.ts +10 -0
- package/lib/types/diagnostics-client.d.ts +13 -0
- package/lib/types/diagnostics-collector.d.ts +36 -0
- package/lib/types/diagnostics-host.d.ts +72 -0
- package/lib/types/diagnostics-remote.d.ts +109 -0
- package/lib/types/diagnostics-types.d.ts +431 -0
- package/lib/types/remote.d.ts +1 -1
- package/lib/types/session-accounts-host.d.ts +1 -1
- package/lib/types/session-continuation-host.d.ts +4 -1
- package/lib/types/session-continuation-types.d.ts +27 -0
- package/package.json +6 -2
- package/lib/request-budget-DLY_aRq0.js +0 -87
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DIAGNOSTICS_OPERATIONS: readonly ["account-global-switch", "account-session-select", "account-session-inherit", "identity-read", "identity-flight", "compaction", "compaction-summary", "collection"];
|
|
3
|
+
export declare const DIAGNOSTICS_STAGES: readonly ["admitted", "rpc-invoked", "host-received", "identity-validation", "model-validation", "cas", "readback", "response-received", "decoded", "client-settled", "summary-attempt", "checkpoint-committed", "ended", "cache-hit", "joined-flight", "cooldown", "dispatched"];
|
|
4
|
+
export declare const DIAGNOSTICS_METRICS: readonly ["started", "stage", "success", "no-op", "cancelled", "policy-rejected", "revoked", "environment-fault", "failed", "unknown", "interrupted", "dropped", "paused", "expired", "clock-discontinuity", "pending-sample"];
|
|
5
|
+
export declare const DIAGNOSTICS_REASONS: readonly ["none", "unknown", "rpc-unavailable", "decode-invalid", "COPILOT_ACCOUNTS_BUSY", "COPILOT_ACCOUNTS_CONFLICT", "COPILOT_ACCOUNTS_CHANGED", "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN", "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT", "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE", "COPILOT_ACCOUNTS_MODELS_FAILED", "COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE", "COPILOT_ACCOUNTS_IDENTITY_TLS", "COPILOT_ACCOUNTS_IDENTITY_NETWORK", "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED", "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED", "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR", "COPILOT_ACCOUNTS_IDENTITY_INVALID", "COPILOT_SESSION_ACCOUNTS_UNAVAILABLE", "COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE", "COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN", "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH", "CONTEXT_WINDOW_EXCEEDED", "COPILOT_MANUAL_RECOVERY_FIXED_PREFIX", "COPILOT_MANUAL_RECOVERY_INDIVISIBLE", "COPILOT_MANUAL_RECOVERY_CALL_LIMIT", "COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY", "COPILOT_MANUAL_RECOVERY_UNBALANCED"];
|
|
6
|
+
export declare const DIAGNOSTICS_MAX_ROWS = 4096;
|
|
7
|
+
export declare const DIAGNOSTICS_MAX_BYTES: number;
|
|
8
|
+
export declare const DIAGNOSTICS_RETENTION_MS: number;
|
|
9
|
+
export declare const DIAGNOSTICS_MAX_LIVE = 128;
|
|
10
|
+
export declare const DiagnosticsRowSchema: z.ZodObject<{
|
|
11
|
+
hour: z.ZodNumber;
|
|
12
|
+
version: z.ZodString;
|
|
13
|
+
layer: z.ZodEnum<{
|
|
14
|
+
client: "client";
|
|
15
|
+
host: "host";
|
|
16
|
+
}>;
|
|
17
|
+
operation: z.ZodEnum<{
|
|
18
|
+
compaction: "compaction";
|
|
19
|
+
"account-global-switch": "account-global-switch";
|
|
20
|
+
"account-session-select": "account-session-select";
|
|
21
|
+
"account-session-inherit": "account-session-inherit";
|
|
22
|
+
"identity-read": "identity-read";
|
|
23
|
+
"identity-flight": "identity-flight";
|
|
24
|
+
"compaction-summary": "compaction-summary";
|
|
25
|
+
collection: "collection";
|
|
26
|
+
}>;
|
|
27
|
+
stage: z.ZodEnum<{
|
|
28
|
+
ended: "ended";
|
|
29
|
+
admitted: "admitted";
|
|
30
|
+
"rpc-invoked": "rpc-invoked";
|
|
31
|
+
"host-received": "host-received";
|
|
32
|
+
"identity-validation": "identity-validation";
|
|
33
|
+
"model-validation": "model-validation";
|
|
34
|
+
cas: "cas";
|
|
35
|
+
readback: "readback";
|
|
36
|
+
"response-received": "response-received";
|
|
37
|
+
decoded: "decoded";
|
|
38
|
+
"client-settled": "client-settled";
|
|
39
|
+
"summary-attempt": "summary-attempt";
|
|
40
|
+
"checkpoint-committed": "checkpoint-committed";
|
|
41
|
+
"cache-hit": "cache-hit";
|
|
42
|
+
"joined-flight": "joined-flight";
|
|
43
|
+
cooldown: "cooldown";
|
|
44
|
+
dispatched: "dispatched";
|
|
45
|
+
}>;
|
|
46
|
+
metric: z.ZodEnum<{
|
|
47
|
+
paused: "paused";
|
|
48
|
+
unknown: "unknown";
|
|
49
|
+
started: "started";
|
|
50
|
+
stage: "stage";
|
|
51
|
+
success: "success";
|
|
52
|
+
"no-op": "no-op";
|
|
53
|
+
cancelled: "cancelled";
|
|
54
|
+
"policy-rejected": "policy-rejected";
|
|
55
|
+
revoked: "revoked";
|
|
56
|
+
"environment-fault": "environment-fault";
|
|
57
|
+
failed: "failed";
|
|
58
|
+
interrupted: "interrupted";
|
|
59
|
+
dropped: "dropped";
|
|
60
|
+
expired: "expired";
|
|
61
|
+
"clock-discontinuity": "clock-discontinuity";
|
|
62
|
+
"pending-sample": "pending-sample";
|
|
63
|
+
}>;
|
|
64
|
+
reason: z.ZodEnum<{
|
|
65
|
+
none: "none";
|
|
66
|
+
COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE: "COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE";
|
|
67
|
+
COPILOT_ACCOUNTS_CHANGED: "COPILOT_ACCOUNTS_CHANGED";
|
|
68
|
+
COPILOT_ACCOUNTS_BUSY: "COPILOT_ACCOUNTS_BUSY";
|
|
69
|
+
COPILOT_ACCOUNTS_CONFLICT: "COPILOT_ACCOUNTS_CONFLICT";
|
|
70
|
+
COPILOT_ACCOUNTS_COMMIT_UNCERTAIN: "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN";
|
|
71
|
+
COPILOT_ACCOUNTS_MODELS_FAILED: "COPILOT_ACCOUNTS_MODELS_FAILED";
|
|
72
|
+
COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE: "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE";
|
|
73
|
+
COPILOT_ACCOUNTS_IDENTITY_INVALID: "COPILOT_ACCOUNTS_IDENTITY_INVALID";
|
|
74
|
+
COPILOT_ACCOUNTS_IDENTITY_TIMEOUT: "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT";
|
|
75
|
+
COPILOT_ACCOUNTS_IDENTITY_TLS: "COPILOT_ACCOUNTS_IDENTITY_TLS";
|
|
76
|
+
COPILOT_ACCOUNTS_IDENTITY_NETWORK: "COPILOT_ACCOUNTS_IDENTITY_NETWORK";
|
|
77
|
+
COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED: "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED";
|
|
78
|
+
COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED: "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED";
|
|
79
|
+
COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR: "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR";
|
|
80
|
+
unknown: "unknown";
|
|
81
|
+
"rpc-unavailable": "rpc-unavailable";
|
|
82
|
+
"decode-invalid": "decode-invalid";
|
|
83
|
+
COPILOT_SESSION_ACCOUNTS_UNAVAILABLE: "COPILOT_SESSION_ACCOUNTS_UNAVAILABLE";
|
|
84
|
+
COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE: "COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE";
|
|
85
|
+
COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN: "COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN";
|
|
86
|
+
COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH: "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH";
|
|
87
|
+
CONTEXT_WINDOW_EXCEEDED: "CONTEXT_WINDOW_EXCEEDED";
|
|
88
|
+
COPILOT_MANUAL_RECOVERY_FIXED_PREFIX: "COPILOT_MANUAL_RECOVERY_FIXED_PREFIX";
|
|
89
|
+
COPILOT_MANUAL_RECOVERY_INDIVISIBLE: "COPILOT_MANUAL_RECOVERY_INDIVISIBLE";
|
|
90
|
+
COPILOT_MANUAL_RECOVERY_CALL_LIMIT: "COPILOT_MANUAL_RECOVERY_CALL_LIMIT";
|
|
91
|
+
COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY: "COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY";
|
|
92
|
+
COPILOT_MANUAL_RECOVERY_UNBALANCED: "COPILOT_MANUAL_RECOVERY_UNBALANCED";
|
|
93
|
+
}>;
|
|
94
|
+
bucket: z.ZodNumber;
|
|
95
|
+
count: z.ZodNumber;
|
|
96
|
+
}, z.core.$strict>;
|
|
97
|
+
export declare const DiagnosticsPendingSchema: z.ZodObject<{
|
|
98
|
+
version: z.ZodString;
|
|
99
|
+
operation: z.ZodEnum<{
|
|
100
|
+
compaction: "compaction";
|
|
101
|
+
"account-global-switch": "account-global-switch";
|
|
102
|
+
"account-session-select": "account-session-select";
|
|
103
|
+
"account-session-inherit": "account-session-inherit";
|
|
104
|
+
"identity-read": "identity-read";
|
|
105
|
+
"identity-flight": "identity-flight";
|
|
106
|
+
"compaction-summary": "compaction-summary";
|
|
107
|
+
collection: "collection";
|
|
108
|
+
}>;
|
|
109
|
+
stage: z.ZodEnum<{
|
|
110
|
+
ended: "ended";
|
|
111
|
+
admitted: "admitted";
|
|
112
|
+
"rpc-invoked": "rpc-invoked";
|
|
113
|
+
"host-received": "host-received";
|
|
114
|
+
"identity-validation": "identity-validation";
|
|
115
|
+
"model-validation": "model-validation";
|
|
116
|
+
cas: "cas";
|
|
117
|
+
readback: "readback";
|
|
118
|
+
"response-received": "response-received";
|
|
119
|
+
decoded: "decoded";
|
|
120
|
+
"client-settled": "client-settled";
|
|
121
|
+
"summary-attempt": "summary-attempt";
|
|
122
|
+
"checkpoint-committed": "checkpoint-committed";
|
|
123
|
+
"cache-hit": "cache-hit";
|
|
124
|
+
"joined-flight": "joined-flight";
|
|
125
|
+
cooldown: "cooldown";
|
|
126
|
+
dispatched: "dispatched";
|
|
127
|
+
}>;
|
|
128
|
+
bucket: z.ZodNumber;
|
|
129
|
+
count: z.ZodNumber;
|
|
130
|
+
}, z.core.$strict>;
|
|
131
|
+
export declare const DiagnosticsSnapshotSchema: z.ZodObject<{
|
|
132
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
133
|
+
coverageVersion: z.ZodLiteral<1>;
|
|
134
|
+
epoch: z.ZodNumber;
|
|
135
|
+
updatedAt: z.ZodNumber;
|
|
136
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
137
|
+
hour: z.ZodNumber;
|
|
138
|
+
version: z.ZodString;
|
|
139
|
+
layer: z.ZodEnum<{
|
|
140
|
+
client: "client";
|
|
141
|
+
host: "host";
|
|
142
|
+
}>;
|
|
143
|
+
operation: z.ZodEnum<{
|
|
144
|
+
compaction: "compaction";
|
|
145
|
+
"account-global-switch": "account-global-switch";
|
|
146
|
+
"account-session-select": "account-session-select";
|
|
147
|
+
"account-session-inherit": "account-session-inherit";
|
|
148
|
+
"identity-read": "identity-read";
|
|
149
|
+
"identity-flight": "identity-flight";
|
|
150
|
+
"compaction-summary": "compaction-summary";
|
|
151
|
+
collection: "collection";
|
|
152
|
+
}>;
|
|
153
|
+
stage: z.ZodEnum<{
|
|
154
|
+
ended: "ended";
|
|
155
|
+
admitted: "admitted";
|
|
156
|
+
"rpc-invoked": "rpc-invoked";
|
|
157
|
+
"host-received": "host-received";
|
|
158
|
+
"identity-validation": "identity-validation";
|
|
159
|
+
"model-validation": "model-validation";
|
|
160
|
+
cas: "cas";
|
|
161
|
+
readback: "readback";
|
|
162
|
+
"response-received": "response-received";
|
|
163
|
+
decoded: "decoded";
|
|
164
|
+
"client-settled": "client-settled";
|
|
165
|
+
"summary-attempt": "summary-attempt";
|
|
166
|
+
"checkpoint-committed": "checkpoint-committed";
|
|
167
|
+
"cache-hit": "cache-hit";
|
|
168
|
+
"joined-flight": "joined-flight";
|
|
169
|
+
cooldown: "cooldown";
|
|
170
|
+
dispatched: "dispatched";
|
|
171
|
+
}>;
|
|
172
|
+
metric: z.ZodEnum<{
|
|
173
|
+
paused: "paused";
|
|
174
|
+
unknown: "unknown";
|
|
175
|
+
started: "started";
|
|
176
|
+
stage: "stage";
|
|
177
|
+
success: "success";
|
|
178
|
+
"no-op": "no-op";
|
|
179
|
+
cancelled: "cancelled";
|
|
180
|
+
"policy-rejected": "policy-rejected";
|
|
181
|
+
revoked: "revoked";
|
|
182
|
+
"environment-fault": "environment-fault";
|
|
183
|
+
failed: "failed";
|
|
184
|
+
interrupted: "interrupted";
|
|
185
|
+
dropped: "dropped";
|
|
186
|
+
expired: "expired";
|
|
187
|
+
"clock-discontinuity": "clock-discontinuity";
|
|
188
|
+
"pending-sample": "pending-sample";
|
|
189
|
+
}>;
|
|
190
|
+
reason: z.ZodEnum<{
|
|
191
|
+
none: "none";
|
|
192
|
+
COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE: "COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE";
|
|
193
|
+
COPILOT_ACCOUNTS_CHANGED: "COPILOT_ACCOUNTS_CHANGED";
|
|
194
|
+
COPILOT_ACCOUNTS_BUSY: "COPILOT_ACCOUNTS_BUSY";
|
|
195
|
+
COPILOT_ACCOUNTS_CONFLICT: "COPILOT_ACCOUNTS_CONFLICT";
|
|
196
|
+
COPILOT_ACCOUNTS_COMMIT_UNCERTAIN: "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN";
|
|
197
|
+
COPILOT_ACCOUNTS_MODELS_FAILED: "COPILOT_ACCOUNTS_MODELS_FAILED";
|
|
198
|
+
COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE: "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE";
|
|
199
|
+
COPILOT_ACCOUNTS_IDENTITY_INVALID: "COPILOT_ACCOUNTS_IDENTITY_INVALID";
|
|
200
|
+
COPILOT_ACCOUNTS_IDENTITY_TIMEOUT: "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT";
|
|
201
|
+
COPILOT_ACCOUNTS_IDENTITY_TLS: "COPILOT_ACCOUNTS_IDENTITY_TLS";
|
|
202
|
+
COPILOT_ACCOUNTS_IDENTITY_NETWORK: "COPILOT_ACCOUNTS_IDENTITY_NETWORK";
|
|
203
|
+
COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED: "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED";
|
|
204
|
+
COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED: "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED";
|
|
205
|
+
COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR: "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR";
|
|
206
|
+
unknown: "unknown";
|
|
207
|
+
"rpc-unavailable": "rpc-unavailable";
|
|
208
|
+
"decode-invalid": "decode-invalid";
|
|
209
|
+
COPILOT_SESSION_ACCOUNTS_UNAVAILABLE: "COPILOT_SESSION_ACCOUNTS_UNAVAILABLE";
|
|
210
|
+
COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE: "COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE";
|
|
211
|
+
COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN: "COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN";
|
|
212
|
+
COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH: "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH";
|
|
213
|
+
CONTEXT_WINDOW_EXCEEDED: "CONTEXT_WINDOW_EXCEEDED";
|
|
214
|
+
COPILOT_MANUAL_RECOVERY_FIXED_PREFIX: "COPILOT_MANUAL_RECOVERY_FIXED_PREFIX";
|
|
215
|
+
COPILOT_MANUAL_RECOVERY_INDIVISIBLE: "COPILOT_MANUAL_RECOVERY_INDIVISIBLE";
|
|
216
|
+
COPILOT_MANUAL_RECOVERY_CALL_LIMIT: "COPILOT_MANUAL_RECOVERY_CALL_LIMIT";
|
|
217
|
+
COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY: "COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY";
|
|
218
|
+
COPILOT_MANUAL_RECOVERY_UNBALANCED: "COPILOT_MANUAL_RECOVERY_UNBALANCED";
|
|
219
|
+
}>;
|
|
220
|
+
bucket: z.ZodNumber;
|
|
221
|
+
count: z.ZodNumber;
|
|
222
|
+
}, z.core.$strict>>;
|
|
223
|
+
pending: z.ZodArray<z.ZodObject<{
|
|
224
|
+
version: z.ZodString;
|
|
225
|
+
operation: z.ZodEnum<{
|
|
226
|
+
compaction: "compaction";
|
|
227
|
+
"account-global-switch": "account-global-switch";
|
|
228
|
+
"account-session-select": "account-session-select";
|
|
229
|
+
"account-session-inherit": "account-session-inherit";
|
|
230
|
+
"identity-read": "identity-read";
|
|
231
|
+
"identity-flight": "identity-flight";
|
|
232
|
+
"compaction-summary": "compaction-summary";
|
|
233
|
+
collection: "collection";
|
|
234
|
+
}>;
|
|
235
|
+
stage: z.ZodEnum<{
|
|
236
|
+
ended: "ended";
|
|
237
|
+
admitted: "admitted";
|
|
238
|
+
"rpc-invoked": "rpc-invoked";
|
|
239
|
+
"host-received": "host-received";
|
|
240
|
+
"identity-validation": "identity-validation";
|
|
241
|
+
"model-validation": "model-validation";
|
|
242
|
+
cas: "cas";
|
|
243
|
+
readback: "readback";
|
|
244
|
+
"response-received": "response-received";
|
|
245
|
+
decoded: "decoded";
|
|
246
|
+
"client-settled": "client-settled";
|
|
247
|
+
"summary-attempt": "summary-attempt";
|
|
248
|
+
"checkpoint-committed": "checkpoint-committed";
|
|
249
|
+
"cache-hit": "cache-hit";
|
|
250
|
+
"joined-flight": "joined-flight";
|
|
251
|
+
cooldown: "cooldown";
|
|
252
|
+
dispatched: "dispatched";
|
|
253
|
+
}>;
|
|
254
|
+
bucket: z.ZodNumber;
|
|
255
|
+
count: z.ZodNumber;
|
|
256
|
+
}, z.core.$strict>>;
|
|
257
|
+
dropped: z.ZodNumber;
|
|
258
|
+
clientDropped: z.ZodNumber;
|
|
259
|
+
clientUnconfirmed: z.ZodNumber;
|
|
260
|
+
saturated: z.ZodNumber;
|
|
261
|
+
evicted: z.ZodNumber;
|
|
262
|
+
interrupted: z.ZodNumber;
|
|
263
|
+
}, z.core.$strict>;
|
|
264
|
+
export declare const DiagnosticsViewSchema: z.ZodObject<{
|
|
265
|
+
enabled: z.ZodBoolean;
|
|
266
|
+
state: z.ZodEnum<{
|
|
267
|
+
error: "error";
|
|
268
|
+
ready: "ready";
|
|
269
|
+
unavailable: "unavailable";
|
|
270
|
+
loading: "loading";
|
|
271
|
+
}>;
|
|
272
|
+
diagnostic: z.ZodEnum<{
|
|
273
|
+
none: "none";
|
|
274
|
+
"storage-unavailable": "storage-unavailable";
|
|
275
|
+
"storage-invalid": "storage-invalid";
|
|
276
|
+
"storage-write-failed": "storage-write-failed";
|
|
277
|
+
"profile-unavailable": "profile-unavailable";
|
|
278
|
+
"settings-unavailable": "settings-unavailable";
|
|
279
|
+
"settings-conflict": "settings-conflict";
|
|
280
|
+
"client-report-failed": "client-report-failed";
|
|
281
|
+
"client-report-revoked": "client-report-revoked";
|
|
282
|
+
closed: "closed";
|
|
283
|
+
}>;
|
|
284
|
+
persistedAt: z.ZodOptional<z.ZodNumber>;
|
|
285
|
+
dirty: z.ZodBoolean;
|
|
286
|
+
snapshot: z.ZodObject<{
|
|
287
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
288
|
+
coverageVersion: z.ZodLiteral<1>;
|
|
289
|
+
epoch: z.ZodNumber;
|
|
290
|
+
updatedAt: z.ZodNumber;
|
|
291
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
292
|
+
hour: z.ZodNumber;
|
|
293
|
+
version: z.ZodString;
|
|
294
|
+
layer: z.ZodEnum<{
|
|
295
|
+
client: "client";
|
|
296
|
+
host: "host";
|
|
297
|
+
}>;
|
|
298
|
+
operation: z.ZodEnum<{
|
|
299
|
+
compaction: "compaction";
|
|
300
|
+
"account-global-switch": "account-global-switch";
|
|
301
|
+
"account-session-select": "account-session-select";
|
|
302
|
+
"account-session-inherit": "account-session-inherit";
|
|
303
|
+
"identity-read": "identity-read";
|
|
304
|
+
"identity-flight": "identity-flight";
|
|
305
|
+
"compaction-summary": "compaction-summary";
|
|
306
|
+
collection: "collection";
|
|
307
|
+
}>;
|
|
308
|
+
stage: z.ZodEnum<{
|
|
309
|
+
ended: "ended";
|
|
310
|
+
admitted: "admitted";
|
|
311
|
+
"rpc-invoked": "rpc-invoked";
|
|
312
|
+
"host-received": "host-received";
|
|
313
|
+
"identity-validation": "identity-validation";
|
|
314
|
+
"model-validation": "model-validation";
|
|
315
|
+
cas: "cas";
|
|
316
|
+
readback: "readback";
|
|
317
|
+
"response-received": "response-received";
|
|
318
|
+
decoded: "decoded";
|
|
319
|
+
"client-settled": "client-settled";
|
|
320
|
+
"summary-attempt": "summary-attempt";
|
|
321
|
+
"checkpoint-committed": "checkpoint-committed";
|
|
322
|
+
"cache-hit": "cache-hit";
|
|
323
|
+
"joined-flight": "joined-flight";
|
|
324
|
+
cooldown: "cooldown";
|
|
325
|
+
dispatched: "dispatched";
|
|
326
|
+
}>;
|
|
327
|
+
metric: z.ZodEnum<{
|
|
328
|
+
paused: "paused";
|
|
329
|
+
unknown: "unknown";
|
|
330
|
+
started: "started";
|
|
331
|
+
stage: "stage";
|
|
332
|
+
success: "success";
|
|
333
|
+
"no-op": "no-op";
|
|
334
|
+
cancelled: "cancelled";
|
|
335
|
+
"policy-rejected": "policy-rejected";
|
|
336
|
+
revoked: "revoked";
|
|
337
|
+
"environment-fault": "environment-fault";
|
|
338
|
+
failed: "failed";
|
|
339
|
+
interrupted: "interrupted";
|
|
340
|
+
dropped: "dropped";
|
|
341
|
+
expired: "expired";
|
|
342
|
+
"clock-discontinuity": "clock-discontinuity";
|
|
343
|
+
"pending-sample": "pending-sample";
|
|
344
|
+
}>;
|
|
345
|
+
reason: z.ZodEnum<{
|
|
346
|
+
none: "none";
|
|
347
|
+
COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE: "COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE";
|
|
348
|
+
COPILOT_ACCOUNTS_CHANGED: "COPILOT_ACCOUNTS_CHANGED";
|
|
349
|
+
COPILOT_ACCOUNTS_BUSY: "COPILOT_ACCOUNTS_BUSY";
|
|
350
|
+
COPILOT_ACCOUNTS_CONFLICT: "COPILOT_ACCOUNTS_CONFLICT";
|
|
351
|
+
COPILOT_ACCOUNTS_COMMIT_UNCERTAIN: "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN";
|
|
352
|
+
COPILOT_ACCOUNTS_MODELS_FAILED: "COPILOT_ACCOUNTS_MODELS_FAILED";
|
|
353
|
+
COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE: "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE";
|
|
354
|
+
COPILOT_ACCOUNTS_IDENTITY_INVALID: "COPILOT_ACCOUNTS_IDENTITY_INVALID";
|
|
355
|
+
COPILOT_ACCOUNTS_IDENTITY_TIMEOUT: "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT";
|
|
356
|
+
COPILOT_ACCOUNTS_IDENTITY_TLS: "COPILOT_ACCOUNTS_IDENTITY_TLS";
|
|
357
|
+
COPILOT_ACCOUNTS_IDENTITY_NETWORK: "COPILOT_ACCOUNTS_IDENTITY_NETWORK";
|
|
358
|
+
COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED: "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED";
|
|
359
|
+
COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED: "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED";
|
|
360
|
+
COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR: "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR";
|
|
361
|
+
unknown: "unknown";
|
|
362
|
+
"rpc-unavailable": "rpc-unavailable";
|
|
363
|
+
"decode-invalid": "decode-invalid";
|
|
364
|
+
COPILOT_SESSION_ACCOUNTS_UNAVAILABLE: "COPILOT_SESSION_ACCOUNTS_UNAVAILABLE";
|
|
365
|
+
COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE: "COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE";
|
|
366
|
+
COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN: "COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN";
|
|
367
|
+
COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH: "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH";
|
|
368
|
+
CONTEXT_WINDOW_EXCEEDED: "CONTEXT_WINDOW_EXCEEDED";
|
|
369
|
+
COPILOT_MANUAL_RECOVERY_FIXED_PREFIX: "COPILOT_MANUAL_RECOVERY_FIXED_PREFIX";
|
|
370
|
+
COPILOT_MANUAL_RECOVERY_INDIVISIBLE: "COPILOT_MANUAL_RECOVERY_INDIVISIBLE";
|
|
371
|
+
COPILOT_MANUAL_RECOVERY_CALL_LIMIT: "COPILOT_MANUAL_RECOVERY_CALL_LIMIT";
|
|
372
|
+
COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY: "COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY";
|
|
373
|
+
COPILOT_MANUAL_RECOVERY_UNBALANCED: "COPILOT_MANUAL_RECOVERY_UNBALANCED";
|
|
374
|
+
}>;
|
|
375
|
+
bucket: z.ZodNumber;
|
|
376
|
+
count: z.ZodNumber;
|
|
377
|
+
}, z.core.$strict>>;
|
|
378
|
+
pending: z.ZodArray<z.ZodObject<{
|
|
379
|
+
version: z.ZodString;
|
|
380
|
+
operation: z.ZodEnum<{
|
|
381
|
+
compaction: "compaction";
|
|
382
|
+
"account-global-switch": "account-global-switch";
|
|
383
|
+
"account-session-select": "account-session-select";
|
|
384
|
+
"account-session-inherit": "account-session-inherit";
|
|
385
|
+
"identity-read": "identity-read";
|
|
386
|
+
"identity-flight": "identity-flight";
|
|
387
|
+
"compaction-summary": "compaction-summary";
|
|
388
|
+
collection: "collection";
|
|
389
|
+
}>;
|
|
390
|
+
stage: z.ZodEnum<{
|
|
391
|
+
ended: "ended";
|
|
392
|
+
admitted: "admitted";
|
|
393
|
+
"rpc-invoked": "rpc-invoked";
|
|
394
|
+
"host-received": "host-received";
|
|
395
|
+
"identity-validation": "identity-validation";
|
|
396
|
+
"model-validation": "model-validation";
|
|
397
|
+
cas: "cas";
|
|
398
|
+
readback: "readback";
|
|
399
|
+
"response-received": "response-received";
|
|
400
|
+
decoded: "decoded";
|
|
401
|
+
"client-settled": "client-settled";
|
|
402
|
+
"summary-attempt": "summary-attempt";
|
|
403
|
+
"checkpoint-committed": "checkpoint-committed";
|
|
404
|
+
"cache-hit": "cache-hit";
|
|
405
|
+
"joined-flight": "joined-flight";
|
|
406
|
+
cooldown: "cooldown";
|
|
407
|
+
dispatched: "dispatched";
|
|
408
|
+
}>;
|
|
409
|
+
bucket: z.ZodNumber;
|
|
410
|
+
count: z.ZodNumber;
|
|
411
|
+
}, z.core.$strict>>;
|
|
412
|
+
dropped: z.ZodNumber;
|
|
413
|
+
clientDropped: z.ZodNumber;
|
|
414
|
+
clientUnconfirmed: z.ZodNumber;
|
|
415
|
+
saturated: z.ZodNumber;
|
|
416
|
+
evicted: z.ZodNumber;
|
|
417
|
+
interrupted: z.ZodNumber;
|
|
418
|
+
}, z.core.$strict>;
|
|
419
|
+
}, z.core.$strict>;
|
|
420
|
+
export type DiagnosticsRow = z.infer<typeof DiagnosticsRowSchema>;
|
|
421
|
+
export type DiagnosticsSnapshot = z.infer<typeof DiagnosticsSnapshotSchema>;
|
|
422
|
+
export type DiagnosticsView = z.infer<typeof DiagnosticsViewSchema>;
|
|
423
|
+
export type DiagnosticsOperation = typeof DIAGNOSTICS_OPERATIONS[number];
|
|
424
|
+
export type DiagnosticsStage = typeof DIAGNOSTICS_STAGES[number];
|
|
425
|
+
export type DiagnosticsMetric = typeof DIAGNOSTICS_METRICS[number];
|
|
426
|
+
export type DiagnosticsReason = typeof DIAGNOSTICS_REASONS[number];
|
|
427
|
+
export type DiagnosticsOutcome = Exclude<DiagnosticsMetric, 'started' | 'stage' | 'dropped' | 'paused' | 'expired' | 'clock-discontinuity' | 'pending-sample'>;
|
|
428
|
+
export declare function diagnosticsBucket(ms: number): number;
|
|
429
|
+
export declare function diagnosticsReason(error: unknown): DiagnosticsReason;
|
|
430
|
+
export declare function diagnosticsOutcome(reason: DiagnosticsReason): DiagnosticsOutcome;
|
|
431
|
+
//# sourceMappingURL=diagnostics-types.d.ts.map
|
package/lib/types/remote.d.ts
CHANGED
|
@@ -56,8 +56,8 @@ export declare const GitHubCopilotAuthorizationViewSchema: z.ZodObject<{
|
|
|
56
56
|
error: "error";
|
|
57
57
|
ready: "ready";
|
|
58
58
|
unavailable: "unavailable";
|
|
59
|
-
idle: "idle";
|
|
60
59
|
loading: "loading";
|
|
60
|
+
idle: "idle";
|
|
61
61
|
stale: "stale";
|
|
62
62
|
disposed: "disposed";
|
|
63
63
|
unconfigured: "unconfigured";
|
|
@@ -27,7 +27,7 @@ export declare class SessionAccountsHost {
|
|
|
27
27
|
private captureIdentity;
|
|
28
28
|
recordRequest(signal?: AbortSignal): void;
|
|
29
29
|
requestBinding(signal?: AbortSignal): CopilotAccountBinding;
|
|
30
|
-
set(agent: SessionOwner, accountId: string | null, revision: number): Promise<void>;
|
|
30
|
+
set(agent: SessionOwner, accountId: string | null, revision: number, observed?: import('./diagnostics-collector.ts').DiagnosticsHandle): Promise<void>;
|
|
31
31
|
}
|
|
32
32
|
export {};
|
|
33
33
|
//# sourceMappingURL=session-accounts-host.d.ts.map
|
|
@@ -4,6 +4,7 @@ import type { GenerateOptions } from '@deepseek-ai/dsh-llm';
|
|
|
4
4
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
5
5
|
import { SessionContinuationTurn } from './session-continuation.ts';
|
|
6
6
|
import type { SessionContinuationView } from './session-continuation-types.ts';
|
|
7
|
+
import type { CompactionContinuationStatus } from './session-continuation-types.ts';
|
|
7
8
|
declare module '@deepseek-ai/cordis' {
|
|
8
9
|
interface Context {
|
|
9
10
|
githubCopilotSessionContinuation: SessionContinuationController;
|
|
@@ -12,6 +13,7 @@ declare module '@deepseek-ai/cordis' {
|
|
|
12
13
|
interface Admission {
|
|
13
14
|
readonly turn: number;
|
|
14
15
|
readonly enabled: boolean;
|
|
16
|
+
readonly persistentEnabled: boolean;
|
|
15
17
|
readonly filter: SessionContinuationTurn;
|
|
16
18
|
step: number;
|
|
17
19
|
signal: AbortSignal;
|
|
@@ -20,7 +22,8 @@ export declare class SessionContinuationController extends TypertRemoteService {
|
|
|
20
22
|
private readonly active;
|
|
21
23
|
private readonly once;
|
|
22
24
|
private readonly ready;
|
|
23
|
-
|
|
25
|
+
private readonly summaryStatus;
|
|
26
|
+
constructor(ctx: Context, active: Map<object, Admission>, once?: Set<object>, ready?: Promise<void>, summaryStatus?: (agent: Agent) => CompactionContinuationStatus | undefined);
|
|
24
27
|
get(agent: Agent): Promise<SessionContinuationView>;
|
|
25
28
|
set(agent: Agent, revision: number, enabled: boolean | null): Promise<SessionContinuationView>;
|
|
26
29
|
authorizeNext(agent: Agent, revision: number, enabled: boolean): Promise<SessionContinuationView>;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const COMPACTION_CONTINUATION = "githubCopilotCompactionLifecycle";
|
|
3
|
+
export declare const CompactionContinuationStatusSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
state: z.ZodEnum<{
|
|
6
|
+
running: "running";
|
|
7
|
+
cancelled: "cancelled";
|
|
8
|
+
failed: "failed";
|
|
9
|
+
completed: "completed";
|
|
10
|
+
blocked: "blocked";
|
|
11
|
+
}>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export type CompactionContinuationStatus = z.infer<typeof CompactionContinuationStatusSchema>;
|
|
14
|
+
export declare const CompactionContinuationLifecycleSchema: z.ZodObject<{
|
|
15
|
+
id: z.ZodNullable<z.ZodString>;
|
|
16
|
+
running: z.ZodBoolean;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
export type CompactionContinuationLifecycle = z.infer<typeof CompactionContinuationLifecycleSchema>;
|
|
2
19
|
export declare const SessionContinuationPreferenceSchema: z.ZodObject<{
|
|
3
20
|
sessionId: z.ZodString;
|
|
4
21
|
version: z.ZodLiteral<1>;
|
|
@@ -30,6 +47,16 @@ export declare const SessionContinuationViewSchema: z.ZodObject<{
|
|
|
30
47
|
session: "session";
|
|
31
48
|
}>>;
|
|
32
49
|
nextTurnAuthorized: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
compaction: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
state: z.ZodEnum<{
|
|
53
|
+
running: "running";
|
|
54
|
+
cancelled: "cancelled";
|
|
55
|
+
failed: "failed";
|
|
56
|
+
completed: "completed";
|
|
57
|
+
blocked: "blocked";
|
|
58
|
+
}>;
|
|
59
|
+
}, z.core.$strict>>;
|
|
33
60
|
}, z.core.$strict>;
|
|
34
61
|
export type SessionContinuationView = z.infer<typeof SessionContinuationViewSchema>;
|
|
35
62
|
//# sourceMappingURL=session-continuation-types.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.123",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"docs/auto-task-routing.md",
|
|
75
75
|
"docs/auto-high-cost.md",
|
|
76
76
|
"docs/evidence-driven-iteration.md",
|
|
77
|
+
"docs/plugin-diagnostics.md",
|
|
77
78
|
"docs/auto-iteration-review.json",
|
|
78
79
|
"scripts/iteration-review.mjs",
|
|
79
80
|
"docs/image-input-compatibility.md",
|
|
@@ -150,7 +151,7 @@
|
|
|
150
151
|
"dependencies": {
|
|
151
152
|
"@earendil-works/pi-ai": "0.87.1",
|
|
152
153
|
"undici": "6.28.1",
|
|
153
|
-
"zod": "
|
|
154
|
+
"zod": "4.6.5"
|
|
154
155
|
},
|
|
155
156
|
"devDependencies": {
|
|
156
157
|
"@deepseek-ai/cordis": "~4.0.4",
|
|
@@ -180,6 +181,9 @@
|
|
|
180
181
|
"@deepseek-ai/dsh-session-format-catalog": "0.2.0-rc.2",
|
|
181
182
|
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
|
|
182
183
|
"@deepseek-ai/dsh-settings": "0.2.0-rc.2",
|
|
184
|
+
"@deepseek-ai/dsh-storage": "0.2.0-rc.2",
|
|
185
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.0-rc.2",
|
|
186
|
+
"@deepseek-ai/dsh-storage-json": "0.2.0-rc.2",
|
|
183
187
|
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
184
188
|
"@deepseek-ai/dsh-tool-web": "0.2.0-rc.2",
|
|
185
189
|
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
//#region lib/types/request-budget.js
|
|
2
|
-
/** The safety allowance matches the pinned native SDK; pressure is a separate opt-in check. */
|
|
3
|
-
const DEFAULT_REQUEST_BUDGET_POLICY = Object.freeze({
|
|
4
|
-
safetyTokens: 4096,
|
|
5
|
-
pressureRatio: .9,
|
|
6
|
-
compactionReasoning: "prefer-low"
|
|
7
|
-
});
|
|
8
|
-
/** Validate deployment policy before applying defaults; unknown keys fail rather than silently drift. */
|
|
9
|
-
function resolveRequestBudgetPolicy(config = {}) {
|
|
10
|
-
const keys = /* @__PURE__ */ new Set([
|
|
11
|
-
"safetyTokens",
|
|
12
|
-
"pressureRatio",
|
|
13
|
-
"compactionReasoning"
|
|
14
|
-
]);
|
|
15
|
-
for (const key of Object.keys(config)) if (!keys.has(key)) throw new Error(`COPILOT_REQUEST_BUDGET_POLICY_INVALID: unknown setting ${key}`);
|
|
16
|
-
const safetyTokens = config.safetyTokens === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens : config.safetyTokens;
|
|
17
|
-
const pressureRatio = config.pressureRatio === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio : config.pressureRatio;
|
|
18
|
-
const compactionReasoning = config.compactionReasoning === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning : config.compactionReasoning;
|
|
19
|
-
if (!Number.isSafeInteger(safetyTokens) || safetyTokens < 0) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: safetyTokens must be a non-negative safe integer");
|
|
20
|
-
if (!Number.isFinite(pressureRatio) || pressureRatio <= 0 || pressureRatio > 1) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: pressureRatio must be greater than zero and at most one");
|
|
21
|
-
if (compactionReasoning !== "prefer-low" && compactionReasoning !== "preserve") throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: unsupported compactionReasoning");
|
|
22
|
-
return Object.freeze({
|
|
23
|
-
safetyTokens,
|
|
24
|
-
pressureRatio,
|
|
25
|
-
compactionReasoning
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function failure(code, message) {
|
|
29
|
-
return Object.freeze({
|
|
30
|
-
ok: false,
|
|
31
|
-
code,
|
|
32
|
-
message: `${code}: ${message}`
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function positiveInteger(value) {
|
|
36
|
-
return Number.isSafeInteger(value) && value > 0;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Reserve output under the combined context and independently enforce the prompt ceiling.
|
|
40
|
-
* `policy` must come from resolveRequestBudgetPolicy; no caller cap or catalog object is changed.
|
|
41
|
-
*/
|
|
42
|
-
function calculateRequestBudget(limits, requestedMaxTokens, policy = DEFAULT_REQUEST_BUDGET_POLICY) {
|
|
43
|
-
const { contextWindow, maxInputTokens, maxTokens } = limits;
|
|
44
|
-
if (!positiveInteger(contextWindow) || !positiveInteger(maxTokens) || maxInputTokens !== void 0 && !positiveInteger(maxInputTokens)) return failure("COPILOT_REQUEST_INVALID_LIMITS", "model token capacities must be positive safe integers");
|
|
45
|
-
if (requestedMaxTokens !== void 0 && !positiveInteger(requestedMaxTokens)) return failure("COPILOT_REQUEST_INVALID_OUTPUT_LIMIT", "request output cap must be a positive safe integer");
|
|
46
|
-
const outputReservation = requestedMaxTokens ?? maxTokens;
|
|
47
|
-
if (outputReservation > maxTokens) return failure("COPILOT_REQUEST_OUTPUT_LIMIT_EXCEEDED", `request output cap ${outputReservation} exceeds model output capacity ${maxTokens}`);
|
|
48
|
-
const contextInputLimit = contextWindow - outputReservation;
|
|
49
|
-
const limitingFactor = maxInputTokens !== void 0 && maxInputTokens <= contextInputLimit ? "prompt" : "context";
|
|
50
|
-
const hardInputLimit = Math.min(maxInputTokens ?? contextInputLimit, contextInputLimit) - policy.safetyTokens;
|
|
51
|
-
if (hardInputLimit <= 0) return failure("COPILOT_REQUEST_NO_INPUT_HEADROOM", "output reservation and safety allowance leave no positive input budget");
|
|
52
|
-
return Object.freeze({
|
|
53
|
-
ok: true,
|
|
54
|
-
budget: Object.freeze({
|
|
55
|
-
contextWindow,
|
|
56
|
-
...maxInputTokens === void 0 ? {} : { maxInputTokens },
|
|
57
|
-
maxOutputTokens: maxTokens,
|
|
58
|
-
outputReservation,
|
|
59
|
-
hardInputLimit,
|
|
60
|
-
pressureInputLimit: Math.floor(hardInputLimit * policy.pressureRatio),
|
|
61
|
-
limitingFactor
|
|
62
|
-
})
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Check an estimated full prompt; estimates are not provider-exact token counts.
|
|
67
|
-
* Enable pressure only for an owned ordinary loop call with a compaction recovery path.
|
|
68
|
-
* Auxiliary and agentless calls use hard admission, including compaction itself.
|
|
69
|
-
*/
|
|
70
|
-
function assessRequestBudget(estimatedInput, budget, pressure = false) {
|
|
71
|
-
if (!Number.isFinite(estimatedInput) || estimatedInput < 0 || estimatedInput > Number.MAX_SAFE_INTEGER) return failure("COPILOT_REQUEST_INVALID_ESTIMATE", "estimated input must be finite, non-negative, and safely representable");
|
|
72
|
-
const input = Math.ceil(estimatedInput);
|
|
73
|
-
if (input > budget.hardInputLimit) return failure(budget.limitingFactor === "prompt" ? "COPILOT_REQUEST_INPUT_LIMIT_EXCEEDED" : "COPILOT_REQUEST_CONTEXT_LIMIT_EXCEEDED", `estimated input ${input} exceeds input budget ${budget.hardInputLimit} with output reservation ${budget.outputReservation}`);
|
|
74
|
-
if (pressure && input > budget.pressureInputLimit) return failure("COPILOT_REQUEST_PRESSURE_EXCEEDED", `estimated input ${input} exceeds proactive compaction budget ${budget.pressureInputLimit}`);
|
|
75
|
-
return Object.freeze({ ok: true });
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Select a low-cost supported effort only for a caller-confirmed compaction request.
|
|
79
|
-
* A supplied effort, including a materialized provider default, wins unchanged; native validation
|
|
80
|
-
* remains authoritative. Unsupported low-cost controls preserve the provider default, never off/none.
|
|
81
|
-
*/
|
|
82
|
-
function selectCompactionReasoning(supportedEfforts, requestedEffort, mode = DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning) {
|
|
83
|
-
if (requestedEffort !== void 0 || mode === "preserve") return requestedEffort;
|
|
84
|
-
return supportedEfforts.find((effort) => effort === "minimal") ?? supportedEfforts.find((effort) => effort === "low");
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
|
-
export { selectCompactionReasoning as a, resolveRequestBudgetPolicy as i, assessRequestBudget as n, calculateRequestBudget as r, DEFAULT_REQUEST_BUDGET_POLICY as t };
|