@toddzheng024/dscode-bundle 0.7.5 → 0.7.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/THIRD_PARTY_NOTICES.md +3 -3
- package/cordis.patch.yml +26 -5
- package/package.json +4 -4
- package/plugins/auto-review/index.mjs +6 -1
- package/plugins/code-review/index.mjs +9 -4
- package/plugins/compaction/tetris.mjs +65 -0
- package/plugins/compaction/threshold.mjs +46 -0
- package/plugins/credentials/index.mjs +2 -2
- package/plugins/dscode/index.mjs +4 -10
- package/plugins/exec/cli.mjs +3 -2
- package/plugins/exec/index.mjs +6 -1
- package/plugins/i18n/messages.mjs +18 -0
- package/plugins/memory/index.mjs +7 -3
- package/plugins/openrouter/adapter.mjs +157 -0
- package/plugins/openrouter/index.mjs +112 -0
- package/plugins/openrouter/models.mjs +151 -0
- package/plugins/openrouter/search.mjs +109 -0
- package/plugins/openrouter/wire.mjs +413 -0
- package/plugins/providers/catalog.mjs +28 -26
- package/plugins/providers/effort.mjs +35 -0
- package/plugins/providers/openrouter-account.mjs +171 -0
- package/plugins/session-cards/index.mjs +5 -1
- package/plugins/session-metrics/balance.mjs +29 -19
- package/plugins/session-metrics/index.mjs +19 -6
- package/plugins/session-metrics/pricing.mjs +45 -14
- package/plugins/session-metrics/view.mjs +1 -1
- package/plugins/tui-tools/doctor.mjs +3 -1
- package/plugins/tui-tools/index.mjs +1 -1
- package/plugins/ultra/policy.mjs +0 -16
- package/presets/dscode/agent.cordis.yml +1 -1
- package/vendor/compaction-basic/index.js +983 -0
- package/vendor/compaction-basic/types/config.d.ts +37 -0
- package/vendor/compaction-basic/types/index.d.ts +84 -0
- package/vendor/compaction-basic/types/region.d.ts +65 -0
- package/vendor/compaction-basic/types/summarizer.d.ts +64 -0
- package/vendor/compaction-basic/types/types.d.ts +73 -0
- package/vendor/deepseek/index.js +1 -1
- package/vendor/subagent/index.js +3 -3
- package/vendor/tui/dscode-providers/catalog.mjs +28 -26
- package/vendor/tui/dscode-providers/effort.mjs +35 -0
- package/vendor/tui/dscode-providers/openrouter-account.mjs +171 -0
- package/vendor/tui/index.mjs +395 -133
- package/vendor/pi-ai/index.js +0 -2702
- package/vendor/pi-ai/types/adapter.d.ts +0 -105
- package/vendor/pi-ai/types/auth.d.ts +0 -60
- package/vendor/pi-ai/types/catalog.d.ts +0 -355
- package/vendor/pi-ai/types/config.d.ts +0 -208
- package/vendor/pi-ai/types/context.d.ts +0 -42
- package/vendor/pi-ai/types/discovery.d.ts +0 -43
- package/vendor/pi-ai/types/index.d.ts +0 -69
- package/vendor/pi-ai/types/login.d.ts +0 -21
- package/vendor/pi-ai/types/provider.d.ts +0 -59
- package/vendor/pi-ai/types/replay.d.ts +0 -63
- package/vendor/pi-ai/types/stream.d.ts +0 -43
- /package/vendor/{pi-ai → compaction-basic}/LICENSE +0 -0
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic pi-ai-backed implementation of the Harness LLM seam.
|
|
3
|
-
*
|
|
4
|
-
* Each resolution produces one **immutable** snapshot — the profiles plus a
|
|
5
|
-
* `Models` collection holding the `Provider` each route built — and an
|
|
6
|
-
* operation captures a whole snapshot before its first `await`. A
|
|
7
|
-
* configuration change builds a *new* collection rather than mutating the one
|
|
8
|
-
* in use, because `Models.streamSimple()` is lazy: it resolves the provider
|
|
9
|
-
* when the stream is first consumed, which is after the credential await, so a
|
|
10
|
-
* mutated collection would let a request that started under one configuration
|
|
11
|
-
* finish under another — or fail with a provider that no longer exists. This is
|
|
12
|
-
* what makes the seam's per-step call freeze (`llm.prepareCall()`) hold all the
|
|
13
|
-
* way down: switching models mid-reply takes effect on the next step, never
|
|
14
|
-
* inside the one in flight.
|
|
15
|
-
*
|
|
16
|
-
* A route naming a credential reference still resolves it through the harness
|
|
17
|
-
* seam and passes it as the request's `apiKey` option, which pi-ai treats as
|
|
18
|
-
* the highest-priority auth override — that is what keeps the fail-loud
|
|
19
|
-
* reference semantics. Everything that override does not cover reaches pi-ai
|
|
20
|
-
* through the collection's own auth: the credential store holds the records a
|
|
21
|
-
* login wrote and a refresh rotates, and the auth context answers the ambient
|
|
22
|
-
* questions a provider asks while resolving. Both are stable across snapshots,
|
|
23
|
-
* so a configuration change rebuilds the collection without forgetting who is
|
|
24
|
-
* signed in.
|
|
25
|
-
*
|
|
26
|
-
* @module dsh-llm-pi-ai/adapter
|
|
27
|
-
*/
|
|
28
|
-
import type { AuthContext, CredentialStore } from '@earendil-works/pi-ai';
|
|
29
|
-
import { LlmAdapter } from '@deepseek-ai/dsh-llm';
|
|
30
|
-
import type { GenerateOptions, ImageAttachmentAccess, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, PreparedAdapterCall, ResolvedRetryPolicy, StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
31
|
-
import type { AttachmentStore, ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
32
|
-
import type { ResolvedPiAiProviderProfile } from './config.ts';
|
|
33
|
-
/** Constructor options for {@link PiAiAdapter}: the two resolution hooks the plugin owns. */
|
|
34
|
-
export interface PiAiAdapterOptions {
|
|
35
|
-
/** Current validated profiles by provider route; called once per operation. */
|
|
36
|
-
profiles: () => ReadonlyMap<string, ResolvedPiAiProviderProfile>;
|
|
37
|
-
/**
|
|
38
|
-
* Resolve the credential for one already-resolved profile; called once per
|
|
39
|
-
* stream call and frozen for that call. `undefined` defers to the route's own
|
|
40
|
-
* pi-ai auth, which for an installed catalog route is its provider-native
|
|
41
|
-
* ambient discovery; the plugin allows that only for a profile naming no
|
|
42
|
-
* credential at all, because a named reference that misses throws `LlmError`
|
|
43
|
-
* `MISSING_CREDENTIAL` rather than falling back.
|
|
44
|
-
*/
|
|
45
|
-
resolveApiKey: (provider: string, profile: ResolvedPiAiProviderProfile) => Promise<string | undefined>;
|
|
46
|
-
/**
|
|
47
|
-
* How every collection this adapter builds resolves auth the request-level
|
|
48
|
-
* `apiKey` override does not cover. Required rather than optional: a
|
|
49
|
-
* collection built without them gets pi-ai's in-memory default store, which
|
|
50
|
-
* is empty at every boot and discarded on every configuration change, so a
|
|
51
|
-
* route whose only method is a login would report itself unconfigured on
|
|
52
|
-
* every request no matter how often the human signed in.
|
|
53
|
-
*/
|
|
54
|
-
auth: PiAiAuthInjection;
|
|
55
|
-
/** Resolve the optional durable attachment service at request time. */
|
|
56
|
-
resolveAttachments?: () => AttachmentStore | undefined;
|
|
57
|
-
/** Bridge one attachment reference into the current model-tool execution world. */
|
|
58
|
-
resolveImageAccess?: (attachments: AttachmentStore, ref: ImageAttachmentRef) => ImageAttachmentAccess | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* Observe one assistant history message degrading to provider-neutral
|
|
61
|
-
* conversion because its stored replay state is unusable by this build.
|
|
62
|
-
*/
|
|
63
|
-
onReplayDegrade?: (detail: {
|
|
64
|
-
provider: string;
|
|
65
|
-
model: string;
|
|
66
|
-
reason: string;
|
|
67
|
-
}) => void;
|
|
68
|
-
}
|
|
69
|
-
/** The two auth injectables a pi-ai collection is built with. */
|
|
70
|
-
export interface PiAiAuthInjection {
|
|
71
|
-
/** Durable storage for credentials pi-ai itself writes: logins, and the refreshes it runs under its own lock. */
|
|
72
|
-
credentials: CredentialStore;
|
|
73
|
-
/** Ambient lookups a provider performs while resolving its own auth. */
|
|
74
|
-
authContext: AuthContext;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* pi-ai-backed multi-provider adapter. Each operation reads the current
|
|
78
|
-
* profiles, so a configuration change reaches the next request without a
|
|
79
|
-
* restart; model descriptors come from the collection those profiles built.
|
|
80
|
-
*/
|
|
81
|
-
export declare class PiAiAdapter extends LlmAdapter {
|
|
82
|
-
private readonly config;
|
|
83
|
-
private snapshot;
|
|
84
|
-
constructor(config: PiAiAdapterOptions);
|
|
85
|
-
/**
|
|
86
|
-
* The snapshot for the current profiles. Resolution memoizes its result, so
|
|
87
|
-
* an unchanged configuration is recognized by identity; a changed one gets a
|
|
88
|
-
* brand-new collection, leaving any snapshot an operation already captured
|
|
89
|
-
* untouched for as long as that operation holds it.
|
|
90
|
-
*/
|
|
91
|
-
private current;
|
|
92
|
-
/** The profile for one route within one snapshot, or the not-owned failure. */
|
|
93
|
-
private profileOf;
|
|
94
|
-
/** The configured descriptor for one exact route/model pair within one snapshot. */
|
|
95
|
-
private modelOf;
|
|
96
|
-
providerInfo(provider: string): LlmProviderInfo;
|
|
97
|
-
providerRetryPolicy(provider: string): ResolvedRetryPolicy | undefined;
|
|
98
|
-
listModels(provider: string): Promise<readonly LlmModelInfo[]>;
|
|
99
|
-
resolveModel(provider: string, model: string, _signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
100
|
-
private modelInfo;
|
|
101
|
-
prepareCall(provider: string, model: string, _signal?: AbortSignal): Promise<PreparedAdapterCall>;
|
|
102
|
-
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
103
|
-
private streamWithSnapshot;
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The three adapters between pi-ai's auth model and the harness credential
|
|
3
|
-
* plane. Every pi-ai-specific concept stays on this side of them: the harness
|
|
4
|
-
* seams they consume — `ctx.credentials` records and `ctx.authorization` flows —
|
|
5
|
-
* name nothing from this library, so another adapter family can arrive with a
|
|
6
|
-
* different auth model and share the same two seams.
|
|
7
|
-
*
|
|
8
|
-
* @module dsh-llm-pi-ai/auth
|
|
9
|
-
*/
|
|
10
|
-
import type { AuthContext, CredentialStore } from '@earendil-works/pi-ai';
|
|
11
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
-
import type { CredentialKey } from '@deepseek-ai/dsh-credentials';
|
|
13
|
-
/**
|
|
14
|
-
* The record scope every credential this adapter family stores is written
|
|
15
|
-
* under. It is the plugin's registered name, which is what tells a later
|
|
16
|
-
* reader — a configuration UI, or a second adapter family serving the same
|
|
17
|
-
* provider name — that this plugin owns the format inside the record.
|
|
18
|
-
*/
|
|
19
|
-
export declare const RECORD_SCOPE = "llm-pi-ai";
|
|
20
|
-
/**
|
|
21
|
-
* The record address for one pi-ai provider id.
|
|
22
|
-
* @param providerId - pi-ai's own provider id, which is also the harness route key.
|
|
23
|
-
* @returns the scoped credential key this adapter family reads and writes.
|
|
24
|
-
*/
|
|
25
|
-
export declare function recordKeyFor(providerId: string): CredentialKey;
|
|
26
|
-
/**
|
|
27
|
-
* A pi-ai `CredentialStore` over the harness credential records.
|
|
28
|
-
*
|
|
29
|
-
* pi-ai runs OAuth refresh *inside* `modify()`, so this store's exclusion has
|
|
30
|
-
* to cover a network round trip rather than a file rename — which is why the
|
|
31
|
-
* record write path takes a wait limit of its own rather than the short one a
|
|
32
|
-
* local write would need.
|
|
33
|
-
*
|
|
34
|
-
* pi-ai asks this store about every provider in the collection, hand-declared
|
|
35
|
-
* routes included, and a route key is an arbitrary settings dict key while a
|
|
36
|
-
* record id is not. An id outside the record grammar can never have stored a
|
|
37
|
-
* record, so reads answer "nothing stored" and a delete has nothing to remove;
|
|
38
|
-
* only `modify` refuses it, because a write that cannot land must not report
|
|
39
|
-
* that it did.
|
|
40
|
-
* @param ctx - the plugin context carrying the optional `ctx.credentials`.
|
|
41
|
-
* @returns the store to hand `createModels()`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function credentialStoreFrom(ctx: Context): CredentialStore;
|
|
44
|
-
/**
|
|
45
|
-
* A pi-ai `AuthContext` over the harness credential plane and the host
|
|
46
|
-
* filesystem.
|
|
47
|
-
*
|
|
48
|
-
* `env()` answers from the credential seam first, so a value a deployment
|
|
49
|
-
* stored through the harness is found by a provider's own ambient discovery —
|
|
50
|
-
* without this, that discovery reads only the process environment and a stored
|
|
51
|
-
* `AWS_ACCESS_KEY_ID` is invisible to it. `fileExists()` answers about the host
|
|
52
|
-
* process's own filesystem rather than the workspace `ctx.fs` seam, because the
|
|
53
|
-
* paths it is asked about (`~/.aws/credentials`, application-default
|
|
54
|
-
* credentials) are facts about where this process runs, not about the project
|
|
55
|
-
* under edit.
|
|
56
|
-
* @param ctx - the plugin context carrying the optional `ctx.credentials`.
|
|
57
|
-
* @returns the auth context to hand `createModels()`.
|
|
58
|
-
*/
|
|
59
|
-
export declare function authContextFrom(ctx: Context): AuthContext;
|
|
60
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Materialization of one provider route's model catalog. The installed pi-ai
|
|
3
|
-
* catalog supplies defaults keyed by model id, and a profile's own model
|
|
4
|
-
* entries override them field by field, so a route naming a catalog provider
|
|
5
|
-
* stays configuration-free while a route pi-ai has never heard of is fully
|
|
6
|
-
* describable from `settings.yaml`.
|
|
7
|
-
*
|
|
8
|
-
* Strict resolution rejects unserviceable models before settings writes.
|
|
9
|
-
* Deferred resolution retains their diagnostics so stored catalog drift does
|
|
10
|
-
* not prevent inspection, repair, or requests to independently valid models.
|
|
11
|
-
*
|
|
12
|
-
* @module dsh-llm-pi-ai/catalog
|
|
13
|
-
*/
|
|
14
|
-
import type { AnthropicMessagesCompat, Api, BedrockCompat, ChatTemplateKwargValue, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, Provider } from '@earendil-works/pi-ai';
|
|
15
|
-
/** One request modality a pi-ai model may accept. */
|
|
16
|
-
export type PiAiModality = Model<Api>['input'][number];
|
|
17
|
-
/** Every request modality a profile may declare. */
|
|
18
|
-
export declare const MODALITIES: readonly PiAiModality[];
|
|
19
|
-
/** Every pi-ai thinking level a profile may declare, in escalation order. */
|
|
20
|
-
export declare const THINKING_LEVELS: readonly ModelThinkingLevel[];
|
|
21
|
-
/** One reasoning-dispatch wire format a profile may name. */
|
|
22
|
-
export type PiAiThinkingFormat = NonNullable<OpenAICompletionsCompat['thinkingFormat']>;
|
|
23
|
-
/** Reasoning-dispatch wire formats a profile may name, most-reached first. */
|
|
24
|
-
export declare const SUPPORTED_THINKING_FORMATS: readonly PiAiThinkingFormat[];
|
|
25
|
-
/** The output-cap field spellings pi-ai accepts. */
|
|
26
|
-
export type PiAiMaxTokensField = NonNullable<OpenAICompletionsCompat['maxTokensField']>;
|
|
27
|
-
/** The output-cap field spellings a profile may name. */
|
|
28
|
-
export declare const MAX_TOKENS_FIELDS: readonly PiAiMaxTokensField[];
|
|
29
|
-
/** The reasoning-budget field spellings pi-ai accepts. */
|
|
30
|
-
export type PiAiThinkingTokenBudgetField = NonNullable<OpenAICompletionsCompat['thinkingTokenBudgetField']>;
|
|
31
|
-
/** The reasoning-budget field spellings a profile may name. */
|
|
32
|
-
export declare const THINKING_TOKEN_BUDGET_FIELDS: readonly PiAiThinkingTokenBudgetField[];
|
|
33
|
-
/** The prompt-cache marker conventions pi-ai accepts. */
|
|
34
|
-
export type PiAiCacheControlFormat = NonNullable<OpenAICompletionsCompat['cacheControlFormat']>;
|
|
35
|
-
/** The prompt-cache marker conventions a profile may name. */
|
|
36
|
-
export declare const CACHE_CONTROL_FORMATS: readonly PiAiCacheControlFormat[];
|
|
37
|
-
/** The request-state placeholders a `chat_template_kwargs` value may name. */
|
|
38
|
-
export type PiAiChatTemplateVar = Extract<ChatTemplateKwargValue, {
|
|
39
|
-
$var: string;
|
|
40
|
-
}>['$var'];
|
|
41
|
-
/** The request-state placeholders a profile may name. */
|
|
42
|
-
export declare const CHAT_TEMPLATE_VARS: readonly PiAiChatTemplateVar[];
|
|
43
|
-
/**
|
|
44
|
-
* The installed catalog provider for one route, when pi-ai ships one.
|
|
45
|
-
* @param provider - provider route key.
|
|
46
|
-
* @returns the catalog provider, or `undefined` for a route pi-ai does not ship.
|
|
47
|
-
*/
|
|
48
|
-
export declare function catalogProvider(provider: string): Provider | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Every provider route the installed pi-ai catalog ships.
|
|
51
|
-
* @returns the catalog provider ids.
|
|
52
|
-
*/
|
|
53
|
-
export declare function catalogProviderIds(): readonly string[];
|
|
54
|
-
/**
|
|
55
|
-
* The installed catalog models for one route, indexed by model id.
|
|
56
|
-
* @param provider - provider route key.
|
|
57
|
-
* @returns catalog models by id; empty for a route pi-ai does not ship.
|
|
58
|
-
*/
|
|
59
|
-
export declare function catalogModels(provider: string): Map<string, Model<Api>>;
|
|
60
|
-
/**
|
|
61
|
-
* Selectable reasoning efforts for one model: each key is a level the model
|
|
62
|
-
* offers (and selectors show), and its value is the wire spelling dispatch
|
|
63
|
-
* sends for it. `off` alone may leave its value empty — "supported, send
|
|
64
|
-
* nothing" — because for most providers not thinking is the parameter's
|
|
65
|
-
* absence; every other declared level must name a wire value. A level absent
|
|
66
|
-
* from the dict is not offered.
|
|
67
|
-
*/
|
|
68
|
-
export type PiAiReasoningEfforts = Partial<Record<ModelThinkingLevel, string | null>>;
|
|
69
|
-
/**
|
|
70
|
-
* Disposition of every `OpenAICompletionsCompat` field. The `Record` key type
|
|
71
|
-
* is a drift gate: a pi-ai upgrade that adds a field fails compilation here
|
|
72
|
-
* until it is classified, so the offer never silently lags the upstream set.
|
|
73
|
-
*/
|
|
74
|
-
declare const COMPLETIONS_COMPAT_GATE: {
|
|
75
|
-
readonly supportsStore: "offer";
|
|
76
|
-
readonly supportsDeveloperRole: "offer";
|
|
77
|
-
readonly supportsReasoningEffort: "offer";
|
|
78
|
-
readonly supportsUsageInStreaming: "offer";
|
|
79
|
-
readonly supportsFinishReason: "offer";
|
|
80
|
-
readonly maxTokensField: "offer";
|
|
81
|
-
readonly requiresToolResultName: "offer";
|
|
82
|
-
readonly requiresAssistantAfterToolResult: "offer";
|
|
83
|
-
readonly requiresThinkingAsText: "offer";
|
|
84
|
-
readonly requiresReasoningContentOnAssistantMessages: "offer";
|
|
85
|
-
readonly thinkingFormat: "offer";
|
|
86
|
-
readonly chatTemplateKwargs: "offer";
|
|
87
|
-
readonly chatTemplateArgs: "offer";
|
|
88
|
-
readonly supportsThinkingTokenBudget: "offer";
|
|
89
|
-
readonly thinkingTokenBudgetField: "offer";
|
|
90
|
-
readonly vllmPriority: "offer";
|
|
91
|
-
readonly supportsStrictMode: "offer";
|
|
92
|
-
readonly cacheControlFormat: "offer";
|
|
93
|
-
readonly supportsLongCacheRetention: "offer";
|
|
94
|
-
readonly openRouterRouting: "withhold";
|
|
95
|
-
readonly vercelGatewayRouting: "withhold";
|
|
96
|
-
readonly zaiToolStream: "withhold";
|
|
97
|
-
readonly supportsOpenAIGrammarTools: "withhold";
|
|
98
|
-
readonly sendSessionAffinityHeaders: "withhold";
|
|
99
|
-
readonly deferredToolsMode: "withhold";
|
|
100
|
-
readonly sessionAffinityFormat: "withhold";
|
|
101
|
-
};
|
|
102
|
-
/** Disposition of every `OpenAIResponsesCompat` field; a drift gate like the one above. */
|
|
103
|
-
declare const RESPONSES_COMPAT_GATE: {
|
|
104
|
-
readonly supportsDeveloperRole: "offer";
|
|
105
|
-
readonly supportsMaxOutputTokens: "offer";
|
|
106
|
-
readonly supportsStrictMode: "offer";
|
|
107
|
-
readonly supportsLongCacheRetention: "offer";
|
|
108
|
-
readonly sessionAffinityFormat: "withhold";
|
|
109
|
-
readonly supportsOpenAIGrammarTools: "withhold";
|
|
110
|
-
readonly supportsAdditionalTools: "withhold";
|
|
111
|
-
readonly supportsToolSearch: "withhold";
|
|
112
|
-
readonly supportsExplicitPromptCacheMode: "withhold";
|
|
113
|
-
};
|
|
114
|
-
/** Disposition of every `AnthropicMessagesCompat` field; a drift gate like the one above. */
|
|
115
|
-
declare const ANTHROPIC_COMPAT_GATE: {
|
|
116
|
-
readonly supportsEagerToolInputStreaming: "offer";
|
|
117
|
-
readonly supportsLongCacheRetention: "offer";
|
|
118
|
-
readonly supportsCacheControlOnTools: "offer";
|
|
119
|
-
readonly supportsTemperature: "offer";
|
|
120
|
-
readonly forceAdaptiveThinking: "offer";
|
|
121
|
-
readonly allowEmptySignature: "offer";
|
|
122
|
-
readonly supportsStrictTools: "offer";
|
|
123
|
-
readonly sendSessionAffinityHeaders: "withhold";
|
|
124
|
-
readonly supportsToolReferences: "withhold";
|
|
125
|
-
readonly supportsMidConvoEffort: "withhold";
|
|
126
|
-
readonly allowedFallbackModels: "withhold";
|
|
127
|
-
};
|
|
128
|
-
/** Disposition of every `BedrockCompat` field; a drift gate like the one above. */
|
|
129
|
-
declare const BEDROCK_COMPAT_GATE: {
|
|
130
|
-
readonly supportsStrictMode: "offer";
|
|
131
|
-
};
|
|
132
|
-
/** The field names one gate offers. */
|
|
133
|
-
type OfferedIn<G> = {
|
|
134
|
-
[K in keyof G]: G[K] extends 'offer' ? K : never;
|
|
135
|
-
}[keyof G];
|
|
136
|
-
/** Every compat field name a profile may set, on whichever protocol takes it. */
|
|
137
|
-
type OfferedCompatField = OfferedIn<typeof COMPLETIONS_COMPAT_GATE> | OfferedIn<typeof RESPONSES_COMPAT_GATE> | OfferedIn<typeof ANTHROPIC_COMPAT_GATE> | OfferedIn<typeof BEDROCK_COMPAT_GATE>;
|
|
138
|
-
/**
|
|
139
|
-
* pi-ai wire-compatibility switches, set on the route (its models' default) or
|
|
140
|
-
* per model (winning over the route, field by field).
|
|
141
|
-
*
|
|
142
|
-
* pi-ai decides each of these from the provider id and baseURL when no layer
|
|
143
|
-
* sets it, and a private gateway's URL says nothing: for an endpoint it does
|
|
144
|
-
* not recognize the detection answers as though it were OpenAI itself, which
|
|
145
|
-
* is wrong for most OpenAI-compatible gateways. So every field here is one a
|
|
146
|
-
* deployment must be able to state because nothing can infer it, while the
|
|
147
|
-
* fields pi-ai's catalog sets for a named vendor stay withheld.
|
|
148
|
-
*
|
|
149
|
-
* A field belongs to the protocols whose upstream compat type declares it: a
|
|
150
|
-
* model-level switch its protocol does not take fails resolution, and a
|
|
151
|
-
* route-level one skips past models it cannot fit. "The three Responses
|
|
152
|
-
* protocols" below means `openai-responses`, `azure-openai-responses`, and
|
|
153
|
-
* `openai-codex-responses`, which pi-ai gives one shared compat type, so a
|
|
154
|
-
* switch settable on one is settable on all three.
|
|
155
|
-
*/
|
|
156
|
-
export interface PiAiCompatProfile {
|
|
157
|
-
/** Whether the endpoint accepts `store`; `openai-completions`. */
|
|
158
|
-
supportsStore?: boolean;
|
|
159
|
-
/**
|
|
160
|
-
* Whether the endpoint accepts the `developer` role for the system prompt,
|
|
161
|
-
* which pi-ai sends only to a reasoning model; `false` keeps `system`.
|
|
162
|
-
* `openai-completions` and the three Responses protocols.
|
|
163
|
-
*/
|
|
164
|
-
supportsDeveloperRole?: boolean;
|
|
165
|
-
/** Whether the endpoint accepts `reasoning_effort`; `openai-completions`. */
|
|
166
|
-
supportsReasoningEffort?: boolean;
|
|
167
|
-
/** Whether the endpoint accepts `stream_options: {include_usage: true}`; `openai-completions`. */
|
|
168
|
-
supportsUsageInStreaming?: boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Whether streams include `finish_reason`; `false` lets pi-ai infer the
|
|
171
|
-
* terminal reason when the stream ends; `openai-completions`.
|
|
172
|
-
*/
|
|
173
|
-
supportsFinishReason?: boolean;
|
|
174
|
-
/** Which output-cap field the endpoint reads; `openai-completions`. */
|
|
175
|
-
maxTokensField?: NonNullable<OpenAICompletionsCompat['maxTokensField']>;
|
|
176
|
-
/** Whether tool results must carry `name`; `openai-completions`. */
|
|
177
|
-
requiresToolResultName?: boolean;
|
|
178
|
-
/** Whether a user message after tool results needs an assistant message between; `openai-completions`. */
|
|
179
|
-
requiresAssistantAfterToolResult?: boolean;
|
|
180
|
-
/** Whether thinking blocks must travel as text in `<thinking>` delimiters; `openai-completions`. */
|
|
181
|
-
requiresThinkingAsText?: boolean;
|
|
182
|
-
/** Whether replayed assistant messages need an empty `reasoning_content` while reasoning is on; `openai-completions`. */
|
|
183
|
-
requiresReasoningContentOnAssistantMessages?: boolean;
|
|
184
|
-
/** Reasoning parameter format the endpoint expects; `openai-completions`. */
|
|
185
|
-
thinkingFormat?: PiAiThinkingFormat;
|
|
186
|
-
/**
|
|
187
|
-
* Kwargs sent as `chat_template_kwargs`, which pi-ai reads only under the
|
|
188
|
-
* two `chat-template` thinking formats; `openai-completions`. Nothing checks
|
|
189
|
-
* that pairing: the format in force may come from the installed catalog
|
|
190
|
-
* entry or from pi-ai's own baseURL detection, neither of which resolution
|
|
191
|
-
* can read, so kwargs set beside another format are sent nowhere.
|
|
192
|
-
*/
|
|
193
|
-
chatTemplateKwargs?: NonNullable<OpenAICompletionsCompat['chatTemplateKwargs']>;
|
|
194
|
-
/** Arguments sent as `chat_template_args` under the `baseten` thinking format; `openai-completions`. */
|
|
195
|
-
chatTemplateArgs?: NonNullable<OpenAICompletionsCompat['chatTemplateArgs']>;
|
|
196
|
-
/** Alias for `thinkingTokenBudgetField: "thinking_token_budget"`; an explicit field wins. `openai-completions`. */
|
|
197
|
-
supportsThinkingTokenBudget?: boolean;
|
|
198
|
-
/** Request field carrying the reasoning budget from `thinkingBudgets`; omitted unless configured. `openai-completions`. */
|
|
199
|
-
thinkingTokenBudgetField?: PiAiThinkingTokenBudgetField;
|
|
200
|
-
/** vLLM scheduler `priority`; lower runs earlier, and the server must enable priority scheduling. Omitted unless configured. */
|
|
201
|
-
vllmPriority?: number;
|
|
202
|
-
/** Whether `openai-responses` accepts `max_output_tokens`; `false` omits it. Azure and Codex ignore this shared compat field. */
|
|
203
|
-
supportsMaxOutputTokens?: boolean;
|
|
204
|
-
/**
|
|
205
|
-
* Whether the endpoint accepts `strict` in tool definitions;
|
|
206
|
-
* `openai-completions`, the three Responses protocols, `bedrock-converse-stream`.
|
|
207
|
-
*/
|
|
208
|
-
supportsStrictMode?: boolean;
|
|
209
|
-
/** Prompt-cache marker convention; `openai-completions`. */
|
|
210
|
-
cacheControlFormat?: NonNullable<OpenAICompletionsCompat['cacheControlFormat']>;
|
|
211
|
-
/**
|
|
212
|
-
* Whether the endpoint accepts long prompt-cache retention;
|
|
213
|
-
* `openai-completions`, the three Responses protocols, `anthropic-messages`.
|
|
214
|
-
*/
|
|
215
|
-
supportsLongCacheRetention?: boolean;
|
|
216
|
-
/** Whether the endpoint accepts per-tool `eager_input_streaming`; `anthropic-messages`. */
|
|
217
|
-
supportsEagerToolInputStreaming?: boolean;
|
|
218
|
-
/** Whether the endpoint accepts `cache_control` on tool definitions; `anthropic-messages`. */
|
|
219
|
-
supportsCacheControlOnTools?: boolean;
|
|
220
|
-
/** Whether the endpoint accepts the `temperature` request field; `anthropic-messages`. */
|
|
221
|
-
supportsTemperature?: boolean;
|
|
222
|
-
/** Whether to force adaptive thinking regardless of model id; `anthropic-messages`. */
|
|
223
|
-
forceAdaptiveThinking?: boolean;
|
|
224
|
-
/** Whether to replay an empty thinking signature instead of converting thinking to text; `anthropic-messages`. */
|
|
225
|
-
allowEmptySignature?: boolean;
|
|
226
|
-
/** Whether the endpoint accepts Anthropic strict tool schemas; `anthropic-messages`. */
|
|
227
|
-
supportsStrictTools?: boolean;
|
|
228
|
-
}
|
|
229
|
-
/** Compile-time constraint that `T` is `never`. */
|
|
230
|
-
type AssertNever<T extends never> = T;
|
|
231
|
-
/**
|
|
232
|
-
* Proof that every documented field is one a gate offers. A field the profile
|
|
233
|
-
* declares past the gates fails compilation with its own name in the error.
|
|
234
|
-
*/
|
|
235
|
-
export type EveryProfileFieldIsOffered = AssertNever<Exclude<keyof PiAiCompatProfile, OfferedCompatField>>;
|
|
236
|
-
/**
|
|
237
|
-
* Proof that every offered field is documented. A gate entry flipped to
|
|
238
|
-
* `offer` without a profile field fails compilation with its own name in the
|
|
239
|
-
* error, which is the half a schema alone cannot catch.
|
|
240
|
-
*/
|
|
241
|
-
export type EveryOfferedFieldIsDocumented = AssertNever<Exclude<OfferedCompatField, keyof PiAiCompatProfile>>;
|
|
242
|
-
/** Compile-time constraint that `T` is `true`. */
|
|
243
|
-
type AssertTrue<T extends true> = T;
|
|
244
|
-
/** Every compat type a gate classifies, merged so one `Pick` reaches all offered fields. */
|
|
245
|
-
type UpstreamCompat = OpenAICompletionsCompat & OpenAIResponsesCompat & AnthropicMessagesCompat & BedrockCompat;
|
|
246
|
-
/**
|
|
247
|
-
* Proof that each documented field carries its upstream type, not a hand-copied
|
|
248
|
-
* restatement of it. The name gates above pin *which* fields exist; this pins
|
|
249
|
-
* their types, in both directions because each catches a different drift. A
|
|
250
|
-
* profile field wider than upstream accepts a value the provider rejects, and
|
|
251
|
-
* `resolveModelCompat`'s cast to `ModelCompat` would hide it; a narrower one
|
|
252
|
-
* refuses a value the provider accepts, which is how an upgrade that widens a
|
|
253
|
-
* union would otherwise leave configuration silently behind.
|
|
254
|
-
*/
|
|
255
|
-
export type EveryProfileFieldMatchesUpstream = AssertTrue<PiAiCompatProfile extends Partial<Pick<UpstreamCompat, OfferedCompatField>> ? Partial<Pick<UpstreamCompat, OfferedCompatField>> extends PiAiCompatProfile ? true : false : false>;
|
|
256
|
-
/** One configured model entry: an id plus the catalog fields it overrides. */
|
|
257
|
-
export interface PiAiModelProfile {
|
|
258
|
-
/** Model id sent to the provider and accepted by {@link GenerateOptions.model}. */
|
|
259
|
-
id: string;
|
|
260
|
-
/** Display name for selectors; defaults to the catalog name, then the id. */
|
|
261
|
-
name?: string;
|
|
262
|
-
/** Maximum combined request and response context in tokens. */
|
|
263
|
-
contextWindow?: number;
|
|
264
|
-
/**
|
|
265
|
-
* Maximum output tokens. Configuring one also makes it this model's
|
|
266
|
-
* per-request default; a value inherited from the installed catalog, or the
|
|
267
|
-
* route's fallback, is the model's capability and never becomes a request
|
|
268
|
-
* default on its own.
|
|
269
|
-
*/
|
|
270
|
-
maxTokens?: number;
|
|
271
|
-
/**
|
|
272
|
-
* Request modalities this model accepts. Absent — or empty, which describes
|
|
273
|
-
* a model that accepts nothing and so states no answer either — keeps the
|
|
274
|
-
* installed catalog entry's modalities, then the route's `defaultInput`.
|
|
275
|
-
* Declaring images is what makes a hand-declared vision model usable, and
|
|
276
|
-
* declaring text alone corrects a catalog model whose gateway does not serve
|
|
277
|
-
* what the catalog records. This is a claim about the endpoint, not a check
|
|
278
|
-
* of it: nothing interrogates a gateway for what it accepts, so a model
|
|
279
|
-
* claiming images its endpoint refuses is refused by the provider instead,
|
|
280
|
-
* mid-turn.
|
|
281
|
-
*/
|
|
282
|
-
input?: PiAiModality[];
|
|
283
|
-
/**
|
|
284
|
-
* Selectable reasoning efforts. Absent inherits the installed catalog
|
|
285
|
-
* entry's capability (a hand-declared model has none and does not reason);
|
|
286
|
-
* `false` declares a non-reasoning model, which is how a profile strips
|
|
287
|
-
* reasoning from a catalog model its gateway cannot serve; a non-empty dict
|
|
288
|
-
* declares the offered levels and their wire spellings.
|
|
289
|
-
*/
|
|
290
|
-
reasoningEfforts?: false | PiAiReasoningEfforts;
|
|
291
|
-
/** pi-ai wire-compatibility switches for this model, winning over the route's per field; one its protocol does not declare is refused. */
|
|
292
|
-
compat?: PiAiCompatProfile;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Customization of one installed catalog model, keyed by its id in the
|
|
296
|
-
* route's `modelOverrides` dict — the same fields a `models` entry may set,
|
|
297
|
-
* with the id living in the key. Unlike a `models` list, overrides leave the
|
|
298
|
-
* rest of the catalog serving untouched, which is what makes "correct one
|
|
299
|
-
* model, keep the other thirty-seven" a three-line edit.
|
|
300
|
-
*/
|
|
301
|
-
export type PiAiModelOverride = Omit<PiAiModelProfile, 'id'>;
|
|
302
|
-
/** The route-level facts model materialization reads. */
|
|
303
|
-
export interface RouteCatalogRequest {
|
|
304
|
-
/** Provider route key, stamped onto every materialized model. */
|
|
305
|
-
provider: string;
|
|
306
|
-
/** Wire protocol override; absent defers to each catalog model's own API. */
|
|
307
|
-
api?: string;
|
|
308
|
-
/** Endpoint override; absent defers to the catalog model, then the catalog provider. */
|
|
309
|
-
baseURL?: string;
|
|
310
|
-
/** Configured catalog; absent means the whole installed catalog for this route. */
|
|
311
|
-
models?: readonly PiAiModelProfile[];
|
|
312
|
-
/** Installed-catalog customizations by model id; only meaningful while `models` is absent. */
|
|
313
|
-
modelOverrides?: Readonly<Record<string, PiAiModelOverride>>;
|
|
314
|
-
/** Route-level wire-compatibility switches, landing on each model whose protocol declares them; entries override per field. */
|
|
315
|
-
compat?: PiAiCompatProfile;
|
|
316
|
-
/** Context capacity for a model neither the entry nor the catalog sizes. */
|
|
317
|
-
defaultContextWindow: number;
|
|
318
|
-
/** Output capability for a model neither the entry nor the catalog sizes. */
|
|
319
|
-
defaultMaxTokens: number;
|
|
320
|
-
/** Modalities for a model neither the entry nor the catalog declares. */
|
|
321
|
-
defaultInput: Model<Api>['input'];
|
|
322
|
-
}
|
|
323
|
-
/** An expected configuration failure that stored-catalog reads may retain for repair. */
|
|
324
|
-
export declare class PiAiCatalogError extends Error {
|
|
325
|
-
}
|
|
326
|
-
/** One route's materialized catalog, plus the request caps its profile chose. */
|
|
327
|
-
export interface RouteCatalog {
|
|
328
|
-
/** The materialized models in configuration order. */
|
|
329
|
-
models: readonly Model<Api>[];
|
|
330
|
-
/** Models that cannot be resolved, retained as diagnostics during stored-config reads. */
|
|
331
|
-
modelErrors: ReadonlyMap<string, string>;
|
|
332
|
-
/**
|
|
333
|
-
* Per-request output caps this profile explicitly configured, by model id.
|
|
334
|
-
*
|
|
335
|
-
* Separate from `Model.maxTokens` because the two answer different
|
|
336
|
-
* questions: pi-ai requires `maxTokens` as the model's output *capability*,
|
|
337
|
-
* while the harness seam's `defaultMaxTokens` is a cap the deployment chose
|
|
338
|
-
* to send on requests that name none. Materializing a catalog capability as
|
|
339
|
-
* a request default would start capping every request at a number nobody
|
|
340
|
-
* picked, so only an explicit configuration lands here.
|
|
341
|
-
*/
|
|
342
|
-
configuredMaxTokens: ReadonlyMap<string, number>;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Materialize one route's catalog by merging the installed catalog defaults
|
|
346
|
-
* under the configured entries. A route with no configured `models` serves the
|
|
347
|
-
* installed catalog unchanged, which is what keeps an existing
|
|
348
|
-
* `providers: { deepseek: { apiKeyEnv: … } }` profile working untouched.
|
|
349
|
-
* @param request - the route-level catalog facts.
|
|
350
|
-
* @param validation - strict writes reject every error; deferred reads retain model diagnostics.
|
|
351
|
-
* @returns the materialized models and the explicitly configured request caps.
|
|
352
|
-
*/
|
|
353
|
-
export declare function resolveRouteModels(request: RouteCatalogRequest, validation?: 'strict' | 'deferred'): RouteCatalog;
|
|
354
|
-
export {};
|
|
355
|
-
//# sourceMappingURL=catalog.d.ts.map
|