@aiwayds/dsh-model-sync 0.12.1 → 0.13.0
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 +18 -17
- package/README.zh-CN.md +18 -17
- package/lib/index.d.ts +54 -384
- package/lib/index.js +306 -1107
- package/lib/index.js.map +1 -1
- package/lib/official-adapter.d.ts +80 -0
- package/lib/official-adapter.js +34 -0
- package/lib/official-adapter.js.map +1 -0
- package/lib/official-migrate.d.ts +116 -0
- package/lib/official-migrate.js +643 -0
- package/lib/official-migrate.js.map +1 -0
- package/lib/official-scheduler.d.ts +72 -0
- package/lib/official-scheduler.js +195 -0
- package/lib/official-scheduler.js.map +1 -0
- package/lib/official-store.d.ts +41 -0
- package/lib/official-store.js +84 -0
- package/lib/official-store.js.map +1 -0
- package/lib/official-sync.d.ts +68 -0
- package/lib/official-sync.js +274 -0
- package/lib/official-sync.js.map +1 -0
- package/lib/opencode-go-adapter.d.ts +56 -0
- package/lib/opencode-go-adapter.js +455 -0
- package/lib/opencode-go-adapter.js.map +1 -0
- package/lib/opencode-go-patch-file.d.ts +11 -0
- package/lib/opencode-go-patch-file.js +175 -11
- package/lib/opencode-go-patch-file.js.map +1 -1
- package/lib/opencode-go-source.d.ts +1 -1
- package/lib/opencode-go-source.js +1 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +3 -3
- package/src/index.ts +352 -1281
- package/src/official-adapter.ts +111 -0
- package/src/official-migrate.ts +840 -0
- package/src/official-scheduler.ts +235 -0
- package/src/official-store.ts +122 -0
- package/src/official-sync.ts +371 -0
- package/src/opencode-go-adapter.ts +494 -0
- package/src/opencode-go-patch-file.ts +175 -9
- package/src/opencode-go-source.ts +1 -1
- package/lib/opencode-go-diagnose.d.ts +0 -96
- package/lib/opencode-go-diagnose.js +0 -177
- package/lib/opencode-go-diagnose.js.map +0 -1
- package/lib/opencode-go-grouping.d.ts +0 -7
- package/lib/opencode-go-grouping.js +0 -21
- package/lib/opencode-go-grouping.js.map +0 -1
- package/lib/opencode-go-host-catalog.d.ts +0 -42
- package/lib/opencode-go-host-catalog.js +0 -98
- package/lib/opencode-go-host-catalog.js.map +0 -1
- package/lib/opencode-go-journal.d.ts +0 -114
- package/lib/opencode-go-journal.js +0 -406
- package/lib/opencode-go-journal.js.map +0 -1
- package/lib/opencode-go-migrate.d.ts +0 -378
- package/lib/opencode-go-migrate.js +0 -1529
- package/lib/opencode-go-migrate.js.map +0 -1
- package/lib/opencode-go-migration.d.ts +0 -270
- package/lib/opencode-go-migration.js +0 -473
- package/lib/opencode-go-migration.js.map +0 -1
- package/lib/opencode-go-one-shot.d.ts +0 -282
- package/lib/opencode-go-one-shot.js +0 -1131
- package/lib/opencode-go-one-shot.js.map +0 -1
- package/lib/opencode-go-planner.d.ts +0 -168
- package/lib/opencode-go-planner.js +0 -407
- package/lib/opencode-go-planner.js.map +0 -1
- package/lib/opencode-go-scheduler.d.ts +0 -128
- package/lib/opencode-go-scheduler.js +0 -241
- package/lib/opencode-go-scheduler.js.map +0 -1
- package/lib/opencode-go-store.d.ts +0 -18
- package/lib/opencode-go-store.js +0 -68
- package/lib/opencode-go-store.js.map +0 -1
- package/lib/opencode-go-sync.d.ts +0 -107
- package/lib/opencode-go-sync.js +0 -388
- package/lib/opencode-go-sync.js.map +0 -1
- package/lib/opencode-go-writer.d.ts +0 -148
- package/lib/opencode-go-writer.js +0 -1061
- package/lib/opencode-go-writer.js.map +0 -1
- package/src/opencode-go-diagnose.ts +0 -276
- package/src/opencode-go-grouping.ts +0 -26
- package/src/opencode-go-host-catalog.ts +0 -125
- package/src/opencode-go-journal.ts +0 -460
- package/src/opencode-go-migrate.ts +0 -1951
- package/src/opencode-go-migration.ts +0 -666
- package/src/opencode-go-one-shot.ts +0 -1399
- package/src/opencode-go-planner.ts +0 -582
- package/src/opencode-go-scheduler.ts +0 -315
- package/src/opencode-go-store.ts +0 -73
- package/src/opencode-go-sync.ts +0 -541
- package/src/opencode-go-writer.ts +0 -1301
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Upstream Provider Adapter contract and registry for Official Sync.
|
|
3
|
+
*
|
|
4
|
+
* Supported vendors expose an authoritative models API that is mapped into
|
|
5
|
+
* per-protocol Managed Custom Providers, detached from pi-ai's built-in
|
|
6
|
+
* catalog. Providers without an adapter explicitly report unsupported on
|
|
7
|
+
* official sync or migration commands while continuing to use pi.dev on bare
|
|
8
|
+
* `/model-sync`.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-model-sync/official-adapter
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { SettingsModelProfile } from './translate.ts'
|
|
14
|
+
import type { GoAuthStatus, GoFailureKind, GoFetchLike } from './opencode-go-source.ts'
|
|
15
|
+
import { opencodeGoAdapter } from './opencode-go-adapter.ts'
|
|
16
|
+
|
|
17
|
+
export type SessionHeaderMode = 'auto' | 'static' | 'none'
|
|
18
|
+
|
|
19
|
+
export interface OfficialAdapterConfig {
|
|
20
|
+
intervalMinutes: number
|
|
21
|
+
modelsUrl: string
|
|
22
|
+
sessionHeader: SessionHeaderMode
|
|
23
|
+
routes: Record<string, string>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CustomProviderSpec {
|
|
27
|
+
slot: string
|
|
28
|
+
routeId: string
|
|
29
|
+
displayName: string
|
|
30
|
+
api: string
|
|
31
|
+
baseURL: string
|
|
32
|
+
apiKeyEnv: string
|
|
33
|
+
models: SettingsModelProfile[]
|
|
34
|
+
compat?: Record<string, unknown>
|
|
35
|
+
headers?: Record<string, string>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface OfficialFetchResult {
|
|
39
|
+
ok: boolean
|
|
40
|
+
providers: CustomProviderSpec[]
|
|
41
|
+
activeSlots: string[]
|
|
42
|
+
emptySlots: string[]
|
|
43
|
+
warnings: string[]
|
|
44
|
+
authStatus: GoAuthStatus
|
|
45
|
+
failureKind?: GoFailureKind
|
|
46
|
+
error?: {
|
|
47
|
+
kind: GoFailureKind
|
|
48
|
+
status?: number
|
|
49
|
+
message: string
|
|
50
|
+
}
|
|
51
|
+
observedAt: number
|
|
52
|
+
totalModels: number
|
|
53
|
+
sessionHeaderApplied: boolean
|
|
54
|
+
hostNativeSessionHeader: boolean
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type CompatHintsByProtocol = Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, unknown>>>>>>
|
|
58
|
+
|
|
59
|
+
export interface OfficialFetchOptions {
|
|
60
|
+
apiKey: string
|
|
61
|
+
apiKeyEnv: string
|
|
62
|
+
config: OfficialAdapterConfig
|
|
63
|
+
timeoutMs?: number
|
|
64
|
+
signal?: AbortSignal
|
|
65
|
+
fetchImpl?: GoFetchLike
|
|
66
|
+
/** Test seam: override host native `x-opencode-session` detection. */
|
|
67
|
+
detectHostSessionHeader?: () => boolean
|
|
68
|
+
/** Test seam: override pi-ai compat hints lookup. */
|
|
69
|
+
loadPiAiCompatHints?: () => CompatHintsByProtocol
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface UpstreamProviderAdapter {
|
|
73
|
+
readonly id: string
|
|
74
|
+
readonly aliases: readonly string[]
|
|
75
|
+
readonly builtinProviderId: string
|
|
76
|
+
readonly displayName: string
|
|
77
|
+
readonly defaultIntervalMinutes: number
|
|
78
|
+
readonly defaultModelsUrl: string
|
|
79
|
+
readonly defaultKeyRefs: readonly string[]
|
|
80
|
+
readonly slotOrder: readonly string[]
|
|
81
|
+
readonly defaultSlotRoutes: Readonly<Record<string, string>>
|
|
82
|
+
readonly legacyExtraRoutes: readonly string[]
|
|
83
|
+
detectHostSessionHeader?(): boolean
|
|
84
|
+
fetchAndPlan(options: OfficialFetchOptions): Promise<OfficialFetchResult>
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const OFFICIAL_ADAPTERS: readonly UpstreamProviderAdapter[] = [
|
|
88
|
+
opencodeGoAdapter,
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
export function listOfficialAdapters(): readonly UpstreamProviderAdapter[] {
|
|
92
|
+
return OFFICIAL_ADAPTERS
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function resolveOfficialAdapter(input: string): UpstreamProviderAdapter | undefined {
|
|
96
|
+
const normalized = input.trim().toLowerCase()
|
|
97
|
+
if (normalized === '') return undefined
|
|
98
|
+
return OFFICIAL_ADAPTERS.find((adapter) =>
|
|
99
|
+
adapter.id.toLowerCase() === normalized
|
|
100
|
+
|| adapter.aliases.some((alias) => alias.toLowerCase() === normalized),
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function formatUnsupportedProviderError(providerName: string): string {
|
|
105
|
+
const supported = OFFICIAL_ADAPTERS.map((a) => `${a.id} (${a.aliases.join(' / ')})`).join(', ')
|
|
106
|
+
return [
|
|
107
|
+
`Provider "${providerName}" is not supported for official models API sync or migration yet.`,
|
|
108
|
+
`Currently supported: ${supported}.`,
|
|
109
|
+
'Other providers continue to sync from pi.dev via bare `/model-sync`.',
|
|
110
|
+
].join(' ')
|
|
111
|
+
}
|