pi-advisor-flow 0.13.3-dev.3 → 0.13.3-dev.4
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/CHANGELOG.md +2 -0
- package/dist/index.js +0 -4
- package/package.json +2 -2
- package/src/config/schema.ts +8 -8
- package/src/config/types.ts +0 -5
- package/src/follow-up.ts +1 -1
- package/src/herdr.ts +0 -2
- package/src/images.ts +1 -1
- package/src/jev/classifier-key-store.ts +0 -7
- package/src/jev/classifier.ts +4 -4
- package/src/jev/client.ts +1 -3
- package/src/jev/decisions-client.ts +2 -2
- package/src/jev/decisions-response.ts +1 -1
- package/src/jev/key-store.ts +5 -8
- package/src/jev/ledger.ts +3 -3
- package/src/jev/openai-key-store.ts +1 -1
- package/src/jev/questions.ts +0 -4
- package/src/jev/state.ts +1 -1
- package/src/jev/transport.ts +2 -2
- package/src/tools/jev-turn-gate.ts +1 -1
- package/src/tools/register-renderers.ts +3 -6
- package/src/ui/jev-setup-support.ts +1 -1
- package/src/ui/types.ts +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,8 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
13
13
|
### Changed
|
|
14
14
|
|
|
15
15
|
- Updated development dependencies: Pi packages (`pi-ai`, `pi-coding-agent`, `pi-tui`) to 1.3.0 and TypeBox to 1.4.1; the supported peer range stays `^1.0.0`. The codemode composition tests now retry while Pi's process-wide codemode worker limit still counts finished workers as shutting down, matching Pi 1.3.0's admission behavior.
|
|
16
|
+
- Removed dead code surfaced by a Knip audit: the unused `writeJevClassifierKeyCandidate` and `hasRuntimeSecretStore` helpers and the unreferenced `TurnGateQuestions` and `SettingValue` types are gone, about thirty further module-internal symbols are no longer exported, and the turn-gate result renderer now derives its partial details type from the turn-gate contract to reduce type drift.
|
|
17
|
+
- Knip now runs as a CI gate and passes from a clean configuration: the audit wrapper is invoked through `bun run` so Knip resolves it, and redundant ignore patterns were dropped from `knip.json`.
|
|
16
18
|
- Jev screening and turn-gate now use Pi's native classifier registry instead of pi-advisor's duplicate Jev inference clients. Existing screening policy is unchanged; provider authentication stays Pi-managed, and screening classifier input cost uses the selected model's Pi catalog rates.
|
|
17
19
|
- Screening classifier usage is included once with Advisor usage in `ask_advisor` tool totals. Manual and turn-gate classifier usage remains in the local Jev summary.
|
|
18
20
|
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,6 @@ import {
|
|
|
3
3
|
DEFAULT_MAX_BYTES as PI_DEFAULT_MAX_BYTES,
|
|
4
4
|
DEFAULT_MAX_LINES as PI_DEFAULT_MAX_LINES
|
|
5
5
|
} from "@earendil-works/pi-coding-agent";
|
|
6
|
-
import {
|
|
7
|
-
DEFAULT_MAX_BYTES,
|
|
8
|
-
DEFAULT_MAX_LINES
|
|
9
|
-
} from "@earendil-works/pi-coding-agent";
|
|
10
6
|
var DEFAULT_CONTEXT_MAX_CHARS = 15000;
|
|
11
7
|
var MAX_CONTEXT_MAX_CHARS = Number.MAX_SAFE_INTEGER;
|
|
12
8
|
var DEFAULT_ADVISOR_TOOL_RESULT_MAX_LINES = PI_DEFAULT_MAX_LINES;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-advisor-flow",
|
|
3
|
-
"version": "0.13.3-dev.
|
|
3
|
+
"version": "0.13.3-dev.4",
|
|
4
4
|
"description": "Advanced Executor/Advisor flow for Pi, fully configurable and extendable.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"advisor",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"main": "dist/index.js",
|
|
32
32
|
"types": "extensions/index.ts",
|
|
33
33
|
"scripts": {
|
|
34
|
-
"audit": "bun scripts/audit.mjs",
|
|
34
|
+
"audit": "bun run scripts/audit.mjs",
|
|
35
35
|
"bench:decisions": "bun bench/src/cli.ts decisions",
|
|
36
36
|
"bench:evaluate": "bun bench/src/cli.ts evaluate",
|
|
37
37
|
"bench:replay": "bun bench/src/cli.ts replay",
|
package/src/config/schema.ts
CHANGED
|
@@ -124,7 +124,7 @@ export const isValidToolResultMaxLines = (value: unknown): value is number =>
|
|
|
124
124
|
export const isValidToolResultMaxBytes = (value: unknown): value is number =>
|
|
125
125
|
nonNegativeSafeInteger(value);
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
const isValidJevTimeoutMs = (value: unknown): value is number =>
|
|
128
128
|
typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
|
|
129
129
|
|
|
130
130
|
const isValidScoutTimeoutMs = (value: unknown): value is number =>
|
|
@@ -133,19 +133,19 @@ const isValidScoutTimeoutMs = (value: unknown): value is number =>
|
|
|
133
133
|
value >= 1 &&
|
|
134
134
|
value <= MAX_SCOUT_TIMEOUT_MS;
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
const isValidJevDigestMaxChars = (value: unknown): value is number =>
|
|
137
137
|
nonNegativeSafeInteger(value);
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
const isValidJevPricePerMtok = (value: unknown): value is number =>
|
|
140
140
|
typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
const isValidJevSkipConfidence = (value: unknown): value is number =>
|
|
143
143
|
typeof value === "number" &&
|
|
144
144
|
Number.isFinite(value) &&
|
|
145
145
|
value >= 0.5 &&
|
|
146
146
|
value <= 1;
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
const isValidJevNoulMargin = (value: unknown): value is number =>
|
|
149
149
|
typeof value === "number" &&
|
|
150
150
|
Number.isFinite(value) &&
|
|
151
151
|
value >= 0 &&
|
|
@@ -153,15 +153,15 @@ export const isValidJevNoulMargin = (value: unknown): value is number =>
|
|
|
153
153
|
|
|
154
154
|
const JEV_TRANSPORT_NAMES = new Set<string>(JEV_TRANSPORTS);
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
const isValidJevTransport = (value: unknown): value is JevTransport =>
|
|
157
157
|
isString(value) && JEV_TRANSPORT_NAMES.has(value);
|
|
158
158
|
|
|
159
159
|
/** An empty value clears the endpoint; anything else must be a usable Base URL. */
|
|
160
|
-
|
|
160
|
+
const isValidJevBaseUrl = (value: unknown): value is string =>
|
|
161
161
|
isString(value) &&
|
|
162
162
|
(value.trim() === "" || normalizeJevBaseUrl(value).baseUrl !== undefined);
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
const isValidJevKeyProvider = (value: unknown): value is string =>
|
|
165
165
|
isString(value) && (value.trim() === "" || !/\s/u.test(value.trim()));
|
|
166
166
|
|
|
167
167
|
/** One declarative entry per AdvisorConfig key: JSON type, persistence, and
|
package/src/config/types.ts
CHANGED
|
@@ -5,11 +5,6 @@ import {
|
|
|
5
5
|
|
|
6
6
|
import type { GitContextLevel } from "../git.ts";
|
|
7
7
|
|
|
8
|
-
export {
|
|
9
|
-
DEFAULT_MAX_BYTES,
|
|
10
|
-
DEFAULT_MAX_LINES,
|
|
11
|
-
} from "@earendil-works/pi-coding-agent";
|
|
12
|
-
|
|
13
8
|
export const DEFAULT_CONTEXT_MAX_CHARS = 15_000;
|
|
14
9
|
export const MAX_CONTEXT_MAX_CHARS = Number.MAX_SAFE_INTEGER;
|
|
15
10
|
const DEFAULT_ADVISOR_TOOL_RESULT_MAX_LINES = PI_DEFAULT_MAX_LINES;
|
package/src/follow-up.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Message } from "@earendil-works/pi-ai/compat";
|
|
2
2
|
|
|
3
3
|
export const FOLLOW_UP_TTL_MS = 5 * 60 * 1000;
|
|
4
|
-
|
|
4
|
+
const FOLLOW_UP_MAX_DEPTH = 3;
|
|
5
5
|
export const FOLLOW_UP_MAX_TOOL_CALLS = 3;
|
|
6
6
|
|
|
7
7
|
export interface AdvisorFollowUpPayload {
|
package/src/herdr.ts
CHANGED
package/src/images.ts
CHANGED
|
@@ -194,10 +194,3 @@ export const consumeJevClassifierKey = async () => {
|
|
|
194
194
|
|
|
195
195
|
return stored.key;
|
|
196
196
|
};
|
|
197
|
-
|
|
198
|
-
export const writeJevClassifierKeyCandidate = async (key: string) => {
|
|
199
|
-
const previous = await readJevClassifierKey();
|
|
200
|
-
const written = await writeJevClassifierKey(key);
|
|
201
|
-
|
|
202
|
-
return { previous, written };
|
|
203
|
-
};
|
package/src/jev/classifier.ts
CHANGED
|
@@ -16,19 +16,19 @@ import type { JevState } from "./state.ts";
|
|
|
16
16
|
|
|
17
17
|
export type JevQuestionSet = ClassifierContext["questions"];
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
interface JevBooleanPolicyAnswer {
|
|
20
20
|
noul: number;
|
|
21
21
|
type: "noul";
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
interface JevChoicePolicyAnswer {
|
|
25
25
|
choice: string;
|
|
26
26
|
confidence: number;
|
|
27
27
|
probabilities: Record<string, number>;
|
|
28
28
|
type: "choice";
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
type JevPolicyAnswer = JevBooleanPolicyAnswer | JevChoicePolicyAnswer;
|
|
32
32
|
|
|
33
33
|
export interface JevAnswers {
|
|
34
34
|
self_answerable?: JevPolicyAnswer;
|
|
@@ -36,7 +36,7 @@ export interface JevAnswers {
|
|
|
36
36
|
stakes?: JevPolicyAnswer;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
interface JevClassifierUsage {
|
|
40
40
|
cost?: number;
|
|
41
41
|
inputTokens: number;
|
|
42
42
|
outputTokens: number;
|
package/src/jev/client.ts
CHANGED
|
@@ -23,11 +23,9 @@ import { JevFailureError } from "./failure.ts";
|
|
|
23
23
|
import type { JevErrorCategory } from "./failure.ts";
|
|
24
24
|
import type { JevCredentials, JevTransportKind } from "./transport.ts";
|
|
25
25
|
|
|
26
|
-
export type { JevErrorCategory } from "./failure.ts";
|
|
27
|
-
|
|
28
26
|
export { JevFailureError as JevFailure } from "./failure.ts";
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
interface JevUsage {
|
|
31
29
|
cost?: number;
|
|
32
30
|
inputTokens: number;
|
|
33
31
|
outputTokens: number;
|
|
@@ -6,13 +6,13 @@ import { JevFailureError } from "./failure.ts";
|
|
|
6
6
|
export const OPENAI_DECISIONS_ENDPOINT = "https://api.openai.com/v1/decisions";
|
|
7
7
|
export const OPENAI_DECISIONS_MODEL = "gpt-6-luna";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
interface DecisionsPredicateQuestion {
|
|
10
10
|
instructions: string;
|
|
11
11
|
name: string;
|
|
12
12
|
type: "predicate";
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
interface DecisionsScoreLevel {
|
|
16
16
|
description: string;
|
|
17
17
|
label: string;
|
|
18
18
|
}
|
package/src/jev/key-store.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface JevKeyStoreResult {
|
|
|
27
27
|
ok: boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
interface JevSecretEntry {
|
|
31
31
|
name: string;
|
|
32
32
|
service: string;
|
|
33
33
|
}
|
|
@@ -50,10 +50,10 @@ export interface JevKeyStoreDeps {
|
|
|
50
50
|
writeFileStore?: (key: string) => void;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const TYPESAFE_KEY_ENV_VAR = "TYPESAFE_API_KEY";
|
|
54
|
+
const TYPESAFE_KEY_SERVICE = "pi-advisor";
|
|
55
|
+
const TYPESAFE_KEY_NAME = "typesafe-api-key";
|
|
56
|
+
const TYPESAFE_KEY_CONFIG_FIELD = "typesafe_api_key";
|
|
57
57
|
|
|
58
58
|
const KEY_FILE_MODE = 0o600;
|
|
59
59
|
|
|
@@ -70,9 +70,6 @@ const runtimeSecrets = (): JevSecretsLike | undefined => {
|
|
|
70
70
|
return bun.Bun?.secrets;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
/** Whether the current runtime offers a Bun.secrets store. */
|
|
74
|
-
export const hasRuntimeSecretStore = () => runtimeSecrets() !== undefined;
|
|
75
|
-
|
|
76
73
|
const normalizeKey = (value: string | null | undefined): string | undefined =>
|
|
77
74
|
value?.trim() || undefined;
|
|
78
75
|
|
package/src/jev/ledger.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatTokenCount } from "../usage.ts";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface AdvisorJevUsageTotals {
|
|
4
4
|
cost: number;
|
|
5
5
|
inputTokens: number;
|
|
6
6
|
outputTokens: number;
|
|
@@ -8,7 +8,7 @@ export interface AdvisorJevUsageTotals {
|
|
|
8
8
|
knownCostCalls: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
interface AdvisorJevFilterLedger {
|
|
12
12
|
allowed: number;
|
|
13
13
|
failures: number;
|
|
14
14
|
overrides: number;
|
|
@@ -17,7 +17,7 @@ export interface AdvisorJevFilterLedger {
|
|
|
17
17
|
skipped: number;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
interface AdvisorJevGateLedger {
|
|
21
21
|
checks: number;
|
|
22
22
|
consultations: number;
|
|
23
23
|
failures: number;
|
|
@@ -16,7 +16,7 @@ export const OPENAI_DECISIONS_KEY_SERVICE = "pi-advisor";
|
|
|
16
16
|
export const OPENAI_DECISIONS_KEY_NAME = "openai-decisions-api-key";
|
|
17
17
|
const KEY_FILE_MODE = 0o600;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
type OpenAIDecisionsKeySource = "openai-bun-secrets" | "openai-file";
|
|
20
20
|
|
|
21
21
|
export interface OpenAIDecisionsKeyResolution {
|
|
22
22
|
key?: string;
|
package/src/jev/questions.ts
CHANGED
|
@@ -61,10 +61,6 @@ export const nativeScreeningQuestions = {
|
|
|
61
61
|
},
|
|
62
62
|
} satisfies Record<string, ClassifierQuestion>;
|
|
63
63
|
|
|
64
|
-
export interface TurnGateQuestions {
|
|
65
|
-
instructions: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
64
|
export interface ScreeningCriteria {
|
|
69
65
|
noulMargin: number;
|
|
70
66
|
skipConfidence: number;
|
package/src/jev/state.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { recentConversation } from "../conversation.ts";
|
|
|
9
9
|
import { redactAndCapText } from "../redaction.ts";
|
|
10
10
|
|
|
11
11
|
/** Per-field byte cap for executor question and draft sent to Jev. */
|
|
12
|
-
|
|
12
|
+
const JEV_TEXT_CAP_BYTES = 8 * 1024;
|
|
13
13
|
|
|
14
14
|
export interface JevStateInput {
|
|
15
15
|
draft?: string;
|
package/src/jev/transport.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type JevTransportKind =
|
|
|
19
19
|
| "openai-decisions"
|
|
20
20
|
| "typesafe-compatible";
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
type JevCredentialSource =
|
|
23
23
|
| JevKeySource
|
|
24
24
|
| "openai-env"
|
|
25
25
|
| "openai-provider-credential"
|
|
@@ -40,7 +40,7 @@ export interface JevEndpointTarget {
|
|
|
40
40
|
keyProvider?: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
interface JevProviderAuthResult {
|
|
44
44
|
auth: { apiKey?: string };
|
|
45
45
|
source?: string;
|
|
46
46
|
}
|
|
@@ -10,6 +10,7 @@ import { Box, Markdown, Text } from "@earendil-works/pi-tui";
|
|
|
10
10
|
import { getAdvisorSettings } from "../config/state.ts";
|
|
11
11
|
import { isString } from "../content-utils.ts";
|
|
12
12
|
import { formatAdvisorUsage } from "../usage.ts";
|
|
13
|
+
import type { TurnGateResultDetails as TurnGateResultRecord } from "./jev-turn-gate.ts";
|
|
13
14
|
import { adviceForDisplay, renderAdvisorCallBox } from "./render-common.ts";
|
|
14
15
|
import { renderScoutDetails } from "./scout-status.ts";
|
|
15
16
|
import type { GateDecision, ScoutToolDetails } from "./types.ts";
|
|
@@ -18,12 +19,8 @@ interface CallMessageDetails {
|
|
|
18
19
|
question?: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
agentRulesBytes?: number;
|
|
24
|
-
text?: string;
|
|
25
|
-
usage?: unknown;
|
|
26
|
-
}
|
|
22
|
+
// Renderers must tolerate partial details from replayed or older messages.
|
|
23
|
+
type TurnGateResultDetails = Partial<TurnGateResultRecord>;
|
|
27
24
|
|
|
28
25
|
interface LoopResultDetails {
|
|
29
26
|
advisor?: string;
|
|
@@ -207,7 +207,7 @@ export const keyEntryPrompt = (transport: JevTransportKind): string => {
|
|
|
207
207
|
return "Paste a TypeSafe API key";
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
const defaultVerify = async (credentials: JevCredentials) => {
|
|
211
211
|
const client = jevClientFromCredentials(credentials);
|
|
212
212
|
|
|
213
213
|
try {
|
package/src/ui/types.ts
CHANGED
|
@@ -151,7 +151,7 @@ export interface JevProviderSelection {
|
|
|
151
151
|
transport: JevTransport;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
interface JevSetupResult {
|
|
155
155
|
message?: string;
|
|
156
156
|
ok: boolean;
|
|
157
157
|
}
|
|
@@ -235,5 +235,3 @@ export interface TextSettingSubmenuOptions {
|
|
|
235
235
|
title: string;
|
|
236
236
|
tui: RenderRequester;
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
export type SettingValue = string | undefined;
|