@sriinnu/fiche 0.18.0-bootstrap.0 → 0.19.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 +134 -0
- package/LICENSE +22 -0
- package/NOTICE +13 -0
- package/PRIVACY.md +41 -0
- package/README.md +289 -0
- package/SECURITY.md +53 -0
- package/assets/JETBRAINS_MONO_LICENSE.txt +89 -0
- package/assets/SPLEEN_LICENSE.txt +24 -0
- package/assets/UNIFONT_LICENSE.txt +476 -0
- package/assets/fiche-logo-dark.svg +61 -0
- package/assets/fiche-logo-light.svg +61 -0
- package/assets/fiche-logo.svg +71 -0
- package/assets/fiche-mark.svg +48 -0
- package/bin/cli.js +7 -0
- package/bin/mcp.js +8 -0
- package/dist/calibrate.d.ts +30 -0
- package/dist/calibrate.js +588 -0
- package/dist/core/anthropic-vision.d.ts +28 -0
- package/dist/core/anthropic-vision.js +34 -0
- package/dist/core/applicability.d.ts +63 -0
- package/dist/core/applicability.js +151 -0
- package/dist/core/atlas-gray-jbmono10.d.ts +26 -0
- package/dist/core/atlas-gray-jbmono10.js +64 -0
- package/dist/core/atlas-gray-jbmono12.d.ts +26 -0
- package/dist/core/atlas-gray-jbmono12.js +64 -0
- package/dist/core/atlas-gray-jbmono14.d.ts +26 -0
- package/dist/core/atlas-gray-jbmono14.js +64 -0
- package/dist/core/atlas-gray.d.ts +26 -0
- package/dist/core/atlas-gray.js +64 -0
- package/dist/core/atlas-jbmono10.d.ts +34 -0
- package/dist/core/atlas-jbmono10.js +71 -0
- package/dist/core/atlas-jbmono12.d.ts +34 -0
- package/dist/core/atlas-jbmono12.js +71 -0
- package/dist/core/atlas-jbmono14.d.ts +34 -0
- package/dist/core/atlas-jbmono14.js +71 -0
- package/dist/core/atlas.d.ts +34 -0
- package/dist/core/atlas.js +71 -0
- package/dist/core/baseline.d.ts +121 -0
- package/dist/core/baseline.js +200 -0
- package/dist/core/calibration.d.ts +86 -0
- package/dist/core/calibration.js +547 -0
- package/dist/core/casi-delta.d.ts +63 -0
- package/dist/core/casi-delta.js +1271 -0
- package/dist/core/claude-model-profiles.d.ts +53 -0
- package/dist/core/claude-model-profiles.js +160 -0
- package/dist/core/client-tool-round.d.ts +31 -0
- package/dist/core/client-tool-round.js +58 -0
- package/dist/core/codex-cache.d.ts +20 -0
- package/dist/core/codex-cache.js +59 -0
- package/dist/core/context-mmu.d.ts +350 -0
- package/dist/core/context-mmu.js +3028 -0
- package/dist/core/cpt-fit.d.ts +70 -0
- package/dist/core/cpt-fit.js +197 -0
- package/dist/core/env.d.ts +8 -0
- package/dist/core/env.js +15 -0
- package/dist/core/export.d.ts +127 -0
- package/dist/core/export.js +385 -0
- package/dist/core/factsheet.d.ts +77 -0
- package/dist/core/factsheet.js +494 -0
- package/dist/core/gemini-model-profiles.d.ts +20 -0
- package/dist/core/gemini-model-profiles.js +134 -0
- package/dist/core/google.d.ts +76 -0
- package/dist/core/google.js +1380 -0
- package/dist/core/gpt-model-profiles.d.ts +218 -0
- package/dist/core/gpt-model-profiles.js +570 -0
- package/dist/core/gpt-tokens.d.ts +14 -0
- package/dist/core/gpt-tokens.js +165 -0
- package/dist/core/history.d.ts +197 -0
- package/dist/core/history.js +1003 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.js +16 -0
- package/dist/core/library.d.ts +80 -0
- package/dist/core/library.js +131 -0
- package/dist/core/measurement.d.ts +34 -0
- package/dist/core/measurement.js +280 -0
- package/dist/core/messages-chat-bridge.d.ts +23 -0
- package/dist/core/messages-chat-bridge.js +747 -0
- package/dist/core/messages-responses-bridge.d.ts +11 -0
- package/dist/core/messages-responses-bridge.js +893 -0
- package/dist/core/openai-history.d.ts +184 -0
- package/dist/core/openai-history.js +1279 -0
- package/dist/core/openai-savings.d.ts +57 -0
- package/dist/core/openai-savings.js +116 -0
- package/dist/core/openai.d.ts +68 -0
- package/dist/core/openai.js +2523 -0
- package/dist/core/pin.d.ts +199 -0
- package/dist/core/pin.js +1353 -0
- package/dist/core/png.d.ts +14 -0
- package/dist/core/png.js +188 -0
- package/dist/core/prefix-tape.d.ts +102 -0
- package/dist/core/prefix-tape.js +315 -0
- package/dist/core/price-id.d.ts +10 -0
- package/dist/core/price-id.js +26 -0
- package/dist/core/prices.generated.d.ts +36 -0
- package/dist/core/prices.generated.js +369 -0
- package/dist/core/pricing.d.ts +134 -0
- package/dist/core/pricing.js +335 -0
- package/dist/core/profile-base.d.ts +30 -0
- package/dist/core/profile-base.js +67 -0
- package/dist/core/provider-router.d.ts +51 -0
- package/dist/core/provider-router.js +121 -0
- package/dist/core/proxy.d.ts +252 -0
- package/dist/core/proxy.js +2929 -0
- package/dist/core/reader-tier.d.ts +24 -0
- package/dist/core/reader-tier.js +118 -0
- package/dist/core/render.d.ts +280 -0
- package/dist/core/render.js +1302 -0
- package/dist/core/request-guard.d.ts +31 -0
- package/dist/core/request-guard.js +126 -0
- package/dist/core/request-transform.d.ts +43 -0
- package/dist/core/request-transform.js +173 -0
- package/dist/core/schema-compiler.d.ts +64 -0
- package/dist/core/schema-compiler.js +1696 -0
- package/dist/core/schema-strip.d.ts +29 -0
- package/dist/core/schema-strip.js +173 -0
- package/dist/core/session-state.d.ts +219 -0
- package/dist/core/session-state.js +929 -0
- package/dist/core/stage-plugins.d.ts +45 -0
- package/dist/core/stage-plugins.js +205 -0
- package/dist/core/text-history.d.ts +74 -0
- package/dist/core/text-history.js +612 -0
- package/dist/core/text-hygiene.d.ts +160 -0
- package/dist/core/text-hygiene.js +2259 -0
- package/dist/core/toon.d.ts +29 -0
- package/dist/core/toon.js +425 -0
- package/dist/core/tracker.d.ts +223 -0
- package/dist/core/tracker.js +290 -0
- package/dist/core/transform.d.ts +589 -0
- package/dist/core/transform.js +3153 -0
- package/dist/core/types.d.ts +87 -0
- package/dist/core/types.js +8 -0
- package/dist/core/upstream-hosts.d.ts +127 -0
- package/dist/core/upstream-hosts.js +398 -0
- package/dist/core/vision-cost.d.ts +63 -0
- package/dist/core/vision-cost.js +137 -0
- package/dist/dashboard/fragments.d.ts +87 -0
- package/dist/dashboard/fragments.js +1515 -0
- package/dist/dashboard/types.d.ts +217 -0
- package/dist/dashboard/types.js +3 -0
- package/dist/dashboard/vendor.d.ts +3 -0
- package/dist/dashboard/vendor.js +6 -0
- package/dist/dashboard.d.ts +372 -0
- package/dist/dashboard.js +2731 -0
- package/dist/export-collect.d.ts +36 -0
- package/dist/export-collect.js +59 -0
- package/dist/file-tracker.d.ts +42 -0
- package/dist/file-tracker.js +234 -0
- package/dist/kosha-sync.d.ts +74 -0
- package/dist/kosha-sync.js +272 -0
- package/dist/launchd-socket.d.ts +22 -0
- package/dist/launchd-socket.js +210 -0
- package/dist/mcp/cli.d.ts +2 -0
- package/dist/mcp/cli.js +55 -0
- package/dist/mcp/server.d.ts +48 -0
- package/dist/mcp/server.js +987 -0
- package/dist/mmu-store.d.ts +31 -0
- package/dist/mmu-store.js +179 -0
- package/dist/node-fetch.d.ts +22 -0
- package/dist/node-fetch.js +489 -0
- package/dist/node.d.ts +9 -0
- package/dist/node.js +244396 -0
- package/dist/request-decoding.d.ts +30 -0
- package/dist/request-decoding.js +85 -0
- package/dist/sessions.d.ts +179 -0
- package/dist/sessions.js +837 -0
- package/dist/stats.d.ts +114 -0
- package/dist/stats.js +439 -0
- package/dist/turn-report.d.ts +65 -0
- package/dist/turn-report.js +724 -0
- package/dist/warp/app-launch.d.ts +26 -0
- package/dist/warp/app-launch.js +155 -0
- package/dist/warp/ca.d.ts +74 -0
- package/dist/warp/ca.js +416 -0
- package/dist/warp/connect.d.ts +42 -0
- package/dist/warp/connect.js +686 -0
- package/dist/warp/der.d.ts +57 -0
- package/dist/warp/der.js +151 -0
- package/dist/warp/index.d.ts +79 -0
- package/dist/warp/index.js +650 -0
- package/dist/warp/resolve.d.ts +12 -0
- package/dist/warp/resolve.js +49 -0
- package/dist/warp/route.d.ts +71 -0
- package/dist/warp/route.js +134 -0
- package/dist/worker.d.ts +71 -0
- package/dist/worker.js +174 -0
- package/docs/SECURITY_MODEL.md +84 -0
- package/package.json +115 -3
- package/plugins/fiche-companion/README.md +42 -0
- package/plugins/fiche-companion/assets/logo.svg +48 -0
- package/plugins/fiche-companion/hooks.json +11 -0
- package/plugins/fiche-companion/mcp_config.json +8 -0
- package/plugins/fiche-companion/plugin.json +18 -0
- package/plugins/fiche-companion/scripts/claude-statusline.mjs +35 -0
- package/plugins/fiche-companion/scripts/post-invocation.mjs +122 -0
- package/plugins/fiche-companion/scripts/resolve-turn-report.mjs +132 -0
- package/plugins/fiche-companion/skills/fiche/SKILL.md +61 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensible pipeline stages & skills registry (edge/browser-safe: zero `node:` imports).
|
|
3
|
+
*
|
|
4
|
+
* Built-in stages represent Fiche's deterministic/optical compiler stages.
|
|
5
|
+
* Node hosts discover custom `~/.fiche/plugins/` manifests and `~/.agents/skills/`
|
|
6
|
+
* / `~/.gemini/config/plugins/fiche-companion/skills/` entries and merge them with
|
|
7
|
+
* persisted enabled overrides via `mergeStagePlugins()`.
|
|
8
|
+
*/
|
|
9
|
+
export type PipelineStage = 'pre-hygiene' | 'hygiene' | 'history' | 'optical' | 'skill';
|
|
10
|
+
export type PluginKind = 'builtin' | 'custom' | 'skill';
|
|
11
|
+
export interface StagePluginDescriptor {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly stage: PipelineStage;
|
|
15
|
+
readonly kind: PluginKind;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly enabled: boolean;
|
|
18
|
+
readonly version?: string;
|
|
19
|
+
readonly sourcePath?: string;
|
|
20
|
+
}
|
|
21
|
+
export type PluginOverrides = Record<string, boolean>;
|
|
22
|
+
export interface StageToggles {
|
|
23
|
+
readonly optical: boolean;
|
|
24
|
+
readonly tscg: boolean;
|
|
25
|
+
readonly toon: boolean;
|
|
26
|
+
readonly acdc: boolean;
|
|
27
|
+
readonly casi: boolean;
|
|
28
|
+
readonly lsm: boolean;
|
|
29
|
+
readonly mmu: boolean;
|
|
30
|
+
readonly skillLinker: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Built-in Fiche context-compiler pipeline stages, enabled by default. */
|
|
33
|
+
export declare const BUILTIN_STAGE_PLUGINS: readonly StagePluginDescriptor[];
|
|
34
|
+
export declare function isValidPluginId(id: unknown): id is string;
|
|
35
|
+
/** True for third-party plugins and extensions (built-in compiler stages and fiche's own skill stay excluded). */
|
|
36
|
+
export declare function isThirdPartyPlugin(plugin: Pick<StagePluginDescriptor, 'id' | 'kind'>): boolean;
|
|
37
|
+
/** Parse a `plugin.json` manifest into a StagePluginDescriptor, or null if malformed. */
|
|
38
|
+
export declare function parsePluginManifest(rawJson: string, fallbackId: string, sourcePath?: string): StagePluginDescriptor | null;
|
|
39
|
+
/** Parse YAML frontmatter from a `SKILL.md` file into a skill StagePluginDescriptor. */
|
|
40
|
+
export declare function parseSkillManifest(markdown: string, fallbackId: string, sourcePath?: string): StagePluginDescriptor | null;
|
|
41
|
+
/** Merge built-in stages with discovered custom plugins/skills and persisted overrides. */
|
|
42
|
+
export declare function mergeStagePlugins(discovered: readonly StagePluginDescriptor[], overrides?: PluginOverrides): StagePluginDescriptor[];
|
|
43
|
+
/** Derive active pipeline stage toggles from persisted plugin overrides (`plugins.json`). */
|
|
44
|
+
export declare function stageTogglesFromOverrides(overrides?: PluginOverrides): StageToggles;
|
|
45
|
+
//# sourceMappingURL=stage-plugins.d.ts.map
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensible pipeline stages & skills registry (edge/browser-safe: zero `node:` imports).
|
|
3
|
+
*
|
|
4
|
+
* Built-in stages represent Fiche's deterministic/optical compiler stages.
|
|
5
|
+
* Node hosts discover custom `~/.fiche/plugins/` manifests and `~/.agents/skills/`
|
|
6
|
+
* / `~/.gemini/config/plugins/fiche-companion/skills/` entries and merge them with
|
|
7
|
+
* persisted enabled overrides via `mergeStagePlugins()`.
|
|
8
|
+
*/
|
|
9
|
+
const VALID_STAGES = new Set([
|
|
10
|
+
'pre-hygiene',
|
|
11
|
+
'hygiene',
|
|
12
|
+
'history',
|
|
13
|
+
'optical',
|
|
14
|
+
'skill',
|
|
15
|
+
]);
|
|
16
|
+
/** Built-in Fiche context-compiler pipeline stages, enabled by default. */
|
|
17
|
+
export const BUILTIN_STAGE_PLUGINS = [
|
|
18
|
+
{
|
|
19
|
+
id: 'optical-microfiche',
|
|
20
|
+
name: 'Optical Microfiche',
|
|
21
|
+
stage: 'optical',
|
|
22
|
+
kind: 'builtin',
|
|
23
|
+
description: 'Renders bulky stale context into dense lossless PNG pages for strong page readers.',
|
|
24
|
+
enabled: true,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'tscg-schema',
|
|
28
|
+
name: 'TSCG Schema Compiler',
|
|
29
|
+
stage: 'pre-hygiene',
|
|
30
|
+
kind: 'builtin',
|
|
31
|
+
description: 'Deterministic prefix-safe tool schema and static system-prompt compaction.',
|
|
32
|
+
enabled: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'toon-structured',
|
|
36
|
+
name: 'TOON Structured Encoder',
|
|
37
|
+
stage: 'hygiene',
|
|
38
|
+
kind: 'builtin',
|
|
39
|
+
description: 'Lossless tabular TOON encoding for repetitive JSON array payloads in tool outputs.',
|
|
40
|
+
enabled: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'acdc-epochs',
|
|
44
|
+
name: 'ACDC Epoch Collapse',
|
|
45
|
+
stage: 'history',
|
|
46
|
+
kind: 'builtin',
|
|
47
|
+
description: 'Amortized cache-safe deterministic collapsing of older text history turns.',
|
|
48
|
+
enabled: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'casi-delta',
|
|
52
|
+
name: 'CASI Delta Deduplicator',
|
|
53
|
+
stage: 'hygiene',
|
|
54
|
+
kind: 'builtin',
|
|
55
|
+
description: 'Content-addressed duplicate and delta referencing across live tool outputs.',
|
|
56
|
+
enabled: true,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'lsm-context',
|
|
60
|
+
name: 'LSM-Context Hierarchy',
|
|
61
|
+
stage: 'history',
|
|
62
|
+
kind: 'builtin',
|
|
63
|
+
description: 'Multi-level LSM history compaction tiers for long-running sessions.',
|
|
64
|
+
enabled: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'context-mmu',
|
|
68
|
+
name: 'Context-MMU Virtual Memory',
|
|
69
|
+
stage: 'history',
|
|
70
|
+
kind: 'builtin',
|
|
71
|
+
description: 'Virtual context paging, Markovian causal episode folding, and live-tail hydration.',
|
|
72
|
+
enabled: true,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'skill-linker',
|
|
76
|
+
name: 'Session Skill Linker',
|
|
77
|
+
stage: 'pre-hygiene',
|
|
78
|
+
kind: 'builtin',
|
|
79
|
+
description: 'Turn-1 pinned skill catalog stubbing with speculative Turn-N auto-hydration.',
|
|
80
|
+
enabled: true,
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
const FORBIDDEN_PLUGIN_IDS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
84
|
+
export function isValidPluginId(id) {
|
|
85
|
+
if (typeof id !== 'string')
|
|
86
|
+
return false;
|
|
87
|
+
const trimmed = id.trim();
|
|
88
|
+
return !FORBIDDEN_PLUGIN_IDS.has(trimmed) && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(trimmed);
|
|
89
|
+
}
|
|
90
|
+
/** True for third-party plugins and extensions (built-in compiler stages and fiche's own skill stay excluded). */
|
|
91
|
+
export function isThirdPartyPlugin(plugin) {
|
|
92
|
+
return plugin.kind !== 'builtin' && plugin.id !== 'skill:fiche';
|
|
93
|
+
}
|
|
94
|
+
/** Parse a `plugin.json` manifest into a StagePluginDescriptor, or null if malformed. */
|
|
95
|
+
export function parsePluginManifest(rawJson, fallbackId, sourcePath) {
|
|
96
|
+
let parsed;
|
|
97
|
+
try {
|
|
98
|
+
parsed = JSON.parse(rawJson);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
104
|
+
return null;
|
|
105
|
+
const obj = parsed;
|
|
106
|
+
const rawId = typeof obj.id === 'string' && obj.id.trim()
|
|
107
|
+
? obj.id.trim()
|
|
108
|
+
: typeof obj.name === 'string' && obj.name.trim()
|
|
109
|
+
? obj.name.trim()
|
|
110
|
+
: fallbackId.trim();
|
|
111
|
+
if (!isValidPluginId(rawId))
|
|
112
|
+
return null;
|
|
113
|
+
const name = typeof obj.displayName === 'string' && obj.displayName.trim()
|
|
114
|
+
? obj.displayName.trim()
|
|
115
|
+
: typeof obj.name === 'string' && obj.name.trim()
|
|
116
|
+
? obj.name.trim()
|
|
117
|
+
: rawId;
|
|
118
|
+
const stage = typeof obj.stage === 'string' && VALID_STAGES.has(obj.stage)
|
|
119
|
+
? obj.stage
|
|
120
|
+
: 'hygiene';
|
|
121
|
+
const description = typeof obj.description === 'string' ? obj.description.trim() : '';
|
|
122
|
+
const enabled = typeof obj.enabled === 'boolean' ? obj.enabled : true;
|
|
123
|
+
const version = typeof obj.version === 'string' && obj.version.trim() ? obj.version.trim() : undefined;
|
|
124
|
+
return {
|
|
125
|
+
id: rawId,
|
|
126
|
+
name,
|
|
127
|
+
stage,
|
|
128
|
+
kind: 'custom',
|
|
129
|
+
description,
|
|
130
|
+
enabled,
|
|
131
|
+
...(version !== undefined ? { version } : {}),
|
|
132
|
+
...(sourcePath !== undefined ? { sourcePath } : {}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** Parse YAML frontmatter from a `SKILL.md` file into a skill StagePluginDescriptor. */
|
|
136
|
+
export function parseSkillManifest(markdown, fallbackId, sourcePath) {
|
|
137
|
+
const cleanFallback = fallbackId.trim();
|
|
138
|
+
const slug = cleanFallback.startsWith('skill:') ? cleanFallback.slice('skill:'.length).trim() : cleanFallback;
|
|
139
|
+
if (!isValidPluginId(slug))
|
|
140
|
+
return null;
|
|
141
|
+
const fmMatch = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(markdown);
|
|
142
|
+
let name = slug;
|
|
143
|
+
let description = '';
|
|
144
|
+
if (fmMatch && fmMatch[1]) {
|
|
145
|
+
for (const rawLine of fmMatch[1].split(/\r?\n/)) {
|
|
146
|
+
const sep = rawLine.indexOf(':');
|
|
147
|
+
if (sep <= 0)
|
|
148
|
+
continue;
|
|
149
|
+
const key = rawLine.slice(0, sep).trim().toLowerCase();
|
|
150
|
+
let val = rawLine.slice(sep + 1).trim();
|
|
151
|
+
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
|
|
152
|
+
val = val.slice(1, -1);
|
|
153
|
+
}
|
|
154
|
+
if (key === 'name' && val)
|
|
155
|
+
name = val;
|
|
156
|
+
else if (key === 'description' && val)
|
|
157
|
+
description = val;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const idBase = `skill:${slug}`;
|
|
161
|
+
return {
|
|
162
|
+
id: idBase,
|
|
163
|
+
name,
|
|
164
|
+
stage: 'skill',
|
|
165
|
+
kind: 'skill',
|
|
166
|
+
description,
|
|
167
|
+
enabled: true,
|
|
168
|
+
...(sourcePath !== undefined ? { sourcePath } : {}),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** Merge built-in stages with discovered custom plugins/skills and persisted overrides. */
|
|
172
|
+
export function mergeStagePlugins(discovered, overrides = {}) {
|
|
173
|
+
const byId = new Map();
|
|
174
|
+
for (const builtin of BUILTIN_STAGE_PLUGINS) {
|
|
175
|
+
const enabled = Object.hasOwn(overrides, builtin.id) && typeof overrides[builtin.id] === 'boolean'
|
|
176
|
+
? overrides[builtin.id]
|
|
177
|
+
: builtin.enabled;
|
|
178
|
+
byId.set(builtin.id, { ...builtin, enabled });
|
|
179
|
+
}
|
|
180
|
+
for (const item of discovered) {
|
|
181
|
+
// Built-in stage IDs stay authoritative so third-party manifests cannot shadow core stages.
|
|
182
|
+
if (byId.has(item.id))
|
|
183
|
+
continue;
|
|
184
|
+
const enabled = Object.hasOwn(overrides, item.id) && typeof overrides[item.id] === 'boolean'
|
|
185
|
+
? overrides[item.id]
|
|
186
|
+
: item.enabled;
|
|
187
|
+
byId.set(item.id, { ...item, enabled });
|
|
188
|
+
}
|
|
189
|
+
return [...byId.values()];
|
|
190
|
+
}
|
|
191
|
+
/** Derive active pipeline stage toggles from persisted plugin overrides (`plugins.json`). */
|
|
192
|
+
export function stageTogglesFromOverrides(overrides = {}) {
|
|
193
|
+
const flag = (id) => !(Object.hasOwn(overrides, id) && overrides[id] === false);
|
|
194
|
+
return {
|
|
195
|
+
optical: flag('optical-microfiche'),
|
|
196
|
+
tscg: flag('tscg-schema'),
|
|
197
|
+
toon: flag('toon-structured'),
|
|
198
|
+
acdc: flag('acdc-epochs'),
|
|
199
|
+
casi: flag('casi-delta'),
|
|
200
|
+
lsm: flag('lsm-context'),
|
|
201
|
+
mmu: flag('context-mmu'),
|
|
202
|
+
skillLinker: flag('skill-linker'),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=stage-plugins.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ACDC: Append-Only Frozen-Epoch Extractive History Compactor for Text-Only Models.
|
|
3
|
+
*
|
|
4
|
+
* Grounded in:
|
|
5
|
+
* - "Context Has a Price" (Yang et al., Nov 2026) & CAPC (July 2026):
|
|
6
|
+
* mutating recent/live turns causes re-search loops or breaks prefix caches.
|
|
7
|
+
* - "The Complexity Trap" (2025/2026) & SWE-Pruner (Jan 2026): deterministic
|
|
8
|
+
* structural skeleton + outcome extraction over *aged* completed epochs
|
|
9
|
+
* matches heavy LLM summarization at zero inference cost.
|
|
10
|
+
*
|
|
11
|
+
* Strictly groups aged blocks behind `keepTailMessages` into fixed frozen
|
|
12
|
+
* epochs (`>= epochTokenTarget` tokens). Trailing unsealed blocks are untouched
|
|
13
|
+
* until full, so sealed epochs stay bit-identical across subsequent turns.
|
|
14
|
+
* Every epoch passes a kosha cache-payback or cliff-avoidance gate.
|
|
15
|
+
*
|
|
16
|
+
* Workers-safe: zero `node:` imports.
|
|
17
|
+
*/
|
|
18
|
+
export interface CacheBreakpointMarker {
|
|
19
|
+
/** Message index in `messages`, or `-1` for tools/system. */
|
|
20
|
+
readonly msgIndex: number;
|
|
21
|
+
/** Block index within `messages[msgIndex].content`, or `Number.MAX_SAFE_INTEGER` for message-level. */
|
|
22
|
+
readonly blockIndex: number;
|
|
23
|
+
/** Cache TTL in seconds (`3600` for `1h`, `300` for `5m`). */
|
|
24
|
+
readonly ttlSec: number;
|
|
25
|
+
}
|
|
26
|
+
export interface TextEpochBlock {
|
|
27
|
+
readonly msgIndex: number;
|
|
28
|
+
readonly blockIndex?: number;
|
|
29
|
+
readonly refId: string;
|
|
30
|
+
readonly toolName?: string;
|
|
31
|
+
readonly getText: () => string;
|
|
32
|
+
readonly setText: (next: string) => void;
|
|
33
|
+
}
|
|
34
|
+
export interface TextEpochPlanArgs {
|
|
35
|
+
readonly blocks: readonly TextEpochBlock[];
|
|
36
|
+
readonly totalMessages: number;
|
|
37
|
+
readonly model?: string;
|
|
38
|
+
readonly totalPromptTokens: number;
|
|
39
|
+
readonly expectedOutputTokens?: number;
|
|
40
|
+
readonly ttlSec?: number;
|
|
41
|
+
readonly msgTotalTokens?: readonly number[];
|
|
42
|
+
readonly cacheBreakpoints?: readonly CacheBreakpointMarker[];
|
|
43
|
+
readonly keepTailMessages?: number;
|
|
44
|
+
readonly epochTokenTarget?: number;
|
|
45
|
+
readonly maxPaybackReads?: number;
|
|
46
|
+
readonly sessionKey?: string;
|
|
47
|
+
readonly sessionCacheCold?: boolean;
|
|
48
|
+
readonly enableLsm?: boolean;
|
|
49
|
+
readonly lsmEditTailMessages?: number;
|
|
50
|
+
readonly lsmMinLargeBlockTokens?: number;
|
|
51
|
+
/** When true, only replay already-sealed sticky epochs without sealing new candidates. */
|
|
52
|
+
readonly stickyOnly?: boolean;
|
|
53
|
+
readonly onPageOut?: (block: TextEpochBlock, raw: string, digest: string) => string | undefined;
|
|
54
|
+
}
|
|
55
|
+
export interface TextEpochPlanResult {
|
|
56
|
+
readonly changed: boolean;
|
|
57
|
+
readonly sealedEpochs: number;
|
|
58
|
+
readonly compactedBlocks: number;
|
|
59
|
+
readonly savedChars: number;
|
|
60
|
+
readonly savedTokens: number;
|
|
61
|
+
readonly cliffAvoided?: {
|
|
62
|
+
at: number;
|
|
63
|
+
multiplier: number;
|
|
64
|
+
savedUsd: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Test seam: drop in-memory sticky epoch caches (e.g. to verify restart recovery via session-state). */
|
|
68
|
+
export declare function resetTextEpochStickyState(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Deterministic extractive structural digest for aged tool outputs.
|
|
71
|
+
*/
|
|
72
|
+
export declare function extractStructuralDigest(text: string, refId?: string): string;
|
|
73
|
+
export declare function planAndApplyTextEpochs(args: TextEpochPlanArgs): TextEpochPlanResult;
|
|
74
|
+
//# sourceMappingURL=text-history.d.ts.map
|