@aiwayds/dsh-model-sync 0.9.0 → 0.10.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 +8 -3
- package/README.zh-CN.md +8 -3
- package/lib/builtin-catalog-snapshot.js +6 -3
- package/lib/builtin-catalog-snapshot.js.map +1 -1
- package/lib/index.d.ts +366 -0
- package/lib/index.js +729 -13
- package/lib/index.js.map +1 -1
- package/lib/opencode-go-diagnose.d.ts +74 -0
- package/lib/opencode-go-diagnose.js +146 -0
- package/lib/opencode-go-diagnose.js.map +1 -0
- package/lib/opencode-go-grouping.d.ts +29 -0
- package/lib/opencode-go-grouping.js +77 -0
- package/lib/opencode-go-grouping.js.map +1 -0
- package/lib/opencode-go-journal.d.ts +110 -0
- package/lib/opencode-go-journal.js +406 -0
- package/lib/opencode-go-journal.js.map +1 -0
- package/lib/opencode-go-migrate.d.ts +343 -0
- package/lib/opencode-go-migrate.js +1300 -0
- package/lib/opencode-go-migrate.js.map +1 -0
- package/lib/opencode-go-migration.d.ts +227 -0
- package/lib/opencode-go-migration.js +384 -0
- package/lib/opencode-go-migration.js.map +1 -0
- package/lib/opencode-go-planner.d.ts +153 -0
- package/lib/opencode-go-planner.js +339 -0
- package/lib/opencode-go-planner.js.map +1 -0
- package/lib/opencode-go-profile.d.ts +57 -0
- package/lib/opencode-go-profile.js +103 -0
- package/lib/opencode-go-profile.js.map +1 -0
- package/lib/opencode-go-scheduler.d.ts +128 -0
- package/lib/opencode-go-scheduler.js +241 -0
- package/lib/opencode-go-scheduler.js.map +1 -0
- package/lib/opencode-go-source.d.ts +117 -0
- package/lib/opencode-go-source.js +331 -0
- package/lib/opencode-go-source.js.map +1 -0
- package/lib/opencode-go-store.d.ts +18 -0
- package/lib/opencode-go-store.js +68 -0
- package/lib/opencode-go-store.js.map +1 -0
- package/lib/opencode-go-sync.d.ts +94 -0
- package/lib/opencode-go-sync.js +364 -0
- package/lib/opencode-go-sync.js.map +1 -0
- package/lib/opencode-go-writer.d.ts +132 -0
- package/lib/opencode-go-writer.js +966 -0
- package/lib/opencode-go-writer.js.map +1 -0
- package/lib/provider-native.d.ts +3 -1
- package/lib/provider-native.js +4 -2
- package/lib/provider-native.js.map +1 -1
- package/lib/remote-catalog.d.ts +37 -0
- package/lib/remote-catalog.js +261 -3
- package/lib/remote-catalog.js.map +1 -1
- package/package.json +15 -15
- package/src/builtin-catalog-snapshot.ts +6 -3
- package/src/index.ts +873 -12
- package/src/opencode-go-diagnose.ts +222 -0
- package/src/opencode-go-grouping.ts +97 -0
- package/src/opencode-go-journal.ts +458 -0
- package/src/opencode-go-migrate.ts +1694 -0
- package/src/opencode-go-migration.ts +552 -0
- package/src/opencode-go-planner.ts +505 -0
- package/src/opencode-go-profile.ts +114 -0
- package/src/opencode-go-scheduler.ts +315 -0
- package/src/opencode-go-source.ts +424 -0
- package/src/opencode-go-store.ts +73 -0
- package/src/opencode-go-sync.ts +503 -0
- package/src/opencode-go-writer.ts +1189 -0
- package/src/provider-native.ts +3 -1
- package/src/remote-catalog.ts +293 -3
|
@@ -0,0 +1,339 @@
|
|
|
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
|
+
// Design refs: §2.1/§6.2.2 (route fields + msg baseURL normalization),
|
|
11
|
+
// §6.2.3 (grouping), §6.2.4 (ownership-aware merge), §6.2.5 (route fields),
|
|
12
|
+
// §9.2-9.4 (keep the name, conflicts, empty routes), ADR-004 (ledger keyed
|
|
13
|
+
// by keyFingerprint), ADR-005 (deletion gates). F25 is intentionally absent:
|
|
14
|
+
// report 19 proved the host injects x-opencode-session, so no special header
|
|
15
|
+
// handling belongs in the plan.
|
|
16
|
+
import { createHash } from 'node:crypto';
|
|
17
|
+
import { deriveKeyRef } from "./route-credential.js";
|
|
18
|
+
import { GO_SLOT_ROUTES, groupGoModelsByProtocol, } from "./opencode-go-grouping.js";
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Static route-field plan (design §2.1 / §6.2.2, confirmed by report 19)
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
/** Host `api` value per slot (llm-pi-ai PROTOCOLS, report 19 §1). */
|
|
23
|
+
export const GO_API_BY_SLOT = {
|
|
24
|
+
chat: 'openai-completions',
|
|
25
|
+
msg: 'anthropic-messages',
|
|
26
|
+
resp: 'openai-responses',
|
|
27
|
+
google: 'google-generative-ai',
|
|
28
|
+
};
|
|
29
|
+
/** The only display field the host uses to group providers (F22/13). */
|
|
30
|
+
export const GO_DISPLAY_NAME_BY_SLOT = {
|
|
31
|
+
chat: 'OpenCode Go',
|
|
32
|
+
msg: 'OpenCode Go · msg',
|
|
33
|
+
resp: 'OpenCode Go · resp',
|
|
34
|
+
google: 'OpenCode Go · google',
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Fallback host baseURLs — the values report 19 confirmed end-to-end. Normally
|
|
38
|
+
* the baseURL comes from the official payload (§6.2.2); these are used only
|
|
39
|
+
* when a record carries no per-protocol `base_url`.
|
|
40
|
+
*/
|
|
41
|
+
export const GO_BASE_URL_BY_SLOT = {
|
|
42
|
+
chat: 'https://opencode.ai/inference/go/openai/v1',
|
|
43
|
+
msg: 'https://opencode.ai/inference/go/anthropic',
|
|
44
|
+
resp: 'https://opencode.ai/inference/go/openai/v1',
|
|
45
|
+
google: 'https://opencode.ai/inference/go/google/v1beta',
|
|
46
|
+
};
|
|
47
|
+
/** Official protocol keys that back each slot (§6.2.2 table). */
|
|
48
|
+
export const GO_PROTOCOLS_BY_SLOT = {
|
|
49
|
+
chat: ['chat-completions'],
|
|
50
|
+
msg: ['messages'],
|
|
51
|
+
resp: ['responses'],
|
|
52
|
+
google: ['interactions', 'generate-content'],
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Normalize an official `base_url` for host use. Only `msg` changes: pi-ai
|
|
56
|
+
* calls `beta.messages.create` and appends `/v1/messages?beta=true`, so the
|
|
57
|
+
* trailing `/v1` must be stripped (ADR-003 / report 19 negative control).
|
|
58
|
+
*/
|
|
59
|
+
export function normalizeGoBaseUrl(raw, slot) {
|
|
60
|
+
const trimmed = raw.replace(/\/+$/, '');
|
|
61
|
+
if (slot === 'msg' && trimmed.endsWith('/v1'))
|
|
62
|
+
return trimmed.slice(0, -3);
|
|
63
|
+
return trimmed;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build the route fields for a slot from the payload's per-protocol base_url.
|
|
67
|
+
* `ref` defaults to the P0-derived `OPENCODE_GO_API_KEY`.
|
|
68
|
+
*/
|
|
69
|
+
export function planGoRouteFields(slot, entries, ref = deriveKeyRef('opencode-go')) {
|
|
70
|
+
const protocols = GO_PROTOCOLS_BY_SLOT[slot];
|
|
71
|
+
let raw;
|
|
72
|
+
for (const entry of entries) {
|
|
73
|
+
for (const protocol of protocols) {
|
|
74
|
+
const base = entry.baseUrls[protocol];
|
|
75
|
+
if (base !== undefined && base.length > 0) {
|
|
76
|
+
raw = base;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (raw !== undefined)
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
api: GO_API_BY_SLOT[slot],
|
|
85
|
+
baseURL: raw !== undefined ? normalizeGoBaseUrl(raw, slot) : GO_BASE_URL_BY_SLOT[slot],
|
|
86
|
+
displayName: GO_DISPLAY_NAME_BY_SLOT[slot],
|
|
87
|
+
apiKeyEnv: ref,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// Model mapping (design §6.1 field mapping)
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
/** Effort keys the host schema accepts (mirrors translate.ts THINKING_LEVELS). */
|
|
94
|
+
const THINKING_LEVELS = new Set(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
|
|
95
|
+
/** Official GoModelRecord → host SettingsModelProfile. `created` never enters. */
|
|
96
|
+
export function mapGoModelToProfile(entry) {
|
|
97
|
+
const profile = { id: entry.id };
|
|
98
|
+
if (entry.name.length > 0)
|
|
99
|
+
profile.name = entry.name;
|
|
100
|
+
if (entry.contextWindow !== undefined)
|
|
101
|
+
profile.contextWindow = entry.contextWindow;
|
|
102
|
+
if (entry.maxOutput !== undefined)
|
|
103
|
+
profile.maxTokens = entry.maxOutput;
|
|
104
|
+
if (entry.inputModalities.length > 0)
|
|
105
|
+
profile.input = [...entry.inputModalities];
|
|
106
|
+
if (entry.reasoning !== undefined && entry.reasoning.efforts.length > 0) {
|
|
107
|
+
const efforts = {};
|
|
108
|
+
for (const effort of entry.reasoning.efforts) {
|
|
109
|
+
if (THINKING_LEVELS.has(effort))
|
|
110
|
+
efforts[effort] = effort;
|
|
111
|
+
}
|
|
112
|
+
if (Object.keys(efforts).length > 0)
|
|
113
|
+
profile.reasoningEfforts = efforts;
|
|
114
|
+
}
|
|
115
|
+
return profile;
|
|
116
|
+
}
|
|
117
|
+
/** Ledger key: one route's ownership is invisible under a different key. */
|
|
118
|
+
export function goOwnershipKey(route, keyFingerprint) {
|
|
119
|
+
return `${route}#${keyFingerprint}`;
|
|
120
|
+
}
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
// Helpers
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
function canonicalize(value) {
|
|
125
|
+
if (Array.isArray(value))
|
|
126
|
+
return value.map(canonicalize);
|
|
127
|
+
if (typeof value !== 'object' || value === null)
|
|
128
|
+
return value;
|
|
129
|
+
const out = {};
|
|
130
|
+
for (const key of Object.keys(value).sort()) {
|
|
131
|
+
out[key] = canonicalize(value[key]);
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
/** Stable hash of a settings profile — the "现值哈希" of the deletion gates. */
|
|
136
|
+
export function profileHash(profile) {
|
|
137
|
+
return createHash('sha256').update(JSON.stringify(canonicalize(profile))).digest('hex');
|
|
138
|
+
}
|
|
139
|
+
const OWNERSHIP_FIELDS = ['api', 'baseURL', 'apiKeyEnv'];
|
|
140
|
+
/** A current route conflicts only when a field is explicitly set to a different value. */
|
|
141
|
+
function detectConflict(slot, route, fields, current) {
|
|
142
|
+
if (current === undefined || !current.exists)
|
|
143
|
+
return undefined;
|
|
144
|
+
for (const field of OWNERSHIP_FIELDS) {
|
|
145
|
+
const actual = current[field];
|
|
146
|
+
if (actual !== undefined && actual !== '' && actual !== fields[field]) {
|
|
147
|
+
return {
|
|
148
|
+
slot,
|
|
149
|
+
route,
|
|
150
|
+
field,
|
|
151
|
+
expected: fields[field],
|
|
152
|
+
actual,
|
|
153
|
+
reason: 'existing route field differs from plan; keep name, skip write (design §9.3)',
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
function ownedFieldsMatch(owned, fields) {
|
|
160
|
+
if (owned === undefined || owned.routeFields === undefined)
|
|
161
|
+
return false;
|
|
162
|
+
return OWNERSHIP_FIELDS.every((field) => owned.routeFields[field] === fields[field]);
|
|
163
|
+
}
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
// Planner
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
/**
|
|
168
|
+
* Build the write plan. Pure: identical inputs always produce an identical
|
|
169
|
+
* plan (report/order included). No mutation of `options` or its nested values.
|
|
170
|
+
*/
|
|
171
|
+
export function planGoRoutes(options) {
|
|
172
|
+
const ref = options.ref ?? deriveKeyRef('opencode-go');
|
|
173
|
+
const routes = { ...GO_SLOT_ROUTES, ...(options.routes ?? {}) };
|
|
174
|
+
const pinned = new Set(options.pinnedModels ?? []);
|
|
175
|
+
const grouping = groupGoModelsByProtocol(options.entries);
|
|
176
|
+
const report = [];
|
|
177
|
+
const conflicts = [];
|
|
178
|
+
const plannedRoutes = [];
|
|
179
|
+
const unsetRoutes = [];
|
|
180
|
+
const nextOwnership = { ...options.ownership };
|
|
181
|
+
const desiredByRoute = {};
|
|
182
|
+
// Unknown / otherwise unsupported protocols are fail-closed: reported, never
|
|
183
|
+
// written (design §6.2.3, V1).
|
|
184
|
+
for (const unassigned of grouping.unassigned) {
|
|
185
|
+
report.push({
|
|
186
|
+
level: 'warn',
|
|
187
|
+
code: unassigned.reason,
|
|
188
|
+
id: unassigned.id,
|
|
189
|
+
message: `model ${unassigned.id} not assigned (${unassigned.protocols.join(',') || 'no protocols'})`,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const entryById = new Map(options.entries.map((entry) => [entry.id, entry]));
|
|
193
|
+
for (const slot of ['chat', 'msg', 'resp', 'google']) {
|
|
194
|
+
const desiredIds = grouping.slots[slot] ?? [];
|
|
195
|
+
const route = routes[slot];
|
|
196
|
+
const current = options.currentRoutes[route];
|
|
197
|
+
const ledgerKey = goOwnershipKey(route, options.keyFingerprint);
|
|
198
|
+
const owned = options.ownership[ledgerKey];
|
|
199
|
+
desiredByRoute[route] = [];
|
|
200
|
+
// Google slot is conditional and default-off (design §2.1): materialize it
|
|
201
|
+
// only when it has members, or when there is a previous ledger to clean up.
|
|
202
|
+
if (slot === 'google' && desiredIds.length === 0 && owned === undefined)
|
|
203
|
+
continue;
|
|
204
|
+
const slotEntries = desiredIds
|
|
205
|
+
.map((id) => entryById.get(id))
|
|
206
|
+
.filter((entry) => entry !== undefined);
|
|
207
|
+
const fields = planGoRouteFields(slot, slotEntries, ref);
|
|
208
|
+
// Empty group: never produce a `models: []` write (§9.4 / A9). Unset a
|
|
209
|
+
// fully plugin-managed route, otherwise skip (keeping the route as-is) and
|
|
210
|
+
// report. A slot with no route at all is not planned at all.
|
|
211
|
+
if (desiredIds.length === 0) {
|
|
212
|
+
const currentModels = current?.models ?? [];
|
|
213
|
+
if (current === undefined || !current.exists)
|
|
214
|
+
continue;
|
|
215
|
+
if (slot === 'chat') {
|
|
216
|
+
// §9.4: an empty main route after a 200 is an upstream anomaly — keep
|
|
217
|
+
// last-good, write nothing.
|
|
218
|
+
plannedRoutes.push({ slot, route, fields, models: [...currentModels], unset: false, skip: true });
|
|
219
|
+
report.push({ level: 'warn', code: 'upstream-empty', route, slot, message: 'main route has no members; kept last-good, no write' });
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const managed = owned?.managed ?? {};
|
|
223
|
+
const fullyManaged = owned !== undefined
|
|
224
|
+
&& currentModels.length > 0
|
|
225
|
+
&& currentModels.every((model) => {
|
|
226
|
+
const record = managed[model.id];
|
|
227
|
+
return record !== undefined && record.hash === profileHash(model);
|
|
228
|
+
})
|
|
229
|
+
&& ownedFieldsMatch(owned, fields);
|
|
230
|
+
if (fullyManaged) {
|
|
231
|
+
plannedRoutes.push({ slot, route, fields, models: [], unset: true, skip: false });
|
|
232
|
+
unsetRoutes.push(route);
|
|
233
|
+
report.push({ level: 'info', code: 'unset-route', route, slot, message: `route ${route} is empty and fully plugin-managed; unset` });
|
|
234
|
+
delete nextOwnership[ledgerKey];
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
plannedRoutes.push({ slot, route, fields, models: [...currentModels], unset: false, skip: true });
|
|
238
|
+
if (currentModels.length > 0) {
|
|
239
|
+
report.push({ level: 'warn', code: 'route-empty-has-user-content', route, slot, message: `route ${route} is empty but has user content; kept, no empty write` });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const conflict = detectConflict(slot, route, fields, current);
|
|
245
|
+
if (conflict !== undefined) {
|
|
246
|
+
conflicts.push(conflict);
|
|
247
|
+
report.push({
|
|
248
|
+
level: 'error',
|
|
249
|
+
code: 'route-conflict',
|
|
250
|
+
route,
|
|
251
|
+
slot,
|
|
252
|
+
message: `${route}.${conflict.field} is ${conflict.actual}, expected ${conflict.expected}`,
|
|
253
|
+
});
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const desiredById = new Map();
|
|
257
|
+
for (const id of desiredIds) {
|
|
258
|
+
const entry = entryById.get(id);
|
|
259
|
+
if (entry !== undefined)
|
|
260
|
+
desiredById.set(id, mapGoModelToProfile(entry));
|
|
261
|
+
}
|
|
262
|
+
desiredByRoute[route] = [...desiredById.values()];
|
|
263
|
+
const currentModels = current?.models ?? [];
|
|
264
|
+
const managed = owned?.managed ?? {};
|
|
265
|
+
const nextManaged = {};
|
|
266
|
+
const kept = [];
|
|
267
|
+
for (const model of currentModels) {
|
|
268
|
+
const id = model.id;
|
|
269
|
+
const desired = desiredById.get(id);
|
|
270
|
+
const record = managed[id];
|
|
271
|
+
const hashMatches = record !== undefined && record.hash === profileHash(model);
|
|
272
|
+
const hasOverride = (current?.overrideIds ?? []).includes(id);
|
|
273
|
+
const isPinned = pinned.has(id);
|
|
274
|
+
if (desired !== undefined) {
|
|
275
|
+
if (record !== undefined && hashMatches) {
|
|
276
|
+
// Plugin-owned and untouched: overwrite with the freshly mapped value.
|
|
277
|
+
const next = desired;
|
|
278
|
+
nextManaged[id] = { hash: profileHash(next) };
|
|
279
|
+
kept.push(next);
|
|
280
|
+
report.push({ level: 'info', code: 'overwrote-managed', route, slot, id, message: `refreshed plugin-managed model ${id}` });
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// Not in ledger, or hash differs (user edited): keep as-is, never claim.
|
|
284
|
+
kept.push(model);
|
|
285
|
+
if (record !== undefined)
|
|
286
|
+
nextManaged[id] = record;
|
|
287
|
+
report.push({
|
|
288
|
+
level: 'info',
|
|
289
|
+
code: 'kept-user-owned',
|
|
290
|
+
route,
|
|
291
|
+
slot,
|
|
292
|
+
id,
|
|
293
|
+
message: record !== undefined ? `model ${id} was modified; kept user value` : `model ${id} is user-owned; kept`,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
// Not desired: the three deletion gates (ADR-005 / §6.2.4).
|
|
299
|
+
if (record !== undefined && hashMatches && !hasOverride && !isPinned) {
|
|
300
|
+
report.push({ level: 'info', code: 'deletion-candidate', route, slot, id, message: `model ${id} passed all three deletion gates` });
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
kept.push(model);
|
|
304
|
+
if (record !== undefined)
|
|
305
|
+
nextManaged[id] = record;
|
|
306
|
+
const code = record === undefined
|
|
307
|
+
? 'kept-user-owned'
|
|
308
|
+
: !hashMatches
|
|
309
|
+
? 'kept-modified'
|
|
310
|
+
: hasOverride
|
|
311
|
+
? 'kept-override'
|
|
312
|
+
: 'kept-pinned';
|
|
313
|
+
report.push({ level: 'info', code, route, slot, id, message: `model ${id} kept (${code}); not removed` });
|
|
314
|
+
}
|
|
315
|
+
// New desired ids (absent from settings) are added and claimed.
|
|
316
|
+
const currentIds = new Set(currentModels.map((model) => model.id));
|
|
317
|
+
for (const id of desiredIds) {
|
|
318
|
+
if (currentIds.has(id))
|
|
319
|
+
continue;
|
|
320
|
+
const profile = desiredById.get(id);
|
|
321
|
+
if (profile === undefined)
|
|
322
|
+
continue;
|
|
323
|
+
nextManaged[id] = { hash: profileHash(profile) };
|
|
324
|
+
kept.push(profile);
|
|
325
|
+
report.push({ level: 'info', code: 'added', route, slot, id, message: `added model ${id}` });
|
|
326
|
+
}
|
|
327
|
+
// `desiredIds` is non-empty here, so the merged array is never empty.
|
|
328
|
+
const merged = [...kept].sort((a, b) => a.id.localeCompare(b.id));
|
|
329
|
+
plannedRoutes.push({ slot, route, fields, models: merged, unset: false, skip: false });
|
|
330
|
+
// P1d-2 ownership: inherit the prior entry so migration-period fields
|
|
331
|
+
// (`preManagedSection` / `appliedAddedIds` and any future ones) survive the
|
|
332
|
+
// plan round-trip untouched. The planner never writes or clears these — it
|
|
333
|
+
// only refreshes the fields it owns (routeFields / managed). The go writer
|
|
334
|
+
// applies the same merge when it persists the ledger entry.
|
|
335
|
+
nextOwnership[ledgerKey] = { ...owned, routeFields: fields, managed: nextManaged };
|
|
336
|
+
}
|
|
337
|
+
return { routes: plannedRoutes, unsetRoutes, conflicts, report, nextOwnership, desiredByRoute };
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=opencode-go-planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,uEAAuE;AACvE,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,gCAAgC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,cAAc,EACd,uBAAuB,GAExB,MAAM,2BAA2B,CAAA;AAElC,8EAA8E;AAC9E,yEAAyE;AACzE,8EAA8E;AAE9E,qEAAqE;AACrE,MAAM,CAAC,MAAM,cAAc,GAA0C;IACnE,IAAI,EAAE,oBAAoB;IAC1B,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,kBAAkB;IACxB,MAAM,EAAE,sBAAsB;CAC/B,CAAA;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAA0C;IAC5E,IAAI,EAAE,aAAa;IACnB,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,sBAAsB;CAC/B,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA0C;IACxE,I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AAI,OAAO,KAAK,SAAS;gBAAE,SAAQ;YACnC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAA;YAChD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAClB,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAA;QAC9F,CAAC;QAED,sEAAsE;QACtE,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACjE,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;QACtF,sEAAsE;QACtE,4EAA4E;QAC5E,2EAA2E;QAC3E,2EAA2E;QAC3E,4DAA4D;QAC5D,aAAa,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAA;IACpF,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,CAAA;AACjG,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Structural context seam: both services are optional peers in cordis. */
|
|
2
|
+
export interface ProfileIdentityContext {
|
|
3
|
+
get(name: 'profileContext'): {
|
|
4
|
+
name?: string;
|
|
5
|
+
dir?: string;
|
|
6
|
+
} | undefined;
|
|
7
|
+
get(name: 'launchEnvironment'): {
|
|
8
|
+
get(key: string): {
|
|
9
|
+
value: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
} | undefined;
|
|
12
|
+
get(name: string): unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the stable profile key from the host, or `undefined` when no identity
|
|
16
|
+
* is available. Structural `ctx.get` keeps the optional peers optional (SDK
|
|
17
|
+
* hosts provide neither, tests provide fakes). Callers on a migration/ownership
|
|
18
|
+
* ledger path MUST treat `undefined` as fail-closed — see
|
|
19
|
+
* `PROFILE_IDENTITY_REQUIRED_MESSAGE` for the actionable error to surface.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveProfileKey(ctx: ProfileIdentityContext): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Actionable error for a ledger path that cannot resolve a profile identity.
|
|
24
|
+
* Names verified against the dsh launcher source: `profileContext` ({ name,
|
|
25
|
+
* dir }) is a cordis service (profile-context.ts), `launchEnvironment` is the
|
|
26
|
+
* launcher snapshot service (`launchEnvironmentOf`), and `DSH_PROFILE` /
|
|
27
|
+
* `DSH_PROFILE_DIR` are the `DSH_` prefixed profile variables defined by the
|
|
28
|
+
* shell-env package (derived from `profileContext` for model-shell subprocesses).
|
|
29
|
+
*/
|
|
30
|
+
export declare const PROFILE_IDENTITY_REQUIRED_MESSAGE: string;
|
|
31
|
+
/**
|
|
32
|
+
* Compact, user-visible hint for a non-strict status refresh that degraded
|
|
33
|
+
* because the file-backed ledger could not be built without a profile identity
|
|
34
|
+
* (N2). Unlike the normal legacy hint, this states the fail-closed fact and how
|
|
35
|
+
* to fix it — it must never masquerade as a normal legacy state.
|
|
36
|
+
*/
|
|
37
|
+
export declare const PROFILE_IDENTITY_STATUS_HINT: string;
|
|
38
|
+
/** Prefix one opaque models-store slot with the profile dimension. */
|
|
39
|
+
export declare function scopedStoreKey(profileKey: string, key: string): string;
|
|
40
|
+
/** Base name of the opencode-go migration record slot (shared with migration.ts). */
|
|
41
|
+
export declare const GO_MIGRATION_STORE_KEY_BASE = "migration:opencode-go";
|
|
42
|
+
/**
|
|
43
|
+
* True only for an UNSCOPED legacy opaque key left in the shared store — one
|
|
44
|
+
* that carries NO profile dimension and whose ownership is therefore unknown.
|
|
45
|
+
*
|
|
46
|
+
* Explicit key shapes (design §6.1 / §14.1):
|
|
47
|
+
* `<profileKey>#<route>#<keyFingerprint>` → scoped ownership (3 parts) — NOT legacy.
|
|
48
|
+
* `<profileKey>#migration:opencode-go` → scoped migration record (2 parts,
|
|
49
|
+
* tail = base name) — NOT legacy.
|
|
50
|
+
* `<route>#<keyFingerprint>` → unscoped legacy ownership (2 parts) — legacy.
|
|
51
|
+
* `migration:opencode-go` → unscoped legacy migration (1 part),
|
|
52
|
+
* reported by the caller explicitly.
|
|
53
|
+
*
|
|
54
|
+
* Such keys are reported, never read or claimed. Scoped keys are NEVER legacy,
|
|
55
|
+
* regardless of how many '#' they contain.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isUnscopedStoreKey(key: string): boolean;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// B1: profile identity for the shared ~/.dsh/models-store.json (design §14.1,
|
|
2
|
+
// §14.7.4, H9). Every dsh profile on a machine writes the SAME models-store.json;
|
|
3
|
+
// without a profile dimension in the ledger/migration-record keys, profile A's
|
|
4
|
+
// `applied` record lets never-migrated profile B through the migration gate and
|
|
5
|
+
// A's rollback clobbers B's ledger + settings. This module supplies the profile
|
|
6
|
+
// dimension and the key primitives used by the file-backed stores.
|
|
7
|
+
//
|
|
8
|
+
// Identity source (host-provided — never guessed from settings or file names):
|
|
9
|
+
// 1. cordis `profileContext.name` (dsh app-boot): the launched profile name.
|
|
10
|
+
// 2. launchEnvironment `DSH_PROFILE`: the same value, launcher-provided env.
|
|
11
|
+
// 3. cordis `profileContext.dir` / launchEnvironment `DSH_PROFILE_DIR`:
|
|
12
|
+
// absolute profile directory, used ONLY when no name is available.
|
|
13
|
+
// 4. NO identity → FAIL CLOSED. `resolveProfileKey` returns undefined and the
|
|
14
|
+
// migration/ownership ledger callers refuse to read or write. There is
|
|
15
|
+
// deliberately NO silent 'default' collapse: two profiles with no resolved
|
|
16
|
+
// identity would share one key and reopen the B1 failure (design H9).
|
|
17
|
+
//
|
|
18
|
+
// Stability: the primary key is the profile NAME. It is fixed for the lifetime
|
|
19
|
+
// of a profile across restarts and processes. The host derives
|
|
20
|
+
// `name = basename(dir)`, so MOVING a profile directory while keeping its
|
|
21
|
+
// basename leaves the key stable; a move that also RENAMES the basename changes
|
|
22
|
+
// the name, hence the key: the old record becomes an orphan in the shared store,
|
|
23
|
+
// the renamed profile reads no record (absent/legacy) and fails CLOSED — it must
|
|
24
|
+
// re-run `migrate plan/apply`. We never auto-claim a record that carries another
|
|
25
|
+
// profile's identity. The directory fallback is less stable (moving/renaming the
|
|
26
|
+
// directory changes it) and is used only as a last resort.
|
|
27
|
+
function nonEmpty(value) {
|
|
28
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the stable profile key from the host, or `undefined` when no identity
|
|
32
|
+
* is available. Structural `ctx.get` keeps the optional peers optional (SDK
|
|
33
|
+
* hosts provide neither, tests provide fakes). Callers on a migration/ownership
|
|
34
|
+
* ledger path MUST treat `undefined` as fail-closed — see
|
|
35
|
+
* `PROFILE_IDENTITY_REQUIRED_MESSAGE` for the actionable error to surface.
|
|
36
|
+
*/
|
|
37
|
+
export function resolveProfileKey(ctx) {
|
|
38
|
+
const profile = ctx.get('profileContext');
|
|
39
|
+
const env = ctx.get('launchEnvironment');
|
|
40
|
+
return nonEmpty(profile?.name)
|
|
41
|
+
?? nonEmpty(env?.get('DSH_PROFILE')?.value)
|
|
42
|
+
?? nonEmpty(profile?.dir)
|
|
43
|
+
?? nonEmpty(env?.get('DSH_PROFILE_DIR')?.value);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Actionable error for a ledger path that cannot resolve a profile identity.
|
|
47
|
+
* Names verified against the dsh launcher source: `profileContext` ({ name,
|
|
48
|
+
* dir }) is a cordis service (profile-context.ts), `launchEnvironment` is the
|
|
49
|
+
* launcher snapshot service (`launchEnvironmentOf`), and `DSH_PROFILE` /
|
|
50
|
+
* `DSH_PROFILE_DIR` are the `DSH_` prefixed profile variables defined by the
|
|
51
|
+
* shell-env package (derived from `profileContext` for model-shell subprocesses).
|
|
52
|
+
*/
|
|
53
|
+
export const PROFILE_IDENTITY_REQUIRED_MESSAGE = [
|
|
54
|
+
'model-sync: cannot resolve the dsh profile identity for the opencode-go migration/ownership ledger.',
|
|
55
|
+
'Refusing to share a single key across profiles: without a stable per-profile key another profile could inherit this migration state.',
|
|
56
|
+
'Fix: launch the plugin inside a dsh profile so ctx.profileContext.name (or ctx.profileContext.dir) is available,',
|
|
57
|
+
'or expose the launcher-provided DSH_PROFILE / DSH_PROFILE_DIR values through ctx.launchEnvironment.',
|
|
58
|
+
'No migration record or ledger key was read or written.',
|
|
59
|
+
].join(' ');
|
|
60
|
+
/**
|
|
61
|
+
* Compact, user-visible hint for a non-strict status refresh that degraded
|
|
62
|
+
* because the file-backed ledger could not be built without a profile identity
|
|
63
|
+
* (N2). Unlike the normal legacy hint, this states the fail-closed fact and how
|
|
64
|
+
* to fix it — it must never masquerade as a normal legacy state.
|
|
65
|
+
*/
|
|
66
|
+
export const PROFILE_IDENTITY_STATUS_HINT = [
|
|
67
|
+
'profile 身份不可用 → opencode-go 迁移记录与账本已 fail-closed(未读未写,同步已跳过);',
|
|
68
|
+
'修复:在 dsh profile 内启动插件,或向 ctx.launchEnvironment 暴露 DSH_PROFILE / DSH_PROFILE_DIR',
|
|
69
|
+
].join(' ');
|
|
70
|
+
/** Prefix one opaque models-store slot with the profile dimension. */
|
|
71
|
+
export function scopedStoreKey(profileKey, key) {
|
|
72
|
+
return `${profileKey}#${key}`;
|
|
73
|
+
}
|
|
74
|
+
/** Base name of the opencode-go migration record slot (shared with migration.ts). */
|
|
75
|
+
export const GO_MIGRATION_STORE_KEY_BASE = 'migration:opencode-go';
|
|
76
|
+
/**
|
|
77
|
+
* True only for an UNSCOPED legacy opaque key left in the shared store — one
|
|
78
|
+
* that carries NO profile dimension and whose ownership is therefore unknown.
|
|
79
|
+
*
|
|
80
|
+
* Explicit key shapes (design §6.1 / §14.1):
|
|
81
|
+
* `<profileKey>#<route>#<keyFingerprint>` → scoped ownership (3 parts) — NOT legacy.
|
|
82
|
+
* `<profileKey>#migration:opencode-go` → scoped migration record (2 parts,
|
|
83
|
+
* tail = base name) — NOT legacy.
|
|
84
|
+
* `<route>#<keyFingerprint>` → unscoped legacy ownership (2 parts) — legacy.
|
|
85
|
+
* `migration:opencode-go` → unscoped legacy migration (1 part),
|
|
86
|
+
* reported by the caller explicitly.
|
|
87
|
+
*
|
|
88
|
+
* Such keys are reported, never read or claimed. Scoped keys are NEVER legacy,
|
|
89
|
+
* regardless of how many '#' they contain.
|
|
90
|
+
*/
|
|
91
|
+
export function isUnscopedStoreKey(key) {
|
|
92
|
+
const parts = key.split('#');
|
|
93
|
+
if (parts.length !== 2)
|
|
94
|
+
return false;
|
|
95
|
+
const [prefix, tail] = parts;
|
|
96
|
+
if (prefix.length === 0 || tail.length === 0)
|
|
97
|
+
return false;
|
|
98
|
+
// A two-part key whose tail is the migration base name is a profile-scoped
|
|
99
|
+
// migration record, not a legacy key. Only other two-part keys (an unscoped
|
|
100
|
+
// `<route>#<keyFingerprint>` ownership slot) are legacy.
|
|
101
|
+
return tail !== GO_MIGRATION_STORE_KEY_BASE;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=opencode-go-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-go-profile.js","sourceRoot":"","sources":["../src/opencode-go-profile.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,kFAAkF;AAClF,+EAA+E;AAC/E,gFAAgF;AAChF,gFAAgF;AAChF,mEAAmE;AACnE,EAAE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AAC,CAAA;AAEX,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,UAAkB,EAAE,GAAW;IAC5D,OAAO,GAAG,UAAU,IAAI,GAAG,EAAE,CAAA;AAC/B,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAA;AAElE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACpC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,KAAK,CAAA;IAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1D,2EAA2E;IAC3E,4EAA4E;IAC5E,yDAAyD;IACzD,OAAO,IAAI,KAAK,2BAA2B,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
}
|