pi-openai-toolkit 0.20.8 → 0.21.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/LICENSE +21 -21
- package/NOTICE +83 -83
- package/README.md +8 -26
- package/README.zh.md +8 -26
- package/config.schema.json +278 -366
- package/docs/configuration.md +294 -310
- package/docs/internals.md +166 -175
- package/package.json +3 -13
- package/src/compact-client.ts +412 -389
- package/src/compaction-errors.ts +96 -0
- package/src/compaction-projection.ts +35 -35
- package/src/config/legacy.ts +519 -717
- package/src/config/migration.ts +103 -100
- package/src/config/notifications.ts +36 -28
- package/src/config/policy.ts +10 -18
- package/src/config/v2.ts +1167 -1380
- package/src/config.ts +310 -319
- package/src/context-management/codex-provider.ts +270 -270
- package/src/context-management/history-notes.ts +357 -357
- package/src/context-management/manual-compact.ts +0 -11
- package/src/context-management/tools.ts +371 -371
- package/src/context-management/types.ts +168 -168
- package/src/context-management/window-manager.ts +801 -801
- package/src/debug.ts +238 -237
- package/src/deferred-tool-carryover.ts +282 -282
- package/src/details-store.ts +151 -151
- package/src/extension-runtime.ts +1662 -1616
- package/src/image-generation/extension.ts +189 -189
- package/src/image-generation/protocol.ts +579 -579
- package/src/image-generation/types.ts +300 -300
- package/src/payload-rewrite.ts +515 -518
- package/src/pi-context-hook.ts +117 -117
- package/src/remote-v2-client.ts +811 -814
- package/src/request-context-cache.ts +155 -155
- package/src/responses-headers.ts +180 -180
- package/src/runtime.ts +865 -832
- package/src/serializer.ts +882 -882
- package/src/supported-environment.ts +27 -27
- package/src/types.ts +565 -648
- package/src/web-search/alpha-client.ts +876 -876
- package/src/web-search/extension.ts +530 -530
- package/src/web-search/payload.ts +299 -299
- package/src/web-search/prompt.ts +60 -60
- package/src/web-search/types.ts +166 -166
- package/tsconfig.check.json +50 -54
- package/src/auto-mode/classifier.ts +0 -161
- package/src/auto-mode/extension.ts +0 -691
- package/src/auto-mode/model-selection-guard.ts +0 -52
- package/src/auto-mode/policy.ts +0 -146
- package/src/auto-mode/prompt.ts +0 -279
- package/src/auto-mode/reviewer.ts +0 -325
- package/src/auto-mode/tool-review-tui.ts +0 -211
- package/src/auto-mode/transcript.ts +0 -135
- package/src/auto-mode/types.ts +0 -137
package/src/auto-mode/types.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import type { AutoModeConfig } from "../types";
|
|
2
|
-
|
|
3
|
-
export const AUTO_MODE_ENTRY_TYPE = "pi-openai-toolkit.auto-mode-decision.v1";
|
|
4
|
-
export const AUTO_MODE_STATUS_KEY = "pi-openai-toolkit:auto-mode";
|
|
5
|
-
export const AUTO_MODE_FLAG = "auto";
|
|
6
|
-
export const AUTO_MODE_COMMAND = "auto";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Built-in tools that change state outside the conversation. Everything else is
|
|
10
|
-
* read-only by default and only reviewed when the user opts in through
|
|
11
|
-
* `autoMode.extraTools` or `gate: "all"`.
|
|
12
|
-
*/
|
|
13
|
-
export const SIDE_EFFECT_TOOLS = ["bash", "write", "edit"] as const;
|
|
14
|
-
|
|
15
|
-
export const MAX_REVIEW_INPUT_CHARS = 8_000;
|
|
16
|
-
export const MAX_REVIEW_INTENT_CHARS = 2_000;
|
|
17
|
-
export const MAX_REVIEW_REASON_CHARS = 600;
|
|
18
|
-
export const MAX_REVIEW_MODEL_KEY_CHARS = 256;
|
|
19
|
-
|
|
20
|
-
/** Budgets for the compact transcript handed to the reviewer. */
|
|
21
|
-
export const MAX_TRANSCRIPT_CHARS = 24_000;
|
|
22
|
-
export const MAX_TRANSCRIPT_TOOL_CHARS = 12_000;
|
|
23
|
-
export const MAX_TRANSCRIPT_ENTRY_CHARS = 2_000;
|
|
24
|
-
export const MAX_TRANSCRIPT_RECENT_ENTRIES = 40;
|
|
25
|
-
export const TRUNCATION_MARKER = "<truncated />";
|
|
26
|
-
|
|
27
|
-
/** Risk of the planned action itself, as scored by the reviewer. */
|
|
28
|
-
export type RiskLevel = "low" | "medium" | "high" | "critical";
|
|
29
|
-
|
|
30
|
-
/** How far the observed conversation actually authorizes that action. */
|
|
31
|
-
export type UserAuthorization = "unknown" | "low" | "medium" | "high";
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Why a review could not be completed. Kept separate from `deny` on purpose: an
|
|
35
|
-
* infrastructure failure must never be reported to the agent as a safety verdict.
|
|
36
|
-
*/
|
|
37
|
-
export type ReviewFailureCause =
|
|
38
|
-
| "not-configured"
|
|
39
|
-
| "timeout"
|
|
40
|
-
| "cancelled"
|
|
41
|
-
| "provider-error"
|
|
42
|
-
| "invalid-output";
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The reviewer's full verdict. Only `outcome` is required from the model; the
|
|
46
|
-
* remaining fields are back-filled by `parseReviewVerdict` so that a terse
|
|
47
|
-
* `{"outcome":"allow"}` answer is still a usable, recordable decision.
|
|
48
|
-
*/
|
|
49
|
-
export type GuardianVerdict = {
|
|
50
|
-
outcome: "allow" | "deny";
|
|
51
|
-
riskLevel: RiskLevel;
|
|
52
|
-
userAuthorization: UserAuthorization;
|
|
53
|
-
rationale: string;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Result of asking the reviewer model about one pending tool call.
|
|
58
|
-
* `unavailable` means the review could not be completed at all; it is never
|
|
59
|
-
* treated as approval.
|
|
60
|
-
*/
|
|
61
|
-
export type ReviewOutcome =
|
|
62
|
-
| {
|
|
63
|
-
kind: "allow";
|
|
64
|
-
verdict: GuardianVerdict;
|
|
65
|
-
reviewerModel: string;
|
|
66
|
-
evidenceRounds: number;
|
|
67
|
-
}
|
|
68
|
-
| {
|
|
69
|
-
kind: "deny";
|
|
70
|
-
verdict: GuardianVerdict;
|
|
71
|
-
reviewerModel: string;
|
|
72
|
-
evidenceRounds: number;
|
|
73
|
-
}
|
|
74
|
-
| { kind: "unavailable"; reason: string; cause: ReviewFailureCause };
|
|
75
|
-
|
|
76
|
-
/** Non-blocking pre-score produced by the trajectory classifier. */
|
|
77
|
-
export type ClassifierRisk = "low" | "high";
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Why the classifier's cached score could or could not satisfy a gated call.
|
|
81
|
-
* Mirrors the deferral reasons the blocking reviewer exists to cover: anything
|
|
82
|
-
* other than `low_risk` falls through to the synchronous review.
|
|
83
|
-
*/
|
|
84
|
-
export type FastDecisionReason =
|
|
85
|
-
| "low_risk"
|
|
86
|
-
| "elevated_risk"
|
|
87
|
-
| "stale_score"
|
|
88
|
-
| "scoring_failure"
|
|
89
|
-
| "missing_score"
|
|
90
|
-
| "authorization_changed"
|
|
91
|
-
| "requires_synchronous_review";
|
|
92
|
-
|
|
93
|
-
export type AutoModeDecisionSource =
|
|
94
|
-
| "reviewer"
|
|
95
|
-
| "classifier"
|
|
96
|
-
| "human"
|
|
97
|
-
| "policy"
|
|
98
|
-
| "circuit-breaker";
|
|
99
|
-
|
|
100
|
-
export type AutoModeDecisionRecord = {
|
|
101
|
-
timestamp: number;
|
|
102
|
-
toolName: string;
|
|
103
|
-
toolCallId: string;
|
|
104
|
-
decision:
|
|
105
|
-
| "allow"
|
|
106
|
-
| "deny"
|
|
107
|
-
| "unavailable-allowed"
|
|
108
|
-
| "unavailable-blocked"
|
|
109
|
-
| "turn-interrupted";
|
|
110
|
-
reason: string;
|
|
111
|
-
reviewerModel?: string;
|
|
112
|
-
source: AutoModeDecisionSource;
|
|
113
|
-
/** Present on reviewer verdicts; omitted for classifier fast paths. */
|
|
114
|
-
riskLevel?: RiskLevel;
|
|
115
|
-
userAuthorization?: UserAuthorization;
|
|
116
|
-
evidenceRounds?: number;
|
|
117
|
-
/** Only present when `source` is `classifier`. */
|
|
118
|
-
fastDecision?: FastDecisionReason;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export type AutoModeModelRef = {
|
|
122
|
-
provider?: string;
|
|
123
|
-
id?: string;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export type AutoModeGateSource = AutoModeConfig["gate"];
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Truncate to a bounded single-line-safe diagnostic. Reviewer reasons and tool
|
|
130
|
-
* arguments both originate from untrusted text, so every persisted copy is capped.
|
|
131
|
-
*/
|
|
132
|
-
export function boundReviewText(value: unknown, maxChars: number): string {
|
|
133
|
-
const text = typeof value === "string" ? value : String(value ?? "");
|
|
134
|
-
const collapsed = text.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "").trim();
|
|
135
|
-
if (collapsed.length <= maxChars) return collapsed;
|
|
136
|
-
return `${collapsed.slice(0, Math.max(0, maxChars - 3))}...`;
|
|
137
|
-
}
|