@sparkelf/dsh-plus 0.2.9-alpha.81 → 0.2.9-alpha.82
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 -0
- package/lib/apply-DycMqLJO.js +852 -0
- package/lib/apply.js +1 -1
- package/lib/bin.js +1 -1
- package/lib/types/apply.js +37 -2
- package/package.json +496 -496
- package/patches/responses-reasoning-status.patch +175 -17
|
@@ -5,7 +5,7 @@ index a232a690..ff7e7bf4 100644
|
|
|
5
5
|
@@ -470,6 +470,31 @@
|
|
6
6
|
padding-top: 12px;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
+.settingToggle {
|
|
10
10
|
+ display: flex;
|
|
11
11
|
+ align-items: center;
|
|
@@ -39,9 +39,9 @@ index 6dc2fb3b..e99773b8 100644
|
|
|
39
39
|
--- a/packages/client/ui-settings-models/src/client/ProviderEditor.tsx
|
|
40
40
|
+++ b/packages/client/ui-settings-models/src/client/ProviderEditor.tsx
|
|
41
41
|
@@ -50,6 +50,9 @@ type EditorLayout = 'deepseek' | 'pi-ai' | 'unknown'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
45
|
+/** Leaf path of the curated OpenAI Responses compatibility setting. */
|
|
46
46
|
+const OMIT_REASONING_INPUT_STATUS_PATH = ['responsesCompatibility', 'omitReasoningInputStatus'] as const
|
|
47
47
|
+
|
|
@@ -195,13 +195,22 @@ index 5dec1bda..f596cd47 100644
|
|
|
195
195
|
customBaseUrlInvalid: 'Insira um URL HTTP ou HTTPS válido.',
|
|
196
196
|
customNeedsModels: 'Um provedor personalizado precisa de pelo menos um modelo.',
|
|
197
197
|
diff --git a/packages/llm/llm-pi-ai/src/adapter.ts b/packages/llm/llm-pi-ai/src/adapter.ts
|
|
198
|
-
index f3f9ac00..
|
|
198
|
+
index f3f9ac00..f5ef95a1 100644
|
|
199
199
|
--- a/packages/llm/llm-pi-ai/src/adapter.ts
|
|
200
200
|
+++ b/packages/llm/llm-pi-ai/src/adapter.ts
|
|
201
|
-
@@ -
|
|
201
|
+
@@ -58,7 +58,7 @@ import type {
|
|
202
|
+
} from '@deepseek-ai/dsh-llm'
|
|
203
|
+
import type { AttachmentStore, ImageAttachmentRef } from '@deepseek-ai/dsh-attachment'
|
|
204
|
+
import { idleWatchdog, timeoutOf } from '@deepseek-ai/dsh-timeout'
|
|
205
|
+
-import type { ResolvedPiAiProviderProfile } from './config.ts'
|
|
206
|
+
+import type { PiAiReasoningSummary, ResolvedPiAiProviderProfile } from './config.ts'
|
|
207
|
+
import { requestImageTarget, toPiContext } from './context.ts'
|
|
208
|
+
import { conversationUpdates, createModels, getSupportedThinkingLevels } from './models.ts'
|
|
209
|
+
import { toStreamChunks } from './stream.ts'
|
|
210
|
+
@@ -145,9 +145,85 @@ export interface PiAiAuthInjection {
|
|
202
211
|
authContext: AuthContext
|
|
203
212
|
}
|
|
204
|
-
|
|
213
|
+
|
|
205
214
|
+/** Whether one Responses input item is replayed reasoning with response status metadata. */
|
|
206
215
|
+function hasReasoningInputStatus(item: unknown): boolean {
|
|
207
216
|
+ const inputItem = item as Record<string, unknown>
|
|
@@ -219,26 +228,167 @@ index f3f9ac00..f2dad40f 100644
|
|
|
219
228
|
+ })
|
|
220
229
|
+ return { ...request, input }
|
|
221
230
|
+}
|
|
231
|
+
+
|
|
232
|
+
+/**
|
|
233
|
+
+ * Force one model's `reasoning.summary` to a chosen spelling, or drop it.
|
|
234
|
+
+ *
|
|
235
|
+
+ * pi-ai writes `summary: options?.reasoningSummary || 'auto'` whenever a
|
|
236
|
+
+ * Responses model reasons, so the field leaves even when nothing asked for it.
|
|
237
|
+
+ * A gateway that refuses the field therefore fails every reply from that model
|
|
238
|
+
+ * rather than merely omitting a summary, and only a payload hook can keep the
|
|
239
|
+
+ * field off the wire.
|
|
240
|
+
+ * @param payload - the request body pi-ai built.
|
|
241
|
+
+ * @param summary - the configured spelling, or `omit` to drop the field.
|
|
242
|
+
+ * @returns the adjusted body, or undefined to leave the request untouched.
|
|
243
|
+
+ */
|
|
244
|
+
+function applyReasoningSummary(payload: unknown, summary: PiAiReasoningSummary): unknown {
|
|
245
|
+
+ const request = payload as Record<string, unknown> & { reasoning?: Record<string, unknown> }
|
|
246
|
+
+ if (request.reasoning === undefined) return undefined
|
|
247
|
+
+ if (summary === 'omit') {
|
|
248
|
+
+ const { summary: _summary, ...reasoning } = request.reasoning
|
|
249
|
+
+ return { ...request, reasoning }
|
|
250
|
+
+ }
|
|
251
|
+
+ return { ...request, reasoning: { ...request.reasoning, summary } }
|
|
252
|
+
+}
|
|
253
|
+
+
|
|
254
|
+
+/**
|
|
255
|
+
+ * The payload hook a model needs, if any.
|
|
256
|
+
+ *
|
|
257
|
+
+ * One hook field is a function, so a model needing both adjustments gets a
|
|
258
|
+
+ * composition rather than one silently replacing the other.
|
|
259
|
+
+ * @param profile - the resolved route profile.
|
|
260
|
+
+ * @param model - the model being called, which may pin its own summary.
|
|
261
|
+
+ * @returns the `onPayload` option for this call, or an empty object.
|
|
262
|
+
+ */
|
|
263
|
+
+function payloadOptions(
|
|
264
|
+
+ profile: ResolvedPiAiProviderProfile,
|
|
265
|
+
+ model: Model<Api>,
|
|
266
|
+
+): { onPayload?: (payload: unknown, model: Model<Api>) => unknown } {
|
|
267
|
+
+ const hooks: ((payload: unknown) => unknown)[] = []
|
|
268
|
+
+ if (profile.responsesCompatibility?.omitReasoningInputStatus === true) hooks.push(omitReasoningInputStatus)
|
|
269
|
+
+ const summary = (model as { reasoningSummary?: PiAiReasoningSummary }).reasoningSummary
|
|
270
|
+
+ if (summary !== undefined) hooks.push(payload => applyReasoningSummary(payload, summary))
|
|
271
|
+
+ const [first, ...rest] = hooks
|
|
272
|
+
+ if (first === undefined) return {}
|
|
273
|
+
+ if (rest.length === 0) return { onPayload: first }
|
|
274
|
+
+ return {
|
|
275
|
+
+ onPayload: (payload: unknown): unknown => {
|
|
276
|
+
+ let current = payload
|
|
277
|
+
+ let changed = false
|
|
278
|
+
+ for (const hook of hooks) {
|
|
279
|
+
+ const next = hook(current)
|
|
280
|
+
+ if (next === undefined) continue
|
|
281
|
+
+ current = next
|
|
282
|
+
+ changed = true
|
|
283
|
+
+ }
|
|
284
|
+
+ return changed ? current : undefined
|
|
285
|
+
+ },
|
|
286
|
+
+ }
|
|
287
|
+
+}
|
|
222
288
|
+
|
|
223
289
|
/** Copy profile stream knobs into pi-ai's common option vocabulary. */
|
|
224
290
|
function profileOptions(
|
|
225
291
|
profile: ResolvedPiAiProviderProfile,
|
|
226
|
-
|
|
292
|
+
+ model: Model<Api>,
|
|
293
|
+
reasoning: ModelThinkingLevel | undefined,
|
|
294
|
+
apiKey: string | undefined,
|
|
295
|
+
): SimpleStreamOptions {
|
|
296
|
+
@@ -160,6 +236,7 @@ function profileOptions(
|
|
227
297
|
...profile.transport === undefined ? {} : { transport: profile.transport },
|
|
228
298
|
...profile.timeoutMs === undefined ? {} : { timeoutMs: profile.timeoutMs },
|
|
229
299
|
...profile.websocketConnectTimeoutMs === undefined ? {} : { websocketConnectTimeoutMs: profile.websocketConnectTimeoutMs },
|
|
230
|
-
+ ...profile
|
|
300
|
+
+ ...payloadOptions(profile, model),
|
|
231
301
|
// The agent recovery layer owns visible attempts; one adapter call is one SDK attempt.
|
|
232
302
|
maxRetries: 0,
|
|
233
303
|
}
|
|
304
|
+
@@ -473,7 +550,7 @@ export class PiAiAdapter extends LlmAdapter {
|
|
305
|
+
this.config.onThinkingOmitted?.({ provider: options.provider, model: options.model, count })
|
|
306
|
+
})
|
|
307
|
+
const events = snapshot.models.streamSimple(model, context, {
|
|
308
|
+
- ...profileOptions(profile, reasoning, apiKey),
|
|
309
|
+
+ ...profileOptions(profile, model, reasoning, apiKey),
|
|
310
|
+
...options.temperature === undefined ? {} : { temperature: options.temperature },
|
|
311
|
+
...options.maxTokens === undefined ? {} : { maxTokens: options.maxTokens },
|
|
312
|
+
...options.sessionId === undefined ? {} : { sessionId: String(options.sessionId) },
|
|
313
|
+
diff --git a/packages/llm/llm-pi-ai/src/catalog.ts b/packages/llm/llm-pi-ai/src/catalog.ts
|
|
314
|
+
index b2103095..cd903ab0 100644
|
|
315
|
+
--- a/packages/llm/llm-pi-ai/src/catalog.ts
|
|
316
|
+
+++ b/packages/llm/llm-pi-ai/src/catalog.ts
|
|
317
|
+
@@ -600,6 +600,29 @@ function assertOfferedCompatFields(
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
+/**
|
|
322
|
+
+ * How one model's `reasoning.summary` leaves for an OpenAI Responses upstream.
|
|
323
|
+
+ *
|
|
324
|
+
+ * `auto`, `concise`, and `detailed` are the values the OpenAI Responses schema
|
|
325
|
+
+ * accepts, so naming one pins the field. `omit` drops it instead.
|
|
326
|
+
+ */
|
|
327
|
+
+export type PiAiReasoningSummary = 'auto' | 'concise' | 'detailed' | 'omit'
|
|
328
|
+
+
|
|
329
|
+
+/**
|
|
330
|
+
+ * The `reasoning.summary` spellings a profile may declare. A drift gate like
|
|
331
|
+
+ * the modality and thinking-level ones, so a new upstream spelling fails
|
|
332
|
+
+ * compilation here until it is classified.
|
|
333
|
+
+ */
|
|
334
|
+
+const REASONING_SUMMARY_GATE: Record<PiAiReasoningSummary, true> = {
|
|
335
|
+
+ auto: true,
|
|
336
|
+
+ concise: true,
|
|
337
|
+
+ detailed: true,
|
|
338
|
+
+ omit: true,
|
|
339
|
+
+}
|
|
340
|
+
+
|
|
341
|
+
+/** Every `reasoning.summary` spelling a profile may declare. */
|
|
342
|
+
+export const REASONING_SUMMARIES = Object.keys(REASONING_SUMMARY_GATE) as readonly PiAiReasoningSummary[]
|
|
343
|
+
+
|
|
344
|
+
/** One configured model entry: an id plus the catalog fields it overrides. */
|
|
345
|
+
export interface PiAiModelProfile {
|
|
346
|
+
/** Model id sent to the provider and accepted by {@link GenerateOptions.model}. */
|
|
347
|
+
@@ -637,6 +660,16 @@ export interface PiAiModelProfile {
|
|
348
|
+
reasoningEfforts?: false | PiAiReasoningEfforts
|
|
349
|
+
/** pi-ai wire-compatibility switches for this model, winning over the route's per field; one its protocol does not declare is refused. */
|
|
350
|
+
compat?: PiAiCompatProfile
|
|
351
|
+
+ /**
|
|
352
|
+
+ * How this model's `reasoning.summary` leaves for an OpenAI Responses
|
|
353
|
+
+ * upstream. Absent keeps pi-ai's own default (`auto`).
|
|
354
|
+
+ *
|
|
355
|
+
+ * `omit` is for a gateway that refuses the field outright: pi-ai writes
|
|
356
|
+
+ * `summary: options?.reasoningSummary || 'auto'` whenever a Responses model
|
|
357
|
+
+ * reasons, so without this knob such a gateway fails every reply from that
|
|
358
|
+
+ * model rather than merely losing a summary.
|
|
359
|
+
+ */
|
|
360
|
+
+ reasoningSummary?: PiAiReasoningSummary
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
@@ -957,6 +990,7 @@ export function resolveRouteModels(
|
|
365
|
+
maxTokens,
|
|
366
|
+
...resolveModelReasoning(provider, entry, base),
|
|
367
|
+
...resolveModelCompat(provider, entry, request.compat, base, api),
|
|
368
|
+
+ ...entry.reasoningSummary === undefined ? {} : { reasoningSummary: entry.reasoningSummary },
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const models: Model<Api>[] = []
|
|
234
372
|
diff --git a/packages/llm/llm-pi-ai/src/config.ts b/packages/llm/llm-pi-ai/src/config.ts
|
|
235
|
-
index 9de6c441..
|
|
373
|
+
index 9de6c441..3f918b9b 100644
|
|
236
374
|
--- a/packages/llm/llm-pi-ai/src/config.ts
|
|
237
375
|
+++ b/packages/llm/llm-pi-ai/src/config.ts
|
|
238
|
-
@@ -
|
|
376
|
+
@@ -29,6 +29,7 @@ import {
|
|
377
|
+
MODALITIES,
|
|
378
|
+
PiAiCatalogError,
|
|
379
|
+
resolveRouteModels,
|
|
380
|
+
+ REASONING_SUMMARIES,
|
|
381
|
+
SUPPORTED_THINKING_FORMATS,
|
|
382
|
+
THINKING_LEVELS,
|
|
383
|
+
THINKING_TOKEN_BUDGET_FIELDS,
|
|
384
|
+
@@ -98,9 +99,16 @@ export type {
|
|
385
|
+
PiAiModelOverride,
|
|
386
|
+
PiAiModelProfile,
|
|
387
|
+
PiAiReasoningEfforts,
|
|
388
|
+
+ PiAiReasoningSummary,
|
|
239
389
|
PiAiThinkingFormat,
|
|
240
390
|
} from './catalog.ts'
|
|
241
|
-
|
|
391
|
+
|
|
242
392
|
+/** OpenAI Responses input-item adjustments for compatible gateways. */
|
|
243
393
|
+export interface PiAiResponsesCompatibility {
|
|
244
394
|
+ /** Omit response-only status metadata from replayed reasoning input items. */
|
|
@@ -248,7 +398,7 @@ index 9de6c441..cd0b062e 100644
|
|
|
248
398
|
/** Configuration for one pi-ai provider route; the `providers` dict key IS the route. */
|
|
249
399
|
export interface PiAiProviderProfile {
|
|
250
400
|
/** Credential reference (environment-variable name) resolved per request through `ctx.credentials`. */
|
|
251
|
-
@@ -138,6 +
|
|
401
|
+
@@ -138,6 +146,8 @@ export interface PiAiProviderProfile {
|
|
252
402
|
* refused rather than left looking applied.
|
|
253
403
|
*/
|
|
254
404
|
compat?: PiAiCompatProfile
|
|
@@ -257,10 +407,18 @@ index 9de6c441..cd0b062e 100644
|
|
|
257
407
|
/**
|
|
258
408
|
* Context capacity for a model this route lists that neither the entry nor
|
|
259
409
|
* the installed catalog sizes (default 1,000,000). A guess by construction, so
|
|
260
|
-
@@ -
|
|
410
|
+
@@ -342,6 +352,7 @@ const modelFields = {
|
|
411
|
+
// installed catalog's capability", while `false` disables reasoning.
|
|
412
|
+
reasoningEfforts: z.union([z.const(false), reasoningEfforts]),
|
|
413
|
+
compat: compatProfile,
|
|
414
|
+
+ reasoningSummary: z.union(REASONING_SUMMARIES),
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const modelProfile: z<PiAiModelProfile> = z.object({
|
|
418
|
+
@@ -352,6 +363,10 @@ const modelProfile: z<PiAiModelProfile> = z.object({
|
|
261
419
|
/** A {@link modelProfile} whose id lives in the `modelOverrides` dict key. */
|
|
262
420
|
const modelOverride: z<PiAiModelOverride> = z.object(modelFields)
|
|
263
|
-
|
|
421
|
+
|
|
264
422
|
+const responsesCompatibility: z<PiAiResponsesCompatibility> = z.object({
|
|
265
423
|
+ omitReasoningInputStatus: z.boolean(),
|
|
266
424
|
+})
|
|
@@ -268,7 +426,7 @@ index 9de6c441..cd0b062e 100644
|
|
|
268
426
|
const profile = z.object({
|
|
269
427
|
apiKeyEnv: z.string().role('credential-ref'),
|
|
270
428
|
displayName: z.string(),
|
|
271
|
-
@@ -360,6 +
|
|
429
|
+
@@ -360,6 +375,7 @@ const profile = z.object({
|
|
272
430
|
models: z.array(modelProfile),
|
|
273
431
|
modelOverrides: z.dict(modelOverride),
|
|
274
432
|
compat: compatProfile,
|
|
@@ -276,7 +434,7 @@ index 9de6c441..cd0b062e 100644
|
|
|
276
434
|
defaultContextWindow: z.number().step(1).min(1).default(DEFAULT_CONTEXT_WINDOW),
|
|
277
435
|
defaultMaxTokens: z.number().step(1).min(1).default(DEFAULT_MAX_TOKENS),
|
|
278
436
|
defaultInput: z.array(z.union(MODALITIES)).default([...DEFAULT_INPUT]),
|
|
279
|
-
@@ -457,6 +
|
|
437
|
+
@@ -457,6 +473,11 @@ export function resolveProfiles(
|
|
280
438
|
throw new Error(`llm-pi-ai: provider "${provider}" has an empty displayName`)
|
|
281
439
|
}
|
|
282
440
|
assertValidHeaders(provider, source.headers)
|