billion-context-pi 0.1.59-pr.324.127 → 0.1.59
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/config.d.ts +0 -10
- package/dist/index.js +7 -148
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +0 -6
- package/package.json +2 -2
- package/dist/strip-images.d.ts +0 -18
package/dist/config.d.ts
CHANGED
|
@@ -114,16 +114,6 @@ export interface CompressSettings {
|
|
|
114
114
|
* window and would suppress every nudge. Maps to kernel
|
|
115
115
|
* nudge.minPressureBenefitTokens. */
|
|
116
116
|
minPressureBenefitTokens?: number;
|
|
117
|
-
/** Opt-in wire-level strip of historical image payloads (issue #321, kernel
|
|
118
|
-
* #215). Default: false (images ride along verbatim, current behavior).
|
|
119
|
-
* When true, every message older than `stripImagesKeepRecent` has its image
|
|
120
|
-
* parts dropped from the outbound provider body (image-only messages
|
|
121
|
-
* collapse to a "[image]" text placeholder). Host-side policy only — the
|
|
122
|
-
* strip primitive lives in acp-kernel's wire layer. */
|
|
123
|
-
stripImages?: boolean;
|
|
124
|
-
/** How many of the MOST RECENT messages keep their image payloads when
|
|
125
|
-
* `stripImages` is enabled. Default: 5. Ignored when stripImages is off. */
|
|
126
|
-
stripImagesKeepRecent?: number;
|
|
127
117
|
}
|
|
128
118
|
/** Per-provider compression overrides. Carries the same tuning fields as the
|
|
129
119
|
* global level, plus an optional per-model map keyed by model id. */
|
package/dist/index.js
CHANGED
|
@@ -3766,9 +3766,7 @@ function mergeCompress(global, provider, model) {
|
|
|
3766
3766
|
maxContextLimit: model?.maxContextLimit ?? provider?.maxContextLimit ?? global?.maxContextLimit,
|
|
3767
3767
|
emergencyThresholdPercent: model?.emergencyThresholdPercent ?? provider?.emergencyThresholdPercent ?? global?.emergencyThresholdPercent,
|
|
3768
3768
|
nudgeGrowthTokens: model?.nudgeGrowthTokens ?? provider?.nudgeGrowthTokens ?? global?.nudgeGrowthTokens,
|
|
3769
|
-
minPressureBenefitTokens: model?.minPressureBenefitTokens ?? provider?.minPressureBenefitTokens ?? global?.minPressureBenefitTokens
|
|
3770
|
-
stripImages: model?.stripImages ?? provider?.stripImages ?? global?.stripImages,
|
|
3771
|
-
stripImagesKeepRecent: model?.stripImagesKeepRecent ?? provider?.stripImagesKeepRecent ?? global?.stripImagesKeepRecent
|
|
3769
|
+
minPressureBenefitTokens: model?.minPressureBenefitTokens ?? provider?.minPressureBenefitTokens ?? global?.minPressureBenefitTokens
|
|
3772
3770
|
};
|
|
3773
3771
|
}
|
|
3774
3772
|
function resolveCompress(compress, provider, modelId) {
|
|
@@ -4194,10 +4192,10 @@ var SessionStateStore = class {
|
|
|
4194
4192
|
}
|
|
4195
4193
|
async save(state, sessionFile, sessionId) {
|
|
4196
4194
|
const file = stateFileFor(sessionFile);
|
|
4195
|
+
if (!file) return;
|
|
4197
4196
|
const key = cacheKey(sessionFile, sessionId);
|
|
4198
4197
|
const liveRefOrigins = this.cache.get(key)?.liveRefOrigins ?? [];
|
|
4199
4198
|
this.cache.set(key, { state, liveRefOrigins });
|
|
4200
|
-
if (!file) return;
|
|
4201
4199
|
const dir = path2.dirname(file);
|
|
4202
4200
|
await fs.mkdir(dir, { recursive: true }).catch((e) => {
|
|
4203
4201
|
logError("state", { event: "save-mkdir-failed", dir, error: e instanceof Error ? e.message : String(e) });
|
|
@@ -4977,13 +4975,6 @@ function createRuntime(adapter) {
|
|
|
4977
4975
|
const m2 = ctx.model;
|
|
4978
4976
|
return resolveConfig(adapterRef, liveContextLimit(ctx), m2?.provider, m2?.id);
|
|
4979
4977
|
}
|
|
4980
|
-
function stripImagesFor(ctx) {
|
|
4981
|
-
const m2 = ctx.model;
|
|
4982
|
-
const c = resolveCompress(adapterRef.compress, m2?.provider, m2?.id);
|
|
4983
|
-
const raw = Number(c.stripImagesKeepRecent);
|
|
4984
|
-
const keepRecent = Number.isFinite(raw) && raw >= 0 ? Math.floor(raw) : 5;
|
|
4985
|
-
return { enabled: c.stripImages === true, keepRecent };
|
|
4986
|
-
}
|
|
4987
4978
|
async function reloadConfig(cwd) {
|
|
4988
4979
|
let user;
|
|
4989
4980
|
try {
|
|
@@ -5062,7 +5053,7 @@ function createRuntime(adapter) {
|
|
|
5062
5053
|
}, nudgeShownFor: (k) => nudgeShownTurns.has(k), nudgeShownTokensFor: (k) => nudgeShownTokens.get(k), clearNudgeTracking: () => {
|
|
5063
5054
|
nudgeShownTurns.clear();
|
|
5064
5055
|
nudgeShownTokens.clear();
|
|
5065
|
-
}, clearNudgeTokenStamps: () => nudgeShownTokens.clear(), noteCompressOutcomes, compressRetryCappedFor, clearCompressRetryTracking, liveContextLimit, configFor, reloadConfig, stateFor, save, acquireLock, overflowFor, overflowDrop, noteDeadCompress, clearDeadCompress, throttleFor, throttleDrop, noteTokenScale, dropTokenScale
|
|
5056
|
+
}, clearNudgeTokenStamps: () => nudgeShownTokens.clear(), noteCompressOutcomes, compressRetryCappedFor, clearCompressRetryTracking, liveContextLimit, configFor, reloadConfig, stateFor, save, acquireLock, overflowFor, overflowDrop, noteDeadCompress, clearDeadCompress, throttleFor, throttleDrop, noteTokenScale, dropTokenScale };
|
|
5066
5057
|
}
|
|
5067
5058
|
|
|
5068
5059
|
// node_modules/typebox/build/system/memory/memory.mjs
|
|
@@ -16648,120 +16639,8 @@ When a background delegate finishes, an automated completion notification is inj
|
|
|
16648
16639
|
- Occasionally a "Recovery notice" is appended to a delegate notification or a delegate tool result: an earlier notification could not be delivered, so its result is delivered there instead. Treat it exactly like the original notification.
|
|
16649
16640
|
`;
|
|
16650
16641
|
|
|
16651
|
-
// node_modules/acp-kernel/dist/wire/index.js
|
|
16652
|
-
import { createHash } from "crypto";
|
|
16653
|
-
function hashId(s) {
|
|
16654
|
-
return createHash("sha256").update(s, "utf8").digest("hex").slice(0, 16);
|
|
16655
|
-
}
|
|
16656
|
-
function createSubagentNamespaces() {
|
|
16657
|
-
const anchors = /* @__PURE__ */ new Map();
|
|
16658
|
-
return {
|
|
16659
|
-
namespaceFor(identityValue, instructions) {
|
|
16660
|
-
if (typeof instructions !== "string" || instructions.trim().length === 0) return identityValue;
|
|
16661
|
-
const fp = hashId(instructions);
|
|
16662
|
-
const anchor = anchors.get(identityValue);
|
|
16663
|
-
if (anchor === void 0) {
|
|
16664
|
-
anchors.set(identityValue, fp);
|
|
16665
|
-
return identityValue;
|
|
16666
|
-
}
|
|
16667
|
-
return anchor === fp ? identityValue : `${identityValue}|sub:${fp}`;
|
|
16668
|
-
}
|
|
16669
|
-
};
|
|
16670
|
-
}
|
|
16671
|
-
var defaultNamespaces = createSubagentNamespaces();
|
|
16672
|
-
var IMAGE_PLACEHOLDER = "[image]";
|
|
16673
|
-
function isObj(v2) {
|
|
16674
|
-
return typeof v2 === "object" && v2 !== null;
|
|
16675
|
-
}
|
|
16676
|
-
function isImagePart(protocol, part) {
|
|
16677
|
-
if (!isObj(part)) return false;
|
|
16678
|
-
if (protocol === "responses") return part.type === "input_image";
|
|
16679
|
-
if (protocol === "openai") return part.type === "image_url";
|
|
16680
|
-
return part.type === "image";
|
|
16681
|
-
}
|
|
16682
|
-
function placeholderContent(protocol) {
|
|
16683
|
-
const type = protocol === "responses" ? "input_text" : "text";
|
|
16684
|
-
return [{ type, text: IMAGE_PLACEHOLDER }];
|
|
16685
|
-
}
|
|
16686
|
-
function stripHistoricalImages(body, protocol, keepRecent) {
|
|
16687
|
-
if (!protocol || !isObj(body)) return { body, removed: 0 };
|
|
16688
|
-
const recentCount = Math.max(0, Math.floor(keepRecent));
|
|
16689
|
-
if (protocol === "responses") {
|
|
16690
|
-
const input = body.input;
|
|
16691
|
-
if (!Array.isArray(input)) return { body, removed: 0 };
|
|
16692
|
-
const cutoff2 = input.length - recentCount;
|
|
16693
|
-
let removed2 = 0;
|
|
16694
|
-
let touched2 = false;
|
|
16695
|
-
const nextInput = input.map((item, i) => {
|
|
16696
|
-
if (i < cutoff2 && isObj(item) && Array.isArray(item.content)) {
|
|
16697
|
-
const content = item.content;
|
|
16698
|
-
const imgs = content.filter((p) => isImagePart("responses", p)).length;
|
|
16699
|
-
if (imgs > 0) {
|
|
16700
|
-
removed2 += imgs;
|
|
16701
|
-
touched2 = true;
|
|
16702
|
-
const kept = content.filter((p) => !isImagePart("responses", p));
|
|
16703
|
-
return {
|
|
16704
|
-
...item,
|
|
16705
|
-
content: kept.length > 0 ? kept : placeholderContent("responses")
|
|
16706
|
-
};
|
|
16707
|
-
}
|
|
16708
|
-
}
|
|
16709
|
-
return item;
|
|
16710
|
-
});
|
|
16711
|
-
if (!touched2) return { body, removed: 0 };
|
|
16712
|
-
return { body: { ...body, input: nextInput }, removed: removed2 };
|
|
16713
|
-
}
|
|
16714
|
-
const messages = body.messages;
|
|
16715
|
-
if (!Array.isArray(messages)) return { body, removed: 0 };
|
|
16716
|
-
const cutoff = messages.length - recentCount;
|
|
16717
|
-
let removed = 0;
|
|
16718
|
-
let touched = false;
|
|
16719
|
-
const nextMessages = messages.map((m2, i) => {
|
|
16720
|
-
if (i < cutoff && isObj(m2) && Array.isArray(m2.content)) {
|
|
16721
|
-
const content = m2.content;
|
|
16722
|
-
const imgs = content.filter((p) => isImagePart(protocol, p)).length;
|
|
16723
|
-
if (imgs > 0) {
|
|
16724
|
-
removed += imgs;
|
|
16725
|
-
touched = true;
|
|
16726
|
-
const kept = content.filter((p) => !isImagePart(protocol, p));
|
|
16727
|
-
return {
|
|
16728
|
-
...m2,
|
|
16729
|
-
content: kept.length > 0 ? kept : placeholderContent(protocol)
|
|
16730
|
-
};
|
|
16731
|
-
}
|
|
16732
|
-
}
|
|
16733
|
-
return m2;
|
|
16734
|
-
});
|
|
16735
|
-
if (!touched) return { body, removed: 0 };
|
|
16736
|
-
return { body: { ...body, messages: nextMessages }, removed };
|
|
16737
|
-
}
|
|
16738
|
-
|
|
16739
|
-
// src/strip-images.ts
|
|
16740
|
-
function apiToStripProtocol(api) {
|
|
16741
|
-
switch (api) {
|
|
16742
|
-
case "anthropic-messages":
|
|
16743
|
-
return "anthropic";
|
|
16744
|
-
case "openai-completions":
|
|
16745
|
-
return "openai";
|
|
16746
|
-
case "openai-responses":
|
|
16747
|
-
case "azure-openai-responses":
|
|
16748
|
-
case "openai-codex-responses":
|
|
16749
|
-
return "responses";
|
|
16750
|
-
default:
|
|
16751
|
-
return null;
|
|
16752
|
-
}
|
|
16753
|
-
}
|
|
16754
|
-
function applyStripImages(body, api, settings2) {
|
|
16755
|
-
if (!settings2.enabled) return { removed: 0 };
|
|
16756
|
-
const protocol = apiToStripProtocol(api);
|
|
16757
|
-
if (!protocol) return { removed: 0 };
|
|
16758
|
-
const result = stripHistoricalImages(body, protocol, settings2.keepRecent);
|
|
16759
|
-
if (result.removed === 0) return { removed: 0 };
|
|
16760
|
-
return { body: result.body, removed: result.removed };
|
|
16761
|
-
}
|
|
16762
|
-
|
|
16763
16642
|
// src/tool-guardrails.ts
|
|
16764
|
-
import { createHash
|
|
16643
|
+
import { createHash } from "crypto";
|
|
16765
16644
|
import {
|
|
16766
16645
|
isToolCallEventType
|
|
16767
16646
|
} from "@earendil-works/pi-coding-agent";
|
|
@@ -16862,7 +16741,7 @@ function canonicalStringify(value) {
|
|
|
16862
16741
|
function repetitionFingerprint(toolName, input) {
|
|
16863
16742
|
const payload = `${toolName}\0${canonicalStringify(input ?? {})}`;
|
|
16864
16743
|
try {
|
|
16865
|
-
return
|
|
16744
|
+
return createHash("sha1").update(payload).digest("hex");
|
|
16866
16745
|
} catch {
|
|
16867
16746
|
return `unhashable:${toolName}`;
|
|
16868
16747
|
}
|
|
@@ -16975,14 +16854,14 @@ import { join as join11, dirname as dirname8 } from "path";
|
|
|
16975
16854
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
16976
16855
|
import { execFile } from "child_process";
|
|
16977
16856
|
import { homedir as homedir7 } from "os";
|
|
16978
|
-
import { createHash as
|
|
16857
|
+
import { createHash as createHash2 } from "crypto";
|
|
16979
16858
|
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME4 } from "@earendil-works/pi-coding-agent";
|
|
16980
16859
|
var PACKAGE_NAME = "billion-context-pi";
|
|
16981
16860
|
var registryUrl = (tag) => `https://registry.npmjs.org/${PACKAGE_NAME}/${encodeURIComponent(tag)}`;
|
|
16982
16861
|
var SEMVER_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/;
|
|
16983
16862
|
var CHECK_INTERVAL_MS = 3 * 60 * 1e3;
|
|
16984
16863
|
function locationKey(location) {
|
|
16985
|
-
return
|
|
16864
|
+
return createHash2("sha256").update(location).digest("hex").slice(0, 12);
|
|
16986
16865
|
}
|
|
16987
16866
|
var throttleFileFor = (extDir) => {
|
|
16988
16867
|
if (process.env.ACP_UPDATE_THROTTLE_FILE) return process.env.ACP_UPDATE_THROTTLE_FILE;
|
|
@@ -17389,7 +17268,6 @@ function createAcpExtension(adapter = {}) {
|
|
|
17389
17268
|
wireDelegateReadTracking(pi);
|
|
17390
17269
|
wireSessionLifecycle(pi, runtime, standDownIfProxied);
|
|
17391
17270
|
wireContextTransform(pi, runtime, standDownIfProxied);
|
|
17392
|
-
wireBeforeProviderRequest(pi, runtime, standDownIfProxied);
|
|
17393
17271
|
wireSystemPrompt(pi, runtime);
|
|
17394
17272
|
wireToolGuardrails(pi, runtime);
|
|
17395
17273
|
wireOverflowSelfHeal(pi, runtime);
|
|
@@ -17503,25 +17381,6 @@ function wireSessionLifecycle(pi, runtime, standDownIfProxied) {
|
|
|
17503
17381
|
closeLogStream();
|
|
17504
17382
|
});
|
|
17505
17383
|
}
|
|
17506
|
-
function wireBeforeProviderRequest(pi, runtime, standDownIfProxied) {
|
|
17507
|
-
pi.on("before_provider_request", async (event, ctx) => {
|
|
17508
|
-
if (runtime.refused) return;
|
|
17509
|
-
if (standDownIfProxied(ctx)) return;
|
|
17510
|
-
const settings2 = runtime.stripImagesFor(ctx);
|
|
17511
|
-
if (!settings2.enabled) return;
|
|
17512
|
-
const outcome = applyStripImages(event.payload, ctx.model?.api, settings2);
|
|
17513
|
-
if (outcome.removed > 0) {
|
|
17514
|
-
logInfo("strip-images", {
|
|
17515
|
-
sid: ctx.sessionManager.getSessionId(),
|
|
17516
|
-
event: "stripped",
|
|
17517
|
-
removed: outcome.removed,
|
|
17518
|
-
keepRecent: settings2.keepRecent
|
|
17519
|
-
});
|
|
17520
|
-
return outcome.body;
|
|
17521
|
-
}
|
|
17522
|
-
return;
|
|
17523
|
-
});
|
|
17524
|
-
}
|
|
17525
17384
|
function wireContextTransform(pi, runtime, standDownIfProxied) {
|
|
17526
17385
|
pi.on("context", async (event, ctx) => {
|
|
17527
17386
|
if (runtime.refused) return;
|