@skydiveai/pi-server 0.1.0-beta.2978 → 0.1.0-beta.3033
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/dist/index.d.mts +6 -0
- package/dist/index.mjs +18 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -248,6 +248,7 @@ declare const modelSpecSchema: z.ZodDiscriminatedUnion<"api", [z.ZodObject<{
|
|
|
248
248
|
api: z.ZodLiteral<"openai-completions">;
|
|
249
249
|
compat: z.ZodOptional<z.ZodObject<{
|
|
250
250
|
supportsReasoningEffort: z.ZodOptional<z.ZodBoolean>;
|
|
251
|
+
supportsStore: z.ZodOptional<z.ZodBoolean>;
|
|
251
252
|
requiresThinkingAsText: z.ZodOptional<z.ZodBoolean>;
|
|
252
253
|
thinkingFormat: z.ZodOptional<z.ZodEnum<["openai", "openrouter", "deepseek", "zai", "qwen", "qwen-chat-template"]>>;
|
|
253
254
|
supportsStrictMode: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -255,6 +256,7 @@ declare const modelSpecSchema: z.ZodDiscriminatedUnion<"api", [z.ZodObject<{
|
|
|
255
256
|
cacheControlFormat: z.ZodOptional<z.ZodLiteral<"anthropic">>;
|
|
256
257
|
}, "strip", z.ZodTypeAny, {
|
|
257
258
|
supportsReasoningEffort?: boolean | undefined;
|
|
259
|
+
supportsStore?: boolean | undefined;
|
|
258
260
|
requiresThinkingAsText?: boolean | undefined;
|
|
259
261
|
thinkingFormat?: "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "zai" | undefined;
|
|
260
262
|
supportsStrictMode?: boolean | undefined;
|
|
@@ -262,6 +264,7 @@ declare const modelSpecSchema: z.ZodDiscriminatedUnion<"api", [z.ZodObject<{
|
|
|
262
264
|
cacheControlFormat?: "anthropic" | undefined;
|
|
263
265
|
}, {
|
|
264
266
|
supportsReasoningEffort?: boolean | undefined;
|
|
267
|
+
supportsStore?: boolean | undefined;
|
|
265
268
|
requiresThinkingAsText?: boolean | undefined;
|
|
266
269
|
thinkingFormat?: "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "zai" | undefined;
|
|
267
270
|
supportsStrictMode?: boolean | undefined;
|
|
@@ -289,6 +292,7 @@ declare const modelSpecSchema: z.ZodDiscriminatedUnion<"api", [z.ZodObject<{
|
|
|
289
292
|
api: "openai-completions";
|
|
290
293
|
compat?: {
|
|
291
294
|
supportsReasoningEffort?: boolean | undefined;
|
|
295
|
+
supportsStore?: boolean | undefined;
|
|
292
296
|
requiresThinkingAsText?: boolean | undefined;
|
|
293
297
|
thinkingFormat?: "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "zai" | undefined;
|
|
294
298
|
supportsStrictMode?: boolean | undefined;
|
|
@@ -316,6 +320,7 @@ declare const modelSpecSchema: z.ZodDiscriminatedUnion<"api", [z.ZodObject<{
|
|
|
316
320
|
api: "openai-completions";
|
|
317
321
|
compat?: {
|
|
318
322
|
supportsReasoningEffort?: boolean | undefined;
|
|
323
|
+
supportsStore?: boolean | undefined;
|
|
319
324
|
requiresThinkingAsText?: boolean | undefined;
|
|
320
325
|
thinkingFormat?: "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "zai" | undefined;
|
|
321
326
|
supportsStrictMode?: boolean | undefined;
|
|
@@ -451,6 +456,7 @@ declare function buildModelFromSpec(spec: ModelSpec): {
|
|
|
451
456
|
api: "openai-completions";
|
|
452
457
|
compat?: {
|
|
453
458
|
supportsReasoningEffort?: boolean | undefined;
|
|
459
|
+
supportsStore?: boolean | undefined;
|
|
454
460
|
requiresThinkingAsText?: boolean | undefined;
|
|
455
461
|
thinkingFormat?: "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "zai" | undefined;
|
|
456
462
|
supportsStrictMode?: boolean | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -741,6 +741,7 @@ const thinkingLevelMapSchema = z.object({
|
|
|
741
741
|
*/
|
|
742
742
|
const openaiCompletionsCompatSchema = z.object({
|
|
743
743
|
supportsReasoningEffort: z.boolean().optional(),
|
|
744
|
+
supportsStore: z.boolean().optional(),
|
|
744
745
|
requiresThinkingAsText: z.boolean().optional(),
|
|
745
746
|
thinkingFormat: z.enum([
|
|
746
747
|
"openai",
|
|
@@ -1803,6 +1804,20 @@ function messageTimestampMs(m) {
|
|
|
1803
1804
|
const ts = m?.timestamp;
|
|
1804
1805
|
return typeof ts === "number" && Number.isFinite(ts) ? ts : null;
|
|
1805
1806
|
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Drop assistant messages recorded as failed model calls (stopReason 'error')
|
|
1809
|
+
* from the session-trailer slice. pi keeps an aborted attempt in the session
|
|
1810
|
+
* when auto-retry re-runs the model call in place, so a recovered turn carries
|
|
1811
|
+
* both the errored attempt and the successful retry. The trailer is only built
|
|
1812
|
+
* on the clean path -- a turn that exhausts its retries fails and never emits
|
|
1813
|
+
* one -- so any stopReason 'error' assistant message in the slice is an
|
|
1814
|
+
* aborted attempt the retry replaced, not a message downstream should join.
|
|
1815
|
+
* A user abort ('aborted') is a cancel, not a retried provider failure, and is
|
|
1816
|
+
* kept, matching the terminal-error capture above.
|
|
1817
|
+
*/
|
|
1818
|
+
function dropAbortedModelAttempts(messages) {
|
|
1819
|
+
return messages.filter((m) => !(m?.role === "assistant" && m.stopReason === "error" && m.errorMessage !== "aborted"));
|
|
1820
|
+
}
|
|
1806
1821
|
function piMessagesToOpenAI(messages) {
|
|
1807
1822
|
const out = [];
|
|
1808
1823
|
for (const m of messages) {
|
|
@@ -2248,7 +2263,8 @@ function runStream$1({ session, sm, prompt, images, sessionId, created, reqStart
|
|
|
2248
2263
|
});
|
|
2249
2264
|
}
|
|
2250
2265
|
function emitSessionMessagesTrailer({ writer, sm, baselineMessageCount, sessionId, created, usage }) {
|
|
2251
|
-
const
|
|
2266
|
+
const all = sm.buildSessionContext().messages;
|
|
2267
|
+
const sessionMessages = piMessagesToOpenAI(dropAbortedModelAttempts(all.slice(baselineMessageCount)));
|
|
2252
2268
|
if (sessionMessages.length === 0 && !usage) return;
|
|
2253
2269
|
const chunk = {
|
|
2254
2270
|
id: sessionId,
|
|
@@ -2371,7 +2387,7 @@ async function runBlocking$1({ session, sm, prompt, images, sessionId, created,
|
|
|
2371
2387
|
};
|
|
2372
2388
|
if (toolCalls.length) message.tool_calls = toolCalls;
|
|
2373
2389
|
const all = sm.buildSessionContext().messages;
|
|
2374
|
-
const sessionMessages = piMessagesToOpenAI(all.slice(baselineMessageCount));
|
|
2390
|
+
const sessionMessages = piMessagesToOpenAI(dropAbortedModelAttempts(all.slice(baselineMessageCount)));
|
|
2375
2391
|
const response = {
|
|
2376
2392
|
id: sessionId,
|
|
2377
2393
|
object: "chat.completion",
|