@oh-my-pi/pi-coding-agent 15.11.4 → 15.11.7
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 +82 -1
- package/dist/cli.js +520 -451
- package/dist/types/cli/bench-cli.d.ts +78 -0
- package/dist/types/cli/usage-cli.d.ts +10 -1
- package/dist/types/commands/bench.d.ts +29 -0
- package/dist/types/commands/usage.d.ts +9 -0
- package/dist/types/config/model-resolver.d.ts +3 -2
- package/dist/types/config/settings-schema.d.ts +125 -3
- package/dist/types/edit/renderer.d.ts +1 -0
- package/dist/types/modes/components/oauth-selector.d.ts +10 -1
- package/dist/types/modes/components/reset-usage-selector.d.ts +12 -0
- package/dist/types/modes/components/session-selector.d.ts +1 -1
- package/dist/types/modes/components/settings-selector.d.ts +8 -1
- package/dist/types/modes/components/snapcompact-shape-preview.d.ts +31 -0
- package/dist/types/modes/components/tool-execution.d.ts +18 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +1 -0
- package/dist/types/modes/interactive-mode.d.ts +10 -0
- package/dist/types/modes/session-observer-registry.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +3 -0
- package/dist/types/modes/setup-wizard/scenes/types.d.ts +10 -1
- package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +3 -0
- package/dist/types/modes/types.d.ts +2 -0
- package/dist/types/modes/utils/context-usage.d.ts +6 -1
- package/dist/types/session/agent-session.d.ts +14 -1
- package/dist/types/session/auth-storage.d.ts +1 -1
- package/dist/types/session/codex-auto-reset.d.ts +107 -0
- package/dist/types/session/snapcompact-inline.d.ts +107 -4
- package/dist/types/slash-commands/helpers/reset-usage.d.ts +27 -0
- package/dist/types/task/render.d.ts +1 -0
- package/dist/types/tools/bash.d.ts +2 -0
- package/dist/types/tools/eval-render.d.ts +1 -0
- package/dist/types/tools/renderers.d.ts +13 -0
- package/dist/types/tools/ssh.d.ts +1 -0
- package/dist/types/tools/todo.d.ts +0 -11
- package/package.json +11 -11
- package/src/cli/bench-cli.ts +437 -0
- package/src/cli/usage-cli.ts +187 -16
- package/src/cli-commands.ts +1 -0
- package/src/commands/bench.ts +42 -0
- package/src/commands/usage.ts +8 -0
- package/src/config/model-registry.ts +52 -5
- package/src/config/model-resolver.ts +36 -5
- package/src/config/settings-schema.ts +148 -3
- package/src/config/settings.ts +9 -0
- package/src/edit/renderer.ts +5 -0
- package/src/hindsight/client.ts +26 -1
- package/src/hindsight/state.ts +6 -2
- package/src/internal-urls/docs-index.generated.ts +2 -2
- package/src/mcp/transports/stdio.ts +81 -7
- package/src/modes/components/oauth-selector.ts +67 -7
- package/src/modes/components/reset-usage-selector.ts +161 -0
- package/src/modes/components/session-selector.ts +8 -2
- package/src/modes/components/settings-selector.ts +89 -47
- package/src/modes/components/snapcompact-shape-preview-doc.md +11 -0
- package/src/modes/components/snapcompact-shape-preview.ts +192 -0
- package/src/modes/components/tool-execution.ts +26 -0
- package/src/modes/components/transcript-container.ts +23 -1
- package/src/modes/controllers/command-controller.ts +24 -1
- package/src/modes/controllers/input-controller.ts +8 -6
- package/src/modes/controllers/selector-controller.ts +72 -2
- package/src/modes/interactive-mode.ts +83 -0
- package/src/modes/session-observer-registry.ts +61 -3
- package/src/modes/setup-wizard/index.ts +1 -0
- package/src/modes/setup-wizard/scenes/glyph.ts +24 -6
- package/src/modes/setup-wizard/scenes/providers.ts +36 -2
- package/src/modes/setup-wizard/scenes/sign-in.ts +10 -1
- package/src/modes/setup-wizard/scenes/theme.ts +28 -1
- package/src/modes/setup-wizard/scenes/types.ts +10 -1
- package/src/modes/setup-wizard/scenes/web-search.ts +22 -6
- package/src/modes/setup-wizard/wizard-overlay.ts +38 -1
- package/src/modes/theme/theme.ts +2 -2
- package/src/modes/types.ts +2 -0
- package/src/modes/utils/context-usage.ts +75 -1
- package/src/prompts/bench.md +7 -0
- package/src/prompts/system/snapcompact-context-frames-note.md +1 -0
- package/src/prompts/system/snapcompact-context-stub.md +1 -0
- package/src/prompts/system/snapcompact-toolresult-note.md +1 -1
- package/src/prompts/tools/browser.md +33 -43
- package/src/prompts/tools/eval.md +27 -50
- package/src/prompts/tools/irc.md +29 -31
- package/src/prompts/tools/read.md +31 -37
- package/src/prompts/tools/todo.md +1 -2
- package/src/sdk.ts +4 -2
- package/src/session/agent-session.ts +136 -6
- package/src/session/auth-storage.ts +3 -0
- package/src/session/codex-auto-reset.ts +190 -0
- package/src/session/snapcompact-inline.ts +404 -75
- package/src/slash-commands/builtin-registry.ts +145 -8
- package/src/slash-commands/helpers/context-report.ts +28 -1
- package/src/slash-commands/helpers/reset-usage.ts +66 -0
- package/src/slash-commands/helpers/usage-report.ts +12 -0
- package/src/task/index.ts +30 -7
- package/src/task/render.ts +34 -19
- package/src/tools/bash.ts +3 -0
- package/src/tools/eval-render.ts +4 -0
- package/src/tools/renderers.ts +13 -0
- package/src/tools/ssh.ts +3 -0
- package/src/tools/todo.ts +8 -128
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import type { InMemorySnapshotStore } from "@oh-my-pi/hashline";
|
|
16
16
|
import { type Agent, type AgentEvent, type AgentMessage, type AgentState, type AgentTool, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
17
17
|
import { type CompactionResult, type ShakeConfig } from "@oh-my-pi/pi-agent-core/compaction";
|
|
18
|
-
import type { AssistantMessage, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, TextContent, ToolChoice, UsageReport } from "@oh-my-pi/pi-ai";
|
|
18
|
+
import type { AssistantMessage, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget, ServiceTier, SimpleStreamOptions, TextContent, ToolChoice, UsageReport } from "@oh-my-pi/pi-ai";
|
|
19
19
|
import { Effort } from "@oh-my-pi/pi-ai";
|
|
20
20
|
import { type AsyncJob, type AsyncJobDeliveryState, AsyncJobManager } from "../async";
|
|
21
21
|
import type { Rule } from "../capability/rule";
|
|
@@ -1052,6 +1052,19 @@ export declare class AgentSession {
|
|
|
1052
1052
|
contextWindow?: number;
|
|
1053
1053
|
}): ContextUsage | undefined;
|
|
1054
1054
|
fetchUsageReports(signal?: AbortSignal): Promise<UsageReport[] | null>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Redeem one saved Codex rate-limit reset for a specific account, injecting
|
|
1057
|
+
* the provider base URL like {@link AgentSession.fetchUsageReports}. Powers
|
|
1058
|
+
* the `/usage reset` command and auto-redeem. Never throws for business
|
|
1059
|
+
* outcomes — inspect the returned `code`.
|
|
1060
|
+
*/
|
|
1061
|
+
redeemResetCredit(target: ResetCreditTarget, signal?: AbortSignal): Promise<ResetCreditRedeemOutcome>;
|
|
1062
|
+
/**
|
|
1063
|
+
* List saved Codex rate-limit resets per stored account, fetched live from
|
|
1064
|
+
* the dedicated credits endpoint (bypasses the usage cache). Powers the
|
|
1065
|
+
* `/usage reset` account selector.
|
|
1066
|
+
*/
|
|
1067
|
+
listResetCredits(signal?: AbortSignal): Promise<ResetCreditAccountStatus[]>;
|
|
1055
1068
|
/**
|
|
1056
1069
|
* Export session to HTML.
|
|
1057
1070
|
* @param outputPath Optional output path (defaults to session directory)
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Re-exports from @oh-my-pi/pi-ai.
|
|
3
3
|
* All credential storage types and the AuthStorage class now live in the ai package.
|
|
4
4
|
*/
|
|
5
|
-
export type { ApiKeyCredential, AuthCredential, AuthCredentialEntry, AuthCredentialStore, AuthStorageData, AuthStorageOptions, CredentialOrigin, CredentialOriginKind, OAuthAccountIdentity, OAuthCredential, SerializedAuthStorage, SnapshotResponse, StoredAuthCredential, } from "@oh-my-pi/pi-ai";
|
|
5
|
+
export type { ApiKeyCredential, AuthCredential, AuthCredentialEntry, AuthCredentialStore, AuthStorageData, AuthStorageOptions, CredentialOrigin, CredentialOriginKind, OAuthAccountIdentity, OAuthCredential, ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget, SerializedAuthStorage, SnapshotResponse, StoredAuthCredential, } from "@oh-my-pi/pi-ai";
|
|
6
6
|
export { AuthBrokerClient, AuthStorage, DEFAULT_SNAPSHOT_CACHE_TTL_MS, REMOTE_REFRESH_SENTINEL, RemoteAuthCredentialStore, readAuthBrokerSnapshotCache, SqliteAuthCredentialStore, writeAuthBrokerSnapshotCache, } from "@oh-my-pi/pi-ai";
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure decision predicate for auto-redeeming a saved OpenAI Codex rate-limit
|
|
3
|
+
* reset, plus the process-wide coordinator that serializes attempts.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS IS REACTIVE-ONLY (never proactive):
|
|
6
|
+
* The only trustworthy "blocked right now" signal is a live 429 /
|
|
7
|
+
* `usage_limit_reached` from a request authenticated as the session's active
|
|
8
|
+
* Codex credential. The session hook calls this predicate from the usage-limit
|
|
9
|
+
* branch of the retry pipeline, *after* free remedies (sibling-account switch)
|
|
10
|
+
* fail and *before* model fallback. A proactive surface (the status-line usage
|
|
11
|
+
* poll) cannot be used: at `used_percent < 100` the account is not actually
|
|
12
|
+
* limited, so redeeming would be a credit-wasting no-op; at exactly 100 the
|
|
13
|
+
* user may be idle, so the freshly-reset weekly window would tick away with
|
|
14
|
+
* nobody working. Saved resets are a scarce, ~monthly, effectively
|
|
15
|
+
* irreversible resource — every gate here is biased to precision over recall:
|
|
16
|
+
* we would rather miss a redeem than waste a credit.
|
|
17
|
+
*
|
|
18
|
+
* THE DECISION-2 TRAP (status MUST NOT be used to find the blocker):
|
|
19
|
+
* `openai-codex.ts` applies the top-level `rate_limit.limit_reached` flag to
|
|
20
|
+
* BOTH the primary (5h) and secondary (weekly) `buildUsageLimit` calls, so when
|
|
21
|
+
* an account is blocked, *both* limit entries carry `status: "exhausted"`
|
|
22
|
+
* regardless of which window is actually at 100%. Only `amount.usedFraction`
|
|
23
|
+
* disambiguates which window is the real blocker. This module therefore keys
|
|
24
|
+
* eligibility off exact limit ids (`openai-codex:primary` /
|
|
25
|
+
* `openai-codex:secondary`) and `usedFraction`, never off `status`.
|
|
26
|
+
*
|
|
27
|
+
* ANTI-WASTE GATES (in evaluation order): the policy must be OFF unless opted
|
|
28
|
+
* in; the active model must be Codex (not Spark — a Spark block lives on a
|
|
29
|
+
* separate meter and it is unknown whether a credit even resets it); a fresh
|
|
30
|
+
* usage report for the active account must confirm `limitReached`; the WEEKLY
|
|
31
|
+
* (secondary) window must be genuinely exhausted — a 5h-only block self-heals
|
|
32
|
+
* within the hour, so a credit spent there buys nothing; the natural reset must be far
|
|
33
|
+
* enough away to justify spending a ~30-day credit yet within one plausible
|
|
34
|
+
* window length; a credit must be verifiably available above the reserve; and
|
|
35
|
+
* the same block episode must not have been attempted already (debounce +
|
|
36
|
+
* per-account cooldown). All of this is pure — no fetches, no IO. The only
|
|
37
|
+
* stateful piece is the {@link CodexAutoRedeemCoordinator} container, whose
|
|
38
|
+
* read-only views are passed in so the predicate itself stays deterministic.
|
|
39
|
+
*/
|
|
40
|
+
import type { OAuthAccountIdentity, ResetCreditTarget, UsageReport } from "@oh-my-pi/pi-ai";
|
|
41
|
+
/** Weekly window counts as exhausted at `usedFraction >= 0.999` (used_percent >= 99.9). */
|
|
42
|
+
export declare const WEEKLY_EXHAUSTED_MIN_FRACTION = 0.999;
|
|
43
|
+
/** A weekly reset can never be more than one window length (7d) away; +1h slack for skew. */
|
|
44
|
+
export declare const MAX_PLAUSIBLE_REMAINING_MS: number;
|
|
45
|
+
/** Report must be no older than the 5-min usage cache TTL plus slack. */
|
|
46
|
+
export declare const REPORT_FRESHNESS_MS: number;
|
|
47
|
+
/** Per-account cooldown that catches blockKey drift across a minute boundary. */
|
|
48
|
+
export declare const ATTEMPT_COOLDOWN_MS = 60000;
|
|
49
|
+
/** Minute bucket for blockKey, absorbing `reset_after_seconds`-derived jitter. */
|
|
50
|
+
export declare const DEBOUNCE_BUCKET_MS = 60000;
|
|
51
|
+
export type CodexAutoRedeemSkipReason = "disabled" | "wrong-provider" | "spark-model" | "no-identity" | "no-report" | "stale-report" | "not-limit-reached" | "weekly-not-exhausted" | "no-reset-time" | "reset-too-soon" | "reset-implausible" | "credits-unknown" | "reserve" | "already-attempted" | "cooldown";
|
|
52
|
+
export interface CodexAutoRedeemInput {
|
|
53
|
+
nowMs: number;
|
|
54
|
+
/** `this.model.provider`. */
|
|
55
|
+
provider: string;
|
|
56
|
+
/** `this.model.id`. */
|
|
57
|
+
modelId: string;
|
|
58
|
+
settings: {
|
|
59
|
+
autoRedeem: boolean;
|
|
60
|
+
minBlockedMinutes: number;
|
|
61
|
+
keepCredits: number;
|
|
62
|
+
};
|
|
63
|
+
/** `getOAuthAccountIdentity("openai-codex", sessionId)`, captured at hook entry before any await. */
|
|
64
|
+
identity: OAuthAccountIdentity | undefined;
|
|
65
|
+
/** `session.fetchUsageReports()` (≤5-min cache). */
|
|
66
|
+
reports: UsageReport[] | null;
|
|
67
|
+
attemptedBlockKeys: ReadonlySet<string>;
|
|
68
|
+
lastAttemptAtByAccount: ReadonlyMap<string, number>;
|
|
69
|
+
}
|
|
70
|
+
export type CodexAutoRedeemDecision = {
|
|
71
|
+
redeem: true;
|
|
72
|
+
target: ResetCreditTarget;
|
|
73
|
+
accountKey: string;
|
|
74
|
+
blockKey: string;
|
|
75
|
+
weeklyResetAtMs: number;
|
|
76
|
+
remainingMs: number;
|
|
77
|
+
availableCount: number;
|
|
78
|
+
} | {
|
|
79
|
+
redeem: false;
|
|
80
|
+
reason: CodexAutoRedeemSkipReason;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Decide whether to auto-redeem a saved Codex reset for the active account.
|
|
84
|
+
*
|
|
85
|
+
* Pure: every gate below is a function of the snapshot inputs only. Order
|
|
86
|
+
* matters — cheapest / most-decisive gates first so the common "not eligible"
|
|
87
|
+
* paths short-circuit before any account/report matching.
|
|
88
|
+
*/
|
|
89
|
+
export declare function evaluateCodexAutoRedeem(input: CodexAutoRedeemInput): CodexAutoRedeemDecision;
|
|
90
|
+
/**
|
|
91
|
+
* Process-wide (NOT per-session) coordinator state. Parallel subagent sessions
|
|
92
|
+
* share the same Codex accounts and must not race a double-spend, so this is a
|
|
93
|
+
* single shared container, not a per-session field.
|
|
94
|
+
*
|
|
95
|
+
* - `attemptedBlockKeys`: one attempt EVER per block episode, regardless of
|
|
96
|
+
* outcome — recorded before calling the consume so exceptions can't re-enter.
|
|
97
|
+
* - `lastAttemptAtByAccount`: per-account cooldown timestamps (epoch ms),
|
|
98
|
+
* catching blockKey drift across a minute boundary.
|
|
99
|
+
* - `inFlightByAccount`: serializes per account — a second session for the same
|
|
100
|
+
* account adopts the in-flight promise instead of starting a second consume.
|
|
101
|
+
*/
|
|
102
|
+
export interface CodexAutoRedeemCoordinator {
|
|
103
|
+
attemptedBlockKeys: Set<string>;
|
|
104
|
+
lastAttemptAtByAccount: Map<string, number>;
|
|
105
|
+
inFlightByAccount: Map<string, Promise<boolean>>;
|
|
106
|
+
}
|
|
107
|
+
export declare const defaultCodexAutoRedeemCoordinator: CodexAutoRedeemCoordinator;
|
|
@@ -1,20 +1,123 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Snapcompact inline imaging: per-request transform that swaps the system
|
|
3
|
-
* prompt and/or large historical tool
|
|
4
|
-
* vision-capable models.
|
|
5
|
-
*
|
|
3
|
+
* prompt, loaded context-file instructions, and/or large historical tool
|
|
4
|
+
* results for dense PNG frames on vision-capable models.
|
|
6
5
|
* Runs inside the agent loop's `transformProviderContext` hook — after the
|
|
7
6
|
* persisted history is converted to the outgoing `Context`, before the
|
|
8
7
|
* provider stream call. It only ever builds NEW message objects/arrays; the
|
|
9
8
|
* input context shares `content` array references with the persisted
|
|
10
9
|
* `SessionMessageEntry` messages, so mutation would leak rendered images
|
|
11
10
|
* into session.jsonl.
|
|
11
|
+
*
|
|
12
|
+
* The swap policy (budget, savings gate, skip rules) lives in
|
|
13
|
+
* `planInlineSwaps`, shared by the transform and the `/context` savings
|
|
14
|
+
* estimate (`estimateInlineSavings`) so the two can never disagree.
|
|
12
15
|
*/
|
|
13
16
|
import type { Context, Model } from "@oh-my-pi/pi-ai";
|
|
17
|
+
import * as snapcompact from "@oh-my-pi/snapcompact";
|
|
18
|
+
export type SnapcompactSystemPromptMode = "none" | "agents-md" | "all";
|
|
14
19
|
export interface SnapcompactInlineOptions {
|
|
15
|
-
renderSystemPrompt:
|
|
20
|
+
renderSystemPrompt: SnapcompactSystemPromptMode;
|
|
16
21
|
renderToolResults: boolean;
|
|
22
|
+
/** Frame variant override; `"auto"`/omitted picks the provider's eval winner. */
|
|
23
|
+
shape?: snapcompact.ShapeVariantName | "auto";
|
|
24
|
+
}
|
|
25
|
+
/** Tool-result swap candidate, in context order. */
|
|
26
|
+
export interface InlineToolResultCandidate {
|
|
27
|
+
/** toolCallId — stable identity for render caching and application. */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Token count of the joined text blocks (0 when empty or image-carrying). */
|
|
30
|
+
textTokens: number;
|
|
31
|
+
/** Frames needed to render the text (0 = empty or below the token floor). */
|
|
32
|
+
frames: number;
|
|
33
|
+
/** Already carries an image (screenshot etc.) — never re-imaged. */
|
|
34
|
+
hasImage: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface InlineSystemPromptCandidate {
|
|
37
|
+
textTokens: number;
|
|
38
|
+
frames: number;
|
|
17
39
|
}
|
|
40
|
+
export interface InlinePlanInput {
|
|
41
|
+
options: SnapcompactInlineOptions;
|
|
42
|
+
shape: snapcompact.Shape;
|
|
43
|
+
/** Provider image-count budget minus images already present in the context. */
|
|
44
|
+
budget: number;
|
|
45
|
+
/** All tool results in context order, INCLUDING the most recent one. */
|
|
46
|
+
toolResults: readonly InlineToolResultCandidate[];
|
|
47
|
+
/** Selected prompt text; undefined when system-prompt imaging is off or empty. */
|
|
48
|
+
systemPrompt: InlineSystemPromptCandidate | undefined;
|
|
49
|
+
/** Whether a user message exists to carry the prompt frames. */
|
|
50
|
+
hasUserMessage: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface InlineSwapPlan {
|
|
53
|
+
/** Tool results to swap, oldest first. */
|
|
54
|
+
toolResults: Array<{
|
|
55
|
+
id: string;
|
|
56
|
+
textTokens: number;
|
|
57
|
+
frames: number;
|
|
58
|
+
}>;
|
|
59
|
+
/** Set when the system prompt should swap to frames (uses leftover budget). */
|
|
60
|
+
systemPrompt: InlineSystemPromptCandidate | undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Decide which content gets swapped for frames. Pure — the same rules drive
|
|
64
|
+
* the provider-request transform and the /context savings estimate.
|
|
65
|
+
*/
|
|
66
|
+
export declare function planInlineSwaps(input: InlinePlanInput): InlineSwapPlan;
|
|
67
|
+
/**
|
|
68
|
+
* Minimal structural view of a history message — both pi-ai `Message`s (the
|
|
69
|
+
* outgoing context) and agent-core `AgentMessage`s (the live session) satisfy
|
|
70
|
+
* it, so the estimator can read session state without conversion.
|
|
71
|
+
*/
|
|
72
|
+
export interface InlineMessageView {
|
|
73
|
+
role: string;
|
|
74
|
+
toolCallId?: string;
|
|
75
|
+
content?: unknown;
|
|
76
|
+
}
|
|
77
|
+
export interface SnapcompactSavingsEstimate {
|
|
78
|
+
/** Frames only ship on models that accept image input. */
|
|
79
|
+
visionCapable: boolean;
|
|
80
|
+
/** Present iff system-prompt imaging is enabled. */
|
|
81
|
+
systemPrompt?: {
|
|
82
|
+
applied: boolean;
|
|
83
|
+
/** Why the prompt stays text when `applied` is false. */
|
|
84
|
+
reason?: "empty" | "margin" | "budget";
|
|
85
|
+
textTokens: number;
|
|
86
|
+
frames: number;
|
|
87
|
+
/** Estimated billed tokens for the frames (0 when there are none). */
|
|
88
|
+
imageTokens: number;
|
|
89
|
+
savedTokens: number;
|
|
90
|
+
scope: Exclude<SnapcompactSystemPromptMode, "none">;
|
|
91
|
+
};
|
|
92
|
+
/** Present iff tool-result imaging is enabled. */
|
|
93
|
+
toolResults?: {
|
|
94
|
+
/** Tool results currently in history. */
|
|
95
|
+
total: number;
|
|
96
|
+
swapped: number;
|
|
97
|
+
/** Text tokens of the swapped results only. */
|
|
98
|
+
textTokens: number;
|
|
99
|
+
frames: number;
|
|
100
|
+
imageTokens: number;
|
|
101
|
+
savedTokens: number;
|
|
102
|
+
};
|
|
103
|
+
/** Net estimated wire savings for the next request. */
|
|
104
|
+
savedTokens: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Estimate what `SnapcompactInlineTransformer.transform` would save on the
|
|
108
|
+
* NEXT request, given the session's live system prompt and message history.
|
|
109
|
+
*
|
|
110
|
+
* Mirrors the transform exactly via `planInlineSwaps`, with one deliberate
|
|
111
|
+
* difference: `hasUserMessage` is assumed true, because the request being
|
|
112
|
+
* estimated is always triggered by a user prompt — even when the current
|
|
113
|
+
* history is still empty.
|
|
114
|
+
*/
|
|
115
|
+
export declare function estimateInlineSavings(input: {
|
|
116
|
+
options: SnapcompactInlineOptions;
|
|
117
|
+
model: Model | undefined;
|
|
118
|
+
systemPrompt: readonly string[];
|
|
119
|
+
messages: readonly InlineMessageView[];
|
|
120
|
+
}): SnapcompactSavingsEstimate;
|
|
18
121
|
/**
|
|
19
122
|
* Stateless with respect to the model (passed per call, so mid-session model
|
|
20
123
|
* switches re-resolve shape and budget); stateful only for the render caches,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the `/usage reset` command (TUI selector + ACP): turn the
|
|
3
|
+
* live per-account reset-credit status into selector rows, and map a redeem
|
|
4
|
+
* outcome code to a human message.
|
|
5
|
+
*/
|
|
6
|
+
import type { ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget } from "../../session/auth-storage";
|
|
7
|
+
export declare const CODEX_PROVIDER_ID = "openai-codex";
|
|
8
|
+
/** One Codex account row for the reset-usage selector. */
|
|
9
|
+
export interface ResetUsageAccount {
|
|
10
|
+
/** Display label (email, else account id). */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Saved resets redeemable for this account right now. */
|
|
13
|
+
availableCount: number;
|
|
14
|
+
/** Identifies the account when redeeming. */
|
|
15
|
+
target: ResetCreditTarget;
|
|
16
|
+
/** Whether this is the session's active Codex account. */
|
|
17
|
+
active: boolean;
|
|
18
|
+
/** Set when this account could not be reached (token/list failure). */
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Map live per-account reset status to selector rows. Sorted with the active
|
|
23
|
+
* account first, then most-credits, then label.
|
|
24
|
+
*/
|
|
25
|
+
export declare function toResetUsageAccounts(statuses: ResetCreditAccountStatus[]): ResetUsageAccount[];
|
|
26
|
+
/** Human-facing summary of a redeem outcome for status lines and ACP output. */
|
|
27
|
+
export declare function describeRedeemOutcome(outcome: ResetCreditRedeemOutcome, label: string): string;
|
|
@@ -124,6 +124,7 @@ export declare function createShellRenderer<TArgs>(config: ShellRendererConfig<T
|
|
|
124
124
|
}, uiTheme: Theme, args?: TArgs): Component;
|
|
125
125
|
mergeCallAndResult: boolean;
|
|
126
126
|
inline: boolean;
|
|
127
|
+
provisionalPendingPreview: boolean;
|
|
127
128
|
};
|
|
128
129
|
export declare const bashToolRenderer: {
|
|
129
130
|
renderCall(args: BashRenderArgs, options: RenderResultOptions, uiTheme: Theme): Component;
|
|
@@ -139,5 +140,6 @@ export declare const bashToolRenderer: {
|
|
|
139
140
|
}, uiTheme: Theme, args?: BashRenderArgs | undefined): Component;
|
|
140
141
|
mergeCallAndResult: boolean;
|
|
141
142
|
inline: boolean;
|
|
143
|
+
provisionalPendingPreview: boolean;
|
|
142
144
|
};
|
|
143
145
|
export {};
|
|
@@ -21,5 +21,18 @@ export type ToolRenderer = {
|
|
|
21
21
|
mergeCallAndResult?: boolean;
|
|
22
22
|
/** Render without background box, inline in the response flow */
|
|
23
23
|
inline?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Collapsed pending preview is provisional — a tail-window or otherwise
|
|
26
|
+
* re-anchored view the result render replaces wholesale (an edit's
|
|
27
|
+
* streamed-diff tail, bash/ssh command caps, eval cells whose outputs
|
|
28
|
+
* interleave under each cell). Its rows must never commit to native
|
|
29
|
+
* scrollback mid-run; see
|
|
30
|
+
* `ToolExecutionComponent.isTranscriptBlockCommitStable`. Absent = the
|
|
31
|
+
* pending preview streams top-anchored append-shaped rows the result
|
|
32
|
+
* render preserves (task context/assignment, write content), which stay
|
|
33
|
+
* commit-eligible so a call taller than the viewport scrolls into history
|
|
34
|
+
* instead of reading as cut off.
|
|
35
|
+
*/
|
|
36
|
+
provisionalPendingPreview?: boolean;
|
|
24
37
|
};
|
|
25
38
|
export declare const toolRenderers: Record<string, ToolRenderer>;
|
|
@@ -9,13 +9,6 @@ export type TodoStatus = "pending" | "in_progress" | "completed" | "abandoned";
|
|
|
9
9
|
export interface TodoItem {
|
|
10
10
|
content: string;
|
|
11
11
|
status: TodoStatus;
|
|
12
|
-
/**
|
|
13
|
-
* Append-only list of freeform notes attached by `op: "note"`.
|
|
14
|
-
* Each element is one note and may itself be multi-line.
|
|
15
|
-
* Rendered as text only when the task is in_progress; otherwise shown as a
|
|
16
|
-
* dim marker indicating the task has notes.
|
|
17
|
-
*/
|
|
18
|
-
notes?: string[];
|
|
19
12
|
}
|
|
20
13
|
export interface TodoPhase {
|
|
21
14
|
name: string;
|
|
@@ -37,7 +30,6 @@ declare const todoSchema: z.ZodObject<{
|
|
|
37
30
|
done: "done";
|
|
38
31
|
drop: "drop";
|
|
39
32
|
init: "init";
|
|
40
|
-
note: "note";
|
|
41
33
|
rm: "rm";
|
|
42
34
|
start: "start";
|
|
43
35
|
view: "view";
|
|
@@ -49,7 +41,6 @@ declare const todoSchema: z.ZodObject<{
|
|
|
49
41
|
task: z.ZodOptional<z.ZodString>;
|
|
50
42
|
phase: z.ZodOptional<z.ZodString>;
|
|
51
43
|
items: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
52
|
-
text: z.ZodOptional<z.ZodString>;
|
|
53
44
|
}, z.core.$strip>>;
|
|
54
45
|
}, z.core.$strip>;
|
|
55
46
|
type TodoParams = z.infer<typeof todoSchema>;
|
|
@@ -111,7 +102,6 @@ export declare class TodoTool implements AgentTool<typeof todoSchema, TodoToolDe
|
|
|
111
102
|
done: "done";
|
|
112
103
|
drop: "drop";
|
|
113
104
|
init: "init";
|
|
114
|
-
note: "note";
|
|
115
105
|
rm: "rm";
|
|
116
106
|
start: "start";
|
|
117
107
|
view: "view";
|
|
@@ -123,7 +113,6 @@ export declare class TodoTool implements AgentTool<typeof todoSchema, TodoToolDe
|
|
|
123
113
|
task: z.ZodOptional<z.ZodString>;
|
|
124
114
|
phase: z.ZodOptional<z.ZodString>;
|
|
125
115
|
items: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
|
-
text: z.ZodOptional<z.ZodString>;
|
|
127
116
|
}, z.core.$strip>>;
|
|
128
117
|
}, z.core.$strip>;
|
|
129
118
|
readonly concurrency = "exclusive";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-coding-agent",
|
|
4
|
-
"version": "15.11.
|
|
4
|
+
"version": "15.11.7",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"@agentclientprotocol/sdk": "0.22.1",
|
|
48
48
|
"@babel/parser": "^7.29.7",
|
|
49
49
|
"@mozilla/readability": "^0.6.0",
|
|
50
|
-
"@oh-my-pi/hashline": "15.11.
|
|
51
|
-
"@oh-my-pi/omp-stats": "15.11.
|
|
52
|
-
"@oh-my-pi/pi-agent-core": "15.11.
|
|
53
|
-
"@oh-my-pi/pi-ai": "15.11.
|
|
54
|
-
"@oh-my-pi/pi-catalog": "15.11.
|
|
55
|
-
"@oh-my-pi/pi-mnemopi": "15.11.
|
|
56
|
-
"@oh-my-pi/pi-natives": "15.11.
|
|
57
|
-
"@oh-my-pi/pi-tui": "15.11.
|
|
58
|
-
"@oh-my-pi/pi-utils": "15.11.
|
|
59
|
-
"@oh-my-pi/snapcompact": "15.11.
|
|
50
|
+
"@oh-my-pi/hashline": "15.11.7",
|
|
51
|
+
"@oh-my-pi/omp-stats": "15.11.7",
|
|
52
|
+
"@oh-my-pi/pi-agent-core": "15.11.7",
|
|
53
|
+
"@oh-my-pi/pi-ai": "15.11.7",
|
|
54
|
+
"@oh-my-pi/pi-catalog": "15.11.7",
|
|
55
|
+
"@oh-my-pi/pi-mnemopi": "15.11.7",
|
|
56
|
+
"@oh-my-pi/pi-natives": "15.11.7",
|
|
57
|
+
"@oh-my-pi/pi-tui": "15.11.7",
|
|
58
|
+
"@oh-my-pi/pi-utils": "15.11.7",
|
|
59
|
+
"@oh-my-pi/snapcompact": "15.11.7",
|
|
60
60
|
"@opentelemetry/api": "^1.9.1",
|
|
61
61
|
"@opentelemetry/context-async-hooks": "^2.7.1",
|
|
62
62
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.218.0",
|