state_marker was found by its text anywhere: any item's string content or any part's text. A Chat tool result or a user message that read a file or log containing the marker stayed whole on every turn, and lifted the task message's protection. carriesState now takes the marker only where the agent writes its state block: an assistant message (Chat, Anthropic, or a Responses message item) whose string content, or a text/output_text part, starts with the marker. Tool results, user text, nested tool_result parts, function_call_output and a marker in the middle of a text count for nothing. page/measure.js rebuilt (build.mjs's transform), README option row and CHANGELOG updated. Ships the8e4105dddocs fix too. Run on mote (Bun 1.4.2, temp HOME), atbf959aa60eplus this change: - bun test packages/fovea: 45 pass, 0 fail (10 new tests). - bun test (whole repo): 5932 pass, 19 skip, 0 fail. bun scripts/check.mjs ok. - Old code (origin/main's middleware) with the new tests: 6 fail - Chat tool result (string and text part), user string, user text block, mid-text assistant, Responses user input_text. The Anthropic tool_result (string, nested part) and function_call_output cases pass on the old code too: it read only top-level content/text, so those were not forgeable; the tests keep them that way. - Broken by hand: role/type check removed, 4 fail; startsWith replaced by includes, 1 fail (mid-text). Not tried: a live gateway request, magpie's moejs run of cases.json. Users who put the marker somewhere other than the start of an assistant text lose the exemption; fovea is not on npm and the option is off by default.
64 lines
2.2 KiB
JSON
64 lines
2.2 KiB
JSON
{
|
|
"name": "@magpie-community/middleware-fovea",
|
|
"version": "0.2.4",
|
|
"description": "magpie gateway middleware: keep the recent window sharp, thin old history to head and tail, and on a saccade drop the old context on a new topic — with an evidence page",
|
|
"type": "module",
|
|
"files": [
|
|
"CHANGELOG.md",
|
|
"LICENSE",
|
|
"README.md",
|
|
"benchmark.mjs",
|
|
"build.mjs",
|
|
"cases.json",
|
|
"fovea.middleware.js",
|
|
"fovea.test.mjs",
|
|
"page/*",
|
|
"preview.mjs",
|
|
"state-block.example.json"
|
|
],
|
|
"keywords": [
|
|
"magpie",
|
|
"magpie-middleware",
|
|
"context",
|
|
"history",
|
|
"compaction",
|
|
"tool-results",
|
|
"token-budget",
|
|
"saccade",
|
|
"llm-gateway"
|
|
],
|
|
"license": "MIT",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/magpie-community/plugins.git",
|
|
"directory": "packages/fovea"
|
|
},
|
|
"magpie": {
|
|
"middleware": "./fovea.middleware.js",
|
|
"page": {
|
|
"title": "Fovea evidence",
|
|
"titles": {
|
|
"zh": "Fovea 对照证据"
|
|
},
|
|
"file": "page/index.html",
|
|
"icon": "page/icon.svg"
|
|
},
|
|
"permissions": [],
|
|
"options": {
|
|
"threshold": 96000,
|
|
"keep_recent": 12,
|
|
"keep_recent_tokens": 16000,
|
|
"tool_head": 600,
|
|
"tool_tail": 300,
|
|
"text_head": 1200,
|
|
"text_tail": 400,
|
|
"drop_old_images": true,
|
|
"protect": [],
|
|
"saccade": "off",
|
|
"state_marker": "",
|
|
"cut_step": 24
|
|
},
|
|
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4IiByb2xlPSJpbWciIGFyaWEtbGFiZWw9IkZvdmVhIGxvZ28gZm9yIGRhcmsgYmFja2dyb3VuZHMiPgogIDx0aXRsZT5Gb3ZlYSDigJQgc2hhcnAgY2VudHJlLCBmYWRpbmcgcGVyaXBoZXJ5IChkYXJrKTwvdGl0bGU+CiAgPGNpcmNsZSBjeD0iNjQiIGN5PSI2NCIgcj0iNTgiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2U4ZWVmNSIgc3Ryb2tlLW9wYWNpdHk9IjAuMjIiIHN0cm9rZS13aWR0aD0iNiIvPgogIDxjaXJjbGUgY3g9IjY0IiBjeT0iNjQiIHI9IjQyIiBmaWxsPSJub25lIiBzdHJva2U9IiNlOGVlZjUiIHN0cm9rZS1vcGFjaXR5PSIwLjUiIHN0cm9rZS13aWR0aD0iNyIvPgogIDxjaXJjbGUgY3g9IjY0IiBjeT0iNjQiIHI9IjI1IiBmaWxsPSJub25lIiBzdHJva2U9IiNlOGVlZjUiIHN0cm9rZS1vcGFjaXR5PSIwLjkiIHN0cm9rZS13aWR0aD0iOCIvPgogIDxjaXJjbGUgY3g9IjY0IiBjeT0iNjQiIHI9IjEwIiBmaWxsPSIjOGRiYmY1Ii8+Cjwvc3ZnPgo="
|
|
}
|
|
}
|