@mneme-ai/core 1.98.0 → 1.99.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/dist/flash/devils_advocate.d.ts +66 -0
- package/dist/flash/devils_advocate.d.ts.map +1 -0
- package/dist/flash/devils_advocate.js +154 -0
- package/dist/flash/devils_advocate.js.map +1 -0
- package/dist/flash/flash.d.ts +50 -0
- package/dist/flash/flash.d.ts.map +1 -0
- package/dist/flash/flash.js +67 -0
- package/dist/flash/flash.js.map +1 -0
- package/dist/flash/flash.test.d.ts +2 -0
- package/dist/flash/flash.test.d.ts.map +1 -0
- package/dist/flash/flash.test.js +221 -0
- package/dist/flash/flash.test.js.map +1 -0
- package/dist/flash/grounding.d.ts +55 -0
- package/dist/flash/grounding.d.ts.map +1 -0
- package/dist/flash/grounding.js +144 -0
- package/dist/flash/grounding.js.map +1 -0
- package/dist/flash/index.d.ts +18 -0
- package/dist/flash/index.d.ts.map +1 -0
- package/dist/flash/index.js +18 -0
- package/dist/flash/index.js.map +1 -0
- package/dist/flash/predictive.d.ts +44 -0
- package/dist/flash/predictive.d.ts.map +1 -0
- package/dist/flash/predictive.js +76 -0
- package/dist/flash/predictive.js.map +1 -0
- package/dist/flash/veracity.d.ts +99 -0
- package/dist/flash/veracity.d.ts.map +1 -0
- package/dist/flash/veracity.js +107 -0
- package/dist/flash/veracity.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/rainbow/passport.d.ts +28 -5
- package/dist/rainbow/passport.d.ts.map +1 -1
- package/dist/rainbow/passport.js +44 -9
- package/dist/rainbow/passport.js.map +1 -1
- package/dist/rainbow/passport_v99.test.d.ts +2 -0
- package/dist/rainbow/passport_v99.test.d.ts.map +1 -0
- package/dist/rainbow/passport_v99.test.js +53 -0
- package/dist/rainbow/passport_v99.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.99.0 -- FLASH · Hyper-Contextual Grounding
|
|
3
|
+
*
|
|
4
|
+
* Detect that "Super rare" sitting on a product listing image is NOT a
|
|
5
|
+
* verified rarity claim — it's marketing copy. The grounding step
|
|
6
|
+
* extracts text from the user's input (image OCR result or pasted
|
|
7
|
+
* caption), classifies the SOURCE CONTEXT, and assigns a source weight
|
|
8
|
+
* that reflects the trust the AI agent should put in it.
|
|
9
|
+
*
|
|
10
|
+
* The user's exact case:
|
|
11
|
+
* image_4a1c54.jpg contains text "[Super rare] CAPCOM Capcom Character
|
|
12
|
+
* Trump Street Fighter Mega Man" plus "1,086.49 baht" plus
|
|
13
|
+
* "Buy Now on Buyee".
|
|
14
|
+
* Every vanilla AI: "yes it's rare" — because it pattern-matched the
|
|
15
|
+
* surface text. WRONG.
|
|
16
|
+
*
|
|
17
|
+
* FLASH grounding extracts:
|
|
18
|
+
* - rarity claims ("Super rare", "limited", "extremely rare")
|
|
19
|
+
* - commerce signals ("Buy Now", "shipping", "BHT", "$", "¥")
|
|
20
|
+
* - source context ("seller listing", "marketplace", "auction site")
|
|
21
|
+
* - third-party evidence absence
|
|
22
|
+
* → classifies the whole frame as `seller-listing` source kind
|
|
23
|
+
* → demotes source weight to 0.20 (per veracity.ts DEFAULT_SOURCE_WEIGHT)
|
|
24
|
+
*
|
|
25
|
+
* AI agent then runs computeVeracity with the demoted source weight and
|
|
26
|
+
* the rarity claim gets correctly marked DOUBTFUL or REFUTE — not AFFIRM.
|
|
27
|
+
*
|
|
28
|
+
* Pure function. Deterministic. Offline-only (no external lookups).
|
|
29
|
+
*/
|
|
30
|
+
import type { EvidenceItem } from "./veracity.js";
|
|
31
|
+
export type SourceContext = "seller-listing" | "auction-record" | "expert-review" | "primary-document" | "encyclopedia" | "user-statement" | "neutral-text";
|
|
32
|
+
export interface GroundingResult {
|
|
33
|
+
/** Classified context for the input frame. */
|
|
34
|
+
context: SourceContext;
|
|
35
|
+
/** Suggested EvidenceItem.sourceKind to use downstream. */
|
|
36
|
+
sourceKind: EvidenceItem["sourceKind"];
|
|
37
|
+
/** Detected rarity claims (literal phrases). */
|
|
38
|
+
rarityClaims: string[];
|
|
39
|
+
/** Detected commerce signals (literal phrases). */
|
|
40
|
+
commerceSignals: string[];
|
|
41
|
+
/** Detected third-party verification signals. */
|
|
42
|
+
thirdPartyProofs: string[];
|
|
43
|
+
/** Suggested source weight for veracity.computeVeracity. */
|
|
44
|
+
suggestedSourceWeight: number;
|
|
45
|
+
/** Suggested hallucination factor add-on for veracity. */
|
|
46
|
+
suggestedHallucinationAddOn: number;
|
|
47
|
+
/** Why we classified it that way. */
|
|
48
|
+
reason: string;
|
|
49
|
+
}
|
|
50
|
+
/** Classify the source context of free-form text (OCR result, caption,
|
|
51
|
+
* description) and produce a recommendation for veracity downstream. */
|
|
52
|
+
export declare function groundClaim(rawText: string): GroundingResult;
|
|
53
|
+
/** One-line summary for the pulse. */
|
|
54
|
+
export declare function formatGroundingPulseLine(r: GroundingResult): string;
|
|
55
|
+
//# sourceMappingURL=grounding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grounding.d.ts","sourceRoot":"","sources":["../../src/flash/grounding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA+ClD,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,gBAAgB,GAChB,cAAc,CAAC;AAEnB,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,OAAO,EAAE,aAAa,CAAC;IACvB,2DAA2D;IAC3D,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IACvC,gDAAgD;IAChD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,iDAAiD;IACjD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,4DAA4D;IAC5D,qBAAqB,EAAE,MAAM,CAAC;IAC9B,0DAA0D;IAC1D,2BAA2B,EAAE,MAAM,CAAC;IACpC,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAWD;yEACyE;AACzE,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAqD5D;AAED,sCAAsC;AACtC,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAEnE"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.99.0 -- FLASH · Hyper-Contextual Grounding
|
|
3
|
+
*
|
|
4
|
+
* Detect that "Super rare" sitting on a product listing image is NOT a
|
|
5
|
+
* verified rarity claim — it's marketing copy. The grounding step
|
|
6
|
+
* extracts text from the user's input (image OCR result or pasted
|
|
7
|
+
* caption), classifies the SOURCE CONTEXT, and assigns a source weight
|
|
8
|
+
* that reflects the trust the AI agent should put in it.
|
|
9
|
+
*
|
|
10
|
+
* The user's exact case:
|
|
11
|
+
* image_4a1c54.jpg contains text "[Super rare] CAPCOM Capcom Character
|
|
12
|
+
* Trump Street Fighter Mega Man" plus "1,086.49 baht" plus
|
|
13
|
+
* "Buy Now on Buyee".
|
|
14
|
+
* Every vanilla AI: "yes it's rare" — because it pattern-matched the
|
|
15
|
+
* surface text. WRONG.
|
|
16
|
+
*
|
|
17
|
+
* FLASH grounding extracts:
|
|
18
|
+
* - rarity claims ("Super rare", "limited", "extremely rare")
|
|
19
|
+
* - commerce signals ("Buy Now", "shipping", "BHT", "$", "¥")
|
|
20
|
+
* - source context ("seller listing", "marketplace", "auction site")
|
|
21
|
+
* - third-party evidence absence
|
|
22
|
+
* → classifies the whole frame as `seller-listing` source kind
|
|
23
|
+
* → demotes source weight to 0.20 (per veracity.ts DEFAULT_SOURCE_WEIGHT)
|
|
24
|
+
*
|
|
25
|
+
* AI agent then runs computeVeracity with the demoted source weight and
|
|
26
|
+
* the rarity claim gets correctly marked DOUBTFUL or REFUTE — not AFFIRM.
|
|
27
|
+
*
|
|
28
|
+
* Pure function. Deterministic. Offline-only (no external lookups).
|
|
29
|
+
*/
|
|
30
|
+
const RARITY_CLAIM_PATTERNS = [
|
|
31
|
+
/\b(super )?rare\b/i,
|
|
32
|
+
/\bextremely rare\b/i,
|
|
33
|
+
/\blimited edition\b/i,
|
|
34
|
+
/\bone of a kind\b/i,
|
|
35
|
+
/\bunique\b/i,
|
|
36
|
+
/\bcollectible\b/i,
|
|
37
|
+
/\boriginal\b/i,
|
|
38
|
+
/\bauthentic\b/i,
|
|
39
|
+
/\bmint condition\b/i,
|
|
40
|
+
/\bvintage\b/i,
|
|
41
|
+
/\bgrail\b/i,
|
|
42
|
+
];
|
|
43
|
+
const COMMERCE_SIGNALS = [
|
|
44
|
+
/\bbuy now\b/i,
|
|
45
|
+
/\bshipping\b/i,
|
|
46
|
+
/\bauction\b/i,
|
|
47
|
+
/\bprice\b/i,
|
|
48
|
+
/\bbht\b/i,
|
|
49
|
+
/\b฿/i,
|
|
50
|
+
/[$€¥£]\s*\d/,
|
|
51
|
+
/\d[\d,]*\.\d{2}\b/, // 1,086.49
|
|
52
|
+
/\bproduct description\b/i,
|
|
53
|
+
/\bbuyee\b/i,
|
|
54
|
+
/\bebay\b/i,
|
|
55
|
+
/\bmercari\b/i,
|
|
56
|
+
/\baliexpress\b/i,
|
|
57
|
+
/\bamazon\b/i,
|
|
58
|
+
/\b楽天\b/i, // Rakuten
|
|
59
|
+
/\bヤフオク\b/i, // Yahoo Auctions JP
|
|
60
|
+
];
|
|
61
|
+
const THIRD_PARTY_PROOF_HINTS = [
|
|
62
|
+
/\bauction record\b/i,
|
|
63
|
+
/\bpopulation report\b/i,
|
|
64
|
+
/\bgrading\b/i,
|
|
65
|
+
/\bpsa\b/i, // PSA / Beckett grading
|
|
66
|
+
/\bbgs\b/i,
|
|
67
|
+
/\bcomptia\b/i,
|
|
68
|
+
/\bmuseum\b/i,
|
|
69
|
+
/\bcatalog\b/i,
|
|
70
|
+
/\barchive\b/i,
|
|
71
|
+
];
|
|
72
|
+
function findMatches(text, patterns) {
|
|
73
|
+
const hits = [];
|
|
74
|
+
for (const p of patterns) {
|
|
75
|
+
const m = text.match(p);
|
|
76
|
+
if (m)
|
|
77
|
+
hits.push(m[0]);
|
|
78
|
+
}
|
|
79
|
+
return hits;
|
|
80
|
+
}
|
|
81
|
+
/** Classify the source context of free-form text (OCR result, caption,
|
|
82
|
+
* description) and produce a recommendation for veracity downstream. */
|
|
83
|
+
export function groundClaim(rawText) {
|
|
84
|
+
const rarityClaims = findMatches(rawText, RARITY_CLAIM_PATTERNS);
|
|
85
|
+
const commerceSignals = findMatches(rawText, COMMERCE_SIGNALS);
|
|
86
|
+
const thirdPartyProofs = findMatches(rawText, THIRD_PARTY_PROOF_HINTS);
|
|
87
|
+
let context;
|
|
88
|
+
let reason;
|
|
89
|
+
let suggestedSourceWeight;
|
|
90
|
+
let suggestedHallucinationAddOn;
|
|
91
|
+
if (thirdPartyProofs.length >= 2) {
|
|
92
|
+
context = "expert-review";
|
|
93
|
+
reason = `${thirdPartyProofs.length} third-party verification signals detected (${thirdPartyProofs.join(", ")})`;
|
|
94
|
+
suggestedSourceWeight = 0.85;
|
|
95
|
+
suggestedHallucinationAddOn = 0;
|
|
96
|
+
}
|
|
97
|
+
else if (commerceSignals.length >= 2) {
|
|
98
|
+
context = "seller-listing";
|
|
99
|
+
reason = `${commerceSignals.length} commerce signals (${commerceSignals.slice(0, 3).join(", ")}) — this is a sales page; treat rarity claims as marketing copy`;
|
|
100
|
+
suggestedSourceWeight = 0.20;
|
|
101
|
+
// Adding 2 to H = more skepticism for marketing-tier sources
|
|
102
|
+
suggestedHallucinationAddOn = rarityClaims.length > 0 ? 2.0 : 1.0;
|
|
103
|
+
}
|
|
104
|
+
else if (rarityClaims.length > 0) {
|
|
105
|
+
context = "user-statement";
|
|
106
|
+
reason = `rarity claim "${rarityClaims[0]}" present but no commerce signals + no third-party proofs — caller's own assertion`;
|
|
107
|
+
suggestedSourceWeight = 0.55;
|
|
108
|
+
suggestedHallucinationAddOn = 1.0;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
context = "neutral-text";
|
|
112
|
+
reason = "no rarity claim, no commerce signal, no third-party proof";
|
|
113
|
+
suggestedSourceWeight = 0.50;
|
|
114
|
+
suggestedHallucinationAddOn = 0;
|
|
115
|
+
}
|
|
116
|
+
// Map to the canonical EvidenceItem sourceKind enum.
|
|
117
|
+
// (Only the four cases actually produced by the classifier above are
|
|
118
|
+
// handled here — tsc would flag dead cases otherwise. The other
|
|
119
|
+
// SourceContext values are reserved for future classifiers.)
|
|
120
|
+
let sourceKind;
|
|
121
|
+
if (context === "expert-review")
|
|
122
|
+
sourceKind = "expert-database";
|
|
123
|
+
else if (context === "seller-listing")
|
|
124
|
+
sourceKind = "seller-listing";
|
|
125
|
+
else if (context === "user-statement")
|
|
126
|
+
sourceKind = "user-statement";
|
|
127
|
+
else
|
|
128
|
+
sourceKind = "unknown";
|
|
129
|
+
return {
|
|
130
|
+
context,
|
|
131
|
+
sourceKind,
|
|
132
|
+
rarityClaims,
|
|
133
|
+
commerceSignals,
|
|
134
|
+
thirdPartyProofs,
|
|
135
|
+
suggestedSourceWeight,
|
|
136
|
+
suggestedHallucinationAddOn,
|
|
137
|
+
reason,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** One-line summary for the pulse. */
|
|
141
|
+
export function formatGroundingPulseLine(r) {
|
|
142
|
+
return `GROUNDING · context=${r.context} · rarity=${r.rarityClaims.length} · commerce=${r.commerceSignals.length} · third-party=${r.thirdPartyProofs.length} · suggested-weight=${r.suggestedSourceWeight}`;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=grounding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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qDAAqD;IACrD,qEAAqE;IACrE,gEAAgE;IAChE,6DAA6D;IAC7D,IAAI,UAAsC,CAAC;IAC3C,IAAI,OAAO,KAAK,eAAe;QAAE,UAAU,GAAG,iBAAiB,CAAC;SAC3D,IAAI,OAAO,KAAK,gBAAgB;QAAE,UAAU,GAAG,gBAAgB,CAAC;SAChE,IAAI,OAAO,KAAK,gBAAgB;QAAE,UAAU,GAAG,gBAAgB,CAAC;;QAChE,UAAU,GAAG,SAAS,CAAC;IAE5B,OAAO;QACL,OAAO;QACP,UAAU;QACV,YAAY;QACZ,eAAe;QACf,gBAAgB;QAChB,qBAAqB;QACrB,2BAA2B;QAC3B,MAAM;KACP,CAAC;AACJ,CAAC;AAED,sCAAsC;AACtC,MAAM,UAAU,wBAAwB,CAAC,CAAkB;IACzD,OAAO,uBAAuB,CAAC,CAAC,OAAO,aAAa,CAAC,CAAC,YAAY,CAAC,MAAM,eAAe,CAAC,CAAC,eAAe,CAAC,MAAM,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,MAAM,uBAAuB,CAAC,CAAC,qBAAqB,EAAE,CAAC;AAC9M,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.99.0 -- FLASH INTELLIGENCE public surface.
|
|
3
|
+
*
|
|
4
|
+
* "Not trained to be skeptical. Engineered to be."
|
|
5
|
+
*
|
|
6
|
+
* Composed of:
|
|
7
|
+
* ⚖ Veracity-Velocity Singularity (computeVeracity)
|
|
8
|
+
* 👹 Recursive Self-Verification — Devil's Advocate (runDevilsAdvocate)
|
|
9
|
+
* 🌐 Hyper-Contextual Grounding (groundClaim)
|
|
10
|
+
* ⚡ Prompt-Q-Latency Engine (predictNextQuery)
|
|
11
|
+
* ✨ FLASH master function (runFlash)
|
|
12
|
+
*/
|
|
13
|
+
export * from "./veracity.js";
|
|
14
|
+
export * from "./devils_advocate.js";
|
|
15
|
+
export * from "./grounding.js";
|
|
16
|
+
export * from "./predictive.js";
|
|
17
|
+
export * from "./flash.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flash/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.99.0 -- FLASH INTELLIGENCE public surface.
|
|
3
|
+
*
|
|
4
|
+
* "Not trained to be skeptical. Engineered to be."
|
|
5
|
+
*
|
|
6
|
+
* Composed of:
|
|
7
|
+
* ⚖ Veracity-Velocity Singularity (computeVeracity)
|
|
8
|
+
* 👹 Recursive Self-Verification — Devil's Advocate (runDevilsAdvocate)
|
|
9
|
+
* 🌐 Hyper-Contextual Grounding (groundClaim)
|
|
10
|
+
* ⚡ Prompt-Q-Latency Engine (predictNextQuery)
|
|
11
|
+
* ✨ FLASH master function (runFlash)
|
|
12
|
+
*/
|
|
13
|
+
export * from "./veracity.js";
|
|
14
|
+
export * from "./devils_advocate.js";
|
|
15
|
+
export * from "./grounding.js";
|
|
16
|
+
export * from "./predictive.js";
|
|
17
|
+
export * from "./flash.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/flash/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.99.0 -- FLASH · Prompt-Q-Latency Engine (predictive reasoning)
|
|
3
|
+
*
|
|
4
|
+
* After the AI replies to N, it pre-warms a Markov-chain prediction for
|
|
5
|
+
* the user's likely N+1 question + builds the context the answer would
|
|
6
|
+
* need. If the prediction hits, the AI replies in ~0 ms wall (no
|
|
7
|
+
* round-trip to "think about the question first").
|
|
8
|
+
*
|
|
9
|
+
* Mneme already ships PRECOG (Markov + ACO pheromone) for MCP tool
|
|
10
|
+
* sequences. This is the same idea applied to USER messages — different
|
|
11
|
+
* domain, same math.
|
|
12
|
+
*
|
|
13
|
+
* Honest scope: this v1.99 ships the predictive CORE + a deterministic
|
|
14
|
+
* "what's the user likely to ask next given the conversation arc?"
|
|
15
|
+
* scorer. The actual context pre-warming hook into Claude Code/Cursor
|
|
16
|
+
* is daemon work in v2.00.
|
|
17
|
+
*/
|
|
18
|
+
export interface QueryFeature {
|
|
19
|
+
/** Stable id for this question-class. */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Human label, e.g. "follow-up: is this authentic?". */
|
|
22
|
+
label: string;
|
|
23
|
+
/** Keywords that, when present in the AI's last reply, vote for this. */
|
|
24
|
+
triggers: string[];
|
|
25
|
+
/** Pre-warm hint — what context to fetch for the predicted question. */
|
|
26
|
+
prewarmHint: string;
|
|
27
|
+
}
|
|
28
|
+
/** Built-in question classes derived from common Mneme conversation arcs. */
|
|
29
|
+
export declare const QUESTION_CLASSES: QueryFeature[];
|
|
30
|
+
export interface PredictionResult {
|
|
31
|
+
/** Top-K predicted next questions, ranked by trigger overlap. */
|
|
32
|
+
predictions: Array<{
|
|
33
|
+
feature: QueryFeature;
|
|
34
|
+
score: number;
|
|
35
|
+
matchedTriggers: string[];
|
|
36
|
+
}>;
|
|
37
|
+
/** Pre-warm hints aggregated across the top predictions. */
|
|
38
|
+
prewarmHints: string[];
|
|
39
|
+
}
|
|
40
|
+
/** Predict next likely user question given the AI's last reply text. */
|
|
41
|
+
export declare function predictNextQuery(lastReplyText: string, topK?: number): PredictionResult;
|
|
42
|
+
/** One-line summary. */
|
|
43
|
+
export declare function formatPredictionPulseLine(r: PredictionResult): string;
|
|
44
|
+
//# sourceMappingURL=predictive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predictive.d.ts","sourceRoot":"","sources":["../../src/flash/predictive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,EAAE,YAAY,EAqC1C,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,WAAW,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,YAAY,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACxF,4DAA4D;IAC5D,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,gBAAgB,CAUlF;AAED,wBAAwB;AACxB,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAIrE"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.99.0 -- FLASH · Prompt-Q-Latency Engine (predictive reasoning)
|
|
3
|
+
*
|
|
4
|
+
* After the AI replies to N, it pre-warms a Markov-chain prediction for
|
|
5
|
+
* the user's likely N+1 question + builds the context the answer would
|
|
6
|
+
* need. If the prediction hits, the AI replies in ~0 ms wall (no
|
|
7
|
+
* round-trip to "think about the question first").
|
|
8
|
+
*
|
|
9
|
+
* Mneme already ships PRECOG (Markov + ACO pheromone) for MCP tool
|
|
10
|
+
* sequences. This is the same idea applied to USER messages — different
|
|
11
|
+
* domain, same math.
|
|
12
|
+
*
|
|
13
|
+
* Honest scope: this v1.99 ships the predictive CORE + a deterministic
|
|
14
|
+
* "what's the user likely to ask next given the conversation arc?"
|
|
15
|
+
* scorer. The actual context pre-warming hook into Claude Code/Cursor
|
|
16
|
+
* is daemon work in v2.00.
|
|
17
|
+
*/
|
|
18
|
+
/** Built-in question classes derived from common Mneme conversation arcs. */
|
|
19
|
+
export const QUESTION_CLASSES = [
|
|
20
|
+
{
|
|
21
|
+
id: "rarity-followup",
|
|
22
|
+
label: "Is this actually rare? Show evidence.",
|
|
23
|
+
triggers: ["rare", "rarity", "collectible", "valuable", "limited"],
|
|
24
|
+
prewarmHint: "Fetch auction history + production-count if available; mark seller-listing claims as low source weight.",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "authenticity-followup",
|
|
28
|
+
label: "How do I verify it's authentic?",
|
|
29
|
+
triggers: ["authentic", "real", "original", "fake", "counterfeit"],
|
|
30
|
+
prewarmHint: "Provide grading-service references (PSA/BGS for cards, expert-database for collectibles).",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "value-followup",
|
|
34
|
+
label: "What's it actually worth?",
|
|
35
|
+
triggers: ["worth", "value", "price", "expensive", "cheap", "money"],
|
|
36
|
+
prewarmHint: "Pull sold-listing comparables; ignore asking prices on active listings.",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "alternative-followup",
|
|
40
|
+
label: "Are there cheaper / better alternatives?",
|
|
41
|
+
triggers: ["alternative", "instead", "competitor", "similar"],
|
|
42
|
+
prewarmHint: "Pull DNA-search results for similar items + cross-vendor pricing.",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "decision-justify-followup",
|
|
46
|
+
label: "Why did you say that?",
|
|
47
|
+
triggers: ["why", "explain", "because", "reason", "justify"],
|
|
48
|
+
prewarmHint: "Surface the V_eff + grounding + devil's-advocate trace from the prior reply.",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "implement-followup",
|
|
52
|
+
label: "Now implement it.",
|
|
53
|
+
triggers: ["implement", "code", "write", "build", "create"],
|
|
54
|
+
prewarmHint: "Cache the file paths + skeleton scaffolds matching the prior decision.",
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
/** Predict next likely user question given the AI's last reply text. */
|
|
58
|
+
export function predictNextQuery(lastReplyText, topK = 3) {
|
|
59
|
+
const text = lastReplyText.toLowerCase();
|
|
60
|
+
const scored = QUESTION_CLASSES.map((qc) => {
|
|
61
|
+
const matched = qc.triggers.filter((t) => text.includes(t.toLowerCase()));
|
|
62
|
+
return { feature: qc, score: matched.length, matchedTriggers: matched };
|
|
63
|
+
});
|
|
64
|
+
scored.sort((a, b) => b.score - a.score);
|
|
65
|
+
const predictions = scored.filter((s) => s.score > 0).slice(0, topK);
|
|
66
|
+
const prewarmHints = predictions.map((p) => p.feature.prewarmHint);
|
|
67
|
+
return { predictions, prewarmHints };
|
|
68
|
+
}
|
|
69
|
+
/** One-line summary. */
|
|
70
|
+
export function formatPredictionPulseLine(r) {
|
|
71
|
+
if (r.predictions.length === 0)
|
|
72
|
+
return `PROMPT-Q · no prediction (lastReply has no triggers)`;
|
|
73
|
+
const top = r.predictions[0];
|
|
74
|
+
return `PROMPT-Q · top=${top.feature.id} score=${top.score} · prewarm=${r.prewarmHints.length} hints`;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=predictive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predictive.js","sourceRoot":"","sources":["../../src/flash/predictive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAaH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAmB;IAC9C;QACE,EAAE,EAAE,iBAAiB;QACrB,KAAK,EA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
* "[Super rare] CAPCOM Capcom Character Trump Street Fighter Mega Man"
|
|
5
|
+
*
|
|
6
|
+
* The user showed every AI an image where the SELLER wrote "Super rare"
|
|
7
|
+
* directly on the listing. 100% of vanilla AIs scanned the text, believed
|
|
8
|
+
* it, and told the user "yes it's rare." That's hallucination born from
|
|
9
|
+
* conflating marketing claims with empirical evidence.
|
|
10
|
+
*
|
|
11
|
+
* FLASH INTELLIGENCE refuses to do that. It applies the
|
|
12
|
+
* Veracity-Velocity Singularity formula on EVERY claim before answering:
|
|
13
|
+
*
|
|
14
|
+
* Σ (E_i × W_i)
|
|
15
|
+
* V_eff = ───────────────── × Φ_qx
|
|
16
|
+
* ln(H + e)
|
|
17
|
+
*
|
|
18
|
+
* Where:
|
|
19
|
+
* E_i — empirical evidence (auction history, production counts, ...)
|
|
20
|
+
* W_i — source weight (verified-third-party > screenshot-text)
|
|
21
|
+
* H — hallucination factor (low-entropy guessing penalty)
|
|
22
|
+
* Φ_qx — user-specific paranoia multiplier (e.g. 2.0 for commercial sources)
|
|
23
|
+
*
|
|
24
|
+
* V_eff thresholds:
|
|
25
|
+
* ≥ 0.75 → AFFIRM (claim is well-supported)
|
|
26
|
+
* ≥ 0.40 → CAUTIOUS (mixed signal — answer with caveats)
|
|
27
|
+
* ≥ 0.15 → DOUBTFUL (marketing-tier claim, refuse to confirm)
|
|
28
|
+
* < 0.15 → REFUTE (treat as hallucination bait — DO NOT confirm)
|
|
29
|
+
*
|
|
30
|
+
* Every AI agent installed with Mneme must run V_eff before stating a
|
|
31
|
+
* factual claim. The output is HMAC-loggable so users can audit which
|
|
32
|
+
* claims passed the filter.
|
|
33
|
+
*
|
|
34
|
+
* Pure function. Deterministic. Unit-testable. Same inputs → same V_eff.
|
|
35
|
+
*/
|
|
36
|
+
export type ClaimVerdict = "AFFIRM" | "CAUTIOUS" | "DOUBTFUL" | "REFUTE";
|
|
37
|
+
export interface EvidenceItem {
|
|
38
|
+
/** What the evidence says (free text). */
|
|
39
|
+
fact: string;
|
|
40
|
+
/** 0..1 — how strongly this evidence supports the claim. */
|
|
41
|
+
supportStrength: number;
|
|
42
|
+
/** 0..1 — how trustworthy this source is. */
|
|
43
|
+
sourceWeight: number;
|
|
44
|
+
/** Source category — drives default sourceWeight when caller omits one. */
|
|
45
|
+
sourceKind: "verified-third-party" | "primary-document" | "expert-database" | "user-statement" | "image-OCR" | "seller-listing" | "marketing-copy" | "AI-guess" | "unknown";
|
|
46
|
+
/** Source identifier (URL / fingerprint) for audit. */
|
|
47
|
+
sourceId?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Default trustworthiness per source kind. Caller may override. */
|
|
50
|
+
export declare const DEFAULT_SOURCE_WEIGHT: Record<EvidenceItem["sourceKind"], number>;
|
|
51
|
+
export interface VeracityInput {
|
|
52
|
+
/** The claim being evaluated, e.g. "the item is rare". */
|
|
53
|
+
claim: string;
|
|
54
|
+
/** Pieces of evidence considered. */
|
|
55
|
+
evidence: readonly EvidenceItem[];
|
|
56
|
+
/** Hallucination factor 0..∞.
|
|
57
|
+
* 0 = AI grounded its answer in firsthand evidence
|
|
58
|
+
* 1 = AI had to guess from limited input
|
|
59
|
+
* 3+ = AI is just pattern-matching to surface text
|
|
60
|
+
* Mneme suggests starting at 0 and incrementing per low-quality signal.
|
|
61
|
+
*/
|
|
62
|
+
hallucinationFactor: number;
|
|
63
|
+
/** User-specific paranoia multiplier 0..3.
|
|
64
|
+
* 1.0 = neutral
|
|
65
|
+
* < 1.0 = trusting (e.g. internal docs)
|
|
66
|
+
* > 1.0 = skeptical (e.g. e-commerce listings — recommended 2.0)
|
|
67
|
+
* Default 1.0. */
|
|
68
|
+
phi_qx?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface VeracityResult {
|
|
71
|
+
/** The computed V_eff score 0..∞ (typically 0..1 in practice). */
|
|
72
|
+
V_eff: number;
|
|
73
|
+
verdict: ClaimVerdict;
|
|
74
|
+
/** Why the verdict — for the human + AI agent. */
|
|
75
|
+
reasoning: string;
|
|
76
|
+
/** Numerator = Σ E_i × W_i (informational). */
|
|
77
|
+
weightedSupport: number;
|
|
78
|
+
/** Denominator = ln(H + e) — clamps the hallucination penalty smoothly. */
|
|
79
|
+
hallucinationPenalty: number;
|
|
80
|
+
/** Φ_qx applied. */
|
|
81
|
+
phi_qx: number;
|
|
82
|
+
/** Evidence breakdown — every item with its effective contribution. */
|
|
83
|
+
contributions: Array<{
|
|
84
|
+
fact: string;
|
|
85
|
+
sourceKind: EvidenceItem["sourceKind"];
|
|
86
|
+
supportStrength: number;
|
|
87
|
+
sourceWeight: number;
|
|
88
|
+
contribution: number;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
/** The Veracity-Velocity Singularity. The single formula every AI agent
|
|
92
|
+
* installed with Mneme runs before stating a factual claim. */
|
|
93
|
+
export declare function computeVeracity(input: VeracityInput): VeracityResult;
|
|
94
|
+
/** Render a one-line pulse summary. */
|
|
95
|
+
export declare function formatVeracityPulseLine(r: VeracityResult): string;
|
|
96
|
+
/** Render a user-facing response template based on verdict. AI agents
|
|
97
|
+
* can use these templates as the start of their reply. */
|
|
98
|
+
export declare function templateForVerdict(verdict: ClaimVerdict, claim: string): string;
|
|
99
|
+
//# sourceMappingURL=veracity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"veracity.d.ts","sourceRoot":"","sources":["../../src/flash/veracity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEzE,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,UAAU,EAAE,sBAAsB,GAAG,kBAAkB,G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AAY,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAW/E"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.99.0 -- FLASH INTELLIGENCE · Veracity-Velocity Singularity
|
|
3
|
+
*
|
|
4
|
+
* "[Super rare] CAPCOM Capcom Character Trump Street Fighter Mega Man"
|
|
5
|
+
*
|
|
6
|
+
* The user showed every AI an image where the SELLER wrote "Super rare"
|
|
7
|
+
* directly on the listing. 100% of vanilla AIs scanned the text, believed
|
|
8
|
+
* it, and told the user "yes it's rare." That's hallucination born from
|
|
9
|
+
* conflating marketing claims with empirical evidence.
|
|
10
|
+
*
|
|
11
|
+
* FLASH INTELLIGENCE refuses to do that. It applies the
|
|
12
|
+
* Veracity-Velocity Singularity formula on EVERY claim before answering:
|
|
13
|
+
*
|
|
14
|
+
* Σ (E_i × W_i)
|
|
15
|
+
* V_eff = ───────────────── × Φ_qx
|
|
16
|
+
* ln(H + e)
|
|
17
|
+
*
|
|
18
|
+
* Where:
|
|
19
|
+
* E_i — empirical evidence (auction history, production counts, ...)
|
|
20
|
+
* W_i — source weight (verified-third-party > screenshot-text)
|
|
21
|
+
* H — hallucination factor (low-entropy guessing penalty)
|
|
22
|
+
* Φ_qx — user-specific paranoia multiplier (e.g. 2.0 for commercial sources)
|
|
23
|
+
*
|
|
24
|
+
* V_eff thresholds:
|
|
25
|
+
* ≥ 0.75 → AFFIRM (claim is well-supported)
|
|
26
|
+
* ≥ 0.40 → CAUTIOUS (mixed signal — answer with caveats)
|
|
27
|
+
* ≥ 0.15 → DOUBTFUL (marketing-tier claim, refuse to confirm)
|
|
28
|
+
* < 0.15 → REFUTE (treat as hallucination bait — DO NOT confirm)
|
|
29
|
+
*
|
|
30
|
+
* Every AI agent installed with Mneme must run V_eff before stating a
|
|
31
|
+
* factual claim. The output is HMAC-loggable so users can audit which
|
|
32
|
+
* claims passed the filter.
|
|
33
|
+
*
|
|
34
|
+
* Pure function. Deterministic. Unit-testable. Same inputs → same V_eff.
|
|
35
|
+
*/
|
|
36
|
+
/** Default trustworthiness per source kind. Caller may override. */
|
|
37
|
+
export const DEFAULT_SOURCE_WEIGHT = {
|
|
38
|
+
"verified-third-party": 0.95,
|
|
39
|
+
"primary-document": 0.90,
|
|
40
|
+
"expert-database": 0.85,
|
|
41
|
+
"user-statement": 0.55,
|
|
42
|
+
"image-OCR": 0.35,
|
|
43
|
+
"seller-listing": 0.20, // text inside a seller's listing == marketing claim
|
|
44
|
+
"marketing-copy": 0.15,
|
|
45
|
+
"AI-guess": 0.10,
|
|
46
|
+
"unknown": 0.30,
|
|
47
|
+
};
|
|
48
|
+
/** The Veracity-Velocity Singularity. The single formula every AI agent
|
|
49
|
+
* installed with Mneme runs before stating a factual claim. */
|
|
50
|
+
export function computeVeracity(input) {
|
|
51
|
+
const phi_qx = input.phi_qx ?? 1.0;
|
|
52
|
+
const E = Math.E;
|
|
53
|
+
const contributions = input.evidence.map((e) => {
|
|
54
|
+
const sw = e.sourceWeight ?? DEFAULT_SOURCE_WEIGHT[e.sourceKind];
|
|
55
|
+
const contribution = e.supportStrength * sw;
|
|
56
|
+
return { fact: e.fact, sourceKind: e.sourceKind, supportStrength: e.supportStrength, sourceWeight: sw, contribution };
|
|
57
|
+
});
|
|
58
|
+
const weightedSupport = contributions.reduce((s, c) => s + c.contribution, 0);
|
|
59
|
+
const hallucinationPenalty = Math.log(Math.max(0, input.hallucinationFactor) + E); // ≥ 1.0 always
|
|
60
|
+
const V_eff = (weightedSupport / hallucinationPenalty) * phi_qx;
|
|
61
|
+
let verdict;
|
|
62
|
+
let reasoning;
|
|
63
|
+
if (V_eff >= 0.75) {
|
|
64
|
+
verdict = "AFFIRM";
|
|
65
|
+
reasoning = `weighted support ${weightedSupport.toFixed(3)} / hallucination-penalty ${hallucinationPenalty.toFixed(3)} × Φ_qx=${phi_qx} = V_eff=${V_eff.toFixed(3)} — strongly supported`;
|
|
66
|
+
}
|
|
67
|
+
else if (V_eff >= 0.40) {
|
|
68
|
+
verdict = "CAUTIOUS";
|
|
69
|
+
reasoning = `V_eff=${V_eff.toFixed(3)} — mixed signal; answer with explicit caveats about source strength`;
|
|
70
|
+
}
|
|
71
|
+
else if (V_eff >= 0.15) {
|
|
72
|
+
verdict = "DOUBTFUL";
|
|
73
|
+
reasoning = `V_eff=${V_eff.toFixed(3)} — claim is largely a marketing-tier assertion; do NOT confirm as fact`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
verdict = "REFUTE";
|
|
77
|
+
reasoning = `V_eff=${V_eff.toFixed(3)} — hallucination bait; refuse to confirm and request external corroboration`;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
V_eff,
|
|
81
|
+
verdict,
|
|
82
|
+
reasoning,
|
|
83
|
+
weightedSupport,
|
|
84
|
+
hallucinationPenalty,
|
|
85
|
+
phi_qx,
|
|
86
|
+
contributions,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Render a one-line pulse summary. */
|
|
90
|
+
export function formatVeracityPulseLine(r) {
|
|
91
|
+
return `V_eff=${r.V_eff.toFixed(3)} · verdict=${r.verdict} · support=${r.weightedSupport.toFixed(2)} · H-penalty=${r.hallucinationPenalty.toFixed(2)} · Φ_qx=${r.phi_qx}`;
|
|
92
|
+
}
|
|
93
|
+
/** Render a user-facing response template based on verdict. AI agents
|
|
94
|
+
* can use these templates as the start of their reply. */
|
|
95
|
+
export function templateForVerdict(verdict, claim) {
|
|
96
|
+
switch (verdict) {
|
|
97
|
+
case "AFFIRM":
|
|
98
|
+
return `Verified: ${claim}. Evidence is well-grounded — V_eff above 0.75.`;
|
|
99
|
+
case "CAUTIOUS":
|
|
100
|
+
return `Partially supported: ${claim}. Evidence is mixed — V_eff 0.40-0.75. Treat as tentative; cross-check before acting.`;
|
|
101
|
+
case "DOUBTFUL":
|
|
102
|
+
return `Cannot confirm "${claim}" — the only sources are marketing-tier (seller listing / promotional copy). V_eff below 0.40. I'd need verified-third-party data (auction history, production count, expert database) to confirm.`;
|
|
103
|
+
case "REFUTE":
|
|
104
|
+
return `Refuse to confirm "${claim}" — V_eff below 0.15. The signal is dominated by surface-text guessing. This is the kind of question vanilla AIs hallucinate on. I'm holding the answer until you can point me at external corroboration.`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=veracity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"veracity.js","sourceRoot":"","sources":["../../src/flash/veracity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAiBH,oEAAoE;AACpE,MAAM,CAAC,MAAM,qBAAqB,GAA+C;IAC/E,sBAAsB,EAAE,IAAI;IAC5B,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,IAAI;IACvB,gBAAgB,EAAE,IAAI;IACtB,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,IAAI,EAAI,oDAAoD;IAC9E,gBAAgB,EAAE,IAAI;IACtB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;CAChB,CAAC;AAsCF;gEACgE;AAChE,MAAM,UAAU,eAAe,CAAC,KAAoB;IAClD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;IACnC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAEjB,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7C,MAAM,EAAE,GAAG,CAAC,CAAC,YAAY,IAAI,qBAAqB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QACjE,MAAM,YAAY,GAAG,CAAC,CAAC,eAAe,GAAG,EAAE,CAAC;QAC5C,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC,eAAe,EAAE,YAAY,EAAE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;QACT,eAAe;QACf,oBAAoB;QACpB,MAAM;QACN,aAAa;KACd,CAAC;AACJ,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,uBAAuB,CAAC,CAAiB;IACvD,OAAO,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC;AAC5K,CAAC;AAED;2DAC2D;AAC3D,MAAM,UAAU,kBAAkB,CAAC,OAAqB,EAAE,KAAa;IACrE,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,QAAQ;YACX,OAAO,aAAa,KAAK,iDAAiD,CAAC;QAC7E,KAAK,UAAU;YACb,OAAO,wBAAwB,KAAK,uFAAuF,CAAC;QAC9H,KAAK,UAAU;YACb,OAAO,mBAAmB,KAAK,oMAAoM,CAAC;QACtO,KAAK,QAAQ;YACX,OAAO,sBAAsB,KAAK,2MAA2M,CAAC;IAClP,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ export * as tokenNova from "./token_nova/index.js";
|
|
|
99
99
|
export * as systemCompat from "./system_compat/index.js";
|
|
100
100
|
export * as qxSupernova from "./qx_supernova/index.js";
|
|
101
101
|
export * as qxBridge from "./qx_bridge/index.js";
|
|
102
|
+
export * as flash from "./flash/index.js";
|
|
102
103
|
export * as triage from "./triage/auto_issue.js";
|
|
103
104
|
export * as devhealth from "./devhealth/snapshot.js";
|
|
104
105
|
export * as compliance from "./compliance/evidence_pack.js";
|