@aiwayds/dsh-model-sync 0.12.1 → 0.13.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 +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 +122 -0
- package/lib/official-migrate.js +653 -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 +863 -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
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
// P1a pure planner: official opencode-go records + current route state +
|
|
2
|
-
// ownership ledger → a settings-independent write plan.
|
|
3
|
-
//
|
|
4
|
-
// Hard boundary (design 07 §6.2.1): this module does no I/O, never calls
|
|
5
|
-
// settings.mutate, never touches credentials, and never schedules timers. The
|
|
6
|
-
// caller in P1b turns the returned plan into settings operations. Everything
|
|
7
|
-
// here is a pure function of its inputs so it can be exercised with offline
|
|
8
|
-
// fixtures only.
|
|
9
|
-
//
|
|
10
|
-
// 0.12.0 single-route (catalog-reuse) shape: the host only reuses pi-ai's
|
|
11
|
-
// builtin catalog provider when a route carries no `api` field, and pi-ai
|
|
12
|
-
// 1.6.0's opencode-go catalog gives every model its own per-protocol baseUrl —
|
|
13
|
-
// so a managed route must never carry `api`/`baseURL`. The plan therefore
|
|
14
|
-
// writes ONE route (the `chat` slot route) holding ALL official entries, and
|
|
15
|
-
// plans cleanup for the three legacy protocol routes: unset when fully
|
|
16
|
-
// plugin-managed, keep+warn when they hold user content. Report 19's per-slot
|
|
17
|
-
// api/baseURL tables are gone with the topology they described.
|
|
18
|
-
import { createHash } from 'node:crypto';
|
|
19
|
-
import { deriveKeyRef } from "./route-credential.js";
|
|
20
|
-
import { HOST_CATALOG_PROVIDER } from "./opencode-go-host-catalog.js";
|
|
21
|
-
import { GO_SLOT_ROUTES, } from "./opencode-go-grouping.js";
|
|
22
|
-
/** The display name planned for the single managed route (F22/13). */
|
|
23
|
-
export const GO_DISPLAY_NAME = 'OpenCode Go';
|
|
24
|
-
/**
|
|
25
|
-
* Legacy route fields the writer must strip from the managed route (and that
|
|
26
|
-
* old 0.11.x routes carry). They are never part of a written plan.
|
|
27
|
-
*/
|
|
28
|
-
export const GO_LEGACY_ROUTE_FIELDS = ['api', 'baseURL'];
|
|
29
|
-
/**
|
|
30
|
-
* Build the planned route fields for the single managed route. `entries` is
|
|
31
|
-
* kept in the signature for symmetry with the migration caller (and future
|
|
32
|
-
* payload-driven fields); with the catalog-reuse shape the fields no longer
|
|
33
|
-
* depend on the payload — the endpoint lives in pi-ai's builtin catalog.
|
|
34
|
-
* `ref` defaults to the P0-derived `OPENCODE_GO_API_KEY`.
|
|
35
|
-
*/
|
|
36
|
-
export function planGoRouteFields(entries, ref = deriveKeyRef('opencode-go')) {
|
|
37
|
-
void entries;
|
|
38
|
-
return {
|
|
39
|
-
displayName: GO_DISPLAY_NAME,
|
|
40
|
-
apiKeyEnv: ref,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
// Model mapping (design §6.1 field mapping)
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
/** Effort keys the host schema accepts (mirrors translate.ts THINKING_LEVELS). */
|
|
47
|
-
const THINKING_LEVELS = new Set(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
|
|
48
|
-
/** Official GoModelRecord → host SettingsModelProfile. `created` never enters. */
|
|
49
|
-
export function mapGoModelToProfile(entry) {
|
|
50
|
-
const profile = { id: entry.id };
|
|
51
|
-
if (entry.name.length > 0)
|
|
52
|
-
profile.name = entry.name;
|
|
53
|
-
if (entry.contextWindow !== undefined)
|
|
54
|
-
profile.contextWindow = entry.contextWindow;
|
|
55
|
-
if (entry.maxOutput !== undefined)
|
|
56
|
-
profile.maxTokens = entry.maxOutput;
|
|
57
|
-
if (entry.inputModalities.length > 0)
|
|
58
|
-
profile.input = [...entry.inputModalities];
|
|
59
|
-
if (entry.reasoning !== undefined && entry.reasoning.efforts.length > 0) {
|
|
60
|
-
const efforts = {};
|
|
61
|
-
for (const effort of entry.reasoning.efforts) {
|
|
62
|
-
if (THINKING_LEVELS.has(effort))
|
|
63
|
-
efforts[effort] = effort;
|
|
64
|
-
}
|
|
65
|
-
if (Object.keys(efforts).length > 0)
|
|
66
|
-
profile.reasoningEfforts = efforts;
|
|
67
|
-
}
|
|
68
|
-
return profile;
|
|
69
|
-
}
|
|
70
|
-
/** Ledger key: one route's ownership is invisible under a different key. */
|
|
71
|
-
export function goOwnershipKey(route, keyFingerprint) {
|
|
72
|
-
return `${route}#${keyFingerprint}`;
|
|
73
|
-
}
|
|
74
|
-
// ---------------------------------------------------------------------------
|
|
75
|
-
// Helpers
|
|
76
|
-
// ---------------------------------------------------------------------------
|
|
77
|
-
function canonicalize(value) {
|
|
78
|
-
if (Array.isArray(value))
|
|
79
|
-
return value.map(canonicalize);
|
|
80
|
-
if (typeof value !== 'object' || value === null)
|
|
81
|
-
return value;
|
|
82
|
-
const out = {};
|
|
83
|
-
for (const key of Object.keys(value).sort()) {
|
|
84
|
-
out[key] = canonicalize(value[key]);
|
|
85
|
-
}
|
|
86
|
-
return out;
|
|
87
|
-
}
|
|
88
|
-
/** Stable hash of a settings profile — the "现值哈希" of the deletion gates. */
|
|
89
|
-
export function profileHash(profile) {
|
|
90
|
-
return createHash('sha256').update(JSON.stringify(canonicalize(profile))).digest('hex');
|
|
91
|
-
}
|
|
92
|
-
const OWNERSHIP_FIELDS = ['apiKeyEnv'];
|
|
93
|
-
/** A current route conflicts only when a field is explicitly set to a different value. */
|
|
94
|
-
function detectConflict(slot, route, fields, current) {
|
|
95
|
-
if (current === undefined || !current.exists)
|
|
96
|
-
return undefined;
|
|
97
|
-
for (const field of OWNERSHIP_FIELDS) {
|
|
98
|
-
const actual = current[field];
|
|
99
|
-
if (actual !== undefined && actual !== '' && actual !== fields[field]) {
|
|
100
|
-
return {
|
|
101
|
-
slot,
|
|
102
|
-
route,
|
|
103
|
-
field,
|
|
104
|
-
expected: fields[field],
|
|
105
|
-
actual,
|
|
106
|
-
reason: 'existing route field differs from plan; keep name, skip write (design §9.3)',
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
function ownedFieldsMatch(owned, fields) {
|
|
113
|
-
if (owned === undefined || owned.routeFields === undefined)
|
|
114
|
-
return false;
|
|
115
|
-
return OWNERSHIP_FIELDS.every((field) => owned.routeFields[field] === fields[field]);
|
|
116
|
-
}
|
|
117
|
-
// ---------------------------------------------------------------------------
|
|
118
|
-
// Planner
|
|
119
|
-
// ---------------------------------------------------------------------------
|
|
120
|
-
/**
|
|
121
|
-
* Build the write plan. Pure: identical inputs always produce an identical
|
|
122
|
-
* plan (report/order included). No mutation of `options` or its nested values.
|
|
123
|
-
*
|
|
124
|
-
* Topology (0.12.0): ONE managed route (the `chat` slot route) receives ALL
|
|
125
|
-
* official entries; the three legacy protocol routes (msg/resp/google) are
|
|
126
|
-
* cleanup targets — unset when fully plugin-managed, kept with a warn when
|
|
127
|
-
* they hold user content.
|
|
128
|
-
*/
|
|
129
|
-
export function planGoRoutes(options) {
|
|
130
|
-
const ref = options.ref ?? deriveKeyRef('opencode-go');
|
|
131
|
-
const routes = { ...GO_SLOT_ROUTES, ...(options.routes ?? {}) };
|
|
132
|
-
const pinned = new Set(options.pinnedModels ?? []);
|
|
133
|
-
const report = [];
|
|
134
|
-
const conflicts = [];
|
|
135
|
-
const plannedRoutes = [];
|
|
136
|
-
const unsetRoutes = [];
|
|
137
|
-
const nextOwnership = { ...options.ownership };
|
|
138
|
-
const desiredByRoute = {};
|
|
139
|
-
const entryById = new Map(options.entries.map((entry) => [entry.id, entry]));
|
|
140
|
-
// 0.12.1 catalog-intersection: ids the host runtime catalog does not know
|
|
141
|
-
// are NEVER desired — the host validates every route model id against its
|
|
142
|
-
// in-memory pi-ai catalog and rejects the whole mutate on one unknown id
|
|
143
|
-
// (fail-closed; incident migrate-go 20261129-114103: beam-free). The full
|
|
144
|
-
// official entry set stays in `entryById` for mapping/reports; the filtered
|
|
145
|
-
// ids are surfaced as one `needs-host-catalog` info line.
|
|
146
|
-
//
|
|
147
|
-
// P1-1 scope: that validation exists ONLY for the route that reuses the
|
|
148
|
-
// builtin catalog — the one NAMED after the catalog provider id
|
|
149
|
-
// (`go.routes.chat === 'opencode-go'`, the default). A custom go.routes.chat
|
|
150
|
-
// name keeps its own api/baseURL (it does not reuse any catalog), so the
|
|
151
|
-
// host never validates its ids against the runtime catalog: the whole
|
|
152
|
-
// restriction (filter, lag report, kept-host-unknown warnings) is off for it.
|
|
153
|
-
const hostSet = options.hostCatalogIds === undefined || routes.chat !== HOST_CATALOG_PROVIDER
|
|
154
|
-
? undefined
|
|
155
|
-
: new Set(options.hostCatalogIds);
|
|
156
|
-
const lagIds = hostSet === undefined
|
|
157
|
-
? []
|
|
158
|
-
: options.entries.map((entry) => entry.id).filter((id) => !hostSet.has(id)).sort((a, b) => a.localeCompare(b));
|
|
159
|
-
if (lagIds.length > 0) {
|
|
160
|
-
report.push({
|
|
161
|
-
level: 'info',
|
|
162
|
-
code: 'needs-host-catalog',
|
|
163
|
-
route: routes.chat,
|
|
164
|
-
slot: 'chat',
|
|
165
|
-
message: `host catalog lag: ${lagIds.join(', ')} not written — 官方 listing 有、宿主内置目录没有(宿主侧滞后,非本插件问题);宿主升级后 sync 自动纳入`,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
// Single-route desired set: every official entry the host catalog knows, in
|
|
169
|
-
// stable id order (0.12.0 behavior when no host catalog was supplied).
|
|
170
|
-
const desiredIds = [...entryById.keys()]
|
|
171
|
-
.filter((id) => hostSet === undefined || hostSet.has(id))
|
|
172
|
-
.sort((a, b) => a.localeCompare(b));
|
|
173
|
-
// --- The single managed route (chat slot) --------------------------------
|
|
174
|
-
const managedSlot = 'chat';
|
|
175
|
-
const managedRoute = routes[managedSlot];
|
|
176
|
-
const current = options.currentRoutes[managedRoute];
|
|
177
|
-
const ledgerKey = goOwnershipKey(managedRoute, options.keyFingerprint);
|
|
178
|
-
const owned = options.ownership[ledgerKey];
|
|
179
|
-
const fields = planGoRouteFields(options.entries, ref);
|
|
180
|
-
desiredByRoute[managedRoute] = [];
|
|
181
|
-
// H2: the main route's field conflict, hoisted so the legacy cleanup below
|
|
182
|
-
// can defer while the managed route is not writable.
|
|
183
|
-
let conflictOnMainRoute;
|
|
184
|
-
if (desiredIds.length === 0) {
|
|
185
|
-
const currentModels = current?.models ?? [];
|
|
186
|
-
if (current !== undefined && current.exists) {
|
|
187
|
-
// §9.4: an empty main route after a 200 is an upstream anomaly — keep
|
|
188
|
-
// last-good, write nothing.
|
|
189
|
-
plannedRoutes.push({ slot: managedSlot, route: managedRoute, fields, models: [...currentModels], unset: false, skip: true });
|
|
190
|
-
report.push({ level: 'warn', code: 'upstream-empty', route: managedRoute, slot: managedSlot, message: 'main route has no members; kept last-good, no write' });
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
const conflict = detectConflict(managedSlot, managedRoute, fields, current);
|
|
195
|
-
if (conflict !== undefined) {
|
|
196
|
-
conflicts.push(conflict);
|
|
197
|
-
conflictOnMainRoute = conflict;
|
|
198
|
-
report.push({
|
|
199
|
-
level: 'error',
|
|
200
|
-
code: 'route-conflict',
|
|
201
|
-
route: managedRoute,
|
|
202
|
-
slot: managedSlot,
|
|
203
|
-
message: `${managedRoute}.${conflict.field} is ${conflict.actual}, expected ${conflict.expected}`,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
const desiredById = new Map();
|
|
208
|
-
for (const id of desiredIds) {
|
|
209
|
-
const entry = entryById.get(id);
|
|
210
|
-
if (entry !== undefined)
|
|
211
|
-
desiredById.set(id, mapGoModelToProfile(entry));
|
|
212
|
-
}
|
|
213
|
-
desiredByRoute[managedRoute] = [...desiredById.values()];
|
|
214
|
-
// Catalog-reuse strip notice: a route still carrying the old 0.11.x
|
|
215
|
-
// `api`/`baseURL` fields gets them unset this round (the writer emits
|
|
216
|
-
// the ops; this line explains why in the report). H3 scope: only the
|
|
217
|
-
// builtin catalog provider route may lose api/baseURL — catalog-reuse
|
|
218
|
-
// only exists for it. A custom go.routes.chat name (or a kept legacy
|
|
219
|
-
// custom route) NEEDS api/baseURL to be servable, so it is never
|
|
220
|
-
// stripped (empty-string fields are still garbage the host rejects and
|
|
221
|
-
// are stripped unconditionally by the writer).
|
|
222
|
-
if (managedRoute === HOST_CATALOG_PROVIDER && current !== undefined && current.exists
|
|
223
|
-
&& GO_LEGACY_ROUTE_FIELDS.some((field) => current[field] !== undefined)) {
|
|
224
|
-
report.push({
|
|
225
|
-
level: 'info',
|
|
226
|
-
code: 'legacy-fields-strip',
|
|
227
|
-
route: managedRoute,
|
|
228
|
-
slot: managedSlot,
|
|
229
|
-
message: `route ${managedRoute} carries legacy api/baseURL fields; unsetting them so the host reuses the pi-ai builtin catalog provider (catalog-reuse fix)`,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
const currentModels = current?.models ?? [];
|
|
233
|
-
const managed = owned?.managed ?? {};
|
|
234
|
-
const nextManaged = {};
|
|
235
|
-
const kept = [];
|
|
236
|
-
// H5: a KEPT id the host catalog does not know poisons every future
|
|
237
|
-
// mutate of this route (the host rejects the whole models array). The
|
|
238
|
-
// plan never removes user content on its own, so it warns instead — the
|
|
239
|
-
// actionable exits are a custom route (with api/baseURL) or the host
|
|
240
|
-
// upgrade.
|
|
241
|
-
const warnKeptHostUnknown = (id) => {
|
|
242
|
-
if (hostSet === undefined || hostSet.has(id))
|
|
243
|
-
return;
|
|
244
|
-
report.push({
|
|
245
|
-
level: 'warn',
|
|
246
|
-
code: 'kept-host-unknown',
|
|
247
|
-
route: managedRoute,
|
|
248
|
-
slot: managedSlot,
|
|
249
|
-
id,
|
|
250
|
-
message: `model ${id} kept but not in the host runtime catalog — 宿主可能拒绝本路由的全部写入;请迁移到带 api/baseURL 的自定义路由或等待宿主升级`,
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
for (const model of currentModels) {
|
|
254
|
-
const id = model.id;
|
|
255
|
-
const desired = desiredById.get(id);
|
|
256
|
-
const record = managed[id];
|
|
257
|
-
const hashMatches = record !== undefined && record.hash === profileHash(model);
|
|
258
|
-
const hasOverride = (current?.overrideIds ?? []).includes(id);
|
|
259
|
-
const isPinned = pinned.has(id);
|
|
260
|
-
if (desired !== undefined) {
|
|
261
|
-
if (record !== undefined && hashMatches) {
|
|
262
|
-
// Plugin-owned and untouched: overwrite with the freshly mapped value.
|
|
263
|
-
const next = desired;
|
|
264
|
-
nextManaged[id] = { hash: profileHash(next) };
|
|
265
|
-
kept.push(next);
|
|
266
|
-
report.push({ level: 'info', code: 'overwrote-managed', route: managedRoute, slot: managedSlot, id, message: `refreshed plugin-managed model ${id}` });
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
// Not in ledger, or hash differs (user edited): keep as-is, never claim.
|
|
270
|
-
kept.push(model);
|
|
271
|
-
if (record !== undefined)
|
|
272
|
-
nextManaged[id] = record;
|
|
273
|
-
report.push({
|
|
274
|
-
level: 'info',
|
|
275
|
-
code: 'kept-user-owned',
|
|
276
|
-
route: managedRoute,
|
|
277
|
-
slot: managedSlot,
|
|
278
|
-
id,
|
|
279
|
-
message: record !== undefined ? `model ${id} was modified; kept user value` : `model ${id} is user-owned; kept`,
|
|
280
|
-
});
|
|
281
|
-
warnKeptHostUnknown(id);
|
|
282
|
-
}
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
// Not desired: the three deletion gates (ADR-005 / §6.2.4).
|
|
286
|
-
if (record !== undefined && hashMatches && !hasOverride && !isPinned) {
|
|
287
|
-
report.push({ level: 'info', code: 'deletion-candidate', route: managedRoute, slot: managedSlot, id, message: `model ${id} passed all three deletion gates` });
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
kept.push(model);
|
|
291
|
-
if (record !== undefined)
|
|
292
|
-
nextManaged[id] = record;
|
|
293
|
-
const code = record === undefined
|
|
294
|
-
? 'kept-user-owned'
|
|
295
|
-
: !hashMatches
|
|
296
|
-
? 'kept-modified'
|
|
297
|
-
: hasOverride
|
|
298
|
-
? 'kept-override'
|
|
299
|
-
: 'kept-pinned';
|
|
300
|
-
report.push({ level: 'info', code, route: managedRoute, slot: managedSlot, id, message: `model ${id} kept (${code}); not removed` });
|
|
301
|
-
warnKeptHostUnknown(id);
|
|
302
|
-
}
|
|
303
|
-
// New desired ids (absent from settings) are added and claimed.
|
|
304
|
-
const currentIds = new Set(currentModels.map((model) => model.id));
|
|
305
|
-
for (const id of desiredIds) {
|
|
306
|
-
if (currentIds.has(id))
|
|
307
|
-
continue;
|
|
308
|
-
const profile = desiredById.get(id);
|
|
309
|
-
if (profile === undefined)
|
|
310
|
-
continue;
|
|
311
|
-
nextManaged[id] = { hash: profileHash(profile) };
|
|
312
|
-
kept.push(profile);
|
|
313
|
-
report.push({ level: 'info', code: 'added', route: managedRoute, slot: managedSlot, id, message: `added model ${id}` });
|
|
314
|
-
}
|
|
315
|
-
// `desiredIds` is non-empty here, so the merged array is never empty.
|
|
316
|
-
const merged = [...kept].sort((a, b) => a.id.localeCompare(b.id));
|
|
317
|
-
plannedRoutes.push({ slot: managedSlot, route: managedRoute, fields, models: merged, unset: false, skip: false });
|
|
318
|
-
// P1d-2 ownership: inherit the prior entry so migration-period fields
|
|
319
|
-
// (`preManagedSection` / `appliedAddedIds` and any future ones) survive the
|
|
320
|
-
// plan round-trip untouched. The planner never writes or clears these — it
|
|
321
|
-
// only refreshes the fields it owns (routeFields / managed). The go writer
|
|
322
|
-
// applies the same merge when it persists the ledger entry.
|
|
323
|
-
nextOwnership[ledgerKey] = { ...owned, routeFields: fields, managed: nextManaged };
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
// --- Legacy protocol routes: cleanup plan ---------------------------------
|
|
327
|
-
// Only on a healthy payload: an anomalous empty listing must not trigger
|
|
328
|
-
// route teardown on top of the upstream anomaly.
|
|
329
|
-
// H2: also NOT while the main route has a field conflict — the writer
|
|
330
|
-
// executes routes independently, and a failed/skipped main-route write must
|
|
331
|
-
// never be followed by legacy unsets (the host validates route REMOVAL
|
|
332
|
-
// against no catalog, so the unsets would succeed and the user's
|
|
333
|
-
// non-chat-protocol models would be gone with the main route unwritten).
|
|
334
|
-
const conflictDeferred = conflictOnMainRoute !== undefined && desiredIds.length > 0;
|
|
335
|
-
if (conflictDeferred) {
|
|
336
|
-
report.push({
|
|
337
|
-
level: 'warn',
|
|
338
|
-
code: 'legacy-cleanup-deferred',
|
|
339
|
-
route: managedRoute,
|
|
340
|
-
slot: managedSlot,
|
|
341
|
-
message: `main route ${managedRoute} has a field conflict; legacy route cleanup is deferred to the round that fixes it (H2: never unset legacy routes while the managed route write is not healthy)`,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
if (desiredIds.length > 0 && conflictOnMainRoute === undefined) {
|
|
345
|
-
for (const slot of ['msg', 'resp', 'google']) {
|
|
346
|
-
const route = routes[slot];
|
|
347
|
-
const routeCurrent = options.currentRoutes[route];
|
|
348
|
-
const legacyLedgerKey = goOwnershipKey(route, options.keyFingerprint);
|
|
349
|
-
const legacyOwned = options.ownership[legacyLedgerKey];
|
|
350
|
-
if ((routeCurrent === undefined || !routeCurrent.exists) && legacyOwned === undefined)
|
|
351
|
-
continue;
|
|
352
|
-
const legacyFields = planGoRouteFields(options.entries, ref);
|
|
353
|
-
const currentModels = routeCurrent?.models ?? [];
|
|
354
|
-
const managed = legacyOwned?.managed ?? {};
|
|
355
|
-
// Fully managed = the plugin owns every model present (an empty route
|
|
356
|
-
// with a ledger entry counts: it was emptied by a previous round), the
|
|
357
|
-
// recorded ownership fields match this plan, AND the section carries no
|
|
358
|
-
// user content the whole-route unset would destroy (M1): no
|
|
359
|
-
// modelOverrides, no pinned ids, no renamed-away apiKeyEnv, no unknown
|
|
360
|
-
// fields (headers, custom keys).
|
|
361
|
-
const overrideIds = routeCurrent?.overrideIds ?? [];
|
|
362
|
-
const unknownKeys = routeCurrent?.unknownKeys ?? [];
|
|
363
|
-
const liveApiKeyEnv = routeCurrent?.apiKeyEnv;
|
|
364
|
-
const apiKeyEnvUserTouched = liveApiKeyEnv !== undefined
|
|
365
|
-
&& liveApiKeyEnv !== '' && liveApiKeyEnv !== legacyFields.apiKeyEnv;
|
|
366
|
-
const fullyManaged = legacyOwned !== undefined
|
|
367
|
-
&& currentModels.every((model) => {
|
|
368
|
-
const record = managed[model.id];
|
|
369
|
-
return record !== undefined && record.hash === profileHash(model);
|
|
370
|
-
})
|
|
371
|
-
&& currentModels.every((model) => !pinned.has(model.id))
|
|
372
|
-
&& overrideIds.length === 0
|
|
373
|
-
&& unknownKeys.length === 0
|
|
374
|
-
&& !apiKeyEnvUserTouched
|
|
375
|
-
&& ownedFieldsMatch(legacyOwned, legacyFields);
|
|
376
|
-
if (fullyManaged) {
|
|
377
|
-
plannedRoutes.push({ slot, route, fields: legacyFields, models: [], unset: true, skip: false });
|
|
378
|
-
unsetRoutes.push(route);
|
|
379
|
-
report.push({ level: 'info', code: 'unset-legacy-route', route, slot, message: `legacy route ${route} is superseded by the single managed route and fully plugin-managed; unset` });
|
|
380
|
-
delete nextOwnership[legacyLedgerKey];
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
plannedRoutes.push({ slot, route, fields: legacyFields, models: [...currentModels], unset: false, skip: true });
|
|
384
|
-
const userContent = [];
|
|
385
|
-
if (currentModels.length > 0)
|
|
386
|
-
userContent.push(`${currentModels.length} model(s)`);
|
|
387
|
-
if (overrideIds.length > 0)
|
|
388
|
-
userContent.push(`modelOverrides: ${overrideIds.join(', ')}`);
|
|
389
|
-
if (unknownKeys.length > 0)
|
|
390
|
-
userContent.push(`custom fields: ${unknownKeys.join(', ')}`);
|
|
391
|
-
if (apiKeyEnvUserTouched)
|
|
392
|
-
userContent.push(`apiKeyEnv: ${liveApiKeyEnv}`);
|
|
393
|
-
// P3: when pinned ids are the ONLY reason the route stays, say so —
|
|
394
|
-
// otherwise the keep looks unexplained (the fully-managed unset gates
|
|
395
|
-
// would have passed without them).
|
|
396
|
-
const pinnedKept = currentModels.filter((model) => pinned.has(model.id)).map((model) => model.id);
|
|
397
|
-
if (pinnedKept.length > 0)
|
|
398
|
-
userContent.push(`pinned: ${pinnedKept.join(', ')}`);
|
|
399
|
-
if (userContent.length > 0) {
|
|
400
|
-
report.push({ level: 'warn', code: 'legacy-route-kept', route, slot, message: `legacy route ${route} holds user content (${userContent.join('; ')}); kept as-is (superseded by the single managed route)` });
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return { routes: plannedRoutes, unsetRoutes, conflicts, report, nextOwnership, desiredByRoute };
|
|
406
|
-
}
|
|
407
|
-
//# sourceMappingURL=opencode-go-planner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-go-planner.js","sourceRoot":"","sources":["../src/opencode-go-planner.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,wDAAwD;AACxD,EAAE;AACF,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,iBAAiB;AACjB,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,+EAA+E;AAC/E,0EAA0E;AAC1E,6EAA6E;AAC7E,uEAAuE;AACvE,8EAA8E;AAC9E,gEAAgE;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAA;AAiBlC,sEAAsE;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAA;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,SAAS,CAAU,CAAA;AAEjE;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAiC,EACjC,MAAc,YAAY,CAAC,aAAa,CAAC;IAEzC,KAAK,OAAO,CAAA;IACZ,OAAO;QACL,WAAW,EAAE,eAAe;QAC5B,SAAS,EAAE,GAAG;KACf,CAAA;AACH,CAAC;AAED,8EAA8E;AAC9E,4CAA4C;AAC5C,8E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AE,CAAC,CAAA;gBAC9M,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,CAAA;AACjG,CAAC"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import type { GoFailureKind } from './opencode-go-source.ts';
|
|
2
|
-
/** Cordis service seams used by index.ts to inject test doubles. */
|
|
3
|
-
export declare const GO_SCHEDULER_TIMERS_SERVICE = "goSchedulerTimers";
|
|
4
|
-
export declare const GO_SCHEDULER_RANDOM_SERVICE = "goSchedulerRandom";
|
|
5
|
-
/** Trigger origin, recorded in every report so auto/manual rounds are distinguishable. */
|
|
6
|
-
export type GoTrigger = 'startup' | 'interval' | 'backoff' | 'manual';
|
|
7
|
-
/** The subset of Config the scheduler reads (live, via a callback). */
|
|
8
|
-
export interface GoSchedulerConfig {
|
|
9
|
-
/** Master switch. Design §6.2.6 default false (unchanged by P1d-1). */
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
/** go.intervalMinutes — default 60, floor 15 (design §6.3 / ADR-007). */
|
|
12
|
-
intervalMinutes: number;
|
|
13
|
-
/** startupDelaySeconds — jitter is added on top (design §6.3). */
|
|
14
|
-
startupDelaySeconds: number;
|
|
15
|
-
}
|
|
16
|
-
/** Opaque timer handle (platform Timeout in production, an id in fake timers). */
|
|
17
|
-
export type GoTimerHandle = unknown;
|
|
18
|
-
/** Minimal clock surface the scheduler needs. Injectable for deterministic tests. */
|
|
19
|
-
export interface GoSchedulerTimers {
|
|
20
|
-
setTimeout(fn: () => void, ms: number): GoTimerHandle;
|
|
21
|
-
clearTimeout(handle: GoTimerHandle): void;
|
|
22
|
-
}
|
|
23
|
-
/** Injectable [0,1) source so startup jitter is deterministic in tests. */
|
|
24
|
-
export interface GoSchedulerRandom {
|
|
25
|
-
next(): number;
|
|
26
|
-
}
|
|
27
|
-
/** What the scheduler needs back from one round to drive backoff + reporting. */
|
|
28
|
-
export interface GoRoundOutcome {
|
|
29
|
-
ok: boolean;
|
|
30
|
-
reason: string;
|
|
31
|
-
/** Report text — passed through unchanged for real rounds (design item 3). */
|
|
32
|
-
text: string;
|
|
33
|
-
/** Source failure taxonomy; set only when the round reached the source. */
|
|
34
|
-
failureKind?: GoFailureKind;
|
|
35
|
-
}
|
|
36
|
-
export interface GoRoundRequest {
|
|
37
|
-
trigger: GoTrigger;
|
|
38
|
-
adopt: boolean;
|
|
39
|
-
/** Aborted by dispose() so an in-flight round stops before it can write settings. */
|
|
40
|
-
signal: AbortSignal;
|
|
41
|
-
}
|
|
42
|
-
export interface GoSchedulerDeps {
|
|
43
|
-
config: () => GoSchedulerConfig;
|
|
44
|
-
timers: GoSchedulerTimers;
|
|
45
|
-
random: GoSchedulerRandom;
|
|
46
|
-
runRound: (request: GoRoundRequest) => Promise<GoRoundOutcome>;
|
|
47
|
-
/** Sink for the per-round report (auto rounds have no caller to return it to). */
|
|
48
|
-
report: (text: string) => void;
|
|
49
|
-
/**
|
|
50
|
-
* M-5: while a migration apply is in progress every round drops immediately
|
|
51
|
-
* (no queue, no retry). Optional so existing scheduling-unit tests stay pure;
|
|
52
|
-
* index.ts wires it to the migration record's `applying` flag.
|
|
53
|
-
*/
|
|
54
|
-
isApplying?: () => boolean | Promise<boolean>;
|
|
55
|
-
}
|
|
56
|
-
/** A scheduled or manually triggered round result, including skips. */
|
|
57
|
-
export interface GoScheduledResult extends GoRoundOutcome {
|
|
58
|
-
/** True when the round was skipped (single-flight / disabled / disposed). */
|
|
59
|
-
skipped: boolean;
|
|
60
|
-
}
|
|
61
|
-
export declare const GO_INTERVAL_MIN_MINUTES = 15;
|
|
62
|
-
export declare const GO_INTERVAL_DEFAULT_MINUTES = 60;
|
|
63
|
-
export declare const GO_STARTUP_JITTER_MAX_MS = 5000;
|
|
64
|
-
export declare const GO_TRANSPORT_BACKOFF_BASE_MS = 60000;
|
|
65
|
-
export declare const GO_TRANSPORT_BACKOFF_CAP_MS: number;
|
|
66
|
-
export declare const GO_AUTH_BACKOFF_BASE_MS: number;
|
|
67
|
-
export declare const GO_AUTH_BACKOFF_CAP_MS: number;
|
|
68
|
-
/** Clamp an interval to the design floor; non-finite falls back to the default. */
|
|
69
|
-
export declare function clampGoIntervalMinutes(value: number): number;
|
|
70
|
-
/** startupDelaySeconds*1000 plus bounded jitter (random is in [0,1)). */
|
|
71
|
-
export declare function goStartupDelayMs(seconds: number, random: number): number;
|
|
72
|
-
/** Exponential backoff with per-class cap (design §6.3). */
|
|
73
|
-
export declare function goBackoffDelayMs(streak: number, failureKind?: GoFailureKind): number;
|
|
74
|
-
/** Report text for a skipped round — always states the reason explicitly. */
|
|
75
|
-
export declare function goSchedulerSkipReport(reason: string, trigger: GoTrigger): string;
|
|
76
|
-
/**
|
|
77
|
-
* The scheduler state machine. One instance per plugin activation; it owns a
|
|
78
|
-
* single timer handle and a single in-flight flag shared by auto and manual
|
|
79
|
-
* triggers (that is the single-flight lock).
|
|
80
|
-
*/
|
|
81
|
-
export declare class GoScheduler {
|
|
82
|
-
private readonly config;
|
|
83
|
-
private readonly timers;
|
|
84
|
-
private readonly random;
|
|
85
|
-
private readonly runRound;
|
|
86
|
-
private readonly report;
|
|
87
|
-
private readonly isApplying?;
|
|
88
|
-
private handle;
|
|
89
|
-
private started;
|
|
90
|
-
private inFlight;
|
|
91
|
-
private disposed;
|
|
92
|
-
private streak;
|
|
93
|
-
private lastFailureKind;
|
|
94
|
-
/** Single lifetime signal: dispose() aborts the round that is currently in flight. */
|
|
95
|
-
private readonly abort;
|
|
96
|
-
constructor(deps: GoSchedulerDeps);
|
|
97
|
-
/** Arm the startup timer. No-op when disabled — zero triggers at enabled=false. */
|
|
98
|
-
start(): void;
|
|
99
|
-
/**
|
|
100
|
-
* Live re-arm after a settings edit. Cancels the pending timer and reads
|
|
101
|
-
* fresh config; a round already in flight keeps its lock and picks up the
|
|
102
|
-
* new config when it schedules its own successor.
|
|
103
|
-
*/
|
|
104
|
-
rearm(): void;
|
|
105
|
-
/**
|
|
106
|
-
* Reset backoff after a credential change. Clears the in-memory streak and
|
|
107
|
-
* re-arms at the normal interval instead of waiting out a capped (up to 6h)
|
|
108
|
-
* backoff — a fixed key must not stay frozen for hours (design §6.3). The
|
|
109
|
-
* caller's listener is disposed with the plugin; a disposed scheduler is a
|
|
110
|
-
* no-op.
|
|
111
|
-
*/
|
|
112
|
-
resetBackoff(): void;
|
|
113
|
-
/** Cancel every timer and abort a round already in flight (design §6.3 卸载). */
|
|
114
|
-
dispose(): void;
|
|
115
|
-
get isInFlight(): boolean;
|
|
116
|
-
get failureStreak(): number;
|
|
117
|
-
/** Manual /model-sync go trigger — shares the single-flight lock with auto rounds. */
|
|
118
|
-
triggerManual(options?: {
|
|
119
|
-
adopt?: boolean;
|
|
120
|
-
}): Promise<GoScheduledResult>;
|
|
121
|
-
private arm;
|
|
122
|
-
private cancel;
|
|
123
|
-
private armFromConfig;
|
|
124
|
-
/** Forget the entire backoff history (transport === auth) — used by reset paths. */
|
|
125
|
-
private clearBackoff;
|
|
126
|
-
private fire;
|
|
127
|
-
private skip;
|
|
128
|
-
}
|