@theokit/sdk 4.48.0 → 4.50.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/CHANGELOG.md +12 -0
- package/dist/index.cjs +68 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -1
- package/dist/index.d.ts +139 -1
- package/dist/index.js +66 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.50.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7e6a0d4: Add `planReaping`: decide which session artifacts may be deleted — and never delete them. Tri-state (keep / reap / undetermined), a keep-last floor, and liveness that outranks age.
|
|
8
|
+
|
|
9
|
+
## 4.49.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- d0d62bd: Add `auditEnvReachability`: report config keys with no environment path and no documented opt-out, and opt-outs that no longer exempt anything.
|
|
14
|
+
|
|
3
15
|
## 4.48.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -661,6 +661,17 @@ var SkillReadTool = class {
|
|
|
661
661
|
}
|
|
662
662
|
};
|
|
663
663
|
|
|
664
|
+
// src/env-reachability.ts
|
|
665
|
+
function auditEnvReachability(input) {
|
|
666
|
+
const reachable = new Set(input.reachable);
|
|
667
|
+
const exempt = new Set(input.optOuts.map((o) => o.key));
|
|
668
|
+
const declared = new Set(input.keys);
|
|
669
|
+
return {
|
|
670
|
+
unreachable: input.keys.filter((k) => !reachable.has(k) && !exempt.has(k)),
|
|
671
|
+
staleOptOuts: input.optOuts.filter((o) => !declared.has(o.key) || reachable.has(o.key)).map((o) => o.key)
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
|
|
664
675
|
// src/event-bus.ts
|
|
665
676
|
var EventBus = class {
|
|
666
677
|
handlers = /* @__PURE__ */ new Map();
|
|
@@ -1560,6 +1571,60 @@ function loadProjectEnv(env = process.env, load = typeof process.loadEnvFile ===
|
|
|
1560
1571
|
}
|
|
1561
1572
|
}
|
|
1562
1573
|
|
|
1574
|
+
// src/reap-plan.ts
|
|
1575
|
+
var RetentionPolicyError = class extends chunkYULF6FPB_cjs.TheokitAgentError {
|
|
1576
|
+
name = "RetentionPolicyError";
|
|
1577
|
+
};
|
|
1578
|
+
function assertPolicy(retention) {
|
|
1579
|
+
const { maxAgeMs, keepLast } = retention;
|
|
1580
|
+
if (!Number.isFinite(maxAgeMs) || maxAgeMs < 0) {
|
|
1581
|
+
throw new RetentionPolicyError(
|
|
1582
|
+
`retention.maxAgeMs must be a non-negative number of milliseconds, got ${String(maxAgeMs)}`
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1585
|
+
if (!Number.isInteger(keepLast) || keepLast < 0) {
|
|
1586
|
+
throw new RetentionPolicyError(
|
|
1587
|
+
`retention.keepLast must be a non-negative integer, got ${String(keepLast)}`
|
|
1588
|
+
);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
function classifyByOwnReason(input) {
|
|
1592
|
+
const keep = [];
|
|
1593
|
+
const atRisk = [];
|
|
1594
|
+
for (const artifact of input.artifacts) {
|
|
1595
|
+
if (artifact.live === "unknown") continue;
|
|
1596
|
+
if (artifact.live === true) {
|
|
1597
|
+
keep.push({ ...artifact, reason: "live" });
|
|
1598
|
+
continue;
|
|
1599
|
+
}
|
|
1600
|
+
if (input.nowMs - artifact.lastModifiedMs <= input.retention.maxAgeMs) {
|
|
1601
|
+
keep.push({ ...artifact, reason: "within-retention" });
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
atRisk.push(artifact);
|
|
1605
|
+
}
|
|
1606
|
+
return { keep, atRisk };
|
|
1607
|
+
}
|
|
1608
|
+
function applyFloor(kept, atRisk, keepLast) {
|
|
1609
|
+
const shortfall = Math.max(0, keepLast - kept.length);
|
|
1610
|
+
const newestFirst = [...atRisk].sort((a, b) => b.lastModifiedMs - a.lastModifiedMs);
|
|
1611
|
+
const spared = new Set(newestFirst.slice(0, shortfall).map((a) => a.id));
|
|
1612
|
+
const rescued = [];
|
|
1613
|
+
const reap = [];
|
|
1614
|
+
for (const artifact of atRisk) {
|
|
1615
|
+
if (spared.has(artifact.id)) rescued.push({ ...artifact, reason: "keep-last" });
|
|
1616
|
+
else reap.push(artifact);
|
|
1617
|
+
}
|
|
1618
|
+
return { rescued, reap };
|
|
1619
|
+
}
|
|
1620
|
+
function planReaping(input) {
|
|
1621
|
+
assertPolicy(input.retention);
|
|
1622
|
+
const undetermined = input.artifacts.filter((a) => a.live === "unknown");
|
|
1623
|
+
const { keep, atRisk } = classifyByOwnReason(input);
|
|
1624
|
+
const { rescued, reap } = applyFloor(keep, atRisk, input.retention.keepLast);
|
|
1625
|
+
return { reap, keep: [...keep, ...rescued], undetermined };
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1563
1628
|
// src/schema-normalizer.ts
|
|
1564
1629
|
function isJsonSchemaObject(s) {
|
|
1565
1630
|
if (typeof s !== "object" || s === null) return false;
|
|
@@ -2359,6 +2424,7 @@ exports.PermissionEngine = PermissionEngine;
|
|
|
2359
2424
|
exports.PermissionPlugin = PermissionPlugin;
|
|
2360
2425
|
exports.Plugin = Plugin;
|
|
2361
2426
|
exports.Provider = Provider;
|
|
2427
|
+
exports.RetentionPolicyError = RetentionPolicyError;
|
|
2362
2428
|
exports.SOVEREIGN_ENV_KEYS = SOVEREIGN_ENV_KEYS;
|
|
2363
2429
|
exports.Security = Security;
|
|
2364
2430
|
exports.Skill = Skill;
|
|
@@ -2371,6 +2437,7 @@ exports.UngatedCapabilityError = UngatedCapabilityError;
|
|
|
2371
2437
|
exports.UnicodeNormalizer = UnicodeNormalizer;
|
|
2372
2438
|
exports.applyMode = applyMode;
|
|
2373
2439
|
exports.applySecurityFloor = applySecurityFloor;
|
|
2440
|
+
exports.auditEnvReachability = auditEnvReachability;
|
|
2374
2441
|
exports.chargeAndCheckThresholds = chargeAndCheckThresholds;
|
|
2375
2442
|
exports.createCounterBudgetTracker = createCounterBudgetTracker;
|
|
2376
2443
|
exports.estimateTokens = estimateTokens;
|
|
@@ -2382,6 +2449,7 @@ exports.migrateSqliteToLance = migrateSqliteToLance2;
|
|
|
2382
2449
|
exports.mkMemoryId = mkMemoryId;
|
|
2383
2450
|
exports.normalizeSchema = normalizeSchema;
|
|
2384
2451
|
exports.normalizeUsage = normalizeUsage;
|
|
2452
|
+
exports.planReaping = planReaping;
|
|
2385
2453
|
exports.preflightCheck = preflightCheck;
|
|
2386
2454
|
exports.recordWiring = recordWiring;
|
|
2387
2455
|
exports.resolveTrustPosture = resolveTrustPosture;
|