@sriinnu/fiche 0.0.0-stage → 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 +288 -2
- 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 +122 -4
- 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,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal, prefix-cache-safe deterministic hygiene for tool/observation text.
|
|
3
|
+
*
|
|
4
|
+
* Grounded in multi-turn coding-agent caching findings:
|
|
5
|
+
* - CoACT (2026): action-preserving deterministic compression of tool outputs
|
|
6
|
+
* compounds quadratically across turns without breaking agent edits.
|
|
7
|
+
* - Prefix caching under 0.05x–0.1x reads ("Context Has a Price", 2026):
|
|
8
|
+
* removing or changing past observations mid-prefix busts caches, whereas a
|
|
9
|
+
* pure deterministic function `f(block)` applied consistently when each tool
|
|
10
|
+
* output enters the transcript produces byte-identical prefixes across turns
|
|
11
|
+
* while shrinking every cache write and subsequent cache read.
|
|
12
|
+
*
|
|
13
|
+
* Works across ALL providers and models — including text-only and weak-vision
|
|
14
|
+
* models (Claude 5.5, DeepSeek, Kimi, GLM, MiniMax, Qwen, Grok) where inkling
|
|
15
|
+
* refuses image rendering.
|
|
16
|
+
*
|
|
17
|
+
* Workers-safe: zero `node:` imports.
|
|
18
|
+
*/
|
|
19
|
+
import { isFileReadToolName } from './context-mmu.js';
|
|
20
|
+
import { type CacheBreakpointMarker } from './text-history.js';
|
|
21
|
+
export { isFileReadToolName };
|
|
22
|
+
export type TextHygieneMode = 'auto' | 'on' | 'off';
|
|
23
|
+
export interface TextHygieneOptions {
|
|
24
|
+
/** Tool name associated with a single-block cleanToolOutput call (used for editSafe file-read protection). */
|
|
25
|
+
toolName?: string;
|
|
26
|
+
/** Whether to run Stage 1 TSCG static/schema compilation when `deepTextCompact` is enabled (default true). */
|
|
27
|
+
enableTscg?: boolean;
|
|
28
|
+
/** Whether to run Stage 2 TOON encoding on tabular JSON (default true). */
|
|
29
|
+
enableToon?: boolean;
|
|
30
|
+
/** Whether to run Stage 3 ACDC frozen-epoch history compaction when `deepTextCompact` is enabled (default true). */
|
|
31
|
+
enableAcdc?: boolean;
|
|
32
|
+
/** Whether to run Stage 3 Drain structural log folding (default true). */
|
|
33
|
+
foldLogs?: boolean;
|
|
34
|
+
/** Whether to run Stage 2 single-level JSON-in-JSON unwrapping (default true). */
|
|
35
|
+
enableJsonUnwrap?: boolean;
|
|
36
|
+
/** Whether to run P3 birth-time IDF density pruning on unstructured prose (default true). */
|
|
37
|
+
enableDensityPrune?: boolean;
|
|
38
|
+
/** Enable TSCG static/schema compilation + ACDC frozen-epoch history compaction. */
|
|
39
|
+
deepTextCompact?: boolean;
|
|
40
|
+
/** Whether to run Stage 5 CASI cross-turn deduplication/delta compression (default true). */
|
|
41
|
+
enableCasi?: boolean;
|
|
42
|
+
/** Also TOON-encode single-line tabular JSON when `INKLING_TEXT_HYGIENE=on`. */
|
|
43
|
+
aggressiveToon?: boolean;
|
|
44
|
+
/** Target model id for kosha payback/cliff math in ACDC. */
|
|
45
|
+
model?: string;
|
|
46
|
+
/** Expected output tokens for kosha cliff avoidance evaluation. */
|
|
47
|
+
expectedOutputTokens?: number;
|
|
48
|
+
/** Raw request body byte length (avoids redundant full-body JSON.stringify). */
|
|
49
|
+
rawBodyBytes?: number;
|
|
50
|
+
/** Native inline/base64 image payload bytes excluded from ACDC token estimates. */
|
|
51
|
+
nativeImageBytes?: number;
|
|
52
|
+
/** Live-tail cutoff message index when optical history collapse follows text hygiene. */
|
|
53
|
+
opticalCollapseCutoffMsg?: number;
|
|
54
|
+
/** Explicit prompt cache TTL (seconds) for cache-aware ACDC payback math. */
|
|
55
|
+
ttlSec?: number;
|
|
56
|
+
/** Opt-in Stage 2 cleaning on bulky user payloads (>=1500 chars, non-code/diff, XML-safe). Default false. */
|
|
57
|
+
cleanUserPayloads?: boolean;
|
|
58
|
+
/** Optional session key pass-through for P2/P3 state integration. */
|
|
59
|
+
sessionKey?: string;
|
|
60
|
+
/** Optional first user turn text pass-through for P2/P3 state integration. */
|
|
61
|
+
firstUserText?: string;
|
|
62
|
+
/** Optional live-tail texts pass-through for P2/P3 state integration. */
|
|
63
|
+
liveTailTexts?: readonly string[];
|
|
64
|
+
/** Optional cold-cache indicator pass-through for P2/P3 state integration. */
|
|
65
|
+
sessionCacheCold?: boolean;
|
|
66
|
+
/** Optional LSM pass-through toggle for P2/P3 integration. */
|
|
67
|
+
enableLsm?: boolean;
|
|
68
|
+
/** Optional LSM edit-tail threshold pass-through for P2/P3 integration. */
|
|
69
|
+
lsmEditTailMessages?: number;
|
|
70
|
+
/** Optional MMU pass-through toggle for P2/P3 integration. */
|
|
71
|
+
enableMmu?: boolean;
|
|
72
|
+
/** Optional skill-linker pass-through toggle for P2/P3 integration. */
|
|
73
|
+
enableSkillLinker?: boolean;
|
|
74
|
+
/** Optional tail hydration callback for P2/P3 integration. */
|
|
75
|
+
appendTailHydration?: (hydrationBlock: string) => void;
|
|
76
|
+
/** Internal slot refId hint for Context-MMU density pruning page attribution. */
|
|
77
|
+
refId?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface TextHygieneResult {
|
|
80
|
+
readonly text: string;
|
|
81
|
+
readonly changed: boolean;
|
|
82
|
+
readonly savedChars: number;
|
|
83
|
+
readonly savedTokens: number;
|
|
84
|
+
readonly stages: readonly string[];
|
|
85
|
+
}
|
|
86
|
+
export interface WireHygieneStats {
|
|
87
|
+
readonly changed: boolean;
|
|
88
|
+
readonly tailHydrated?: boolean;
|
|
89
|
+
readonly savedChars: number;
|
|
90
|
+
readonly savedTokens: number;
|
|
91
|
+
readonly blocks: number;
|
|
92
|
+
readonly stages: readonly string[];
|
|
93
|
+
readonly cliffAvoided?: {
|
|
94
|
+
at: number;
|
|
95
|
+
multiplier: number;
|
|
96
|
+
savedUsd: number;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Resolve text-hygiene activation mode from call options and `INKLING_TEXT_HYGIENE`.
|
|
101
|
+
* - Explicit option/env `on`/`true` activates even when `INKLING_MODELS=off`.
|
|
102
|
+
* - Explicit option/env `off`/`false` disables completely.
|
|
103
|
+
* - `auto` (default) is active whenever `INKLING_MODELS` has any model enabled.
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolveTextHygieneMode(opt?: boolean | TextHygieneMode): TextHygieneMode;
|
|
106
|
+
export declare function isTextHygieneActive(opt?: boolean | TextHygieneMode): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Edit/Action-Preservation Safety Guard:
|
|
109
|
+
* Protects source-code file reads, unified diffs, and code-fence-heavy outputs so
|
|
110
|
+
* Edit / apply_patch exact string matching never loses whitespace or repeated lines.
|
|
111
|
+
* Strips ANSI escapes first so colored git diffs, bat, and ripgrep stay protected.
|
|
112
|
+
*/
|
|
113
|
+
export declare function isCodeOrDiffProtected(text: string): boolean;
|
|
114
|
+
export declare function unwrapNestedJsonStrings(text: string, opts?: {
|
|
115
|
+
enableToon?: boolean;
|
|
116
|
+
foldLogs?: boolean;
|
|
117
|
+
toolName?: string;
|
|
118
|
+
}): {
|
|
119
|
+
text: string;
|
|
120
|
+
stage: 'json_unwrap' | 'toon';
|
|
121
|
+
} | null;
|
|
122
|
+
/**
|
|
123
|
+
* Clean a single tool-output / observation string deterministically.
|
|
124
|
+
* Guaranteed pure function `f(text)` → identical output on every turn.
|
|
125
|
+
*/
|
|
126
|
+
export declare function cleanToolOutput(text: string, opts?: TextHygieneOptions): TextHygieneResult;
|
|
127
|
+
export declare function estimateMessageTokens(rawMsg: unknown): number;
|
|
128
|
+
export declare function markerTtlSeconds(cc: unknown): number | undefined;
|
|
129
|
+
export declare function coveringBreakpointInfo(msgIndex: number, blockIndex: number, cacheBreakpoints: readonly CacheBreakpointMarker[] | undefined, msgTotalTokens: readonly number[] | undefined, totalMessages: number): {
|
|
130
|
+
coveringTtlSec: number;
|
|
131
|
+
downstreamTokens: number;
|
|
132
|
+
};
|
|
133
|
+
/** Deterministic session seal key protecting optically rendered Responses tool outputs from re-mutation. */
|
|
134
|
+
export declare function buildOpticalToolSealKey(refId: string, rawText: string): string;
|
|
135
|
+
/** Clean Anthropic `messages[].content[].type==='tool_result'` (+ TSCG/CASI/ACDC when enabled) in place. */
|
|
136
|
+
export declare function applyAnthropicTextHygiene(req: {
|
|
137
|
+
system?: unknown;
|
|
138
|
+
tools?: unknown[];
|
|
139
|
+
messages?: unknown[];
|
|
140
|
+
}, opts?: TextHygieneOptions): WireHygieneStats;
|
|
141
|
+
/** Clean OpenAI Chat Completions `role==='tool'` (+ TSCG/CASI/ACDC when enabled) in place. */
|
|
142
|
+
export declare function applyOpenAIChatTextHygiene(req: {
|
|
143
|
+
tools?: unknown[];
|
|
144
|
+
messages?: unknown[];
|
|
145
|
+
}, opts?: TextHygieneOptions): WireHygieneStats;
|
|
146
|
+
/** Clean OpenAI Responses `function_call_output` / `custom_tool_call_output` (+ TSCG/CASI/ACDC when enabled) in place. */
|
|
147
|
+
export declare function applyOpenAIResponsesTextHygiene(req: {
|
|
148
|
+
instructions?: unknown;
|
|
149
|
+
tools?: unknown[];
|
|
150
|
+
input?: unknown;
|
|
151
|
+
}, opts?: TextHygieneOptions): WireHygieneStats;
|
|
152
|
+
/** Clean Google / Antigravity `functionResponse.response` & `.parts` (+ TSCG/CASI/ACDC when enabled) in place. */
|
|
153
|
+
export declare function applyGoogleTextHygiene(req: {
|
|
154
|
+
systemInstruction?: {
|
|
155
|
+
parts?: unknown[];
|
|
156
|
+
};
|
|
157
|
+
tools?: unknown[];
|
|
158
|
+
contents?: unknown[];
|
|
159
|
+
}, opts?: TextHygieneOptions): WireHygieneStats;
|
|
160
|
+
//# sourceMappingURL=text-hygiene.d.ts.map
|