chainlesschain 0.166.149 → 0.166.150
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/README.md +19 -5
- package/package.json +1 -1
- package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
- package/src/assets/linux-subreaper/linux-x64/manifest.json +1 -1
- package/src/assets/web-panel/.build-hash +1 -1
- package/src/assets/web-panel/assets/{AIOps-BjBY1txq.js → AIOps-bYMRw36k.js} +1 -1
- package/src/assets/web-panel/assets/{ActionButton-CS2ov4iK.js → ActionButton-xprOFj7C.js} +1 -1
- package/src/assets/web-panel/assets/{Analytics-C9LS7ahG.js → Analytics-BRZ6F3vk.js} +1 -1
- package/src/assets/web-panel/assets/{AppLayout-4_s9gBVg.js → AppLayout-C_volo3Y.js} +1 -1
- package/src/assets/web-panel/assets/{Artifacts-CwS17ayg.js → Artifacts-Db0iD_H2.js} +1 -1
- package/src/assets/web-panel/assets/{Audit-D3QMRsd-.js → Audit-Bzp7NOA9.js} +1 -1
- package/src/assets/web-panel/assets/{BackgroundAgents-Bxau9H9Q.js → BackgroundAgents-CPa5KqjU.js} +1 -1
- package/src/assets/web-panel/assets/{Backup--YSJyAuP.js → Backup-BraBbkcd.js} +1 -1
- package/src/assets/web-panel/assets/{BaseInput-DZolkmdu.js → BaseInput-D8LlXxCM.js} +1 -1
- package/src/assets/web-panel/assets/{Chat-DA-7fNKq.js → Chat-FWtdQ7HW.js} +1 -1
- package/src/assets/web-panel/assets/{ChatBubbleRenderer-DniEWT5j.js → ChatBubbleRenderer-DtxhjGV3.js} +1 -1
- package/src/assets/web-panel/assets/{Checkbox-B4hgbnOB.js → Checkbox-BoCeVuib.js} +1 -1
- package/src/assets/web-panel/assets/{Codegen-BQ3HSq9S.js → Codegen-C58CW3JB.js} +1 -1
- package/src/assets/web-panel/assets/{Col-DJwxq_Wu.js → Col-BlkVpYfD.js} +1 -1
- package/src/assets/web-panel/assets/{Community-DZYVM_iz.js → Community-BmQ95FuI.js} +1 -1
- package/src/assets/web-panel/assets/{Compact-1Yq5o53N.js → Compact-BzWphLgo.js} +1 -1
- package/src/assets/web-panel/assets/{Compliance-52Per8mR.js → Compliance-CG1Plf7v.js} +1 -1
- package/src/assets/web-panel/assets/{Cowork-BaCNxzo7.js → Cowork-CS8_XrAS.js} +1 -1
- package/src/assets/web-panel/assets/{Cron-DADTMPPr.js → Cron-C1m-mGo0.js} +1 -1
- package/src/assets/web-panel/assets/{Crosschain-CS3rx96X.js → Crosschain-TU1UPo_V.js} +1 -1
- package/src/assets/web-panel/assets/{DID-B8eatIvd.js → DID-bhbIsq__.js} +1 -1
- package/src/assets/web-panel/assets/{Dashboard-0vsurC1X.js → Dashboard-B0wCsqTw.js} +1 -1
- package/src/assets/web-panel/assets/{Dropdown-BULy3ccq.js → Dropdown-CVokY3lt.js} +1 -1
- package/src/assets/web-panel/assets/{EmailListRenderer-CcwgCUpu.js → EmailListRenderer-CfatTKx0.js} +1 -1
- package/src/assets/web-panel/assets/{EvolutionSettings-DLs_6II3.js → EvolutionSettings-DnT_Uiag.js} +1 -1
- package/src/assets/web-panel/assets/{FamilyGuardDashboard-DpUpWwQP.js → FamilyGuardDashboard-Dyahx8jQ.js} +1 -1
- package/src/assets/web-panel/assets/{Federation-6hx8MMYA.js → Federation-DuJ39hyj.js} +1 -1
- package/src/assets/web-panel/assets/{FormItemContext-CsdE-ZR5.js → FormItemContext-V4Ic5oQ_.js} +1 -1
- package/src/assets/web-panel/assets/{GenericCardRenderer-DzXneQPV.js → GenericCardRenderer-UlZdAl_W.js} +1 -1
- package/src/assets/web-panel/assets/{Git-D_ThKL1Q.js → Git-B_363OIs.js} +1 -1
- package/src/assets/web-panel/assets/{Governance-BFBSlr-9.js → Governance-C61_SW_q.js} +1 -1
- package/src/assets/web-panel/assets/{Inference-BAI0b1Jl.js → Inference-CU80t_tb.js} +1 -1
- package/src/assets/web-panel/assets/{KnowledgeGraph-CpO6Bdtr.js → KnowledgeGraph-BEtPQz8C.js} +1 -1
- package/src/assets/web-panel/assets/{Logs-BcRaS_HC.js → Logs-CXqWvdFk.js} +1 -1
- package/src/assets/web-panel/assets/{MarkdownRenderer-CmZaA7Ct.js → MarkdownRenderer-BFgkiBfA.js} +1 -1
- package/src/assets/web-panel/assets/{Marketplace-BpHBn0Nw.js → Marketplace-oKgzevz2.js} +1 -1
- package/src/assets/web-panel/assets/{McpTools-auVxEYSE.js → McpTools-DHcNKyfb.js} +1 -1
- package/src/assets/web-panel/assets/{Memory-DpCyb656.js → Memory-DEVpDL-x.js} +1 -1
- package/src/assets/web-panel/assets/{MobileBridge-CEIGi769.js → MobileBridge-D92T6ztp.js} +1 -1
- package/src/assets/web-panel/assets/{MobileProjects-pphH0a8n.js → MobileProjects-B2Y7xpPw.js} +1 -1
- package/src/assets/web-panel/assets/{Mtc-CMJXBEp1.js → Mtc-VOiGefD2.js} +1 -1
- package/src/assets/web-panel/assets/{MtcAudit-BI25yvzM.js → MtcAudit-CAnmf1Im.js} +1 -1
- package/src/assets/web-panel/assets/{Multisig-BhMDExsQ.js → Multisig-BCPOmJxC.js} +1 -1
- package/src/assets/web-panel/assets/{NLProgramming-CatOR9Ez.js → NLProgramming-DYFqTLhe.js} +1 -1
- package/src/assets/web-panel/assets/{Notes-BHG6SBpu.js → Notes--N-8WbHM.js} +1 -1
- package/src/assets/web-panel/assets/{NotificationSettings-BB-m0AbL.js → NotificationSettings-Dka_XX0P.js} +1 -1
- package/src/assets/web-panel/assets/{OrderTableRenderer-W-WReAih.js → OrderTableRenderer-CIVkknQY.js} +1 -1
- package/src/assets/web-panel/assets/{Organization-BkQCgon_.js → Organization-MToqvn2N.js} +1 -1
- package/src/assets/web-panel/assets/{Overflow-kCTwPrIc.js → Overflow-DgYLr6Hh.js} +1 -1
- package/src/assets/web-panel/assets/{P2P-CvOF8whc.js → P2P-DiRHC93-.js} +1 -1
- package/src/assets/web-panel/assets/{PdhVaultBrowser-DYkTzn6u.js → PdhVaultBrowser-Cw8MYDt-.js} +2 -2
- package/src/assets/web-panel/assets/{Permissions-F-UzeWVt.js → Permissions-JhxdHQqC.js} +1 -1
- package/src/assets/web-panel/assets/{PersonalDataHub-BURpZBb6.js → PersonalDataHub-CcEeur_W.js} +1 -1
- package/src/assets/web-panel/assets/{Pipeline-lZYx_7qc.js → Pipeline-Dau0R1tw.js} +1 -1
- package/src/assets/web-panel/assets/{Privacy-DdfYgt1_.js → Privacy-UF1HoZ-q.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectInit-DbMBCojn.js → ProjectInit-DyPmrkmp.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectSettings-DPGbzkyi.js → ProjectSettings-DZ4DQBbI.js} +1 -1
- package/src/assets/web-panel/assets/{Projects-B9-t2ofM.js → Projects-BRhaPrL4.js} +1 -1
- package/src/assets/web-panel/assets/Providers-DVyNl0mO.css +1 -0
- package/src/assets/web-panel/assets/Providers-TFpSkyej.js +1 -0
- package/src/assets/web-panel/assets/{QrScannerModal-BIth1Lij.js → QrScannerModal-Dgvs6EGu.js} +1 -1
- package/src/assets/web-panel/assets/{QuickAsk-C928WbdK.js → QuickAsk-DqKybfXf.js} +1 -1
- package/src/assets/web-panel/assets/{Recommend-CzDNsNPZ.js → Recommend-BGQDw5cu.js} +1 -1
- package/src/assets/web-panel/assets/{RemoteSession-CedjOslI.js → RemoteSession-KE-6VZN0.js} +1 -1
- package/src/assets/web-panel/assets/{Reputation-B8ggKVtj.js → Reputation-Ifxvbk7U.js} +1 -1
- package/src/assets/web-panel/assets/{Row-Cx167nF6.js → Row-DoD3nauz.js} +1 -1
- package/src/assets/web-panel/assets/{RssFeed-Cj8hwiLP.js → RssFeed-BlMKhrqt.js} +1 -1
- package/src/assets/web-panel/assets/{Search-Dsyrkogu.js → Search-D4MaHzRS.js} +1 -1
- package/src/assets/web-panel/assets/{Security-DfOcWFt-.js → Security-DMpqDgSc.js} +1 -1
- package/src/assets/web-panel/assets/{Services-CSyv-JgS.js → Services-C9yzBSd8.js} +1 -1
- package/src/assets/web-panel/assets/{Skeleton-B0chhFP5.js → Skeleton-h8kJILZh.js} +1 -1
- package/src/assets/web-panel/assets/{Skills-B_jrR_AF.js → Skills-jXdYN4vu.js} +1 -1
- package/src/assets/web-panel/assets/{Sla-krP10aUI.js → Sla-Cuk7apSe.js} +1 -1
- package/src/assets/web-panel/assets/{SpeechSettings-Cm_Cjvf2.js → SpeechSettings-B5hPI4N_.js} +1 -1
- package/src/assets/web-panel/assets/{SyncSettings-Cmb-KoqG.js → SyncSettings-MGyaOfUD.js} +1 -1
- package/src/assets/web-panel/assets/{Tasks-DUOiwTxY.js → Tasks-BSqf89Jx.js} +1 -1
- package/src/assets/web-panel/assets/{Templates-DcEPspsP.js → Templates-BYjHba7u.js} +1 -1
- package/src/assets/web-panel/assets/{Tenant-Dw93LtrE.js → Tenant-CEkhV7yX.js} +1 -1
- package/src/assets/web-panel/assets/{Terminal-B04i0AIG.js → Terminal-D2deCxuf.js} +1 -1
- package/src/assets/web-panel/assets/{TimelineRenderer-C-aAORNK.js → TimelineRenderer-C8YVFoC3.js} +1 -1
- package/src/assets/web-panel/assets/{Tokens-W1RBfDKb.js → Tokens-DN-S9EsT.js} +1 -1
- package/src/assets/web-panel/assets/{Trigger-BuuH9sMn.js → Trigger-F6LwAuyn.js} +1 -1
- package/src/assets/web-panel/assets/{Trust-Bma-Vz-f.js → Trust-Cx8jhn1i.js} +1 -1
- package/src/assets/web-panel/assets/{UkeySign-CqWw3_ha.js → UkeySign-BN--f0JV.js} +1 -1
- package/src/assets/web-panel/assets/{VideoEditing-6NYmQRUe.js → VideoEditing-i32OtN88.js} +1 -1
- package/src/assets/web-panel/assets/{Wallet-CTUuBxsr.js → Wallet-DQImHu1X.js} +1 -1
- package/src/assets/web-panel/assets/{WebAuthn-D8mN5UQU.js → WebAuthn-5waEqMup.js} +1 -1
- package/src/assets/web-panel/assets/{WorkflowEditor-DOB46XMH.js → WorkflowEditor-Bh0xyyOO.js} +1 -1
- package/src/assets/web-panel/assets/{chat-BPNlNLwi.js → chat-EXJ3Usf5.js} +1 -1
- package/src/assets/web-panel/assets/{colors-D-LNng0Q.js → colors-Cdoap8Z7.js} +1 -1
- package/src/assets/web-panel/assets/{compact-item-Vkl3KOAb.js → compact-item-QPjKEhW_.js} +1 -1
- package/src/assets/web-panel/assets/{createContext-CFsJ9Bmp.js → createContext-BOGUY650.js} +1 -1
- package/src/assets/web-panel/assets/{hasIn-C1v7eiIB.js → hasIn-DRN_I25i.js} +1 -1
- package/src/assets/web-panel/assets/{index-CD8egQCF.js → index-15P436aq.js} +1 -1
- package/src/assets/web-panel/assets/{index-CfVl0Oqt.js → index-6KPTDWDG.js} +1 -1
- package/src/assets/web-panel/assets/{index-BPwv3l6X.js → index-6nTP4-QK.js} +1 -1
- package/src/assets/web-panel/assets/{index-DbmhJVc3.js → index-9hwjpOFE.js} +1 -1
- package/src/assets/web-panel/assets/{index-0oRhV07J.js → index-BFXhCqpm.js} +1 -1
- package/src/assets/web-panel/assets/index-BFYVw5aJ.js +1 -0
- package/src/assets/web-panel/assets/{index-Cjxxw-1P.js → index-BFh62a_Z.js} +1 -1
- package/src/assets/web-panel/assets/{index-hBzgHVea.js → index-BRo2j8Jz.js} +1 -1
- package/src/assets/web-panel/assets/{index-BefXafSw.js → index-B_J_PUwW.js} +1 -1
- package/src/assets/web-panel/assets/{index-CmkppTkH.js → index-B_pCKR-k.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dq9SDl82.js → index-BeRxNc4x.js} +1 -1
- package/src/assets/web-panel/assets/{index-BMcTUbpz.js → index-BmVIyCgf.js} +1 -1
- package/src/assets/web-panel/assets/{index-BGyhWFpc.js → index-BoDNVZfc.js} +1 -1
- package/src/assets/web-panel/assets/{index-DFErisPY.js → index-BvX72fLD.js} +1 -1
- package/src/assets/web-panel/assets/{index-PCe8NA3J.js → index-C33cfAQE.js} +1 -1
- package/src/assets/web-panel/assets/{index-DVfUt2bK.js → index-CKfdYM3I.js} +1 -1
- package/src/assets/web-panel/assets/{index-5oK4ICcR.js → index-CVJG_i6e.js} +1 -1
- package/src/assets/web-panel/assets/{index-BoZnaD3Q.js → index-CXP_MepL.js} +1 -1
- package/src/assets/web-panel/assets/{index-BVHaJNpn.js → index-CafxYv7t.js} +1 -1
- package/src/assets/web-panel/assets/{index-BQr5mmyc.js → index-DAuglUM-.js} +1 -1
- package/src/assets/web-panel/assets/{index-BgvrlrtJ.js → index-DBb3W3bA.js} +1 -1
- package/src/assets/web-panel/assets/{index-DZ16Oxcu.js → index-DID83zEQ.js} +1 -1
- package/src/assets/web-panel/assets/{index-BiPmMm38.js → index-DISFHFjT.js} +1 -1
- package/src/assets/web-panel/assets/{index-uDSUo2y2.js → index-DNpnprSx.js} +1 -1
- package/src/assets/web-panel/assets/{index-CaJvbmCw.js → index-DULwfIin.js} +1 -1
- package/src/assets/web-panel/assets/{index-ChGe005u.js → index-D_pIGWDh.js} +1 -1
- package/src/assets/web-panel/assets/{index-DgYmI2pD.js → index-DfXsHnc0.js} +1 -1
- package/src/assets/web-panel/assets/{index-9JeeBF92.js → index-Dusibyek.js} +1 -1
- package/src/assets/web-panel/assets/{index-PiL6D-FC.js → index-DzUL46rU.js} +1 -1
- package/src/assets/web-panel/assets/{index-DmUZGqe2.js → index-FBoQQHLy.js} +1 -1
- package/src/assets/web-panel/assets/{index-BxJC59QT.js → index-L3zdSmTh.js} +1 -1
- package/src/assets/web-panel/assets/{index-DuIfomtv.js → index-Lwktngzr.js} +1 -1
- package/src/assets/web-panel/assets/{index-a_H30VZX.js → index-_fW5KelD.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dd0OgZmt.js → index-hmILMYKF.js} +3 -3
- package/src/assets/web-panel/assets/{index-BMsRfvkp.js → index-iYCp3otx.js} +1 -1
- package/src/assets/web-panel/assets/{index-MGJzHAw_.js → index-jo9saD-R.js} +1 -1
- package/src/assets/web-panel/assets/{index-BH5PxoVq.js → index-kc4lgpMy.js} +1 -1
- package/src/assets/web-panel/assets/{index-BObyCZ2w.js → index-shByGhT7.js} +1 -1
- package/src/assets/web-panel/assets/index-wtySft9h.js +1 -0
- package/src/assets/web-panel/assets/{initDefaultProps-CCYgHcTH.js → initDefaultProps-Bno49hyl.js} +1 -1
- package/src/assets/web-panel/assets/{motion-4Yr4ZkjE.js → motion-Cs9KpFRZ.js} +1 -1
- package/src/assets/web-panel/assets/{move-ZP90E-ji.js → move-DN2kt6Fk.js} +1 -1
- package/src/assets/web-panel/assets/{mtc-parser-s0N3WyRA.js → mtc-parser-IXnfFKcF.js} +1 -1
- package/src/assets/web-panel/assets/{omit-BZ6gx9Kf.js → omit-ULuXK3m0.js} +1 -1
- package/src/assets/web-panel/assets/parsers-DftYMnlk.js +3 -0
- package/src/assets/web-panel/assets/{pickAttrs-DxUtFOOQ.js → pickAttrs-B3f1sg_2.js} +1 -1
- package/src/assets/web-panel/assets/{placementArrow-Btzjn1hK.js → placementArrow-CB3ISXbH.js} +1 -1
- package/src/assets/web-panel/assets/{responsiveObserve-DYcoe1XJ.js → responsiveObserve-BhRD48Wz.js} +1 -1
- package/src/assets/web-panel/assets/{slide-BiBewdr4.js → slide-B4qkLP8K.js} +1 -1
- package/src/assets/web-panel/assets/{statusUtils-D9vt0dkG.js → statusUtils-KfItOu2F.js} +1 -1
- package/src/assets/web-panel/assets/{styleChecker-BXsm_vG0.js → styleChecker-BeLQUf-Z.js} +1 -1
- package/src/assets/web-panel/assets/{useFlexGapSupport-CIG8zET4.js → useFlexGapSupport-CPIJfd28.js} +1 -1
- package/src/assets/web-panel/assets/{useFs-ChFPF8GI.js → useFs-CUBjOVdy.js} +1 -1
- package/src/assets/web-panel/assets/{usePersonalDataHub-D4CzWJhY.js → usePersonalDataHub-DEKScTxs.js} +1 -1
- package/src/assets/web-panel/assets/{vnode-6V5tphk5.js → vnode-DhNnfLeH.js} +1 -1
- package/src/assets/web-panel/assets/{zoom-B2H_VwfU.js → zoom-D5rdpCyb.js} +1 -1
- package/src/assets/web-panel/index.html +1 -1
- package/src/command-help-index.json +1 -1
- package/src/commands/llm.js +45 -0
- package/src/commands/setup.js +100 -47
- package/src/data/changelog.json +13 -0
- package/src/gateways/ws/message-dispatcher.js +68 -0
- package/src/lib/config-manager.js +23 -5
- package/src/lib/config-schema.js +10 -5
- package/src/lib/evolution/evolution-file-witness.js +65 -2
- package/src/lib/evolution/evolution-ledger-file-backend.js +18 -1
- package/src/lib/evolution/evolution-ledger-manifest-witness-adapter.js +22 -0
- package/src/lib/evolution/evolution-ledger-v2-journal.js +11 -0
- package/src/lib/evolution/evolution-ledger-v2-manifest-backend.js +19 -1
- package/src/lib/evolution/rrsi-observed-text-index.js +45 -3
- package/src/lib/evolution/rrsi-tenant-index-anchor-history.js +10 -0
- package/src/lib/lk-account-api.cjs +233 -0
- package/src/lib/lk-account.js +20 -0
- package/src/lib/lk-model-catalog.json +1388 -0
- package/src/lib/llm-channel-presets.js +92 -0
- package/src/lib/llm-connection-config.js +105 -19
- package/src/assets/web-panel/assets/Providers-CpAXh_6c.css +0 -1
- package/src/assets/web-panel/assets/Providers-q9dSBLsP.js +0 -1
- package/src/assets/web-panel/assets/index-CLafGdQC.js +0 -1
- package/src/assets/web-panel/assets/index-DYHw3Xoi.js +0 -1
- package/src/assets/web-panel/assets/parsers-YNLm7sQ0.js +0 -4
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { types as utilTypes } from "node:util";
|
|
2
|
+
import {
|
|
3
|
+
captureEvolutionFileWitnessDirectoryBoundaries,
|
|
4
|
+
hasEvolutionFileWitnessDirectoryBoundaries,
|
|
5
|
+
} from "./evolution-file-witness.js";
|
|
2
6
|
|
|
3
7
|
import { EVOLUTION_LEDGER_WITNESS_SCHEMA } from "./evolution-ledger.js";
|
|
4
8
|
import {
|
|
@@ -22,6 +26,7 @@ export const EVOLUTION_LEDGER_MANIFEST_WITNESS_COMMIT_UNKNOWN_CODE =
|
|
|
22
26
|
|
|
23
27
|
const DIGEST = /^sha256:[a-f0-9]{64}$/u;
|
|
24
28
|
const ADAPTERS = new WeakSet();
|
|
29
|
+
const ORIGINAL_WITNESSES = new WeakMap();
|
|
25
30
|
const CONFIG_KEYS = new Set(["descriptor", "manifestAuthority", "witness"]);
|
|
26
31
|
const DESCRIPTOR_KEYS = new Set([
|
|
27
32
|
"epoch",
|
|
@@ -523,6 +528,7 @@ export function createEvolutionLedgerManifestWitnessAdapter(
|
|
|
523
528
|
},
|
|
524
529
|
});
|
|
525
530
|
ADAPTERS.add(adapter);
|
|
531
|
+
ORIGINAL_WITNESSES.set(adapter, data(fields, "witness"));
|
|
526
532
|
return adapter;
|
|
527
533
|
}
|
|
528
534
|
|
|
@@ -552,3 +558,19 @@ export function captureEvolutionLedgerManifestWitnessAdapter(
|
|
|
552
558
|
}
|
|
553
559
|
return value;
|
|
554
560
|
}
|
|
561
|
+
|
|
562
|
+
export function hasEvolutionLedgerManifestWitnessDirectoryBoundaries(value) {
|
|
563
|
+
return hasEvolutionFileWitnessDirectoryBoundaries(
|
|
564
|
+
ORIGINAL_WITNESSES.get(value),
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export function captureEvolutionLedgerManifestWitnessDirectoryBoundaries(
|
|
569
|
+
value,
|
|
570
|
+
) {
|
|
571
|
+
if (arguments.length !== 1 || !ORIGINAL_WITNESSES.has(value))
|
|
572
|
+
throw new TypeError("one original manifest witness adapter is required");
|
|
573
|
+
return captureEvolutionFileWitnessDirectoryBoundaries(
|
|
574
|
+
ORIGINAL_WITNESSES.get(value),
|
|
575
|
+
);
|
|
576
|
+
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
captureEvolutionLedgerV2ManifestBackend,
|
|
15
15
|
captureEvolutionLedgerV2ManifestDirectoryBoundaries,
|
|
16
|
+
captureEvolutionLedgerV2ManifestWitnessDirectoryBoundaries,
|
|
16
17
|
hasEvolutionLedgerV2ManifestDirectoryBoundaries,
|
|
17
18
|
} from "./evolution-ledger-v2-manifest-backend.js";
|
|
18
19
|
|
|
@@ -539,6 +540,16 @@ export function captureEvolutionLedgerV2JournalManifestDirectoryBoundaries(
|
|
|
539
540
|
return captureEvolutionLedgerV2ManifestDirectoryBoundaries(backend);
|
|
540
541
|
}
|
|
541
542
|
|
|
543
|
+
export function captureEvolutionLedgerV2JournalWitnessDirectoryBoundaries(
|
|
544
|
+
value,
|
|
545
|
+
) {
|
|
546
|
+
if (arguments.length !== 1 || !MANIFEST_BACKENDS.has(value))
|
|
547
|
+
throw new TypeError("one original v2 journal is required");
|
|
548
|
+
return captureEvolutionLedgerV2ManifestWitnessDirectoryBoundaries(
|
|
549
|
+
MANIFEST_BACKENDS.get(value),
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
|
|
542
553
|
export function isEvolutionLedgerV2Journal(value) {
|
|
543
554
|
return JOURNALS.has(value);
|
|
544
555
|
}
|
|
@@ -19,7 +19,11 @@ import {
|
|
|
19
19
|
captureEvolutionLedgerManifestCatalogDirectoryBoundary,
|
|
20
20
|
hasEvolutionLedgerManifestCatalogDirectoryBoundary,
|
|
21
21
|
} from "./evolution-ledger-manifest-catalog.js";
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
captureEvolutionLedgerManifestWitnessAdapter,
|
|
24
|
+
captureEvolutionLedgerManifestWitnessDirectoryBoundaries,
|
|
25
|
+
hasEvolutionLedgerManifestWitnessDirectoryBoundaries,
|
|
26
|
+
} from "./evolution-ledger-manifest-witness-adapter.js";
|
|
23
27
|
|
|
24
28
|
export const EVOLUTION_LEDGER_V2_MANIFEST_BACKEND_SCHEMA =
|
|
25
29
|
"chainlesschain.evolution-ledger-v2-manifest-backend/v2";
|
|
@@ -614,6 +618,7 @@ export function createEvolutionLedgerV2ManifestBackend(options = undefined) {
|
|
|
614
618
|
ORIGINAL_MANIFEST_COMPONENTS.set(backend, {
|
|
615
619
|
catalog,
|
|
616
620
|
headStore,
|
|
621
|
+
witnessAdapter,
|
|
617
622
|
boundaries: null,
|
|
618
623
|
});
|
|
619
624
|
return backend;
|
|
@@ -643,6 +648,19 @@ export function captureEvolutionLedgerV2ManifestDirectoryBoundaries(value) {
|
|
|
643
648
|
return components.boundaries;
|
|
644
649
|
}
|
|
645
650
|
|
|
651
|
+
export function captureEvolutionLedgerV2ManifestWitnessDirectoryBoundaries(
|
|
652
|
+
value,
|
|
653
|
+
) {
|
|
654
|
+
if (arguments.length !== 1 || !ORIGINAL_MANIFEST_COMPONENTS.has(value))
|
|
655
|
+
throw new TypeError("one original v2 manifest backend is required");
|
|
656
|
+
const { witnessAdapter } = ORIGINAL_MANIFEST_COMPONENTS.get(value);
|
|
657
|
+
if (!hasEvolutionLedgerManifestWitnessDirectoryBoundaries(witnessAdapter))
|
|
658
|
+
return null;
|
|
659
|
+
return captureEvolutionLedgerManifestWitnessDirectoryBoundaries(
|
|
660
|
+
witnessAdapter,
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
646
664
|
export function captureEvolutionLedgerV2ManifestBackend(value) {
|
|
647
665
|
if (!BACKENDS.has(value)) {
|
|
648
666
|
throw new TypeError(
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/** Retained observations and prohibitions, never proof of causal generation. */
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { isProxy } from "node:util/types";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
captureEvolutionLedgerV2JournalManifestDirectoryBoundaries,
|
|
6
|
+
captureEvolutionLedgerV2JournalWitnessDirectoryBoundaries,
|
|
7
|
+
} from "./evolution-ledger-v2-journal.js";
|
|
5
8
|
import { captureRrsiRegistryStorePolicy } from "./rrsi-registry-store-policy.js";
|
|
6
9
|
import {
|
|
7
10
|
captureEvolutionLedgerFileBackend,
|
|
8
11
|
captureEvolutionLedgerFileBackendSourceDirectoryBoundary,
|
|
12
|
+
captureEvolutionLedgerFileBackendWitnessDirectoryBoundaries,
|
|
9
13
|
} from "./evolution-ledger-file-backend.js";
|
|
10
14
|
import {
|
|
11
15
|
EvolutionArtifactPorts,
|
|
@@ -606,7 +610,13 @@ export function createRrsiObservedTextIndex(input) {
|
|
|
606
610
|
)
|
|
607
611
|
hold("preparation declaration reference differs");
|
|
608
612
|
}
|
|
609
|
-
function load(
|
|
613
|
+
function load(
|
|
614
|
+
manifestBoundaries = null,
|
|
615
|
+
witnessBoundary = null,
|
|
616
|
+
manifestWitnessBoundary = null,
|
|
617
|
+
) {
|
|
618
|
+
witnessBoundary?.recheck();
|
|
619
|
+
manifestWitnessBoundary?.recheck();
|
|
610
620
|
manifestBoundaries?.catalog.recheck();
|
|
611
621
|
manifestBoundaries?.head.recheck();
|
|
612
622
|
sourceJournalBoundary.recheck();
|
|
@@ -699,6 +709,8 @@ export function createRrsiObservedTextIndex(input) {
|
|
|
699
709
|
sourceJournalBoundary.recheck();
|
|
700
710
|
manifestBoundaries?.head.recheck();
|
|
701
711
|
manifestBoundaries?.catalog.recheck();
|
|
712
|
+
witnessBoundary?.recheck();
|
|
713
|
+
manifestWitnessBoundary?.recheck();
|
|
702
714
|
return { head: before, events, records, entries, operations };
|
|
703
715
|
}
|
|
704
716
|
function historyPrefix(state, checkpoint) {
|
|
@@ -759,13 +771,31 @@ export function createRrsiObservedTextIndex(input) {
|
|
|
759
771
|
hold("observed history requires at most two checkpoints");
|
|
760
772
|
const manifestBoundaries =
|
|
761
773
|
captureEvolutionLedgerV2JournalManifestDirectoryBoundaries(ledger);
|
|
774
|
+
const witnessBoundary =
|
|
775
|
+
captureEvolutionLedgerFileBackendWitnessDirectoryBoundaries(backend);
|
|
776
|
+
const sourceWitnessDirectoryBoundaryDigest = rrsiHash(
|
|
777
|
+
"chainlesschain.rrsi-source-witness-directory-boundaries/v1",
|
|
778
|
+
witnessBoundary.descriptor,
|
|
779
|
+
);
|
|
780
|
+
const manifestWitnessBoundary =
|
|
781
|
+
captureEvolutionLedgerV2JournalWitnessDirectoryBoundaries(ledger);
|
|
782
|
+
const manifestWitnessDirectoryBoundaryDigest = manifestWitnessBoundary
|
|
783
|
+
? rrsiHash(
|
|
784
|
+
"chainlesschain.rrsi-manifest-witness-directory-boundaries/v1",
|
|
785
|
+
manifestWitnessBoundary.descriptor,
|
|
786
|
+
)
|
|
787
|
+
: null;
|
|
762
788
|
const manifestDirectoryBoundaryDigest = manifestBoundaries
|
|
763
789
|
? rrsiHash("chainlesschain.rrsi-manifest-directory-boundaries/v1", {
|
|
764
790
|
catalog: manifestBoundaries.catalog.descriptor,
|
|
765
791
|
head: manifestBoundaries.head.descriptor,
|
|
766
792
|
})
|
|
767
793
|
: null;
|
|
768
|
-
const state = load(
|
|
794
|
+
const state = load(
|
|
795
|
+
manifestBoundaries,
|
|
796
|
+
witnessBoundary,
|
|
797
|
+
manifestWitnessBoundary,
|
|
798
|
+
);
|
|
769
799
|
// Anchor v1 cannot represent the genuine null digest at sequence zero.
|
|
770
800
|
// Fresh v2 migration events are included in this nonempty event prefix.
|
|
771
801
|
const current = historyPrefix(state, state.head);
|
|
@@ -810,6 +840,14 @@ export function createRrsiObservedTextIndex(input) {
|
|
|
810
840
|
manifestBoundaryScope: manifestBoundaries
|
|
811
841
|
? "original-catalog-and-head-directories"
|
|
812
842
|
: null,
|
|
843
|
+
sourceWitnessDirectoryBoundaryDigest,
|
|
844
|
+
sourceWitnessDirectoryBoundaryRechecked: true,
|
|
845
|
+
sourceWitnessBoundaryScope: witnessBoundary.descriptor.scope,
|
|
846
|
+
manifestWitnessDirectoryBoundaryDigest,
|
|
847
|
+
manifestWitnessDirectoryBoundaryRechecked:
|
|
848
|
+
manifestWitnessBoundary !== null,
|
|
849
|
+
manifestWitnessBoundaryScope:
|
|
850
|
+
manifestWitnessBoundary?.descriptor.scope ?? null,
|
|
813
851
|
fullPhysicalStorageGraphVerified: false,
|
|
814
852
|
tenantWideIndexAuthorityVerified: false,
|
|
815
853
|
generationProvenanceVerified: false,
|
|
@@ -819,6 +857,8 @@ export function createRrsiObservedTextIndex(input) {
|
|
|
819
857
|
);
|
|
820
858
|
const recheck = () =>
|
|
821
859
|
guarded(() => {
|
|
860
|
+
witnessBoundary.recheck();
|
|
861
|
+
manifestWitnessBoundary?.recheck();
|
|
822
862
|
manifestBoundaries?.catalog.recheck();
|
|
823
863
|
manifestBoundaries?.head.recheck();
|
|
824
864
|
sourceJournalBoundary.recheck();
|
|
@@ -829,6 +869,8 @@ export function createRrsiObservedTextIndex(input) {
|
|
|
829
869
|
sourceJournalBoundary.recheck();
|
|
830
870
|
manifestBoundaries?.head.recheck();
|
|
831
871
|
manifestBoundaries?.catalog.recheck();
|
|
872
|
+
witnessBoundary.recheck();
|
|
873
|
+
manifestWitnessBoundary?.recheck();
|
|
832
874
|
return true;
|
|
833
875
|
});
|
|
834
876
|
recheck();
|
|
@@ -142,6 +142,16 @@ export function verifyRrsiTenantIndexAnchorHistory(input) {
|
|
|
142
142
|
manifestDirectoryBoundaryRechecked:
|
|
143
143
|
snapshot.manifestDirectoryBoundaryRechecked,
|
|
144
144
|
manifestBoundaryScope: snapshot.manifestBoundaryScope,
|
|
145
|
+
sourceWitnessDirectoryBoundaryDigest:
|
|
146
|
+
snapshot.sourceWitnessDirectoryBoundaryDigest,
|
|
147
|
+
sourceWitnessDirectoryBoundaryRechecked:
|
|
148
|
+
snapshot.sourceWitnessDirectoryBoundaryRechecked,
|
|
149
|
+
sourceWitnessBoundaryScope: snapshot.sourceWitnessBoundaryScope,
|
|
150
|
+
manifestWitnessDirectoryBoundaryDigest:
|
|
151
|
+
snapshot.manifestWitnessDirectoryBoundaryDigest,
|
|
152
|
+
manifestWitnessDirectoryBoundaryRechecked:
|
|
153
|
+
snapshot.manifestWitnessDirectoryBoundaryRechecked,
|
|
154
|
+
manifestWitnessBoundaryScope: snapshot.manifestWitnessBoundaryScope,
|
|
145
155
|
previous: snapshot.prefixes[0],
|
|
146
156
|
current: snapshot.current,
|
|
147
157
|
signaturesVerifiedRelativeToExplicitKey: true,
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Canonical LK read-only account API; desktop copy is generated by sync-lk-ide-presets.mjs.
|
|
2
|
+
const number = (value) =>
|
|
3
|
+
typeof value === "number" && Number.isFinite(value) && value >= 0
|
|
4
|
+
? value
|
|
5
|
+
: null;
|
|
6
|
+
const text = (value) =>
|
|
7
|
+
typeof value === "string" ? value.slice(0, 256) : null;
|
|
8
|
+
const counts = (row = {}) =>
|
|
9
|
+
Object.fromEntries(
|
|
10
|
+
[
|
|
11
|
+
"cost",
|
|
12
|
+
"count",
|
|
13
|
+
"success_count",
|
|
14
|
+
"failed_count",
|
|
15
|
+
"refunded_count",
|
|
16
|
+
"refunded_cost",
|
|
17
|
+
].map((key) => [key, number(row[key])]),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
/** Explicit schemas prevent upstream account metadata or credentials reaching UIs. */
|
|
21
|
+
function normalizeLkAccountPart(kind, data) {
|
|
22
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
23
|
+
throw new Error("Invalid account response");
|
|
24
|
+
if (kind === "balance") {
|
|
25
|
+
if (number(data.balance) === null || data.unit !== "算力")
|
|
26
|
+
throw new Error("Invalid balance response");
|
|
27
|
+
const quota = data.api_key_quota || {};
|
|
28
|
+
return {
|
|
29
|
+
balance: number(data.balance),
|
|
30
|
+
unit: "算力",
|
|
31
|
+
quota: {
|
|
32
|
+
used: number(quota.used),
|
|
33
|
+
limit: number(quota.limit),
|
|
34
|
+
remaining: quota.limit === 0 ? null : number(quota.remaining),
|
|
35
|
+
unlimited: quota.limit === 0,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (kind === "usage") {
|
|
40
|
+
if (!Array.isArray(data.by_model) || data.unit !== "算力")
|
|
41
|
+
throw new Error("Invalid usage response");
|
|
42
|
+
return {
|
|
43
|
+
from: text(data.from),
|
|
44
|
+
to: text(data.to),
|
|
45
|
+
unit: "算力",
|
|
46
|
+
scope: text(data.scope),
|
|
47
|
+
total: counts(data.grand_total),
|
|
48
|
+
models: data.by_model.slice(0, 1000).map((row) => ({
|
|
49
|
+
model: text(row.model),
|
|
50
|
+
type: text(row.model_type),
|
|
51
|
+
...counts(row),
|
|
52
|
+
})),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (kind === "records") {
|
|
56
|
+
if (!Array.isArray(data.records) || data.unit !== "算力")
|
|
57
|
+
throw new Error("Invalid billing response");
|
|
58
|
+
return {
|
|
59
|
+
total: number(data.total),
|
|
60
|
+
limit: number(data.limit),
|
|
61
|
+
offset: number(data.offset),
|
|
62
|
+
rows: data.records.slice(0, 200).map((row) => ({
|
|
63
|
+
taskId: text(String(row.task_id ?? "")),
|
|
64
|
+
model: text(row.model),
|
|
65
|
+
group: text(row.channel_group),
|
|
66
|
+
state: text(row.state),
|
|
67
|
+
cost: number(row.cost),
|
|
68
|
+
refunded: row.refunded === true,
|
|
69
|
+
refundedAmount: number(row.refunded_amount),
|
|
70
|
+
createdAt: text(row.created_at),
|
|
71
|
+
completedAt: text(row.completed_at),
|
|
72
|
+
})),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (kind === "pricing") {
|
|
76
|
+
if (!Array.isArray(data.channel_groups))
|
|
77
|
+
throw new Error("Invalid pricing response");
|
|
78
|
+
return {
|
|
79
|
+
model: text(data.name),
|
|
80
|
+
available:
|
|
81
|
+
typeof data.available_for_this_key === "boolean"
|
|
82
|
+
? data.available_for_this_key
|
|
83
|
+
: null,
|
|
84
|
+
unit: "算力",
|
|
85
|
+
tokenDivisor: 1000000,
|
|
86
|
+
groups: data.channel_groups.slice(0, 200).map((row) => ({
|
|
87
|
+
name: text(row.group_name),
|
|
88
|
+
active: row.is_active === true,
|
|
89
|
+
allowed:
|
|
90
|
+
data.available_for_this_key !== false &&
|
|
91
|
+
row.in_key_whitelist === true &&
|
|
92
|
+
row.excluded_for_this_key !== true,
|
|
93
|
+
billingMethod: text(row.billing_method),
|
|
94
|
+
basePrice: number(row.base_price),
|
|
95
|
+
inputPerMillion: number(row.input_token_price),
|
|
96
|
+
outputPerMillion: number(row.output_token_price),
|
|
97
|
+
discount: number(row.current_time_discount),
|
|
98
|
+
})),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
throw new Error("Unknown account response");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function getJson(fetchImpl, origin, path, apiKey) {
|
|
105
|
+
const response = await fetchImpl(origin + path, {
|
|
106
|
+
headers: { Authorization: `Bearer ${apiKey}`, Accept: "application/json" },
|
|
107
|
+
signal: AbortSignal.timeout(12000),
|
|
108
|
+
redirect: "error",
|
|
109
|
+
});
|
|
110
|
+
if (!response.ok) throw new Error("Account request failed");
|
|
111
|
+
// Bound decoded bytes too; Content-Length may be absent or compressed.
|
|
112
|
+
const reader = response.body.getReader();
|
|
113
|
+
const chunks = [];
|
|
114
|
+
let length = 0;
|
|
115
|
+
try {
|
|
116
|
+
for (;;) {
|
|
117
|
+
const { done, value } = await reader.read();
|
|
118
|
+
if (done) break;
|
|
119
|
+
length += value.byteLength;
|
|
120
|
+
if (length > 2 * 1024 * 1024)
|
|
121
|
+
throw new Error("Account response too large");
|
|
122
|
+
chunks.push(value);
|
|
123
|
+
}
|
|
124
|
+
} finally {
|
|
125
|
+
await reader.cancel().catch(() => {});
|
|
126
|
+
}
|
|
127
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Read-only, fresh account queries. No disk cache and no generic provider env keys. */
|
|
131
|
+
async function fetchLkAccount(
|
|
132
|
+
connection,
|
|
133
|
+
options = {},
|
|
134
|
+
{ fetcher = fetch } = {},
|
|
135
|
+
) {
|
|
136
|
+
const days = Number(options.days ?? 1);
|
|
137
|
+
const limit = Number(options.limit ?? 20);
|
|
138
|
+
const offset = Number(options.offset ?? 0);
|
|
139
|
+
const scope = options.scope ?? "key";
|
|
140
|
+
if (
|
|
141
|
+
!Number.isInteger(days) ||
|
|
142
|
+
days < 1 ||
|
|
143
|
+
days > 30 ||
|
|
144
|
+
!Number.isInteger(limit) ||
|
|
145
|
+
limit < 1 ||
|
|
146
|
+
limit > 200 ||
|
|
147
|
+
!Number.isSafeInteger(offset) ||
|
|
148
|
+
offset < 0 ||
|
|
149
|
+
!["key", "user"].includes(scope)
|
|
150
|
+
)
|
|
151
|
+
throw new Error(
|
|
152
|
+
"Use days 1–30, limit 1–200, nonnegative offset and scope key/user",
|
|
153
|
+
);
|
|
154
|
+
if (
|
|
155
|
+
!connection ||
|
|
156
|
+
!/^https:\/\/api\.lk(?:888|666)\.ai\/(?:v1|v1beta)\/?$/.test(
|
|
157
|
+
connection.baseUrl || "",
|
|
158
|
+
) ||
|
|
159
|
+
!connection.apiKey
|
|
160
|
+
)
|
|
161
|
+
throw new Error("An LK connection with its own API key is required");
|
|
162
|
+
const model = options.model ?? connection.model;
|
|
163
|
+
if (
|
|
164
|
+
typeof model !== "string" ||
|
|
165
|
+
!model.trim() ||
|
|
166
|
+
model.length > 256 ||
|
|
167
|
+
/[\r\n\0]/.test(model)
|
|
168
|
+
)
|
|
169
|
+
throw new Error("A valid pricing model is required");
|
|
170
|
+
const origin = new URL(connection.baseUrl).origin;
|
|
171
|
+
const query = new URLSearchParams({ days: String(days), scope });
|
|
172
|
+
const requests = {
|
|
173
|
+
balance: "/v1/skills/balance",
|
|
174
|
+
usage: `/v1/skills/usage?${query}`,
|
|
175
|
+
records: `/v1/skills/usage?${query}&detail=1&limit=${limit}&offset=${offset}`,
|
|
176
|
+
pricing: `/v1/skills/models/${encodeURIComponent(model)}/pricing`,
|
|
177
|
+
};
|
|
178
|
+
const result = {
|
|
179
|
+
channel: "lk",
|
|
180
|
+
origin,
|
|
181
|
+
model,
|
|
182
|
+
days,
|
|
183
|
+
scope,
|
|
184
|
+
fetchedAt: new Date().toISOString(),
|
|
185
|
+
unit: "算力",
|
|
186
|
+
errors: {},
|
|
187
|
+
};
|
|
188
|
+
await Promise.all(
|
|
189
|
+
Object.entries(requests).map(async ([kind, path]) => {
|
|
190
|
+
try {
|
|
191
|
+
result[kind] = normalizeLkAccountPart(
|
|
192
|
+
kind,
|
|
193
|
+
await getJson(fetcher, origin, path, connection.apiKey),
|
|
194
|
+
);
|
|
195
|
+
} catch {
|
|
196
|
+
result[kind] = null;
|
|
197
|
+
result.errors[kind] = "查询失败,请检查 Key 权限或稍后刷新";
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
);
|
|
201
|
+
result.partial = Object.keys(result.errors).length > 0;
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function formatLkAccount(result) {
|
|
206
|
+
const quota = result.balance?.quota;
|
|
207
|
+
return [
|
|
208
|
+
`LK 账户 · ${result.fetchedAt} · ${result.origin}`,
|
|
209
|
+
`账户余额:${result.balance?.balance ?? "未知"} 算力`,
|
|
210
|
+
`Key 已用:${quota?.used ?? "未知"};剩余额度:${quota?.unlimited ? "不限额" : (quota?.remaining ?? "未知")} 算力`,
|
|
211
|
+
`最近 ${result.days} 天 API ${result.scope === "user" ? "全部 Key" : "当前 Key"} 实扣:${result.usage?.total?.cost ?? "未知"} 算力`,
|
|
212
|
+
`动态价格(${result.model},算力/百万 Token):`,
|
|
213
|
+
...(result.pricing?.available === false
|
|
214
|
+
? ["当前 Key 无此模型权限;价格仅供参考。"]
|
|
215
|
+
: []),
|
|
216
|
+
...(result.pricing?.groups || []).map(
|
|
217
|
+
(row) =>
|
|
218
|
+
` ${row.name}: ${row.billingMethod === "按token" ? `输入 ${row.inputPerMillion ?? "未知"} / 输出 ${row.outputPerMillion ?? "未知"}` : `基础价 ${row.basePrice ?? "未知"}`} · ${row.billingMethod} · ${row.active ? "启用" : "停用"} · ${row.allowed ? "Key 可用" : "Key 不可用"}`,
|
|
219
|
+
),
|
|
220
|
+
"账单记录(平台实扣;运行中可能仍为预扣;退款已计入金额):",
|
|
221
|
+
...(result.records?.rows || []).map(
|
|
222
|
+
(row) =>
|
|
223
|
+
` ${row.taskId} ${row.model} ${row.state} ${row.cost ?? "未知"} 算力${row.refunded ? ` · 已退款 ${row.refundedAmount ?? "未知"}` : ""}`,
|
|
224
|
+
),
|
|
225
|
+
`记录 ${result.records?.offset ?? 0} 起 / 共 ${result.records?.total ?? "未知"} 条;--offset 翻页。`,
|
|
226
|
+
"价格含当前时段折扣;实际路由分组以账单为准。账单不返回 Token 数,不能自动对应本地单次请求。金额保留四位,小额显示 0 不代表免费。算力不自动折算充值现金成本。",
|
|
227
|
+
...Object.entries(result.errors || {}).map(
|
|
228
|
+
([kind, error]) => `${kind}: ${error}`,
|
|
229
|
+
),
|
|
230
|
+
].join("\n");
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
module.exports = { normalizeLkAccountPart, fetchLkAccount, formatLkAccount };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { loadConfig } from "./config-manager.js";
|
|
2
|
+
import { isLkEndpoint } from "./llm-channel-presets.js";
|
|
3
|
+
import { resolveLlmConnection } from "./llm-connection-resolution.js";
|
|
4
|
+
import api from "./lk-account-api.cjs";
|
|
5
|
+
export const { normalizeLkAccountPart, formatLkAccount } = api;
|
|
6
|
+
export async function queryLkAccount(
|
|
7
|
+
options = {},
|
|
8
|
+
{ config, fetcher = fetch } = {},
|
|
9
|
+
) {
|
|
10
|
+
const current = (config ?? loadConfig({ failIfUnavailable: true })).llm || {};
|
|
11
|
+
if (
|
|
12
|
+
!isLkEndpoint(current.baseUrl) ||
|
|
13
|
+
!["custom", "openai", "anthropic", "gemini"].includes(current.provider)
|
|
14
|
+
)
|
|
15
|
+
throw new Error("Save an LK connection before querying its account");
|
|
16
|
+
const connection = resolveLlmConnection({}, [current], { env: {} });
|
|
17
|
+
if (!connection.apiKey)
|
|
18
|
+
throw new Error("The saved LK connection requires an API key");
|
|
19
|
+
return api.fetchLkAccount(connection, options, { fetcher });
|
|
20
|
+
}
|