pi-openai-toolkit 0.9.0 → 0.11.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/NOTICE +55 -33
- package/README.md +65 -8
- package/README_zh.md +63 -8
- package/extensions/codex-astra.ts +1 -0
- package/package.json +9 -2
- package/src/auto-mode/classifier.ts +165 -0
- package/src/auto-mode/extension.ts +530 -273
- package/src/auto-mode/policy.ts +70 -1
- package/src/auto-mode/prompt.ts +279 -0
- package/src/auto-mode/reviewer.ts +224 -138
- package/src/auto-mode/transcript.ts +133 -0
- package/src/auto-mode/types.ts +85 -6
- package/src/codex-astra/effort-planner.ts +175 -0
- package/src/codex-astra/extension.ts +123 -0
- package/src/compact-client.ts +12 -2
- package/src/config.ts +183 -2
- package/src/remote-v2-client.ts +17 -1
- package/src/responses-headers.ts +42 -1
- package/src/runtime.ts +17 -0
- package/src/types.ts +68 -0
package/src/runtime.ts
CHANGED
|
@@ -54,6 +54,12 @@ export type ResponsesRuntime = {
|
|
|
54
54
|
headers?: ProviderHeaders;
|
|
55
55
|
responsesPath: string;
|
|
56
56
|
responsesUrl: string;
|
|
57
|
+
/**
|
|
58
|
+
* Conversation identity for Codex prompt-cache affinity headers. Synthetic
|
|
59
|
+
* compaction/review requests must present the same id the live transcript
|
|
60
|
+
* requests used or the backend treats them as a new conversation.
|
|
61
|
+
*/
|
|
62
|
+
sessionId?: string;
|
|
57
63
|
currentModel: RuntimeModel;
|
|
58
64
|
};
|
|
59
65
|
|
|
@@ -229,6 +235,15 @@ export function getRuntimeModelDescriptor(model: RuntimeModel | undefined): {
|
|
|
229
235
|
};
|
|
230
236
|
}
|
|
231
237
|
|
|
238
|
+
/** Best-effort conversation id; header emission then simply skips the affinity headers. */
|
|
239
|
+
export function resolveRuntimeSessionId(ctx: ExtensionContext): string | undefined {
|
|
240
|
+
try {
|
|
241
|
+
return ctx.sessionManager.getSessionId();
|
|
242
|
+
} catch {
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
232
247
|
async function resolveNativeCompactionEnvironmentForModel(
|
|
233
248
|
ctx: ExtensionContext,
|
|
234
249
|
currentModel: RuntimeModel | undefined,
|
|
@@ -336,6 +351,7 @@ async function resolveNativeCompactionEnvironmentForModel(
|
|
|
336
351
|
responsesUrl: buildResponsesUrl(baseUrl, descriptor.api),
|
|
337
352
|
compactPath: buildCompactPath(descriptor.api),
|
|
338
353
|
compactUrl: buildCompactUrl(baseUrl, descriptor.api),
|
|
354
|
+
sessionId: resolveRuntimeSessionId(ctx),
|
|
339
355
|
payload: requestPayload,
|
|
340
356
|
currentModel,
|
|
341
357
|
},
|
|
@@ -361,6 +377,7 @@ export async function resolveResponsesEnvironment(
|
|
|
361
377
|
headers: runtime.headers,
|
|
362
378
|
responsesPath: runtime.responsesPath,
|
|
363
379
|
responsesUrl: runtime.responsesUrl,
|
|
380
|
+
sessionId: runtime.sessionId,
|
|
364
381
|
currentModel: runtime.currentModel,
|
|
365
382
|
},
|
|
366
383
|
};
|
package/src/types.ts
CHANGED
|
@@ -97,6 +97,12 @@ export type ImageGenerationConfig = {
|
|
|
97
97
|
enabled: boolean;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
+
export type CodexAstraConfig = {
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
/** Exact provider/model keys that receive the stable-effort `configuration_update` rewrite. */
|
|
103
|
+
models: string[];
|
|
104
|
+
};
|
|
105
|
+
|
|
100
106
|
/** `side-effect` reviews bash/write/edit plus extras; `all` reviews every tool call. */
|
|
101
107
|
export type AutoModeGate = "side-effect" | "all";
|
|
102
108
|
|
|
@@ -111,16 +117,58 @@ export type AutoModeConfig = {
|
|
|
111
117
|
extraTools: string[];
|
|
112
118
|
/** Reviewer deadline in ms; expiry degrades to human confirmation or fail-closed. */
|
|
113
119
|
timeoutMs: number;
|
|
120
|
+
/** Give the reviewer a bounded transcript so it can judge user authorization. */
|
|
121
|
+
transcript: boolean;
|
|
122
|
+
/** Let the reviewer spend read-only tool calls establishing facts before deciding. */
|
|
123
|
+
evidenceTools: boolean;
|
|
124
|
+
maxEvidenceRounds: number;
|
|
125
|
+
/** Non-blocking trajectory pre-scorer that can satisfy ordinary gated calls. */
|
|
126
|
+
classifier: AutoModeClassifierConfig;
|
|
127
|
+
/** End a turn that keeps getting denied instead of negotiating forever. */
|
|
128
|
+
circuitBreaker: AutoModeCircuitBreakerConfig;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type AutoModeClassifierConfig = {
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
/** "provider/model-id"; falls back to `autoMode.reviewerModel` when unset. */
|
|
134
|
+
model?: string;
|
|
135
|
+
timeoutMs: number;
|
|
136
|
+
/** How many tool calls may elapse between scoring and use before a score is stale. */
|
|
137
|
+
maxLag: number;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type AutoModeCircuitBreakerConfig = {
|
|
141
|
+
/** Consecutive reviewer denials in one turn that end the turn. 0 disables. */
|
|
142
|
+
consecutiveDenials: number;
|
|
143
|
+
/** Denials inside `windowSize` reviewed calls that end the turn. 0 disables. */
|
|
144
|
+
recentDenials: number;
|
|
145
|
+
windowSize: number;
|
|
114
146
|
};
|
|
115
147
|
|
|
116
148
|
export const REVIEWER_TIMEOUT_MIN_MS = 1_000;
|
|
117
149
|
export const REVIEWER_TIMEOUT_MAX_MS = 120_000;
|
|
118
150
|
|
|
151
|
+
/** Read-only investigation rounds the reviewer may spend before it must answer. */
|
|
152
|
+
export const EVIDENCE_ROUNDS_MIN = 0;
|
|
153
|
+
export const EVIDENCE_ROUNDS_MAX = 8;
|
|
154
|
+
|
|
155
|
+
export const CLASSIFIER_MAX_LAG_MIN = 0;
|
|
156
|
+
export const CLASSIFIER_MAX_LAG_MAX = 20;
|
|
157
|
+
|
|
158
|
+
export const DEFAULT_CLASSIFIER_TIMEOUT_MS = 15_000;
|
|
159
|
+
|
|
160
|
+
/** Denial counts are small integers; 0 disables the matching trigger. */
|
|
161
|
+
export const BREAKER_LIMIT_MIN = 0;
|
|
162
|
+
export const BREAKER_LIMIT_MAX = 100;
|
|
163
|
+
export const BREAKER_WINDOW_MIN = 1;
|
|
164
|
+
export const BREAKER_WINDOW_MAX = 200;
|
|
165
|
+
|
|
119
166
|
export type ToolkitConfig = {
|
|
120
167
|
compaction: CompactionConfig;
|
|
121
168
|
webSearch: WebSearchConfig;
|
|
122
169
|
imageGeneration: ImageGenerationConfig;
|
|
123
170
|
autoMode: AutoModeConfig;
|
|
171
|
+
codexAstra: CodexAstraConfig;
|
|
124
172
|
};
|
|
125
173
|
|
|
126
174
|
export type LoadedToolkitConfig = {
|
|
@@ -483,6 +531,11 @@ export const DEFAULT_IMAGE_GENERATION_CONFIG: ImageGenerationConfig = {
|
|
|
483
531
|
enabled: false,
|
|
484
532
|
};
|
|
485
533
|
|
|
534
|
+
export const DEFAULT_CODEX_ASTRA_CONFIG: CodexAstraConfig = {
|
|
535
|
+
enabled: false,
|
|
536
|
+
models: [],
|
|
537
|
+
};
|
|
538
|
+
|
|
486
539
|
export const DEFAULT_AUTO_MODE_CONFIG: AutoModeConfig = {
|
|
487
540
|
enabled: true,
|
|
488
541
|
models: [],
|
|
@@ -490,6 +543,20 @@ export const DEFAULT_AUTO_MODE_CONFIG: AutoModeConfig = {
|
|
|
490
543
|
gate: "side-effect",
|
|
491
544
|
extraTools: [],
|
|
492
545
|
timeoutMs: 30_000,
|
|
546
|
+
transcript: true,
|
|
547
|
+
evidenceTools: true,
|
|
548
|
+
maxEvidenceRounds: 3,
|
|
549
|
+
classifier: {
|
|
550
|
+
enabled: false,
|
|
551
|
+
model: undefined,
|
|
552
|
+
timeoutMs: DEFAULT_CLASSIFIER_TIMEOUT_MS,
|
|
553
|
+
maxLag: 2,
|
|
554
|
+
},
|
|
555
|
+
circuitBreaker: {
|
|
556
|
+
consecutiveDenials: 3,
|
|
557
|
+
recentDenials: 10,
|
|
558
|
+
windowSize: 50,
|
|
559
|
+
},
|
|
493
560
|
};
|
|
494
561
|
|
|
495
562
|
export const DEFAULT_TOOLKIT_CONFIG: ToolkitConfig = {
|
|
@@ -497,4 +564,5 @@ export const DEFAULT_TOOLKIT_CONFIG: ToolkitConfig = {
|
|
|
497
564
|
webSearch: DEFAULT_WEB_SEARCH_CONFIG,
|
|
498
565
|
imageGeneration: DEFAULT_IMAGE_GENERATION_CONFIG,
|
|
499
566
|
autoMode: DEFAULT_AUTO_MODE_CONFIG,
|
|
567
|
+
codexAstra: DEFAULT_CODEX_ASTRA_CONFIG,
|
|
500
568
|
};
|