@aiwayds/dsh-model-sync 0.11.0 → 0.12.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 +1 -1
- package/README.zh-CN.md +1 -1
- package/lib/builtin-catalog-snapshot.js +4 -5
- package/lib/builtin-catalog-snapshot.js.map +1 -1
- package/lib/index.js +22 -2
- package/lib/index.js.map +1 -1
- package/lib/opencode-go-diagnose.d.ts +21 -20
- package/lib/opencode-go-diagnose.js +54 -54
- package/lib/opencode-go-diagnose.js.map +1 -1
- package/lib/opencode-go-grouping.d.ts +4 -26
- package/lib/opencode-go-grouping.js +12 -68
- package/lib/opencode-go-grouping.js.map +1 -1
- package/lib/opencode-go-migrate.d.ts +3 -1
- package/lib/opencode-go-migrate.js +124 -53
- package/lib/opencode-go-migrate.js.map +1 -1
- package/lib/opencode-go-one-shot.js +5 -3
- package/lib/opencode-go-one-shot.js.map +1 -1
- package/lib/opencode-go-planner.d.ts +25 -24
- package/lib/opencode-go-planner.js +175 -209
- package/lib/opencode-go-planner.js.map +1 -1
- package/lib/opencode-go-writer.js +21 -10
- package/lib/opencode-go-writer.js.map +1 -1
- package/package.json +1 -1
- package/src/builtin-catalog-snapshot.ts +4 -5
- package/src/index.ts +22 -2
- package/src/opencode-go-diagnose.ts +68 -67
- package/src/opencode-go-grouping.ts +14 -85
- package/src/opencode-go-migrate.ts +127 -57
- package/src/opencode-go-one-shot.ts +5 -3
- package/src/opencode-go-planner.ts +185 -218
- package/src/opencode-go-writer.ts +21 -9
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// P0 read-only diagnostic: compare the official opencode-go model set with
|
|
2
|
-
// the current profile's opencode-go route
|
|
3
|
-
// structured report (added / missing /
|
|
2
|
+
// the current profile's single managed opencode-go route and produce a
|
|
3
|
+
// structured report (added / missing / superseded legacy routes).
|
|
4
|
+
//
|
|
5
|
+
// 0.12.0 single-route shape: the official listing is diffed against ONE
|
|
6
|
+
// managed route (the `chat` slot route); the three legacy protocol routes are
|
|
7
|
+
// listed separately with a superseded hint (sync unsets them when fully
|
|
8
|
+
// plugin-managed). There is no per-protocol grouping anymore — unknown
|
|
9
|
+
// protocols can no longer fail anything closed.
|
|
4
10
|
//
|
|
5
11
|
// Hard boundary: this module only READS a settings descriptor. It never calls
|
|
6
12
|
// settings.mutate, never writes credentials, and never touches a profile file.
|
|
@@ -8,25 +14,14 @@
|
|
|
8
14
|
//
|
|
9
15
|
// Design: 07-design.md §6.3 (status), §16 P0, C7, final review §1.7.
|
|
10
16
|
import { fetchGoOfficialModels, } from "./opencode-go-source.js";
|
|
11
|
-
import { GO_SLOT_ROUTES
|
|
17
|
+
import { GO_SLOT_ROUTES } from "./opencode-go-grouping.js";
|
|
12
18
|
// ---------------------------------------------------------------------------
|
|
13
19
|
// Read-only profile extraction
|
|
14
20
|
// ---------------------------------------------------------------------------
|
|
15
21
|
function isRecord(value) {
|
|
16
22
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
17
23
|
}
|
|
18
|
-
function
|
|
19
|
-
if (route === GO_SLOT_ROUTES.chat)
|
|
20
|
-
return 'chat';
|
|
21
|
-
if (route === GO_SLOT_ROUTES.msg)
|
|
22
|
-
return 'msg';
|
|
23
|
-
if (route === GO_SLOT_ROUTES.resp)
|
|
24
|
-
return 'resp';
|
|
25
|
-
if (route === GO_SLOT_ROUTES.google)
|
|
26
|
-
return 'google';
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
function toRouteConfig(slot, route, providers) {
|
|
24
|
+
function toRouteConfig(route, managed, providers) {
|
|
30
25
|
const routeData = providers[route];
|
|
31
26
|
const models = isRecord(routeData) ? routeData.models : undefined;
|
|
32
27
|
const configuredIds = Array.isArray(models)
|
|
@@ -34,31 +29,23 @@ function toRouteConfig(slot, route, providers) {
|
|
|
34
29
|
.map((entry) => isRecord(entry) && typeof entry.id === 'string' ? entry.id : undefined)
|
|
35
30
|
.filter((id) => id !== undefined)
|
|
36
31
|
: [];
|
|
37
|
-
return {
|
|
32
|
+
return { route, configuredIds, managed };
|
|
38
33
|
}
|
|
39
34
|
/**
|
|
40
35
|
* Read the profile's opencode-go route model ids from a settings descriptor.
|
|
41
|
-
* The
|
|
42
|
-
*
|
|
43
|
-
* This is a pure read — the descriptor is never modified.
|
|
36
|
+
* The single managed route (`chat` slot) is always present (possibly empty);
|
|
37
|
+
* the three legacy slot routes are listed only when they actually exist in
|
|
38
|
+
* the profile. This is a pure read — the descriptor is never modified.
|
|
44
39
|
*/
|
|
45
40
|
export function readGoRoutesFromDescriptor(desc) {
|
|
46
41
|
const providers = desc?.user?.providers;
|
|
47
42
|
const table = isRecord(providers) ? providers : {};
|
|
48
|
-
const configs = [];
|
|
49
|
-
const
|
|
50
|
-
for (const slot of ['chat', 'msg', 'resp', 'google']) {
|
|
43
|
+
const configs = [toRouteConfig(GO_SLOT_ROUTES.chat, true, table)];
|
|
44
|
+
for (const slot of ['msg', 'resp', 'google']) {
|
|
51
45
|
const route = GO_SLOT_ROUTES[slot];
|
|
52
|
-
|
|
53
|
-
seen.add(route);
|
|
54
|
-
}
|
|
55
|
-
for (const route of Object.keys(table)) {
|
|
56
|
-
if (!route.startsWith('opencode-go') || seen.has(route))
|
|
46
|
+
if (!isRecord(table[route]))
|
|
57
47
|
continue;
|
|
58
|
-
|
|
59
|
-
if (slot === undefined)
|
|
60
|
-
continue;
|
|
61
|
-
configs.push(toRouteConfig(slot, route, table));
|
|
48
|
+
configs.push(toRouteConfig(route, false, table));
|
|
62
49
|
}
|
|
63
50
|
return configs;
|
|
64
51
|
}
|
|
@@ -71,22 +58,34 @@ function missingFrom(left, right) {
|
|
|
71
58
|
}
|
|
72
59
|
/**
|
|
73
60
|
* Build the structured report. When the source read failed (no key, auth,
|
|
74
|
-
entitlement, transport), the official side is empty and the diff is
|
|
75
|
-
* — reporting every configured model as "missing" from a failed
|
|
76
|
-
* misleading. The failure is carried in authStatus / error
|
|
61
|
+
* entitlement, transport), the official side is empty and the diff is
|
|
62
|
+
* suppressed — reporting every configured model as "missing" from a failed
|
|
63
|
+
* read would be misleading. The failure is carried in authStatus / error
|
|
64
|
+
* instead.
|
|
77
65
|
*/
|
|
78
66
|
export function buildGoDiagnosticReport(input) {
|
|
79
67
|
const available = input.source.ok;
|
|
68
|
+
const officialIds = available ? input.source.entries.map((entry) => entry.id) : [];
|
|
80
69
|
const routes = input.routes.map((config) => {
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
if (config.managed) {
|
|
71
|
+
const configured = config.configuredIds;
|
|
72
|
+
return {
|
|
73
|
+
route: config.route,
|
|
74
|
+
official: [...officialIds],
|
|
75
|
+
configured,
|
|
76
|
+
added: available ? missingFrom(officialIds, configured) : [],
|
|
77
|
+
missing: available ? missingFrom(configured, officialIds) : [],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Legacy protocol route: no official placement anymore; listed for the
|
|
81
|
+
// superseded hint only.
|
|
83
82
|
return {
|
|
84
|
-
slot: config.slot,
|
|
85
83
|
route: config.route,
|
|
86
|
-
official,
|
|
87
|
-
configured,
|
|
88
|
-
added:
|
|
89
|
-
missing:
|
|
84
|
+
official: [],
|
|
85
|
+
configured: config.configuredIds,
|
|
86
|
+
added: [],
|
|
87
|
+
missing: [],
|
|
88
|
+
superseded: true,
|
|
90
89
|
};
|
|
91
90
|
});
|
|
92
91
|
const report = {
|
|
@@ -95,7 +94,6 @@ export function buildGoDiagnosticReport(input) {
|
|
|
95
94
|
authStatus: input.source.authStatus,
|
|
96
95
|
keyFingerprint: input.source.keyFingerprint,
|
|
97
96
|
routes,
|
|
98
|
-
unassigned: available ? input.grouping.unassigned : [],
|
|
99
97
|
};
|
|
100
98
|
if (input.source.payloadHash !== undefined)
|
|
101
99
|
report.payloadHash = input.source.payloadHash;
|
|
@@ -116,20 +114,23 @@ export function formatGoDiagnosticReport(report) {
|
|
|
116
114
|
lines.push(` status: ${report.error.kind}${report.error.status !== undefined ? ` (HTTP ${report.error.status})` : ''}`);
|
|
117
115
|
lines.push(` reason: ${report.error.message}`);
|
|
118
116
|
}
|
|
119
|
-
for (const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
for (const route of report.routes) {
|
|
118
|
+
if (route.superseded === true) {
|
|
119
|
+
lines.push(` ${route.route} [legacy/superseded]: configured ${route.configured.length}`
|
|
120
|
+
+ ` (${route.configured.join(', ') || 'none'})`
|
|
121
|
+
+ ' — superseded by the single managed route; sync unsets it when fully plugin-managed');
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
lines.push(` ${route.route} [managed]: official ${route.official.length}, configured ${route.configured.length}`
|
|
125
|
+
+ `; +${route.added.join(', +') || 'none'}`
|
|
126
|
+
+ `; -${route.missing.join(', -') || 'none'}`);
|
|
126
127
|
}
|
|
127
128
|
return lines.join('\n');
|
|
128
129
|
}
|
|
129
130
|
/**
|
|
130
|
-
* Run one read-only diagnostic: fetch official models,
|
|
131
|
-
*
|
|
132
|
-
*
|
|
131
|
+
* Run one read-only diagnostic: fetch official models, read the profile's
|
|
132
|
+
* route config, and return the structured report. Pass `fetchImpl` in tests
|
|
133
|
+
* so no network is ever touched.
|
|
133
134
|
*/
|
|
134
135
|
export async function runGoDiagnostic(options = {}) {
|
|
135
136
|
const source = await fetchGoOfficialModels({
|
|
@@ -139,8 +140,7 @@ export async function runGoDiagnostic(options = {}) {
|
|
|
139
140
|
fetchImpl: options.fetchImpl,
|
|
140
141
|
observedAt: options.generatedAt,
|
|
141
142
|
});
|
|
142
|
-
const grouping = groupGoModelsByProtocol(source.entries);
|
|
143
143
|
const routes = readGoRoutesFromDescriptor(options.descriptor);
|
|
144
|
-
return buildGoDiagnosticReport({ source,
|
|
144
|
+
return buildGoDiagnosticReport({ source, routes, generatedAt: options.generatedAt });
|
|
145
145
|
}
|
|
146
146
|
//# sourceMappingURL=opencode-go-diagnose.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-go-diagnose.js","sourceRoot":"","sources":["../src/opencode-go-diagnose.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"opencode-go-diagnose.js","sourceRoot":"","sources":["../src/opencode-go-diagnose.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,uEAAuE;AACvE,kEAAkE;AAClE,EAAE;AACF,wEAAwE;AACxE,8EAA8E;AAC9E,wEAAwE;AACxE,uEAAuE;AACvE,gDAAgD;AAChD,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,mEAAmE;AACnE,EAAE;AACF,qEAAqE;AAErE,OAAO,EACL,qBAAqB,GAKtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAiD1D,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAE9E,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,OAAgB,EAAE,SAAkC;IACxF,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;IAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;IACjE,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACzC,CAAC,CAAC,MAAM;aACH,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;aACtF,MAAM,CAAC,CAAC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AAK,CAAC,IAAI,CACR,KAAK,KAAK,CAAC,KAAK,wBAAwB,KAAK,CAAC,QAAQ,CAAC,MAAM,gBAAgB,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE;cACpG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,EAAE;cACzC,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,EAAE,CAC9C,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAgBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UAAkC,EAAE;IACxE,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC;QACzC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,UAAU,EAAE,OAAO,CAAC,WAAW;KAChC,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,0BAA0B,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC7D,OAAO,uBAAuB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;AACtF,CAAC"}
|
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** The route slots of the go topology. `chat` is the only managed route; the
|
|
2
|
+
* other three are legacy cleanup targets kept for `go.routes` compat. */
|
|
3
3
|
export type GoRouteSlot = 'chat' | 'msg' | 'resp' | 'google';
|
|
4
4
|
export declare const GO_ROUTE_SLOTS: readonly GoRouteSlot[];
|
|
5
|
-
/** Default route id per slot (design §6.2.6).
|
|
5
|
+
/** Default route id per slot (design §6.2.6). The `chat` id names the single
|
|
6
|
+
* managed route; msg/resp/google name the legacy routes sync cleans up. */
|
|
6
7
|
export declare const GO_SLOT_ROUTES: Readonly<Record<GoRouteSlot, string>>;
|
|
7
|
-
/** Official protocol names this plugin knows how to place. */
|
|
8
|
-
export declare const GO_KNOWN_PROTOCOLS: ReadonlySet<string>;
|
|
9
|
-
export interface GoUnassignedModel {
|
|
10
|
-
id: string;
|
|
11
|
-
protocols: string[];
|
|
12
|
-
reason: 'unsupported-protocol' | 'unknown-protocol';
|
|
13
|
-
}
|
|
14
|
-
export interface GoGroupingResult {
|
|
15
|
-
slots: Record<GoRouteSlot, string[]>;
|
|
16
|
-
/** Models that must not be written anywhere, with the reason why. */
|
|
17
|
-
unassigned: GoUnassignedModel[];
|
|
18
|
-
}
|
|
19
|
-
/** Map an official protocol key to a route slot. */
|
|
20
|
-
export declare function slotForProtocol(protocol: string): GoRouteSlot | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Group official model ids by protocol (design §6.2.3):
|
|
23
|
-
* - chat-completions present → chat (wins over any other protocol)
|
|
24
|
-
* - exactly {messages} → msg; exactly {responses} → resp
|
|
25
|
-
* - subset of {interactions, generate-content} → google
|
|
26
|
-
* - multiple non-chat protocols → recommended_api breaks the tie
|
|
27
|
-
* - empty / unknown / otherwise unsupported → unassigned (reported, never written)
|
|
28
|
-
*/
|
|
29
|
-
export declare function groupGoModelsByProtocol(entries: readonly GoModelRecord[]): GoGroupingResult;
|
|
@@ -1,77 +1,21 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Route topology for the opencode-go single-route (catalog-reuse) write shape.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// 0.12.0 collapsed the four protocol routes into ONE managed route: the host
|
|
4
|
+
// (dsh-llm-pi-ai) only reuses pi-ai's builtin catalog provider when a route
|
|
5
|
+
// carries NO `api` field, and pi-ai 1.6.0's opencode-go catalog entries each
|
|
6
|
+
// carry their own per-protocol baseUrl — so any baseURL written on the single
|
|
7
|
+
// route would point at the wrong endpoint. The plugin therefore manages only
|
|
8
|
+
// the `chat` route and treats the three old protocol routes as legacy cleanup
|
|
9
|
+
// targets.
|
|
10
|
+
//
|
|
11
|
+
// Pure constants only (07-design.md §6.2.2 as revised). No settings/IO here.
|
|
5
12
|
export const GO_ROUTE_SLOTS = ['chat', 'msg', 'resp', 'google'];
|
|
6
|
-
/** Default route id per slot (design §6.2.6).
|
|
13
|
+
/** Default route id per slot (design §6.2.6). The `chat` id names the single
|
|
14
|
+
* managed route; msg/resp/google name the legacy routes sync cleans up. */
|
|
7
15
|
export const GO_SLOT_ROUTES = {
|
|
8
16
|
chat: 'opencode-go',
|
|
9
17
|
msg: 'opencode-go-msg',
|
|
10
18
|
resp: 'opencode-go-resp',
|
|
11
19
|
google: 'opencode-go-google',
|
|
12
20
|
};
|
|
13
|
-
/** Official protocol names this plugin knows how to place. */
|
|
14
|
-
export const GO_KNOWN_PROTOCOLS = new Set([
|
|
15
|
-
'chat-completions',
|
|
16
|
-
'messages',
|
|
17
|
-
'responses',
|
|
18
|
-
'interactions',
|
|
19
|
-
'generate-content',
|
|
20
|
-
]);
|
|
21
|
-
/** Map an official protocol key to a route slot. */
|
|
22
|
-
export function slotForProtocol(protocol) {
|
|
23
|
-
switch (protocol) {
|
|
24
|
-
case 'chat-completions': return 'chat';
|
|
25
|
-
case 'messages': return 'msg';
|
|
26
|
-
case 'responses': return 'resp';
|
|
27
|
-
case 'interactions':
|
|
28
|
-
case 'generate-content': return 'google';
|
|
29
|
-
default: return undefined;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Group official model ids by protocol (design §6.2.3):
|
|
34
|
-
* - chat-completions present → chat (wins over any other protocol)
|
|
35
|
-
* - exactly {messages} → msg; exactly {responses} → resp
|
|
36
|
-
* - subset of {interactions, generate-content} → google
|
|
37
|
-
* - multiple non-chat protocols → recommended_api breaks the tie
|
|
38
|
-
* - empty / unknown / otherwise unsupported → unassigned (reported, never written)
|
|
39
|
-
*/
|
|
40
|
-
export function groupGoModelsByProtocol(entries) {
|
|
41
|
-
const slots = { chat: [], msg: [], resp: [], google: [] };
|
|
42
|
-
const unassigned = [];
|
|
43
|
-
for (const entry of entries) {
|
|
44
|
-
const protocols = entry.protocols;
|
|
45
|
-
const unknown = protocols.filter((protocol) => !GO_KNOWN_PROTOCOLS.has(protocol));
|
|
46
|
-
if (unknown.length > 0) {
|
|
47
|
-
unassigned.push({ id: entry.id, protocols: [...protocols], reason: 'unknown-protocol' });
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
let slot;
|
|
51
|
-
if (protocols.length === 0) {
|
|
52
|
-
// no placement
|
|
53
|
-
}
|
|
54
|
-
else if (protocols.includes('chat-completions')) {
|
|
55
|
-
slot = 'chat';
|
|
56
|
-
}
|
|
57
|
-
else if (protocols.length === 1 && protocols[0] === 'messages') {
|
|
58
|
-
slot = 'msg';
|
|
59
|
-
}
|
|
60
|
-
else if (protocols.length === 1 && protocols[0] === 'responses') {
|
|
61
|
-
slot = 'resp';
|
|
62
|
-
}
|
|
63
|
-
else if (protocols.every((p) => p === 'interactions' || p === 'generate-content')) {
|
|
64
|
-
slot = 'google';
|
|
65
|
-
}
|
|
66
|
-
else if (protocols.length > 1 && entry.recommendedProtocol !== undefined) {
|
|
67
|
-
slot = slotForProtocol(entry.recommendedProtocol);
|
|
68
|
-
}
|
|
69
|
-
if (slot === undefined) {
|
|
70
|
-
unassigned.push({ id: entry.id, protocols: [...protocols], reason: 'unsupported-protocol' });
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
slots[slot].push(entry.id);
|
|
74
|
-
}
|
|
75
|
-
return { slots, unassigned };
|
|
76
|
-
}
|
|
77
21
|
//# sourceMappingURL=opencode-go-grouping.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-go-grouping.js","sourceRoot":"","sources":["../src/opencode-go-grouping.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"opencode-go-grouping.js","sourceRoot":"","sources":["../src/opencode-go-grouping.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,WAAW;AACX,EAAE;AACF,6EAA6E;AAM7E,MAAM,CAAC,MAAM,cAAc,GAA2B,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AAEvF;4EAC4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAA0C;IACnE,IAAI,EAAE,aAAa;IACnB,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,kBAAkB;IACxB,MAAM,EAAE,oBAAoB;CAC7B,CAAA"}
|
|
@@ -9,7 +9,9 @@ import type { Logger, SettingsDescriptor, SettingsService } from './writer.ts';
|
|
|
9
9
|
/** What apply will do with one route. */
|
|
10
10
|
export type MigrationAction = 'create' | 'update' | 'keep' | 'unset';
|
|
11
11
|
/** Classification of one id that exists in the current route (design §14.2). */
|
|
12
|
-
export type MigrationIdKind =
|
|
12
|
+
export type MigrationIdKind =
|
|
13
|
+
/** Official desired id — always targets the single managed route (0.12.0). */
|
|
14
|
+
'desired' | 'legacy-other-protocol' | 'unknown-retired' | 'user-extra'
|
|
13
15
|
/** Public catalog unavailable (offline/401/403) — fail-closed, never deleted (§14.2). */
|
|
14
16
|
| 'unclassified';
|
|
15
17
|
export interface MigrationIdClass {
|
|
@@ -18,10 +18,14 @@
|
|
|
18
18
|
// §14.5 (commands), §14.6 (order + single flight), §14.7 (write authority),
|
|
19
19
|
// V16/V17/V19/V20/V22. No timer, no network, no real ~/.dsh lives here.
|
|
20
20
|
import { createHash } from 'node:crypto';
|
|
21
|
-
import { GO_SLOT_ROUTES,
|
|
22
|
-
import { goOwnershipKey, mapGoModelToProfile, planGoRouteFields, profileHash, } from "./opencode-go-planner.js";
|
|
21
|
+
import { GO_SLOT_ROUTES, } from "./opencode-go-grouping.js";
|
|
22
|
+
import { goOwnershipKey, mapGoModelToProfile, planGoRouteFields, profileHash, GO_LEGACY_ROUTE_FIELDS, } from "./opencode-go-planner.js";
|
|
23
23
|
import { appliedFingerprintOf, fingerprintGoIdentity, fingerprintSection, readGoProviderSections, routeWriter, unclaimedRecordState, } from "./opencode-go-migration.js";
|
|
24
|
-
|
|
24
|
+
// 0.12.0 catalog-reuse: the only route field migrate writes is `apiKeyEnv`.
|
|
25
|
+
// `api`/`baseURL` are stripped (they make the host leave pi-ai's builtin
|
|
26
|
+
// catalog provider — and its x-opencode-session wrapping — behind), and
|
|
27
|
+
// `displayName` is never rewritten so a user rename survives the migration.
|
|
28
|
+
const OWNED_FIELDS = ['apiKeyEnv'];
|
|
25
29
|
const PLAN_VERSION = 1;
|
|
26
30
|
// ---------------------------------------------------------------------------
|
|
27
31
|
// Pure helpers: canonical hash + confirmation code (V16 / V17)
|
|
@@ -108,6 +112,13 @@ export function verifyConsent(plan, planHash, confirmCode, ackManaged) {
|
|
|
108
112
|
// ---------------------------------------------------------------------------
|
|
109
113
|
// Pure plan builder (V16: zero writes / zero external calls)
|
|
110
114
|
// ---------------------------------------------------------------------------
|
|
115
|
+
/** Raw models array of one section from a readGoProviderSections result. */
|
|
116
|
+
function routeModels(sections, route) {
|
|
117
|
+
const section = sections?.[route];
|
|
118
|
+
return isRecord(section) && Array.isArray(section.models)
|
|
119
|
+
? section.models
|
|
120
|
+
: [];
|
|
121
|
+
}
|
|
111
122
|
/** Per-route state, refined from the full-set state (§14.1). */
|
|
112
123
|
function detectRouteStates(sections, record, routeIds, overall) {
|
|
113
124
|
const identityRoutes = record?.appliedIdentityRoutes ?? Object.keys(sections ?? {});
|
|
@@ -177,43 +188,42 @@ export function buildMigrationPlan(input) {
|
|
|
177
188
|
const adoptDisabled = input.adoptDisabled === true;
|
|
178
189
|
const adopt = input.adopt === true && !adoptDisabled;
|
|
179
190
|
const rewriteRefs = input.rewriteRefs ?? 'none';
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
// 0.12.0 desired collapse: EVERY official entry targets the single managed
|
|
192
|
+
// route (routes.chat). The three legacy protocol routes act only as move
|
|
193
|
+
// sources (adopt) / keep sources (conservative) for ids still sitting there.
|
|
194
|
+
const targetRoute = routes.chat;
|
|
195
|
+
const targetSlot = 'chat';
|
|
196
|
+
const fields = planGoRouteFields(input.entries, input.ref);
|
|
197
|
+
const desired = input.entries
|
|
198
|
+
.map(mapGoModelToProfile)
|
|
199
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
200
|
+
const desiredIds = new Set(desired.map((profile) => profile.id));
|
|
201
|
+
// Routes actually in scope for this plan: the managed route always; a legacy
|
|
202
|
+
// slot route only when its section exists (a never-created route has nothing
|
|
203
|
+
// to migrate).
|
|
204
|
+
const scopedRoutes = [{
|
|
205
|
+
slot: targetSlot,
|
|
206
|
+
route: targetRoute,
|
|
207
|
+
state: stateByRoute[targetRoute] ?? 'absent',
|
|
208
|
+
fields,
|
|
209
|
+
desired,
|
|
210
|
+
currentModels: routeModels(sections, targetRoute),
|
|
211
|
+
}];
|
|
212
|
+
for (const slot of ['msg', 'resp', 'google']) {
|
|
200
213
|
const route = routes[slot];
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const desiredTarget = new Map();
|
|
212
|
-
for (const scope of scopedRoutes) {
|
|
213
|
-
for (const profile of scope.desired) {
|
|
214
|
-
desiredTarget.set(profile.id, { slot: scope.slot, route: scope.route, profile });
|
|
215
|
-
}
|
|
214
|
+
if (sections?.[route] === undefined)
|
|
215
|
+
continue;
|
|
216
|
+
scopedRoutes.push({
|
|
217
|
+
slot,
|
|
218
|
+
route,
|
|
219
|
+
state: stateByRoute[route] ?? 'absent',
|
|
220
|
+
fields,
|
|
221
|
+
desired: [],
|
|
222
|
+
currentModels: routeModels(sections, route),
|
|
223
|
+
});
|
|
216
224
|
}
|
|
225
|
+
// desired id → its official target (always the single managed route).
|
|
226
|
+
const desiredTarget = new Map(desired.map((profile) => [profile.id, { slot: targetSlot, route: targetRoute, profile }]));
|
|
217
227
|
// Every id currently in settings, with all the routes it occupies.
|
|
218
228
|
const currentLocations = new Map();
|
|
219
229
|
for (const scope of scopedRoutes) {
|
|
@@ -223,6 +233,12 @@ export function buildMigrationPlan(input) {
|
|
|
223
233
|
currentLocations.set(profile.id, list);
|
|
224
234
|
}
|
|
225
235
|
}
|
|
236
|
+
// Ids whose references change under this plan: desired ids still sitting on
|
|
237
|
+
// a legacy protocol route (they end up on the managed route after apply).
|
|
238
|
+
const targets = desired
|
|
239
|
+
.filter((profile) => (currentLocations.get(profile.id) ?? []).some((loc) => loc.route !== targetRoute))
|
|
240
|
+
.map((profile) => profile.id);
|
|
241
|
+
const references = input.references ?? defaultReferences(targets, rewriteRefs);
|
|
226
242
|
const pinnedIds = new Set(input.pinnedModels ?? []);
|
|
227
243
|
// `undefined` is materially different from an empty list: empty means the
|
|
228
244
|
// catalog was fetched and truly has no such id (→ user-extra); undefined means
|
|
@@ -231,9 +247,8 @@ export function buildMigrationPlan(input) {
|
|
|
231
247
|
const publicIds = new Set(input.publicCatalogIds ?? []);
|
|
232
248
|
const pruneUserExtra = input.pruneUserExtra === true;
|
|
233
249
|
const kindOf = (id) => {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return `desired-${target.slot}`;
|
|
250
|
+
if (desiredTarget.has(id))
|
|
251
|
+
return 'desired';
|
|
237
252
|
// Fail-closed (§14.2): no public catalog → never guess "user-written".
|
|
238
253
|
if (!publicCatalogAvailable)
|
|
239
254
|
return 'unclassified';
|
|
@@ -360,7 +375,7 @@ export function buildMigrationPlan(input) {
|
|
|
360
375
|
willDelete: true,
|
|
361
376
|
reason: action.reason,
|
|
362
377
|
}));
|
|
363
|
-
const
|
|
378
|
+
const plannedRoutesDraft = scopedRoutes.map((scope) => {
|
|
364
379
|
const seen = new Set();
|
|
365
380
|
const existing = [];
|
|
366
381
|
for (const profile of scope.currentModels) {
|
|
@@ -387,18 +402,36 @@ export function buildMigrationPlan(input) {
|
|
|
387
402
|
action = 'update';
|
|
388
403
|
return { slot: scope.slot, route: scope.route, state: scope.state, action, fields: scope.fields, desired: scope.desired, existing };
|
|
389
404
|
});
|
|
405
|
+
// ONE plan-time simulation — the SAME function apply executes — decides both
|
|
406
|
+
// the informed-consent id set and which legacy routes end up emptied. A
|
|
407
|
+
// legacy protocol route whose post-apply models map is empty carries no
|
|
408
|
+
// user content anymore: apply will whole-section unset it (never a
|
|
409
|
+
// `models: []` write) and delete its ledger key.
|
|
410
|
+
const simulation = buildRouteWriteStates({ routes: plannedRoutesDraft, idActions }, input.descriptor);
|
|
411
|
+
const managedByRoute = {};
|
|
412
|
+
for (const [route, state] of simulation.byRoute) {
|
|
413
|
+
managedByRoute[route] = Object.keys(state.managed).sort((a, b) => a.localeCompare(b));
|
|
414
|
+
}
|
|
415
|
+
const plannedRoutes = plannedRoutesDraft.map((planned) => {
|
|
416
|
+
if (planned.slot === 'chat' || planned.state === 'absent')
|
|
417
|
+
return planned;
|
|
418
|
+
const postModels = simulation.byRoute.get(planned.route)?.models;
|
|
419
|
+
if (postModels !== undefined && postModels.size === 0) {
|
|
420
|
+
return { ...planned, action: 'unset' };
|
|
421
|
+
}
|
|
422
|
+
return planned;
|
|
423
|
+
});
|
|
390
424
|
const pinnedSuggestions = new Set();
|
|
391
|
-
|
|
392
|
-
for (const id of
|
|
425
|
+
// Reversible targets: desired ids still sitting on a legacy protocol route.
|
|
426
|
+
for (const id of targets)
|
|
393
427
|
pinnedSuggestions.add(id);
|
|
394
428
|
for (const id of pinnedIds)
|
|
395
429
|
pinnedSuggestions.add(id);
|
|
396
430
|
// B6 informed-consent text — part of the hashed body: any edit to this notice
|
|
397
431
|
// changes planHash and invalidates the old confirmCode/ack. The id list comes
|
|
398
|
-
// from
|
|
399
|
-
// so a user-modified `update` row or a move onto
|
|
400
|
-
// never advertised as managed.
|
|
401
|
-
const managedByRoute = managedIdsAfterApply({ routes: plannedRoutes, idActions }, input.descriptor);
|
|
432
|
+
// from the single `buildRouteWriteStates` simulation above — the SAME engine
|
|
433
|
+
// apply uses for the ledger — so a user-modified `update` row or a move onto
|
|
434
|
+
// a different-valued target is never advertised as managed.
|
|
402
435
|
// N2: no row may claim management on paper if the simulation shows apply
|
|
403
436
|
// will not actually write/adopt that id. Normalise the per-id `managed`
|
|
404
437
|
// flags to the simulated set so even the printed `[managed]` marker cannot
|
|
@@ -446,10 +479,7 @@ export function buildMigrationPlan(input) {
|
|
|
446
479
|
}
|
|
447
480
|
function describeId(kind, adopt) {
|
|
448
481
|
switch (kind) {
|
|
449
|
-
case 'desired
|
|
450
|
-
case 'desired-msg': return 'official messages target (dedicated -msg route)';
|
|
451
|
-
case 'desired-resp': return 'official responses target (dedicated -resp route)';
|
|
452
|
-
case 'desired-google': return 'official google target';
|
|
482
|
+
case 'desired': return 'official desired id (single managed route)';
|
|
453
483
|
case 'legacy-other-protocol': return adopt ? 'legacy id on the wrong protocol route' : 'legacy id kept in conservative mode';
|
|
454
484
|
case 'unknown-retired': return adopt ? 'unknown/retired id, delete only if confirmed in plan' : 'unknown/retired id kept as user-owned';
|
|
455
485
|
case 'user-extra': return 'user-written id, never auto-deleted';
|
|
@@ -499,7 +529,7 @@ export function formatMigrationPlan(plan) {
|
|
|
499
529
|
for (const route of plan.routes) {
|
|
500
530
|
const fields = route.fields;
|
|
501
531
|
lines.push(` ${route.route} [${route.slot}/${route.state}] ${route.action.toUpperCase()}`);
|
|
502
|
-
lines.push(`
|
|
532
|
+
lines.push(` displayName=${fields.displayName} apiKeyEnv=${fields.apiKeyEnv}${route.action === 'unset' ? ' (whole-route unset; fields not written)' : ''}`);
|
|
503
533
|
lines.push(` desired (${route.desired.length}): ${route.desired.map((profile) => profile.id).join(', ') || '(none)'}`);
|
|
504
534
|
if (route.existing.length > 0) {
|
|
505
535
|
lines.push(` existing: ${route.existing.map((entry) => `${entry.id}=${entry.kind}/${entry.action}`).join(', ')}`);
|
|
@@ -623,6 +653,14 @@ function routeOps(desc, route, fields, models) {
|
|
|
623
653
|
ops.push({ op: 'set', path: ['providers', route, field], value: fields[field] });
|
|
624
654
|
}
|
|
625
655
|
}
|
|
656
|
+
// Catalog-reuse: strip legacy `api`/`baseURL` so the host reuses pi-ai's
|
|
657
|
+
// builtin catalog provider for this route.
|
|
658
|
+
for (const field of GO_LEGACY_ROUTE_FIELDS) {
|
|
659
|
+
const value = data?.[field];
|
|
660
|
+
if (value !== undefined && value !== '') {
|
|
661
|
+
ops.push({ op: 'unset', path: ['providers', route, field] });
|
|
662
|
+
}
|
|
663
|
+
}
|
|
626
664
|
const sorted = [...models].sort((a, b) => a.id.localeCompare(b.id));
|
|
627
665
|
const current = [...rawModels(desc, route)].sort((a, b) => a.id.localeCompare(b.id));
|
|
628
666
|
if (current.length !== sorted.length || current.some((profile, index) => profileHash(profile) !== profileHash(sorted[index]))) {
|
|
@@ -866,6 +904,39 @@ export async function applyMigration(args, deps) {
|
|
|
866
904
|
continue;
|
|
867
905
|
}
|
|
868
906
|
const current = rawModels(desc, planned.route);
|
|
907
|
+
// Emptied legacy protocol route (plan action `unset`): whole-section
|
|
908
|
+
// unset + ledger key delete. Never a `models: []` write (§9.4), and no
|
|
909
|
+
// ledger entry survives it (no managedByRoute entry → appliedManagedIds
|
|
910
|
+
// mirrors only routes that still have a ledger, N3).
|
|
911
|
+
if (planned.action === 'unset') {
|
|
912
|
+
const section = rawRoute(desc, planned.route);
|
|
913
|
+
if (section !== undefined) {
|
|
914
|
+
try {
|
|
915
|
+
await mutateWithRetry(deps, [{ op: 'unset', path: ['providers', planned.route] }]);
|
|
916
|
+
writtenRoutes.push(planned.route);
|
|
917
|
+
}
|
|
918
|
+
catch (err) {
|
|
919
|
+
failure = `${planned.route}: settings mutate failed (${errorText(err)})`;
|
|
920
|
+
routesResult.push({ route: planned.route, status: 'failed', reason: errorText(err) });
|
|
921
|
+
break;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
const legacyKey = goOwnershipKey(planned.route, deps.keyFingerprint);
|
|
925
|
+
try {
|
|
926
|
+
await deps.ownershipStore.delete(legacyKey);
|
|
927
|
+
}
|
|
928
|
+
catch (err) {
|
|
929
|
+
failure = `${planned.route}: ledger delete failed (${errorText(err)})`;
|
|
930
|
+
routesResult.push({ route: planned.route, status: 'failed', reason: errorText(err) });
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
routesResult.push({
|
|
934
|
+
route: planned.route,
|
|
935
|
+
status: section !== undefined ? 'wrote' : 'skipped',
|
|
936
|
+
...(section !== undefined ? {} : { reason: 'legacy route superseded; section already absent (no settings write)' }),
|
|
937
|
+
});
|
|
938
|
+
continue;
|
|
939
|
+
}
|
|
869
940
|
// Write only ops that actually change fields/models. keep/update/delete-no
|
|
870
941
|
// rows leave the section byte-identical, so no mutate happens for them.
|
|
871
942
|
const ops = routeOps(desc, planned.route, planned.fields, [...state.models.values()]);
|