@cleocode/core 2026.6.15 → 2026.6.17
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/docs/export-document.js +41 -0
- package/dist/docs/export-document.js.map +1 -1
- package/dist/gc/janitor.d.ts +149 -0
- package/dist/gc/janitor.d.ts.map +1 -0
- package/dist/gc/janitor.js +760 -0
- package/dist/gc/janitor.js.map +1 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -1
- package/dist/llm/cli-ops.d.ts +15 -4
- package/dist/llm/cli-ops.d.ts.map +1 -1
- package/dist/llm/cli-ops.js +78 -21
- package/dist/llm/cli-ops.js.map +1 -1
- package/dist/llm/credential-pool.d.ts +62 -0
- package/dist/llm/credential-pool.d.ts.map +1 -1
- package/dist/llm/credential-pool.js +161 -0
- package/dist/llm/credential-pool.js.map +1 -1
- package/dist/llm/cross-provider-selector.d.ts +8 -3
- package/dist/llm/cross-provider-selector.d.ts.map +1 -1
- package/dist/llm/cross-provider-selector.js +71 -8
- package/dist/llm/cross-provider-selector.js.map +1 -1
- package/dist/llm/plugin-facade.js +122 -1
- package/dist/llm/plugin-facade.js.map +1 -1
- package/dist/selfimprove/fix-gen-context.d.ts +172 -0
- package/dist/selfimprove/fix-gen-context.d.ts.map +1 -0
- package/dist/selfimprove/fix-gen-context.js +218 -0
- package/dist/selfimprove/fix-gen-context.js.map +1 -0
- package/dist/selfimprove/fix-gen.d.ts +60 -4
- package/dist/selfimprove/fix-gen.d.ts.map +1 -1
- package/dist/selfimprove/fix-gen.js +91 -11
- package/dist/selfimprove/fix-gen.js.map +1 -1
- package/dist/selfimprove/op-source-map.d.ts +92 -0
- package/dist/selfimprove/op-source-map.d.ts.map +1 -0
- package/dist/selfimprove/op-source-map.js +187 -0
- package/dist/selfimprove/op-source-map.js.map +1 -0
- package/dist/selfimprove/probe-helper.d.ts +61 -0
- package/dist/selfimprove/probe-helper.d.ts.map +1 -0
- package/dist/selfimprove/probe-helper.js +64 -0
- package/dist/selfimprove/probe-helper.js.map +1 -0
- package/dist/selfimprove/scenarios/seeded-code-regression/golden.json +18 -0
- package/dist/selfimprove/scenarios/seeded-code-regression/scenario.json +12 -0
- package/dist/setup/index.d.ts +1 -0
- package/dist/setup/index.d.ts.map +1 -1
- package/dist/setup/index.js +1 -0
- package/dist/setup/index.js.map +1 -1
- package/dist/setup/sections/models-roles.d.ts +32 -1
- package/dist/setup/sections/models-roles.d.ts.map +1 -1
- package/dist/setup/sections/models-roles.js +118 -19
- package/dist/setup/sections/models-roles.js.map +1 -1
- package/dist/setup/whoami-summary.d.ts +34 -0
- package/dist/setup/whoami-summary.d.ts.map +1 -0
- package/dist/setup/whoami-summary.js +106 -0
- package/dist/setup/whoami-summary.js.map +1 -0
- package/package.json +12 -12
|
@@ -10804,6 +10804,22 @@ var init_operations_registry = __esm({
|
|
|
10804
10804
|
}
|
|
10805
10805
|
]
|
|
10806
10806
|
},
|
|
10807
|
+
// ── selfimprove query: probe (T11988 — seeded-code-regression scenario) ────────
|
|
10808
|
+
// Pure read-only op that returns `{ probe: 'ok', version: probeVersion() }`.
|
|
10809
|
+
// The `probe-helper.ts` intentionally ships with `probeVersion()` returning `2`
|
|
10810
|
+
// (should be `1`) so the seeded-code-regression scenario replay diverges from its
|
|
10811
|
+
// golden (`version: 1`) and gives the fix-gen LLM stage a real, patchable bug.
|
|
10812
|
+
{
|
|
10813
|
+
gateway: "query",
|
|
10814
|
+
domain: "selfimprove",
|
|
10815
|
+
operation: "probe",
|
|
10816
|
+
description: 'selfimprove.probe (query) \u2014 returns { probe: "ok", version: 1 } (health/version probe). Used by the seeded-code-regression scenario to validate the fix-gen pipeline (T11988).',
|
|
10817
|
+
tier: 2,
|
|
10818
|
+
idempotent: true,
|
|
10819
|
+
sessionRequired: false,
|
|
10820
|
+
requiredParams: [],
|
|
10821
|
+
params: []
|
|
10822
|
+
},
|
|
10807
10823
|
// ── selfimprove mutate: run (T11889 / T11889-D — the self-dogfooding loop) ──
|
|
10808
10824
|
// Boots ONE sandbox → replays the named canned scenario → diffs result
|
|
10809
10825
|
// envelopes vs the golden → on a regression emits ONE leased `selfimprove_dhq`
|
|
@@ -11417,6 +11433,31 @@ var init_operations_registry = __esm({
|
|
|
11417
11433
|
cli: { positional: true }
|
|
11418
11434
|
}
|
|
11419
11435
|
]
|
|
11436
|
+
},
|
|
11437
|
+
// T11995 — Janitor MVP: orphan process reaper + stale scope/lock/debris sweep
|
|
11438
|
+
{
|
|
11439
|
+
gateway: "mutate",
|
|
11440
|
+
domain: "admin",
|
|
11441
|
+
operation: "janitor.run",
|
|
11442
|
+
description: "admin.janitor.run (mutate) \u2014 run the janitor sweep: reap orphan processes, stop dead cleo-owned scopes, reclaim stale locks, prune tmp debris",
|
|
11443
|
+
tier: 1,
|
|
11444
|
+
idempotent: true,
|
|
11445
|
+
sessionRequired: false,
|
|
11446
|
+
requiredParams: [],
|
|
11447
|
+
params: [
|
|
11448
|
+
{
|
|
11449
|
+
name: "dryRun",
|
|
11450
|
+
type: "boolean",
|
|
11451
|
+
required: false,
|
|
11452
|
+
description: "Report planned actions without mutating anything."
|
|
11453
|
+
},
|
|
11454
|
+
{
|
|
11455
|
+
name: "gracePeriodMs",
|
|
11456
|
+
type: "number",
|
|
11457
|
+
required: false,
|
|
11458
|
+
description: "Minimum age (ms) of an unregistered process before reap eligibility (default: 600000)."
|
|
11459
|
+
}
|
|
11460
|
+
]
|
|
11420
11461
|
}
|
|
11421
11462
|
];
|
|
11422
11463
|
}
|
|
@@ -42494,6 +42535,60 @@ function isInCooldown(credential) {
|
|
|
42494
42535
|
function sortByPriorityDesc(entries) {
|
|
42495
42536
|
return [...entries].sort((a, b) => b.priority - a.priority);
|
|
42496
42537
|
}
|
|
42538
|
+
async function refreshExpiredOAuthForProvider(provider) {
|
|
42539
|
+
const entries = await listCredentials(provider);
|
|
42540
|
+
const now = Date.now();
|
|
42541
|
+
let attempted = 0;
|
|
42542
|
+
let refreshed = 0;
|
|
42543
|
+
let lastError = null;
|
|
42544
|
+
for (const entry of entries) {
|
|
42545
|
+
if (entry.authType !== "oauth") continue;
|
|
42546
|
+
if (!entry.refreshToken) continue;
|
|
42547
|
+
if (entry.disabled === true) continue;
|
|
42548
|
+
const isExpiredOrNearExpiry = typeof entry.expiresAt === "number" && entry.expiresAt > 0 && entry.expiresAt <= now + PROACTIVE_REFRESH_FLOOR_MS;
|
|
42549
|
+
if (!isExpiredOrNearExpiry) continue;
|
|
42550
|
+
const key = `${provider}::${entry.label}`;
|
|
42551
|
+
const negExpiry = _refreshNegativeCache.get(key);
|
|
42552
|
+
if (typeof negExpiry === "number" && now < negExpiry) {
|
|
42553
|
+
attempted += 1;
|
|
42554
|
+
lastError = lastError ?? new Error(
|
|
42555
|
+
`OAuth refresh suppressed for ${provider}::${entry.label} (negative cache active)`
|
|
42556
|
+
);
|
|
42557
|
+
continue;
|
|
42558
|
+
}
|
|
42559
|
+
attempted += 1;
|
|
42560
|
+
let inFlight = _refreshInFlight.get(key);
|
|
42561
|
+
if (!inFlight) {
|
|
42562
|
+
const pool = new CredentialPool(provider);
|
|
42563
|
+
const expiresAtBefore = entry.expiresAt;
|
|
42564
|
+
inFlight = pool.proactiveRefresh(entry.label).then(async (wasAttempted) => {
|
|
42565
|
+
if (!wasAttempted) {
|
|
42566
|
+
return true;
|
|
42567
|
+
}
|
|
42568
|
+
const after = await getCredentialByLabel(provider, entry.label);
|
|
42569
|
+
const didAdvance = after !== null && typeof after.expiresAt === "number" && after.expiresAt > (expiresAtBefore ?? 0);
|
|
42570
|
+
if (!didAdvance) {
|
|
42571
|
+
throw new Error(
|
|
42572
|
+
`OAuth refresh token exchange failed for ${provider}::${entry.label} \u2014 the stored token may be revoked. Run \`cleo login ${provider}\` to re-authenticate.`
|
|
42573
|
+
);
|
|
42574
|
+
}
|
|
42575
|
+
return true;
|
|
42576
|
+
}).finally(() => {
|
|
42577
|
+
_refreshInFlight.delete(key);
|
|
42578
|
+
});
|
|
42579
|
+
_refreshInFlight.set(key, inFlight);
|
|
42580
|
+
}
|
|
42581
|
+
try {
|
|
42582
|
+
await inFlight;
|
|
42583
|
+
refreshed += 1;
|
|
42584
|
+
} catch (err) {
|
|
42585
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
42586
|
+
_refreshNegativeCache.set(key, Date.now() + REFRESH_NEGATIVE_CACHE_TTL_MS);
|
|
42587
|
+
}
|
|
42588
|
+
}
|
|
42589
|
+
const actionableHint = attempted > 0 && refreshed === 0 && lastError !== null ? `OAuth refresh failed for provider '${provider}'. Run \`cleo login ${provider}\` to re-authenticate.` : null;
|
|
42590
|
+
return { attempted, refreshed, lastError, actionableHint };
|
|
42591
|
+
}
|
|
42497
42592
|
function debugLog(msg, ...rest) {
|
|
42498
42593
|
if (process.env["CLEO_DEBUG"]) {
|
|
42499
42594
|
console.debug(`[cleo:credential-pool] ${msg}`, ...rest);
|
|
@@ -42505,7 +42600,7 @@ function getCredentialPool() {
|
|
|
42505
42600
|
}
|
|
42506
42601
|
return _singleton;
|
|
42507
42602
|
}
|
|
42508
|
-
var COOLDOWN_AUTH_MS, COOLDOWN_RATE_LIMIT_MS, COOLDOWN_DEFAULT_MS, PROACTIVE_REFRESH_FLOOR_MS, PoolExhaustedError, CredentialPool, POOL_SEED_CACHE_TTL_MS, UnifiedCredentialPool, _singleton;
|
|
42603
|
+
var COOLDOWN_AUTH_MS, COOLDOWN_RATE_LIMIT_MS, COOLDOWN_DEFAULT_MS, PROACTIVE_REFRESH_FLOOR_MS, PoolExhaustedError, _refreshInFlight, REFRESH_NEGATIVE_CACHE_TTL_MS, _refreshNegativeCache, CredentialPool, POOL_SEED_CACHE_TTL_MS, UnifiedCredentialPool, _singleton;
|
|
42509
42604
|
var init_credential_pool = __esm({
|
|
42510
42605
|
"packages/core/src/llm/credential-pool.ts"() {
|
|
42511
42606
|
"use strict";
|
|
@@ -42542,6 +42637,9 @@ var init_credential_pool = __esm({
|
|
|
42542
42637
|
/** Stable LAFS error code. */
|
|
42543
42638
|
code = "E_LLM_POOL_EXHAUSTED";
|
|
42544
42639
|
};
|
|
42640
|
+
_refreshInFlight = /* @__PURE__ */ new Map();
|
|
42641
|
+
REFRESH_NEGATIVE_CACHE_TTL_MS = 3e4;
|
|
42642
|
+
_refreshNegativeCache = /* @__PURE__ */ new Map();
|
|
42545
42643
|
CredentialPool = class {
|
|
42546
42644
|
/**
|
|
42547
42645
|
* @param provider - The LLM transport this pool manages.
|
|
@@ -75628,6 +75726,28 @@ function roleTierFor(role) {
|
|
|
75628
75726
|
}
|
|
75629
75727
|
async function selectBestProvisioned(role, opts) {
|
|
75630
75728
|
const taskTier = roleTierFor(role);
|
|
75729
|
+
for (const id of BUILTIN_PROVIDER_IDS) {
|
|
75730
|
+
const creds = await listCredentials(id);
|
|
75731
|
+
const hasExpiredOAuth = creds.some(
|
|
75732
|
+
(c) => c.authType === "oauth" && c.refreshToken && typeof c.expiresAt === "number" && c.expiresAt > 0 && c.expiresAt <= Date.now()
|
|
75733
|
+
);
|
|
75734
|
+
if (!hasExpiredOAuth) continue;
|
|
75735
|
+
try {
|
|
75736
|
+
const result = await refreshExpiredOAuthForProvider(id);
|
|
75737
|
+
if (result.actionableHint) {
|
|
75738
|
+
logger4.warn(
|
|
75739
|
+
{ provider: id, hint: result.actionableHint },
|
|
75740
|
+
"cross-provider-selector: OAuth refresh-on-use failed \u2014 credential will be excluded from resolution"
|
|
75741
|
+
);
|
|
75742
|
+
} else if (result.refreshed > 0) {
|
|
75743
|
+
logger4.debug(
|
|
75744
|
+
{ provider: id, refreshed: result.refreshed },
|
|
75745
|
+
"cross-provider-selector: renewed expired OAuth credential via refresh-on-use"
|
|
75746
|
+
);
|
|
75747
|
+
}
|
|
75748
|
+
} catch {
|
|
75749
|
+
}
|
|
75750
|
+
}
|
|
75631
75751
|
const provisionedIds = [];
|
|
75632
75752
|
for (const id of BUILTIN_PROVIDER_IDS) {
|
|
75633
75753
|
if (isProvisioned(id)) {
|
|
@@ -75724,6 +75844,7 @@ var init_cross_provider_selector = __esm({
|
|
|
75724
75844
|
"packages/core/src/llm/cross-provider-selector.ts"() {
|
|
75725
75845
|
"use strict";
|
|
75726
75846
|
init_logger2();
|
|
75847
|
+
init_credential_pool();
|
|
75727
75848
|
init_credentials2();
|
|
75728
75849
|
init_credentials_store();
|
|
75729
75850
|
logger4 = getLogger("llm-cross-provider-selector");
|