pi-spark 0.18.0 → 0.18.1
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/README.md +1 -1
- package/package.json +1 -1
- package/src/features/recap/manager.ts +3 -10
- package/src/features/title/manager.ts +3 -10
- package/src/utils/model.ts +19 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ pi-spark ships with custom editor, footer, and fullscreen rendering, replacing t
|
|
|
37
37
|
pi-spark shows the active provider's credit balance or rate-limit usage in the status line, so you can keep an eye on what's left without leaving the terminal.
|
|
38
38
|
|
|
39
39
|
- Supported providers: DeepSeek, Fireworks, Kimi Code, Moonshot, OpenAI Codex, OpenRouter, and Vercel AI Gateway.
|
|
40
|
-
- Most provider fetching follows [CodexBar](https://github.com/steipete/codexbar). Fireworks is the exception: its balance sits behind an internal gRPC API, reverse-engineered from the `firectl` binary (see [
|
|
40
|
+
- Most provider fetching follows [CodexBar](https://github.com/steipete/codexbar). Fireworks is the exception: its balance sits behind an internal gRPC API, reverse-engineered from the `firectl` binary (see [Reverse-Engineering Fireworks Credits](./docs/reverse-engineering-fireworks-credits.md)).
|
|
41
41
|
|
|
42
42
|

|
|
43
43
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
2
1
|
import { convertToLlm, serializeConversation } from "@earendil-works/pi-coding-agent";
|
|
3
2
|
|
|
4
3
|
import { clearRecapWidget, setRecapLoadingWidget, setRecapTextWidget } from "./widget";
|
|
5
4
|
import { sanitizeText } from "../../utils/format";
|
|
6
|
-
import { resolveModelSettings } from "../../utils/model";
|
|
5
|
+
import { completeBackground, resolveModelSettings } from "../../utils/model";
|
|
7
6
|
|
|
8
7
|
import type { Api, Model, ModelThinkingLevel, SimpleStreamOptions, Usage } from "@earendil-works/pi-ai";
|
|
9
8
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
@@ -85,18 +84,12 @@ export class RecapManager {
|
|
|
85
84
|
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
86
85
|
if (!auth.ok) throw new Error(auth.error);
|
|
87
86
|
|
|
88
|
-
const options: SimpleStreamOptions = {
|
|
89
|
-
maxTokens: MAX_TOKENS,
|
|
90
|
-
// Codex uses the session ID for request routing; without it, background calls may be
|
|
91
|
-
// routed to an unavailable model.
|
|
92
|
-
sessionId: ctx.sessionManager.getSessionId(),
|
|
93
|
-
signal,
|
|
94
|
-
};
|
|
87
|
+
const options: SimpleStreamOptions = { maxTokens: MAX_TOKENS, signal };
|
|
95
88
|
if (auth.apiKey) options.apiKey = auth.apiKey;
|
|
96
89
|
if (auth.headers) options.headers = auth.headers;
|
|
97
90
|
if (thinkingLevel !== "off") options.reasoning = thinkingLevel;
|
|
98
91
|
|
|
99
|
-
const response = await
|
|
92
|
+
const response = await completeBackground(model, {
|
|
100
93
|
systemPrompt: SYSTEM_PROMPT,
|
|
101
94
|
messages: [{
|
|
102
95
|
role: "user",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
2
1
|
import { convertToLlm, serializeConversation } from "@earendil-works/pi-coding-agent";
|
|
3
2
|
|
|
4
3
|
import { sanitizeText } from "../../utils/format";
|
|
5
|
-
import { resolveModelSettings } from "../../utils/model";
|
|
4
|
+
import { completeBackground, resolveModelSettings } from "../../utils/model";
|
|
6
5
|
|
|
7
6
|
import type { Api, Model, ModelThinkingLevel, SimpleStreamOptions, Usage } from "@earendil-works/pi-ai";
|
|
8
7
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
@@ -68,18 +67,12 @@ export class TitleManager {
|
|
|
68
67
|
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
69
68
|
if (!auth.ok) throw new Error(auth.error);
|
|
70
69
|
|
|
71
|
-
const options: SimpleStreamOptions = {
|
|
72
|
-
maxTokens: MAX_TOKENS,
|
|
73
|
-
// Codex uses the session ID for request routing; without it, background calls may be
|
|
74
|
-
// routed to an unavailable model.
|
|
75
|
-
sessionId: ctx.sessionManager.getSessionId(),
|
|
76
|
-
signal,
|
|
77
|
-
};
|
|
70
|
+
const options: SimpleStreamOptions = { maxTokens: MAX_TOKENS, signal };
|
|
78
71
|
if (auth.apiKey) options.apiKey = auth.apiKey;
|
|
79
72
|
if (auth.headers) options.headers = auth.headers;
|
|
80
73
|
if (thinkingLevel !== "off") options.reasoning = thinkingLevel;
|
|
81
74
|
|
|
82
|
-
const response = await
|
|
75
|
+
const response = await completeBackground(model, {
|
|
83
76
|
systemPrompt: SYSTEM_PROMPT,
|
|
84
77
|
messages: [{
|
|
85
78
|
role: "user",
|
package/src/utils/model.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uuidv7 } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { clampThinkingLevel, cleanupSessionResources } from "@earendil-works/pi-ai";
|
|
3
|
+
import { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
2
4
|
|
|
3
5
|
import { formatModel } from "./format";
|
|
4
6
|
|
|
@@ -29,6 +31,22 @@ export function isFreeModel(model: Model<Api>): boolean {
|
|
|
29
31
|
return model.cost.input === 0 && model.cost.output === 0 && model.cost.cacheRead === 0 && model.cost.cacheWrite === 0;
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Complete a one-shot background request, using an isolated session for OpenAI Codex models.
|
|
36
|
+
* See [the investigation](../../docs/background-model-calls-and-openai-codex-sessions.md).
|
|
37
|
+
*/
|
|
38
|
+
export const completeBackground: typeof completeSimple = async (model, context, options) => {
|
|
39
|
+
if (model.api !== "openai-codex-responses") return completeSimple(model, context, options);
|
|
40
|
+
|
|
41
|
+
const sessionId = uuidv7();
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
return await completeSimple(model, context, { ...options, sessionId });
|
|
45
|
+
} finally {
|
|
46
|
+
cleanupSessionResources(sessionId);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
32
50
|
/**
|
|
33
51
|
* Resolve the model and thinking level for a background feature (recap, title, ...).
|
|
34
52
|
*
|