@adhdev/mesh-shared 1.0.78 → 1.0.79-rc.2
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/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -0
- package/dist/index.mjs.map +1 -1
- package/dist/node-facts.d.ts +22 -0
- package/package.json +1 -1
- package/src/node-facts.ts +47 -0
package/dist/node-facts.d.ts
CHANGED
|
@@ -268,3 +268,25 @@ export declare function supportsQuota(providerType: string | undefined | null):
|
|
|
268
268
|
* daemon-core QuotaMetadata.accountEmail and the server-boundary suite.
|
|
269
269
|
*/
|
|
270
270
|
export declare function formatQuotaAccount(quota: MeshNodeFactsProviderQuota | undefined): string | null;
|
|
271
|
+
/**
|
|
272
|
+
* Stable built-in provider order for a DEFAULTED node priority (no operator
|
|
273
|
+
* order known): these first when present, then the rest alphabetically. The
|
|
274
|
+
* `mesh_init` providerPriority suggestion leads with the same list.
|
|
275
|
+
*/
|
|
276
|
+
export declare const BUILTIN_PROVIDER_PREFERENCE: readonly string[];
|
|
277
|
+
/** Order provider types by BUILTIN_PROVIDER_PREFERENCE, then alphabetically (de-duplicated). */
|
|
278
|
+
export declare function orderProvidersByBuiltinPreference(types: readonly unknown[]): string[];
|
|
279
|
+
/**
|
|
280
|
+
* The provider order a node with NO providerPriority and NO capability slots
|
|
281
|
+
* defaults to, from its own facts bundle: the providers it reports enabled
|
|
282
|
+
* (`providerEnablement[type].enabled === true` — the reporting machine's own
|
|
283
|
+
* verdict), narrowed to the CLIs it reports detected (`providerVersions`, the
|
|
284
|
+
* detection pass that stamps binary versions) when any enabled one is listed
|
|
285
|
+
* there. Ordered by BUILTIN_PROVIDER_PREFERENCE.
|
|
286
|
+
*
|
|
287
|
+
* The single rule for every reader — daemon-core auto-launch / slot resolution,
|
|
288
|
+
* the MCP launch readiness + type-omitted launch, the `adhdev mesh` CLI — so a
|
|
289
|
+
* node is not "launch ready" on one surface and `missing_provider_priority` on
|
|
290
|
+
* another. Returns [] when nothing usable is reported.
|
|
291
|
+
*/
|
|
292
|
+
export declare function defaultProviderPriorityFromNodeFacts(facts: unknown): string[];
|
package/package.json
CHANGED
package/src/node-facts.ts
CHANGED
|
@@ -301,3 +301,50 @@ export function formatQuotaAccount(quota: MeshNodeFactsProviderQuota | undefined
|
|
|
301
301
|
const parts = [email, plan].filter(Boolean)
|
|
302
302
|
return parts.length > 0 ? parts.join(' · ') : null
|
|
303
303
|
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Stable built-in provider order for a DEFAULTED node priority (no operator
|
|
307
|
+
* order known): these first when present, then the rest alphabetically. The
|
|
308
|
+
* `mesh_init` providerPriority suggestion leads with the same list.
|
|
309
|
+
*/
|
|
310
|
+
export const BUILTIN_PROVIDER_PREFERENCE: readonly string[] = ['claude-cli', 'codex-cli', 'gemini-cli']
|
|
311
|
+
|
|
312
|
+
/** Order provider types by BUILTIN_PROVIDER_PREFERENCE, then alphabetically (de-duplicated). */
|
|
313
|
+
export function orderProvidersByBuiltinPreference(types: readonly unknown[]): string[] {
|
|
314
|
+
const unique = [...new Set(types.map((t) => (typeof t === 'string' ? t.trim() : '')).filter(Boolean))]
|
|
315
|
+
const rank = (t: string) => {
|
|
316
|
+
const i = BUILTIN_PROVIDER_PREFERENCE.indexOf(t)
|
|
317
|
+
return i < 0 ? BUILTIN_PROVIDER_PREFERENCE.length : i
|
|
318
|
+
}
|
|
319
|
+
return unique.sort((a, b) => rank(a) - rank(b) || a.localeCompare(b))
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The provider order a node with NO providerPriority and NO capability slots
|
|
324
|
+
* defaults to, from its own facts bundle: the providers it reports enabled
|
|
325
|
+
* (`providerEnablement[type].enabled === true` — the reporting machine's own
|
|
326
|
+
* verdict), narrowed to the CLIs it reports detected (`providerVersions`, the
|
|
327
|
+
* detection pass that stamps binary versions) when any enabled one is listed
|
|
328
|
+
* there. Ordered by BUILTIN_PROVIDER_PREFERENCE.
|
|
329
|
+
*
|
|
330
|
+
* The single rule for every reader — daemon-core auto-launch / slot resolution,
|
|
331
|
+
* the MCP launch readiness + type-omitted launch, the `adhdev mesh` CLI — so a
|
|
332
|
+
* node is not "launch ready" on one surface and `missing_provider_priority` on
|
|
333
|
+
* another. Returns [] when nothing usable is reported.
|
|
334
|
+
*/
|
|
335
|
+
export function defaultProviderPriorityFromNodeFacts(facts: unknown): string[] {
|
|
336
|
+
const f = facts && typeof facts === 'object' && !Array.isArray(facts) ? facts as Record<string, unknown> : null
|
|
337
|
+
const enablement = f?.providerEnablement
|
|
338
|
+
if (!enablement || typeof enablement !== 'object' || Array.isArray(enablement)) return []
|
|
339
|
+
const enabled = Object.entries(enablement as Record<string, unknown>)
|
|
340
|
+
.filter(([, v]) => !!v && typeof v === 'object' && (v as Record<string, unknown>).enabled === true)
|
|
341
|
+
.map(([type]) => type)
|
|
342
|
+
const versions = f?.providerVersions
|
|
343
|
+
const detected = versions && typeof versions === 'object' && !Array.isArray(versions)
|
|
344
|
+
? enabled.filter((type) => {
|
|
345
|
+
const v = (versions as Record<string, unknown>)[type]
|
|
346
|
+
return typeof v === 'string' && !!v.trim()
|
|
347
|
+
})
|
|
348
|
+
: []
|
|
349
|
+
return orderProvidersByBuiltinPreference(detected.length ? detected : enabled)
|
|
350
|
+
}
|