acp-kernel 0.0.82-pr.345.220 → 0.0.82-pr.356.222
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/DESIGN.md +2 -0
- package/README.md +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +138 -77
- package/dist/index.js.map +1 -1
- package/dist/output-steering.d.ts +176 -0
- package/dist/output-steering.d.ts.map +1 -0
- package/dist/recommend.d.ts +11 -12
- package/dist/recommend.d.ts.map +1 -1
- package/package.json +1 -1
package/DESIGN.md
CHANGED
|
@@ -211,6 +211,8 @@ A default `countTokens` ships with the core (word-level + unicode CJK tokenizer,
|
|
|
211
211
|
| compress/decompress/search/status **tool registration** | **adapter** (calls core pure fns) |
|
|
212
212
|
| `/acp` commands | **adapter** |
|
|
213
213
|
| opencode hooks | **OpenCode adapter** |
|
|
214
|
+
| output-steering **decisions** (turn classification / verbosity level / effort clamp, #355) | **core** `decideOutputSteering` (pure; operates on a structural summary — role + block kinds, no content) |
|
|
215
|
+
| output-steering **landing** (wire field write-back, system-prompt carrier selection, numeric budget floors) | **adapter** |
|
|
214
216
|
| config three-layer merge | **adapter** (core only consumes its own `Config`) |
|
|
215
217
|
| logger / auth / persistence / update | **adapter** (core does zero I/O) |
|
|
216
218
|
|
package/README.md
CHANGED
|
@@ -104,6 +104,7 @@ live-recomputed tags, use `renderVisibleRefs` directly.
|
|
|
104
104
|
| `rebuildCompressionState` | Fork-recovery: replay historical compress calls |
|
|
105
105
|
| `applyMessageFilters` | Pluggable message-filter framework |
|
|
106
106
|
| `resolveTransformChannel` | Channel-selection policy: an explicit preference wins; the default is the wire channel only when the caller reports it viable |
|
|
107
|
+
| `decideOutputSteering` / `classifyTurn` / `clampEffortToFloor` / `applySteeringToPrompt` | Output-side steering *decisions* (#355): structural turn classification (`new_user_ask` / `mechanical_continuation` / `error_continuation` / `unknown`), byte-stable verbosity directives L0–L4 (default L2), and clamp-only effort routing. The kernel decides; adapters land decisions onto wire fields. Default OFF |
|
|
107
108
|
| `applySectionOverrides` / `cloneWithDescriptions` / `applyAcpToolOverrides` | Prompt/tool *surface* customization (see below) |
|
|
108
109
|
| `sanitizePackSurface` / `createPackResolver` / `defaultPackSources` | Prompt packs: named, swappable surface presets resolved over pluggable sources (see below) |
|
|
109
110
|
|
package/dist/index.d.ts
CHANGED
|
@@ -53,4 +53,6 @@ export { collectLatestProtected, isMessageLatestProtected, isMessageProtected, m
|
|
|
53
53
|
export { runPipeline, makeIO, type PipelineNode, type PipelineContext, type NodeIO, type NodeEffects, } from "./pipeline.js";
|
|
54
54
|
export * from "./filter/index.js";
|
|
55
55
|
export { VIABLE_RANGE_MIN_TOKENS, viableRanges } from "./viable.js";
|
|
56
|
+
export { classifyTurn, verbosityDirective, renderSteeringBlock, applySteeringToPrompt, clampEffortToFloor, resolveVerbosityLevel, resolveOutputSteeringConfig, decideOutputSteering, VERBOSITY_LEVELS, EFFORT_LADDER, DEFAULT_OUTPUT_STEERING_CONFIG, DEFAULT_STEERING_SENTINEL, DEFAULT_VERBOSITY_LEVEL, MIN_VERBOSITY_LEVEL, MAX_VERBOSITY_LEVEL, } from "./output-steering.js";
|
|
57
|
+
export type { TurnKind, StructuralMessage, StructuralBlock, OutputSteeringConfig, OutputSteeringDecision, SteeringPlacement, EffortValue, } from "./output-steering.js";
|
|
56
58
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,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;AACrB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,WAAW,EACX,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,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B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,WAAW,EACX,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,8BAA8B,EAC9B,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,GACZ,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2233,27 +2233,6 @@ function computeProtectedRefs(messages, state, config, countTokens = estimateTex
|
|
|
2233
2233
|
}
|
|
2234
2234
|
return result;
|
|
2235
2235
|
}
|
|
2236
|
-
function computeOpenTurnMemberIds(messages) {
|
|
2237
|
-
const resultCallIds = /* @__PURE__ */ new Set();
|
|
2238
|
-
for (const msg of messages) {
|
|
2239
|
-
if (msg.contentType === "tool-result" && typeof msg.toolCallId === "string") {
|
|
2240
|
-
resultCallIds.add(msg.toolCallId);
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
const openCallIds = /* @__PURE__ */ new Set();
|
|
2244
|
-
for (const msg of messages) {
|
|
2245
|
-
if (msg.id && msg.role === "assistant" && msg.contentType === "tool-call" && typeof msg.toolCallId === "string" && !resultCallIds.has(msg.toolCallId)) {
|
|
2246
|
-
openCallIds.add(msg.id);
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
|
-
if (openCallIds.size === 0) return /* @__PURE__ */ new Set();
|
|
2250
|
-
const excluded = /* @__PURE__ */ new Set();
|
|
2251
|
-
for (const group of computeTurnGroups(messages)) {
|
|
2252
|
-
if (!group.some((id) => openCallIds.has(id))) continue;
|
|
2253
|
-
for (const id of group) excluded.add(id);
|
|
2254
|
-
}
|
|
2255
|
-
return excluded;
|
|
2256
|
-
}
|
|
2257
2236
|
function buildCompressibleRanges(messages, state, config, protectedZoneRefs, countTokens = estimateTextTokens) {
|
|
2258
2237
|
let compressibleMsgs = [];
|
|
2259
2238
|
const protectedMsgs = [];
|
|
@@ -2302,20 +2281,6 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
2302
2281
|
skipSinceCompressible = false;
|
|
2303
2282
|
skipSinceProtected = true;
|
|
2304
2283
|
}
|
|
2305
|
-
const openTurnIds = computeOpenTurnMemberIds(messages);
|
|
2306
|
-
if (openTurnIds.size > 0) {
|
|
2307
|
-
let gapPending = false;
|
|
2308
|
-
const kept = [];
|
|
2309
|
-
for (const info of compressibleMsgs) {
|
|
2310
|
-
if (openTurnIds.has(info.id)) {
|
|
2311
|
-
gapPending = true;
|
|
2312
|
-
continue;
|
|
2313
|
-
}
|
|
2314
|
-
kept.push(gapPending ? { ...info, gapBefore: true } : info);
|
|
2315
|
-
gapPending = false;
|
|
2316
|
-
}
|
|
2317
|
-
compressibleMsgs = kept;
|
|
2318
|
-
}
|
|
2319
2284
|
const unfoldedIds = computeIntegrityWithdrawals(
|
|
2320
2285
|
messages,
|
|
2321
2286
|
new Set(compressibleMsgs.map((info) => info.id))
|
|
@@ -2333,13 +2298,6 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
2333
2298
|
}
|
|
2334
2299
|
compressibleMsgs = kept;
|
|
2335
2300
|
}
|
|
2336
|
-
const gapCount = compressibleMsgs.reduce(
|
|
2337
|
-
(s, info) => s + (info.gapBefore ? 1 : 0),
|
|
2338
|
-
0
|
|
2339
|
-
);
|
|
2340
|
-
if (gapCount > 0) {
|
|
2341
|
-
compressibleMsgs = refineSegmentsForFoldability(messages, compressibleMsgs);
|
|
2342
|
-
}
|
|
2343
2301
|
const compressible = [];
|
|
2344
2302
|
let cur = null;
|
|
2345
2303
|
for (const info of compressibleMsgs) {
|
|
@@ -2409,41 +2367,6 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
2409
2367
|
protected: protectedRanges
|
|
2410
2368
|
};
|
|
2411
2369
|
}
|
|
2412
|
-
var MAX_REFINEMENT_PASSES = 8;
|
|
2413
|
-
function refineSegmentsForFoldability(messages, infos) {
|
|
2414
|
-
let current = infos;
|
|
2415
|
-
for (let pass = 0; pass < MAX_REFINEMENT_PASSES; pass++) {
|
|
2416
|
-
const segments = [];
|
|
2417
|
-
for (const info of current) {
|
|
2418
|
-
const seg = segments[segments.length - 1];
|
|
2419
|
-
if (seg === void 0 || info.gapBefore) segments.push([info]);
|
|
2420
|
-
else seg.push(info);
|
|
2421
|
-
}
|
|
2422
|
-
const removed = /* @__PURE__ */ new Set();
|
|
2423
|
-
for (const seg of segments) {
|
|
2424
|
-
const withdrawn = computeIntegrityWithdrawals(
|
|
2425
|
-
messages,
|
|
2426
|
-
new Set(seg.map((info) => info.id))
|
|
2427
|
-
).withdrawn;
|
|
2428
|
-
for (const info of seg) {
|
|
2429
|
-
if (withdrawn.has(info.id)) removed.add(info.id);
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
if (removed.size === 0) break;
|
|
2433
|
-
let gapPending = false;
|
|
2434
|
-
const kept = [];
|
|
2435
|
-
for (const info of current) {
|
|
2436
|
-
if (removed.has(info.id)) {
|
|
2437
|
-
gapPending = true;
|
|
2438
|
-
continue;
|
|
2439
|
-
}
|
|
2440
|
-
kept.push(gapPending ? { ...info, gapBefore: true } : info);
|
|
2441
|
-
gapPending = false;
|
|
2442
|
-
}
|
|
2443
|
-
current = kept;
|
|
2444
|
-
}
|
|
2445
|
-
return current;
|
|
2446
|
-
}
|
|
2447
2370
|
function mergeBatch(batch) {
|
|
2448
2371
|
const first = batch[0];
|
|
2449
2372
|
const last = batch[batch.length - 1];
|
|
@@ -5701,6 +5624,129 @@ function makePreview(text, query, len) {
|
|
|
5701
5624
|
const suffix = end < text.length ? "\u2026" : "";
|
|
5702
5625
|
return prefix + clampWindow(text, start, end).trim() + suffix;
|
|
5703
5626
|
}
|
|
5627
|
+
|
|
5628
|
+
// src/output-steering.ts
|
|
5629
|
+
function classifyTurn(messages) {
|
|
5630
|
+
if (messages.length === 0) return "unknown";
|
|
5631
|
+
const last = messages[messages.length - 1];
|
|
5632
|
+
if (!last || last.role !== "user") return "unknown";
|
|
5633
|
+
if (typeof last.text === "string")
|
|
5634
|
+
return last.text.trim() ? "new_user_ask" : "unknown";
|
|
5635
|
+
const blocks = last.blocks;
|
|
5636
|
+
if (!Array.isArray(blocks) || blocks.length === 0) return "unknown";
|
|
5637
|
+
let sawToolResult = false;
|
|
5638
|
+
let sawError = false;
|
|
5639
|
+
for (const b of blocks) {
|
|
5640
|
+
if (!b) return "unknown";
|
|
5641
|
+
switch (b.kind) {
|
|
5642
|
+
case "tool_result":
|
|
5643
|
+
sawToolResult = true;
|
|
5644
|
+
if (b.isError === true) sawError = true;
|
|
5645
|
+
break;
|
|
5646
|
+
case "text":
|
|
5647
|
+
case "image":
|
|
5648
|
+
case "document":
|
|
5649
|
+
return "new_user_ask";
|
|
5650
|
+
default:
|
|
5651
|
+
return "unknown";
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
if (sawError) return "error_continuation";
|
|
5655
|
+
if (sawToolResult) return "mechanical_continuation";
|
|
5656
|
+
return "unknown";
|
|
5657
|
+
}
|
|
5658
|
+
var MIN_VERBOSITY_LEVEL = 0;
|
|
5659
|
+
var MAX_VERBOSITY_LEVEL = 4;
|
|
5660
|
+
var DEFAULT_VERBOSITY_LEVEL = 2;
|
|
5661
|
+
var VERBOSITY_LEVELS = {
|
|
5662
|
+
1: "Skip preamble and postamble. Do not announce what you are about to do or recap what you just did; start with the substance.",
|
|
5663
|
+
2: "Skip preamble and postamble; start with the substance. Never restate code, file contents, diffs, or tool output that already appear in this conversation \u2014 reference them by path and line instead. After a tool call succeeds, continue without narrating the result.",
|
|
5664
|
+
3: "Skip preamble and postamble. Never restate code, file contents, diffs, or tool output already in this conversation \u2014 cite the exact file path and line or symbol instead, always; a reference that omits the location is not a reference. Give conclusions only; omit rationale unless the user asks why. Prefer the smallest edit over rewriting whole files. Keep prose to the minimum needed to be unambiguous. Never drop anything the turn or task needs to be correct, including negations (not, never, no, only, except) \u2014 shorten how you say it, not what you say. Use full prose for destructive or irreversible actions, security warnings, and any multi-step sequence where brevity would create ambiguity.",
|
|
5665
|
+
4: "Minimum tokens. Fragments fine. No preamble, no postamble, no restating context, no rationale. Answer, smallest-possible edits, nothing else. Never drop anything the turn or task needs to be correct, including negations (not, never, no, only, except). Use full prose for destructive or irreversible actions, security warnings, and any multi-step sequence where brevity would create ambiguity."
|
|
5666
|
+
};
|
|
5667
|
+
function verbosityDirective(level) {
|
|
5668
|
+
if (!Number.isInteger(level)) return null;
|
|
5669
|
+
return VERBOSITY_LEVELS[level] ?? null;
|
|
5670
|
+
}
|
|
5671
|
+
var DEFAULT_STEERING_SENTINEL = "<acp_output_steering>";
|
|
5672
|
+
function renderSteeringBlock(level, sentinel = DEFAULT_STEERING_SENTINEL) {
|
|
5673
|
+
const text = verbosityDirective(level);
|
|
5674
|
+
if (text === null) return null;
|
|
5675
|
+
return `${sentinel}
|
|
5676
|
+
${text}
|
|
5677
|
+
</${sentinel.slice(1)}`;
|
|
5678
|
+
}
|
|
5679
|
+
function applySteeringToPrompt(existing, block, sentinel = DEFAULT_STEERING_SENTINEL) {
|
|
5680
|
+
const suffix = `</${sentinel.slice(1)}`;
|
|
5681
|
+
const start = existing.indexOf(sentinel);
|
|
5682
|
+
if (start >= 0) {
|
|
5683
|
+
const found = existing.indexOf(suffix, start);
|
|
5684
|
+
const end = found < 0 ? existing.length : found + suffix.length;
|
|
5685
|
+
const prefix = existing.slice(0, start).replace(/\s+$/, "");
|
|
5686
|
+
const tail = existing.slice(end).replace(/^\n+/, "");
|
|
5687
|
+
const parts = [prefix, block, tail].filter((p) => p.length > 0);
|
|
5688
|
+
const updated2 = parts.join("\n\n");
|
|
5689
|
+
return { updated: updated2, changed: updated2 !== existing };
|
|
5690
|
+
}
|
|
5691
|
+
const trimmed = existing.trim();
|
|
5692
|
+
const updated = trimmed.length > 0 ? `${existing.replace(/\s+$/, "")}
|
|
5693
|
+
|
|
5694
|
+
${block}` : block;
|
|
5695
|
+
return { updated, changed: updated !== existing };
|
|
5696
|
+
}
|
|
5697
|
+
var EFFORT_LADDER = [
|
|
5698
|
+
"minimal",
|
|
5699
|
+
"low",
|
|
5700
|
+
"medium",
|
|
5701
|
+
"high",
|
|
5702
|
+
"xhigh"
|
|
5703
|
+
];
|
|
5704
|
+
function clampEffortToFloor(current, floor = "low") {
|
|
5705
|
+
if (typeof current !== "string") return null;
|
|
5706
|
+
const ci = EFFORT_LADDER.indexOf(current);
|
|
5707
|
+
if (ci === -1) return null;
|
|
5708
|
+
const fi = EFFORT_LADDER.indexOf(floor);
|
|
5709
|
+
return ci > fi ? floor : null;
|
|
5710
|
+
}
|
|
5711
|
+
var DEFAULT_OUTPUT_STEERING_CONFIG = {
|
|
5712
|
+
enabled: false,
|
|
5713
|
+
verbosityLevel: DEFAULT_VERBOSITY_LEVEL,
|
|
5714
|
+
effortRouting: true
|
|
5715
|
+
};
|
|
5716
|
+
function resolveVerbosityLevel(v) {
|
|
5717
|
+
if (typeof v === "number" && Number.isInteger(v) && v >= MIN_VERBOSITY_LEVEL && v <= MAX_VERBOSITY_LEVEL) {
|
|
5718
|
+
return { level: v };
|
|
5719
|
+
}
|
|
5720
|
+
const level = DEFAULT_OUTPUT_STEERING_CONFIG.verbosityLevel;
|
|
5721
|
+
if (v === void 0) return { level };
|
|
5722
|
+
return {
|
|
5723
|
+
level,
|
|
5724
|
+
warning: `[config] outputSteering.verbosityLevel must be an integer ${MIN_VERBOSITY_LEVEL}-${MAX_VERBOSITY_LEVEL}; got ${JSON.stringify(v)} \u2014 falling back to ${level}`
|
|
5725
|
+
};
|
|
5726
|
+
}
|
|
5727
|
+
function resolveOutputSteeringConfig(v) {
|
|
5728
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) {
|
|
5729
|
+
return { config: DEFAULT_OUTPUT_STEERING_CONFIG, warnings: [] };
|
|
5730
|
+
}
|
|
5731
|
+
const obj = v;
|
|
5732
|
+
const lvl = resolveVerbosityLevel(obj.verbosityLevel);
|
|
5733
|
+
return {
|
|
5734
|
+
config: {
|
|
5735
|
+
enabled: obj.enabled === true,
|
|
5736
|
+
verbosityLevel: lvl.level,
|
|
5737
|
+
effortRouting: obj.effortRouting !== false
|
|
5738
|
+
},
|
|
5739
|
+
warnings: lvl.warning ? [lvl.warning] : []
|
|
5740
|
+
};
|
|
5741
|
+
}
|
|
5742
|
+
function decideOutputSteering(messages, config = DEFAULT_OUTPUT_STEERING_CONFIG) {
|
|
5743
|
+
const turnKind = classifyTurn(messages);
|
|
5744
|
+
return {
|
|
5745
|
+
turnKind,
|
|
5746
|
+
verbosityLevel: config.enabled ? config.verbosityLevel : 0,
|
|
5747
|
+
lowerEffort: config.enabled && config.effortRouting && turnKind === "mechanical_continuation"
|
|
5748
|
+
};
|
|
5749
|
+
}
|
|
5704
5750
|
export {
|
|
5705
5751
|
ABSORB_PROMPT_MARKER,
|
|
5706
5752
|
ABSORB_TOOL,
|
|
@@ -5749,10 +5795,16 @@ export {
|
|
|
5749
5795
|
DECOMPRESS_TOOL_RESPONSES,
|
|
5750
5796
|
DEFAULT_ABSORB_CONFIG,
|
|
5751
5797
|
DEFAULT_ALGORITHM,
|
|
5798
|
+
DEFAULT_OUTPUT_STEERING_CONFIG,
|
|
5752
5799
|
DEFAULT_ROLE_WEIGHTS,
|
|
5753
5800
|
DEFAULT_RULE_LIMITS,
|
|
5801
|
+
DEFAULT_STEERING_SENTINEL,
|
|
5802
|
+
DEFAULT_VERBOSITY_LEVEL,
|
|
5803
|
+
EFFORT_LADDER,
|
|
5754
5804
|
HOW_TO_COMPRESS_RULES,
|
|
5755
5805
|
LEAN_HOW_TO_COMPRESS,
|
|
5806
|
+
MAX_VERBOSITY_LEVEL,
|
|
5807
|
+
MIN_VERBOSITY_LEVEL,
|
|
5756
5808
|
RULES_USAGE_PROMPT,
|
|
5757
5809
|
RULE_TOOL_NAME,
|
|
5758
5810
|
SEARCH_CONTEXT_TOOL,
|
|
@@ -5763,6 +5815,7 @@ export {
|
|
|
5763
5815
|
SUMMARY_HEADER,
|
|
5764
5816
|
TIER2_DISTILL_RULES,
|
|
5765
5817
|
TIER3_CONDENSE_RULES,
|
|
5818
|
+
VERBOSITY_LEVELS,
|
|
5766
5819
|
VIABLE_RANGE_MIN_TOKENS,
|
|
5767
5820
|
activeBlockSpans,
|
|
5768
5821
|
activeBlocks,
|
|
@@ -5776,6 +5829,7 @@ export {
|
|
|
5776
5829
|
applyAcpToolOverrides,
|
|
5777
5830
|
applyMessageFilters,
|
|
5778
5831
|
applySectionOverrides,
|
|
5832
|
+
applySteeringToPrompt,
|
|
5779
5833
|
assignRefs,
|
|
5780
5834
|
blockById,
|
|
5781
5835
|
blockDocs,
|
|
@@ -5790,6 +5844,8 @@ export {
|
|
|
5790
5844
|
buildRestoredContentPreview,
|
|
5791
5845
|
buildStatusReport,
|
|
5792
5846
|
builtinSource,
|
|
5847
|
+
clampEffortToFloor,
|
|
5848
|
+
classifyTurn,
|
|
5793
5849
|
clearDocFeatures,
|
|
5794
5850
|
clearMessageFilters,
|
|
5795
5851
|
clearRules,
|
|
@@ -5806,6 +5862,7 @@ export {
|
|
|
5806
5862
|
createPackResolver,
|
|
5807
5863
|
createRenderRefsNode,
|
|
5808
5864
|
deactivateBlock,
|
|
5865
|
+
decideOutputSteering,
|
|
5809
5866
|
decomposeSample,
|
|
5810
5867
|
defaultConfig,
|
|
5811
5868
|
defaultCountTokens,
|
|
@@ -5861,13 +5918,16 @@ export {
|
|
|
5861
5918
|
renderMessage2 as renderMessage,
|
|
5862
5919
|
renderNudgeText,
|
|
5863
5920
|
renderRefsNode,
|
|
5921
|
+
renderSteeringBlock,
|
|
5864
5922
|
renderVisibleRefs,
|
|
5865
5923
|
resolveAbsorbConfig,
|
|
5866
5924
|
resolveBlockSpan,
|
|
5867
5925
|
resolveBoundaries,
|
|
5926
|
+
resolveOutputSteeringConfig,
|
|
5868
5927
|
resolvePrompts,
|
|
5869
5928
|
resolveRuleLimits,
|
|
5870
5929
|
resolveTransformChannel,
|
|
5930
|
+
resolveVerbosityLevel,
|
|
5871
5931
|
runPipeline,
|
|
5872
5932
|
sanitizePackSurface,
|
|
5873
5933
|
searchBlocks,
|
|
@@ -5878,6 +5938,7 @@ export {
|
|
|
5878
5938
|
syncBlocks,
|
|
5879
5939
|
truncateLargeToolOutputs,
|
|
5880
5940
|
validateConfig,
|
|
5941
|
+
verbosityDirective,
|
|
5881
5942
|
viableRanges,
|
|
5882
5943
|
visibleBlockAnchor
|
|
5883
5944
|
};
|