// Psychology in Christ public MCP reader v1, revision 3 — expanded pinned archive and system-scope policy. // Fixed public endpoint only. No model calls, credentials, private files or automatic retries. export const heavenCoinScopeNotice='HeavenCoin does not score human worth, conscience, or identity. It evaluates system integrity, resource stewardship, and institutional accountability.'; export const heavenCoinScopeSubjects=['operator_org','corporation','nonprofit','municipality','validator_org','cooperative','infrastructure_system'] as const; export const heavenCoinScopeMeasures=['institutional_behavior','market_conduct','resource_stewardship','governance_actions','audit_outcomes','restoration_status','official_capacity_actions'] as const; /** Public policy only: deliberately excludes private archive identifiers and digests. */ export const heavenCoinPublicScope={scope:'system_only',sourceDate:'2026-04-16',statement:heavenCoinScopeNotice,notScored:['private human worth','conscience','identity','spiritual standing','personhood value','private religious beliefs'],subjects:heavenCoinScopeSubjects,measures:heavenCoinScopeMeasures,enforcement:'Declared scope validation in the financial accountability workbench; no network-wide scoring service or enforcement established.'} as const; /** Compare a received declaration with this release's known public policy. * This does not establish that a remote operator actually enforces the policy. */ export function matchesHeavenCoinPublicScope(value:unknown):boolean{ if(!value||typeof value!=='object'||Array.isArray(value))return false; const v=value as Record; const expected=heavenCoinPublicScope; const keys=Object.keys(expected) as (keyof typeof expected)[]; if(Object.keys(v).length!==keys.length||!keys.every(k=>Object.prototype.hasOwnProperty.call(v,k)))return false; return keys.every(k=>{const e=expected[k],a=v[k];return Array.isArray(e)?Array.isArray(a)&&a.length===e.length&&e.every((x,i)=>a[i]===x):a===e;}); } export type PublicMcpCheckStep={label:string;detail:string}; export type PublicMcpCheckReport={ format:"dij-public-mcp-client-check";version:1;checkedAt:string;endpoint:string; outcome:"public-reads-pass"|"check-stopped";protocolVersion:string|null; strictNotificationBody:boolean|null;requestsAttempted:number; steps:PublicMcpCheckStep[];warnings:string[];failure:string|null; signed:false;archiveIntegrity:ArchiveIntegrityResult;notice:string; }; const ENDPOINT="https://jesusos.online/_api/public-collaboration-mcp"; const TOOLS=["read_public_course","read_public_archive_index","read_public_archive_text","read_public_charter"]; const VERSIONS=["2025-11-25","2025-06-18","2025-03-26"]; const LIMIT=4194304; const ARCHIVE_BASELINE:Readonly>=Object.freeze({ "pfbid02dxfS1RBw9FSohCXp5kmZZA8TPtbKfNS65rFKQYKRZTK9p76fX1ejmZXtv11N3zy4l": "df1e5be5f062cb178d68297e29e59bf78982c0b663d1e80be051e91c10e7edce", "pfbid0syQWJtpsVwuJG1gzwaAd6ADVGxAMzoGXeLtQsebtLRFj4zDEjzcZphaqK1n2Loubl": "ba973185ff01cfc932c272b71855c7bf7e3d39310f68c83eb61923c2874c1657", "pfbid0nkMATj5P7iXTi2xoeoUP16cQHcGBFU2z3iHmL2d7tLyVWd2k36ZynmKbNBJHsjAjl": "7b2202ce84e737e555324c3f8d5e6007a2027ea837a375dbfa0b7e57c557183c", "pfbid0UV1ah5nbmiqvD3rSpyxYuyr5yibtThPNxyhfjxDTT4d6dW4z1XPE9f8DVB4KLSgdl": "22855c07044c1f3b756156af793851b18006a85f1a5b44b4c8bcfaf6724b353d", "pfbid02XhDG2wRyXjFMfvFNiLZLRpv9HKCvQZiyvSckUhwkCPpYMABWDviGt7GCcU9kAw1Pl": "0c219060bb67d95c8663d4e0be493e85f45c1a6b7f3de24a3ed2d07d54deec65", "pfbid02yuXVVWjfCb6AGkaCjfTZxWULQuUxYEUVLUESh3ji52ths7PmE9w4qSrrnL9SPmMhl": "64bcacba6c912ecf016f3813d4398cec1fb38849f4b224cba1a622287a18d986", "pfbid0281TZApG3Qeg7dDmniihk5zYGTaxe4SzgNpBSTYArpaM5tstq4JK7eLabE3BTQsMbl": "c040237df3d0b646c237d794698c55a1330e38a5d9941d030d983839a0b3587d", "pfbid0W5BcLu9HUY5oxh8AwFtRgGr4FtyH5pYTqUBktkd8xeHRXAwWEqsK6iR6oba7jXzzl": "4bf4c143d6562b0494051be92b97c88a7f9d6ee58a6aac1053439765a0fe7fab", "pfbid0SBtBco8EFPWyZMQrZ151Ku499LYWQ5QBbkemcYYFFgj12JaVKRXU15s7qcRSJMral": "9eff19d696ca5c8b0bbe21ecea5c3de80bba63dac0b40e86fedc0c93182754c2", "pfbid0dNvFdFWqYn4nCZjXp2pKRUvkP3Bmehwm9yGMXVsfegvAoj1GJPMjpVe82VvcBjZ8l": "dc5f240daa28a1ee6c3b6570919cb83a29c5db70d91dc519673c36a965ec72c3", "pfbid0ugne6ZGt9z2LsevG7GjScbeLzSE2qjfvPjJ5m81A3m27vLbfqYrsRXjJAShvsYpml": "0e19ca14c558bcd67da774fd8b3690f80dc718d60435a93923e45ad1d177719a", "pfbid0YGJaVa1rFow2EJeLtQFuLt6raPxfDZ5jrNDVwvin4r2MP7Yr6AfkLfCVuHZGiDWyl": "f7e5940aaeeeaf3ca630d3f41f349cca073ae50f0c1a4e3c0a6ddf704706e991", "pfbid02WVRjrfo6968hx91pSERuDB5yTnbpuTvKeLFLRtqX6bLsBUg1hTfF37bRf2gN2kW2l": "367c987a72ae2ef009a118309f91f27d99e2007afe1899d091bc59a7ada52142", "pfbid02wbxktR4Bxv7rdpVWJRLZhQnjsPFgY3juDQdfiPbU9ak7Xf73r4hdQ38Yq2FJ6xWnl": "2cc6625ad8e2c05879ed262a16a1551066c3de540588c93676cd9dee5cf2bd20", "pfbid023i2FQgohB2SrbvmswEPxxvCvqaq7g7LLTMRzaBmgGeAQvGZG9kwtXTm7fyFxQAq3l": "60abe1334349e666f689f264866e33fcbf935d536e54e2a3f8608cef4e47d4bc", "pfbid0RKkmUY4aHVHxRF5ooFjdE5GfXXDKPNy9ASV8tJftXq12vXRfjo57iFSua3Uwaz5Sl": "13d1caacb47dc331771ca9c179df8e9af8036e4a8e6242f5b9a9e3929fcf4fec", "pfbid02X2DyopdXwWKP9jKriTxctcdL6CJpFXS41V4aiHvCt4hm9zzAvQR7xz9PjVXyoyvml": "55caf48783ac37e57ae017102c002ad2495b6d855e3dabd56b81a1b1de1cbf5c", "pfbid0UjD12CGCcmZeVwYjiqp4aihQApDKWXgjd9vpksDSm5iX7GPUCZC89GARxXW7pBxFl": "eda100caeef4dc9d806497e22fcfc15d336a4a590480a55b8fc6aa9ce39a074a", "pfbid036G7M2HKvcGV8HgBeRR5MCra4C5atoriX9UbJeXmoLzXEMnjAusocQGSHQeP3skd1l": "a9aa1feeb602e45c0cdfdb013e216f34be9c4219bc773adb0192fcf8ca6a0da5", "pfbid02wAJDvnh9oJ28qRUbfZvagXquhEDXDyvLrJRk5jStfvhKyVAGvGhQoSmHHuoQwawCl": "48915163ec22f4525e70a924a2f24f13072de72a597f82af7bcffb6596d62446", "pfbid0bhPoM2tzg7EBKa7YCTgdAnGwzvmXJGXFjXG36FKMVKKupHe6nyhJewmbHbj8mHNUl": "cf7a2d5cb1d2f7137376603aa4d2ef6e96f3dd61ad451ef1e63e10064e1721f5", "pfbid05bnAbbDMcbMWRJPfyaZ8631u37VDNHkBRgVgBXhGotCjwuW6deQR3rkifWDYQDKEl": "d9068e0911e87e6a376a01edea8fc7e82b72dd9b44e1baa592987d8aafbd6c94", "pfbid0DskwTYuwe7JSs5qBrcXR6B63P6VXZhM5xZzpddy7JZy9uhhCLZ1cnYV7reDtMB46l": "56ac81ed2e6bb93bd3b743015949b48d3c445325f7b7420d76b5c27b4aa8f0a7", "pfbid02Zr9bQ2VFRRSZDK1XsWWpQonAryi894vp41kkJb5neVApaxyLdeAhfn28xm1C9HeXl": "6a53c531bab3d1e300e3a5f6ede4cd9e13903692cb4e0a6c043632efab283611", "pfbid02zNq3CBRKJ1TMz2N2agF91SFTYanfUCcXfQzLSrfrzeFoqkawyYSAAjYmDSR5DdCol": "97f38e17652b8a36df29277f168b2123226cfd2b9972bec1db0eb90a3f323533", "pfbid029L1o5egxMWQ7xNn66w14tSYukpvkXUurCj4ukdatYzc1CCwo3sTYrVa6AuSmc2mZl": "4c156db06dc2ad9d44d223658585fc0a651d1b5a18ee4b58c661a77a5b6465f6", "pfbid02Nqhv5zfgLM7m8sJjGn8uzWbi5ay83eRxF5ZL9J5XqppiZKQz5BbTSvmnfcf8zUSrl": "c748ee3249771facf224fd4fe0a4d3b6786fd3e936489343cf17d2c527786857", "pfbid0MKTyghP3Uzgx63Wj5fpWAShhdRgXQvzU7fhfoY4J5Kj98cT6qK1d2QkmnW4S5yuwl": "adde6a4b7e43607c34fdc2cf15e82c60b4903149b591a57f1f820beb12db396a", "pfbid0746A83sNKQ3VCPAamNCoPSFhHbn12sshchzVQq843mkaF2CjqipYxxGxBM3AeZ36l": "8e50c91be8dbd3a0eb6b2dc849eb3eaef3f7be4c1d970784e2d54327487d7d04", "pfbid0EXsa4HKHeB3DWTuxqohwdHmaJTkRdL52zdyGqaD67ASPXbga57sDrmUfHdnV39h9l": "b7495ba4b1b3aac475237cf2a200b0058316e5a33c36aa732c4ace027e0ad6f7", "pfbid02nn6T7kFcYE8SxueSgCyGneybDJh7gskonnQyrouAEHg2E78P7Lkoep58W99HCnqNl": "5f94fc197bfee2994149191725eaca76a0c1ffddc0eb1b3adb0cbf8fe05117b4", "pfbid0FuGVvPNLj7YXf1DDbbbP1GYGmRf7Lp1zU75bTvwbjPxaSRjuxe11c8ZJN15t4LXQl": "ba585f46f5487fdd090dc48d8c3a0a8c86c5adec5e605ec51651207a70b05e75", "pfbid02USc7vw1CEYwhuSu7PB4PxhmTShz8j97pdQTXHk2huQuJEpeZ4RhiRi4KdRHqxSiHl": "1f3a77904129d2af05394c139b15647d5aa6501ccb6dbc1e069c318125f21230", "pfbid0mNBsUy6oh3mX3ap86defuwySgkCZSr1WvLCik642UWJXLRZyeKECPz44XYs4r6gRl": "99596f0e6a390cf233a03be30b766b32621a73ba57906fff393629cc97601cfe", "pfbid0fzikHixU9D5AbiewGY47gqUHwZQTLSvLLS8Y5eCFHDZgsJ8BWx3auzfbgWiYV6PRl": "4ddd27ced9a3cb985dc85d84484d4dad48f614fd71368dbc436d0f1e63fe067f", "pfbid0y62BSaKro3H2H4WMfjwPsrCifPgt7DReY6vnvLCDgZhGiWniT1AiMTuSviZ394T8l": "79dba29a662c7e7c3bb22984f2ef7d8bedb5045ce02f8e22457caf9b5c1df97b", "pfbid02DXZ2jbkNcttaBZt2AwByFkTyLFKFe6yndegtL1Q8CXt5DnoCGYCsw6XcitkSy6a7l": "3173e44a27c70b674fd6b31f9a577c9c8e3acafd3f351a2fbacca1992a637fe0", "pfbid0tr5Zvw2JGRToiyhwHUyKzEnNxsjubZD9KWKeEtfPaSu1FVP7JqrMcE851w6faPh4l": "5e2e3e679cbb1b83ea7b0be1ee514ead37752728f7d317ebd003e9f7608d3269", "pfbid02VYAcitG2YhpoEYraPspvnop1SdGnskFBQNJsQXG9emE9tR7eFVkGQC6m7thzrcH4l": "385c97f3ebae403a1d8969c41b8cbe9f97b92435d594f4879c750301b5354ed6", "pfbid02gN1rU2EMk63XESvsYNuNsjQcriz9DFejG2gvMuNdDS77rgC7PhotytoBhf9vwnnzl": "46115000c3ad05e629f8c1fdf99f07394c124eb69bc549a372975a09d5dabc82", "pfbid0DCmcMxqJNbgGFXWHLCXBagsKwDpvoquJGTYD6AbQycksJich3niNJEWwATqUHruRl": "cbfad22fe27bbc863d07aa2ccf782672bfff9dd4c8536f4db476c56692ce2a35", "pfbid02TPtK6FNW4U6acwXrozgWXFX6sYwBz7hawikn5HzYJoJwLHJEy4rUQTbotKGZbpnWl": "f7afa162aaa6897524851cedbbd1010f607c9e0ea927c406722fcfc8795b6372", "pfbid02Fq1RxVg4vf6yfnxA5BsVZ6k4978YWJ1fsXuFMQ7Yspnned2Y9HANeh7X41x34ACVl": "fe5ee11e8d8f85b8c0f4fafd0b985daf74941de004b0d5512f7a3e6647b79cf9", "pfbid02S9hR4HVUQbuUJXNx9b6VfYvnL2Eky9qBvCeHLLDoybGjAw2tMULhJXT7XhMALfgWl": "578bdc5439d9787135da858f36afe098c66c08261417e9de5d2317a3bb9b65d6", "pfbid0Nd9YXumm1H5ScMESpqUbrhftfHW3b2DiVKiaGTs1GzJrhyQekpsZexqvNosYtf5zl": "efba15b37183b7115cdd1a2368cf7329e9365f2f33f4a49b2b6f9d5e22a89cfc", "pfbid02adgvbJaAiPcHzYyv6Bg73CnSAWZ3s7Hyef7qN5feK45Z4L9ntzBQw9WvBAy1tN5Kl": "9e453110b2b14dc163824d3c0b58b9d28dc87d695b9595f0251e233b73156f41", "pfbid02mXaXVwUAFxpaBgQ2EMFa8845zbAC8cTmYBMKZnf4RTRa43jxjP3yhTnq7EZ6joAql": "c0060bb3f9f3b32c1b8bfcfc86f28b38856c15eb5ac3c68208a22498d8e5b4fb", "pfbid0ohwEsebZpCAkjaKrDiY6mH6bgWY6Y5TZHEWYvrps4H4g7XJaquNbG2FEPEKhTmmTl": "04c7dfd3261be82585bbbe6c2e16906f97ccf8696cbc9dff1323281851b48c29", "pfbid0KQWRKYvvRKGuSAz62hzqx1WVc9WzbwH5q6CUXEhYKaoyxJ5iorwAEr4QwGBKXQstl": "012bed29967e178acb088d8213caa5f8a16fa4bf5fb377d3892f46c01b29e364", "pfbid02FHZAGtfsiZtxbmJC57ShmPNVbpUNsWhXQ4KSxNKtqLwoyPkKBJVTnQxvjeMhtjL5l": "8ab4f36f68456d2f53867ac9094dcb4988a723294b26e5c7978281c7c17ae8bb", "pfbid02NvMBbDsLTFLiVhhTgk4FDWzxskDEgTmjxkwHTCxb72gxUgVwsqQTWCujzCSRk5Sl": "98c742ef5d57464a330ef4baafc2f3a5bd944211e19c0c977e6142ac299841a0", "pfbid02nbHHuycd7Kur1PBDpD4b2NzXDPNazNJsftcbmqTcqzAAzGbP4nyNjC4mXXuQCAMAl": "8c9cb10ed8e3aaa2b17c5e2c9957f89c455864290af7a8936567a4c56431ec05", "pfbid036sAa2sKNwNAdsSd3Tekmb6gPcToVSanxoqmPh1SG4AQkduDKKYDWKQQndYZ17pS9l": "dbbcc9610e2a5e3cea7dc218585b578df9c886aab8487232096d4fbf2382caf2", "pfbid0zK1Kxbz4iR5te3YhNNzCRU16sz29qBiGWwVuFWBCYE4dmdBKbuVXVjrS5nZ8XH48l": "6411bc83d7d9e43b83bca960f26368a607c863aa44f8b290d30ebe319c13cbb9", "pfbid09tT5oq75g2pZD5NE2Jq6fm5MW5DATW7pUKAZZoEbnHRgbgRVU17Xw4gvBrTaDDVol": "f8b5518ce7394cd2e9af37b81e06b346e793477d4b7e8e114df6344cae759646", "pfbid02qKkDoHNi1hdZ9UjfSTmwjzW2GUdVVs5SE9mdzSfG9UsRAUReGTMNNmtyvrq6qYdDl": "61c8af9eef3f50dcbe2ab3ec954a2617298b1ef32f6c98084e18b1de9e105596", "pfbid07WxLrftprY9zr59eDGKWZiqDPSuWqyXi94tyz4nstGoXsh8FjAtT2cs2x54s6Gvbl": "8460d3a196b9b25dc4705ff6f2d35ea191905f10c7f0532408702e9bbb23d087", "pfbid0ieAEG15cpZsS2Qt8nJJ3Pt7HEZi6sHqCRuANgpQywFruqtmsqbmmqwhb7DtmUBj3l": "5c8cf99f1e1d28075299716778757d8f1bf3ba2ed071abd57fddc04c0d3cf76b", "pfbid024T3sN4thGcvUax6NzrDnrN8dG2XuK5pRxGy6fHgzozyaCHgDDrant6LoXqRRcBh4l": "a90677493c7dbbe674712ca19804feb2e03d189e74da489119fc7ca562879cd6", "pfbid02CaHubpDK2NwGBho6FiscWzRSH9uXuTjLHBb4wCTaQz4YYBt8VumfmkseAT5n5XE9l": "a15687e7bce1a0c5ba57c512923b82cf745f39d7ec1d5bb3403ff02f5ffdb4a7", "pfbid02YAJ66jKt5x1wXVwB1iuEGmfKw6wddQLnpt5duzDh3u8LtKGgDGbU3fG3bhk8o8BBl": "61b4de70e025bec7f324eceb1d808df9b29e1348d6b577ed7870f56aca5fc20c", "pfbid0iRboEhHY4Thgk9yogy8PGR3hdZxYP1G8vmMu4u88Xh7FkA79dsHmC4QXv7Kcdyuxl": "2d69a326f7d0d7dc86e2c167f746a6e2420b0c78fc6e339a2c4ef282be93c95a", "pfbid0376bhZ2nkxwQVYzmKJdVYyoHzgv5oFfEfTSMH2sGrC6rcj6oEywj2DfeBjqHP2Kpfl": "b8dd21cc6a8a5d4cf9d8400f07fe384c1a40a37661a58821356072de77cc4a49" }); const BASELINE_ID="2026-11-30-captured-records-v2"; type ArchiveIntegrityRecord={id:string;textChecksumMatches:boolean;recordChecksumMatches:boolean;baselineMatches:boolean;indexChecksumsMatch:boolean}; type ArchiveIntegrityResult={baseline:string;status:"not-checked"|"passed"|"failed";expectedRecords:number;verifiedRecords:number;records:ArchiveIntegrityRecord[]}; async function verifyPublicArchive(index:Record,bundle:Record,result:ArchiveIntegrityResult,signal?:AbortSignal){ result.status="failed"; if(!globalThis.crypto?.subtle)throw Error("Archive cryptographic checks are unavailable in this environment."); const expected=Object.keys(ARCHIVE_BASELINE); if(!Array.isArray(index.records)||!Array.isArray(bundle.records)||index.records.length!==expected.length||bundle.records.length!==expected.length)throw Error("Archive record count differs from this reader's pinned baseline."); for(const document of [index,bundle]){ if(!object(document.recordHashSpec)||document.recordHashSpec.name!=="jesus-cloud-os-archive-record-v1"||document.recordHashSpec.algorithm!=="SHA-256")throw Error("Archive commitment specification differs."); } const knownIndex=new Map>(); for(const entry of index.records){ if(!object(entry)||typeof entry.id!=="string"||!Object.prototype.hasOwnProperty.call(ARCHIVE_BASELINE,entry.id)||knownIndex.has(entry.id))throw Error("Archive index contains an unknown or duplicate record."); knownIndex.set(entry.id,entry); } const seen=new Set(); const hash=async(text:string)=>{ if(signal?.aborted)throw Error("Check cancelled."); const digest=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(text)); if(signal?.aborted)throw Error("Check cancelled."); return Array.from(new Uint8Array(digest)).map(b=>b.toString(16).padStart(2,"0")).join(""); }; for(const r of bundle.records){ if(!object(r)||typeof r.id!=="string"||!Object.prototype.hasOwnProperty.call(ARCHIVE_BASELINE,r.id)||seen.has(r.id))throw Error("Archive bundle contains an unknown or duplicate record."); seen.add(r.id); for(const [key,max] of [["title",500],["author",100],["publishedDate",10],["capturedDate",10],["sourceUrl",500],["method",2000],["reviewStatus",1000],["text",200000]] as const){ if(typeof r[key]!=="string"||(r[key] as string).length<1||(r[key] as string).length>max)throw Error("Archive captured record has an invalid bounded field."); } for(const key of ["publishedDate","capturedDate"] as const){ const value=r[key] as string; if(!/^\d{4}-\d{2}-\d{2}$/.test(value)||Number.isNaN(Date.parse(value))||new Date(value).toISOString().slice(0,10)!==value)throw Error("Archive capture date is invalid."); } if(r.sourceUrl!=="https://www.facebook.com/jeremy.wilson.9847867/posts/"+r.id)throw Error("Archive original source reference differs."); if(typeof r.textSha256!=="string"||typeof r.recordSha256!=="string"||!/^[a-f0-9]{64}$/.test(r.textSha256)||!/^[a-f0-9]{64}$/.test(r.recordSha256))throw Error("Archive checksum shape differs."); const textHash=await hash(r.text as string); const recordHash=await hash(JSON.stringify(["jesus-cloud-os-archive-record-v1",r.id,r.title,r.author,r.publishedDate,r.capturedDate,r.sourceUrl,r.method,r.reviewStatus,textHash])); const indexed=knownIndex.get(r.id)!; const checked:ArchiveIntegrityRecord={ id:r.id,textChecksumMatches:textHash===r.textSha256,recordChecksumMatches:recordHash===r.recordSha256, baselineMatches:recordHash===ARCHIVE_BASELINE[r.id], indexChecksumsMatch:indexed.textSha256===textHash&&indexed.recordSha256===recordHash }; result.records.push(checked); if(!checked.textChecksumMatches||!checked.recordChecksumMatches||!checked.baselineMatches||!checked.indexChecksumsMatch)throw Error("Archive copy differs from its text, metadata, index or pinned captured-record commitment. No automatic correction was made."); result.verifiedRecords++; } if(seen.size!==expected.length)throw Error("Archive baseline record set is incomplete."); result.status="passed"; } const NOTICE="Unsigned technical check by this project's own reader. Checks protocol responses, public document shape and 63 captured-record SHA-256 commitments against the baseline pinned in this reader. Checksums cover preserved text and capture metadata, not source-index summaries or classification. They do not prove truth, authorship, source authenticity, independent fact checking, income, decentralization or other applications' compatibility. The baseline and reader are maintained by the same central project; keep a trusted copy to detect later changes. Hosting and receiving-app AI may incur costs. The server updates an operational rate counter; no participant record is changed."; function object(v:unknown):v is Record{return typeof v==="object"&&v!==null&&!Array.isArray(v);} async function responseText(response:Response,signal:AbortSignal){ const declared=response.headers.get("Content-Length"); if(declared!==null&&(!/^\d+$/.test(declared)||Number(declared)>LIMIT))throw Error("Response exceeds its size limit or has an invalid size header."); if(!response.body)return ""; const reader=response.body.getReader(),decoder=new TextDecoder("utf-8",{fatal:true}); let bytes=0,text="";let stop:()=>void; const aborted=new Promise((_,reject)=>{ stop=()=>reject(Error("Request cancelled or timed out.")); if(signal.aborted)stop();else signal.addEventListener("abort",stop,{once:true}); }); try{ while(true){ const part=await Promise.race([reader.read(),aborted]);if(part.done)break; bytes+=part.value.byteLength;if(bytes>LIMIT)throw Error("Response exceeds 4 MiB."); text+=decoder.decode(part.value,{stream:true}); } return text+decoder.decode(); }catch(e){await reader.cancel().catch(()=>{});throw e;} finally{signal.removeEventListener("abort",stop!);reader.releaseLock();} } export async function checkPublicMcp( fetcher:typeof fetch=fetch, options:{signal?:AbortSignal;onStep?:(step:PublicMcpCheckStep)=>void}={} ):Promise{ const report:PublicMcpCheckReport={ format:"dij-public-mcp-client-check",version:1,checkedAt:new Date().toISOString(),endpoint:ENDPOINT, outcome:"check-stopped",protocolVersion:null,strictNotificationBody:null,requestsAttempted:0, steps:[],warnings:[],failure:null,signed:false,archiveIntegrity:{baseline:BASELINE_ID,status:"not-checked",expectedRecords:63,verifiedRecords:0,records:[]},notice:NOTICE }; const step=(label:string,detail:string)=>{const item={label,detail};report.steps.push(item);options.onStep?.(item);}; let id=0; async function send(method:string,params?:Record,notification=false){ if(report.requestsAttempted>=7)throw Error("Seven-request check limit reached."); if(options.signal?.aborted)throw Error("Check cancelled."); const controller=new AbortController(); const cancel=()=>controller.abort();options.signal?.addEventListener("abort",cancel,{once:true}); const timer=setTimeout(cancel,10000); let rejectAbort:()=>void; const aborted=new Promise((_,reject)=>{rejectAbort=()=>reject(Error("Request cancelled or timed out."));controller.signal.addEventListener("abort",rejectAbort,{once:true});}); const requestId=notification?undefined:++id; report.requestsAttempted++; try{ const response=await Promise.race([fetcher(ENDPOINT,{ method:"POST",credentials:"omit",redirect:"error",cache:"no-store",signal:controller.signal, headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream",...(report.protocolVersion?{"MCP-Protocol-Version":report.protocolVersion}:{})}, body:JSON.stringify({jsonrpc:"2.0",...(!notification?{id:requestId}:{}),method,...(params===undefined?{}:{params})}) }),aborted]); if(controller.signal.aborted)throw Error("Check cancelled or request timed out."); const text=await responseText(response,controller.signal); if(notification){ if(response.status!==202)throw Error("Notification acknowledgment returned HTTP "+response.status+"."); if(text!==""&&text.trim()!=="")throw Error("Notification acknowledgment contains unexpected content."); report.strictNotificationBody=text===""; if(text!=="")report.warnings.push("Hosted notification acknowledgment contains whitespace instead of the empty body required by MCP. This reader tolerates whitespace; full protocol conformance and other clients' compatibility are not established."); return {}; } if(response.status!==200)throw Error("Public request returned HTTP "+response.status+". Check stopped without retry."); if((response.headers.get("Content-Type")??"").split(";")[0].trim().toLowerCase()!=="application/json")throw Error("Expected a JSON response."); let envelope:unknown;try{envelope=JSON.parse(text);}catch{throw Error("Response is not valid JSON.");} if(!object(envelope)||envelope.jsonrpc!=="2.0"||envelope.id!==requestId)throw Error("JSON-RPC version or response id does not match."); if(Object.prototype.hasOwnProperty.call(envelope,"error"))throw Error("Server returned a JSON-RPC error. Check stopped."); if(!object(envelope.result))throw Error("JSON-RPC result must be an object."); return envelope.result; }finally{clearTimeout(timer);controller.signal.removeEventListener("abort",rejectAbort!);options.signal?.removeEventListener("abort",cancel);} } try{ const initialized=await send("initialize",{protocolVersion:VERSIONS[0],capabilities:{},clientInfo:{name:"dij-built-public-reader",version:"1.0.0"}}); if(typeof initialized.protocolVersion!=="string"||!VERSIONS.includes(initialized.protocolVersion)||!object(initialized.capabilities)||!object(initialized.capabilities.tools)||!object(initialized.serverInfo)||typeof initialized.serverInfo.name!=="string")throw Error("Initialization did not negotiate a supported tool server."); report.protocolVersion=initialized.protocolVersion; step("Initialize","Negotiated "+report.protocolVersion+"."); await send("notifications/initialized",undefined,true); step("Acknowledge",report.strictNotificationBody?"HTTP 202 with an empty body.":"HTTP 202; hosted whitespace caveat recorded."); const list=await send("tools/list"); if(!Array.isArray(list.tools)||list.tools.length!==4)throw Error("Expected exactly four public tools."); const names=list.tools.map((t:unknown)=>object(t)?t.name:null); if(new Set(names).size!==4||!TOOLS.every(name=>names.includes(name)))throw Error("Tool list differs from the fixed public allowlist."); for(const tool of list.tools){ if(!object(tool)||!object(tool.inputSchema)||tool.inputSchema.type!=="object"||tool.inputSchema.additionalProperties!==false||!object(tool.annotations)||tool.annotations.readOnlyHint!==true||tool.annotations.destructiveHint!==false||tool.annotations.openWorldHint!==false)throw Error("Tool declaration differs from its read-only empty-argument contract."); } step("Discover tools","Four fixed public tools; empty arguments and read-only declarations checked."); let archiveIndex:Record|undefined,archiveBundle:Record|undefined; for(const name of TOOLS){ const result=await send("tools/call",{name,arguments:{}}); if(result.isError!==false||!Array.isArray(result.content)||result.content.length!==1||!object(result.content[0])||result.content[0].type!=="text"||typeof result.content[0].text!=="string")throw Error("Public tool did not return one successful text result."); let document:unknown;try{document=JSON.parse(result.content[0].text);}catch{throw Error("Public document is not valid JSON.");} if(!object(document)||document.version!==1)throw Error("Unexpected public document version."); let detail=""; switch(name){ case "read_public_course": if(document.format!=="psychology-in-christ-public-course"||!Array.isArray(document.lessons)||document.lessons.length!==6)throw Error("Course document shape differs."); detail="Six introductory lessons returned.";break; case "read_public_archive_index": if(document.format!=="jesus-cloud-os-public-archive-index"||!Array.isArray(document.records)||document.records.length!==63||document.signed!==false)throw Error("Archive index shape differs."); archiveIndex=document;detail="63 unsigned public index records returned.";break; case "read_public_archive_text": if(document.format!=="jesus-cloud-os-original-text-bundle"||!Array.isArray(document.records)||document.records.length!==63||document.signed!==false)throw Error("Archive bundle shape differs."); archiveBundle=document;detail="63 unsigned preserved-text records returned.";break; case "read_public_charter": if(document.format!=="dij-christ-ai-charter"||document.id!=="dij-christ-charter-v1"||!Array.isArray(document.clauses))throw Error("Charter shape differs."); if(!matchesHeavenCoinPublicScope(document.heavenCoinSystemScope))throw Error("Charter HeavenCoin system-only policy is missing or differs from this reader’s expected declaration."); detail="Versioned charter and system-only accountability declaration match this reader. Actual enforcement is not established by the declaration.";break; } step(name,detail); } if(!archiveIndex||!archiveBundle)throw Error("Archive documents are incomplete."); await verifyPublicArchive(archiveIndex,archiveBundle,report.archiveIntegrity,options.signal); step("Verify archive integrity","63 of 63 preserved texts and capture metadata match this reader\'s pinned baseline and the returned index checksums. This does not verify factual claims."); report.outcome="public-reads-pass"; }catch(e){ // Show only errors generated by this reader; never echo arbitrary server or source text. report.failure=e instanceof Error&&/^(Response |Request |Check |Seven-request |Notification |Public |Expected |JSON-RPC |Server |Initialization |Tool |Course |Archive |Charter )/.test(e.message)?e.message:"The connection check stopped. Retry manually after checking connectivity and the server limit."; } return report; }