@juli-os/ledger 0.1.3 → 0.1.4
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/index.js +49 -65
- package/dist/juli-ledger.js +49 -61
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -118,10 +118,6 @@ var withOriginal = (cf, o, now) => ({
|
|
|
118
118
|
...cf,
|
|
119
119
|
original: {
|
|
120
120
|
from: o.from,
|
|
121
|
-
// Sender display name (RFC2047-decoded) — recorded into the case file with
|
|
122
|
-
// the original message after the 2026-10-01 Chen Lijun hallucination
|
|
123
|
-
// incident: the legitimate source for reply salutations, so the agent is no
|
|
124
|
-
// longer forced to invent a name from the address.
|
|
125
121
|
...o.fromName !== void 0 && o.fromName !== "" ? { from_name: o.fromName } : {},
|
|
126
122
|
subject: o.subject,
|
|
127
123
|
body: o.body,
|
|
@@ -599,11 +595,9 @@ var createLedgerStore = (dbPath, deps = {}) => {
|
|
|
599
595
|
};
|
|
600
596
|
},
|
|
601
597
|
activeRunForSession: (session) => activeRunOf(session),
|
|
602
|
-
/**
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
* "literal backslash + any character", the pattern never matches — and
|
|
606
|
-
* dedup fails wholesale (09-07 incident). */
|
|
598
|
+
/** 活跃去重:同 dedup_key 且工作流仍在途 → 跳过重复建流。
|
|
599
|
+
* ⚠ ESCAPE '\' 必须与转义成对:message-id 几乎必含 `_`,漏写 ESCAPE 时
|
|
600
|
+
* `\_` 成了"字面反斜杠+任意字符",模式永不匹配——去重整体失效(09-07 事故)。 */
|
|
607
601
|
hasActiveDedup(key) {
|
|
608
602
|
const r = db.prepare(
|
|
609
603
|
`SELECT 1 FROM workflows WHERE status IN (${sqlInList(DEDUP_WINDOW_STATUSES)})
|
|
@@ -611,10 +605,8 @@ var createLedgerStore = (dbPath, deps = {}) => {
|
|
|
611
605
|
).get(dedupPattern(key));
|
|
612
606
|
return r !== void 0;
|
|
613
607
|
},
|
|
614
|
-
/**
|
|
615
|
-
*
|
|
616
|
-
* polling won't fetch it again. Retries go through step retry, not
|
|
617
|
-
* re-ingestion. */
|
|
608
|
+
/** 已摄取去重(轮询层):同 dedup_key 存在任何非 rejected 工作流 → 这封
|
|
609
|
+
* 邮件已被处理过(含 failed),轮询不再重复拉取。重试走步骤 retry,不走再摄取。 */
|
|
618
610
|
hasSeenDedup(key) {
|
|
619
611
|
const r = db.prepare(
|
|
620
612
|
`SELECT 1 FROM workflows WHERE status != 'rejected'
|
|
@@ -622,14 +614,11 @@ var createLedgerStore = (dbPath, deps = {}) => {
|
|
|
622
614
|
).get(dedupPattern(key));
|
|
623
615
|
return r !== void 0;
|
|
624
616
|
},
|
|
625
|
-
/**
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
* exact comparison: JSON-encode to the actually stored bytes; %/_/\ are
|
|
631
|
-
* escaped in pairs like dedupPattern (a message-id almost always contains
|
|
632
|
-
* `_`). */
|
|
617
|
+
/** 自回环守卫查询(2026-09-20 断点十三):message_id 是否命中本引擎已
|
|
618
|
+
* 发送记录——completed send 步的 output.message_id(email_sent 事件同源
|
|
619
|
+
* 落账)。进件层据此丢弃投递副本回灌(引擎给轮询邮箱自己发信的 echo)。
|
|
620
|
+
* LIKE 预筛 + 精确比对:JSON 编码取实际存储字节,%/_/\ 照 dedupPattern
|
|
621
|
+
* 成对转义(message-id 几乎必含 `_`)。 */
|
|
633
622
|
recordSentMessageId(messageId, meta) {
|
|
634
623
|
if (messageId === "") return;
|
|
635
624
|
db.prepare(
|
|
@@ -741,61 +730,59 @@ var PRICING_SOURCE = "https://docs.bigmodel.cn/cn/guide/start/pricing";
|
|
|
741
730
|
var PRICING_RETRIEVED_AT = "2026-10-06";
|
|
742
731
|
var K32 = 32e3;
|
|
743
732
|
var K200 = 200;
|
|
744
|
-
var flat = (input, cache, output, note = "
|
|
733
|
+
var flat = (input, cache, output, note = "\u7EDF\u4E00\u4EF7") => ({ when: {}, input, cache, output, note });
|
|
745
734
|
var BIGMODEL_PRICES = [
|
|
746
|
-
// ---- Flagship ----
|
|
747
735
|
{ id: "glm-5.3", label: "GLM-5.3", tiers: [flat(8, 2, 28)] },
|
|
748
736
|
{ id: "glm-5.3-flash", label: "GLM-5.3-Flash", tiers: [flat(0.8, 0.23, 2.8)] },
|
|
749
737
|
{ id: "glm-5.3-flashx", label: "GLM-5.3-FlashX", tiers: [flat(2, 0.57, 7)] },
|
|
750
|
-
// ---- Text ----
|
|
751
738
|
{ id: "glm-5.2", label: "GLM-5.2", tiers: [flat(8, 2, 28)] },
|
|
752
739
|
{
|
|
753
740
|
id: "glm-5.1",
|
|
754
741
|
label: "GLM-5.1",
|
|
755
742
|
tiers: [
|
|
756
|
-
{ when: { inputLt: K32 }, input: 6, cache: 1.3, output: 24, note: "
|
|
757
|
-
{ when: { inputGte: K32 }, input: 8, cache: 2, output: 28, note: "
|
|
743
|
+
{ when: { inputLt: K32 }, input: 6, cache: 1.3, output: 24, note: "\u5165<32K" },
|
|
744
|
+
{ when: { inputGte: K32 }, input: 8, cache: 2, output: 28, note: "\u5165\u226532K" }
|
|
758
745
|
]
|
|
759
746
|
},
|
|
760
747
|
{
|
|
761
748
|
id: "glm-5-turbo",
|
|
762
749
|
label: "GLM-5-Turbo",
|
|
763
750
|
tiers: [
|
|
764
|
-
{ when: { inputLt: K32 }, input: 5, cache: 1.2, output: 22, note: "
|
|
765
|
-
{ when: { inputGte: K32 }, input: 7, cache: 1.8, output: 26, note: "
|
|
751
|
+
{ when: { inputLt: K32 }, input: 5, cache: 1.2, output: 22, note: "\u5165<32K" },
|
|
752
|
+
{ when: { inputGte: K32 }, input: 7, cache: 1.8, output: 26, note: "\u5165\u226532K" }
|
|
766
753
|
]
|
|
767
754
|
},
|
|
768
755
|
{
|
|
769
756
|
id: "glm-5",
|
|
770
757
|
label: "GLM-5",
|
|
771
758
|
tiers: [
|
|
772
|
-
{ when: { inputLt: K32 }, input: 4, cache: 1, output: 18, note: "
|
|
773
|
-
{ when: { inputGte: K32 }, input: 6, cache: 1.5, output: 22, note: "
|
|
759
|
+
{ when: { inputLt: K32 }, input: 4, cache: 1, output: 18, note: "\u5165<32K" },
|
|
760
|
+
{ when: { inputGte: K32 }, input: 6, cache: 1.5, output: 22, note: "\u5165\u226532K" }
|
|
774
761
|
]
|
|
775
762
|
},
|
|
776
763
|
{
|
|
777
764
|
id: "glm-4.7",
|
|
778
765
|
label: "GLM-4.7",
|
|
779
766
|
tiers: [
|
|
780
|
-
{ when: { inputLt: K32, outputLt: K200 }, input: 2, cache: 0.4, output: 8, note: "
|
|
781
|
-
{ when: { inputLt: K32, outputGte: K200 }, input: 3, cache: 0.6, output: 14, note: "
|
|
782
|
-
{ when: { inputGte: K32 }, input: 4, cache: 0.8, output: 16, note: "
|
|
767
|
+
{ when: { inputLt: K32, outputLt: K200 }, input: 2, cache: 0.4, output: 8, note: "\u5165<32K\xB7\u51FA<0.2K" },
|
|
768
|
+
{ when: { inputLt: K32, outputGte: K200 }, input: 3, cache: 0.6, output: 14, note: "\u5165<32K\xB7\u51FA\u22650.2K" },
|
|
769
|
+
{ when: { inputGte: K32 }, input: 4, cache: 0.8, output: 16, note: "\u516532K\u2013200K" }
|
|
783
770
|
]
|
|
784
771
|
},
|
|
785
772
|
{
|
|
786
773
|
id: "glm-4.5-air",
|
|
787
774
|
label: "GLM-4.5-Air",
|
|
788
775
|
tiers: [
|
|
789
|
-
{ when: { inputLt: K32, outputLt: K200 }, input: 0.8, cache: 0.16, output: 2, note: "
|
|
790
|
-
{ when: { inputLt: K32, outputGte: K200 }, input: 0.8, cache: 0.16, output: 6, note: "
|
|
791
|
-
{ when: { inputGte: K32 }, input: 1.2, cache: 0.24, output: 8, note: "
|
|
776
|
+
{ when: { inputLt: K32, outputLt: K200 }, input: 0.8, cache: 0.16, output: 2, note: "\u5165<32K\xB7\u51FA<0.2K" },
|
|
777
|
+
{ when: { inputLt: K32, outputGte: K200 }, input: 0.8, cache: 0.16, output: 6, note: "\u5165<32K\xB7\u51FA\u22650.2K" },
|
|
778
|
+
{ when: { inputGte: K32 }, input: 1.2, cache: 0.24, output: 8, note: "\u516532K\u2013128K" }
|
|
792
779
|
]
|
|
793
780
|
},
|
|
794
781
|
{ id: "glm-4.7-flashx", label: "GLM-4.7-FlashX", tiers: [flat(0.5, 0.1, 3)] },
|
|
795
|
-
{ id: "glm-4.7-flash", label: "GLM-4.7-Flash
|
|
782
|
+
{ id: "glm-4.7-flash", label: "GLM-4.7-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, 0, 0, "\u514D\u8D39")] },
|
|
796
783
|
{ id: "glm-4-plus", label: "GLM-4-Plus", tiers: [flat(5, 2.5, 5)] },
|
|
797
784
|
{ id: "glm-4-air-250414", label: "GLM-4-Air-250414", tiers: [flat(0.5, 0.25, 0.5)] },
|
|
798
|
-
{ id: "glm-4-air", label: "GLM-4-Air
|
|
785
|
+
{ id: "glm-4-air", label: "GLM-4-Air\uFF08\u540C 250414 \u7248\u4EF7\uFF09", tiers: [flat(0.5, 0.25, 0.5)] },
|
|
799
786
|
{ id: "glm-4-airx", label: "GLM-4-AirX", tiers: [flat(10, null, 10)] },
|
|
800
787
|
{ id: "glm-4-long", label: "GLM-4-Long", tiers: [flat(1, 0.5, 1)] },
|
|
801
788
|
{ id: "glm-4-assistant", label: "GLM-4-Assistant", tiers: [flat(5, null, 5)] },
|
|
@@ -803,55 +790,53 @@ var BIGMODEL_PRICES = [
|
|
|
803
790
|
{ id: "glm-z1-airx", label: "GLM-Z1-AirX", tiers: [flat(5, null, 5)] },
|
|
804
791
|
{ id: "glm-z1-flashx", label: "GLM-Z1-FlashX", tiers: [flat(0.1, null, 0.1)] },
|
|
805
792
|
{ id: "glm-4-flashx-250414", label: "GLM-4-FlashX-250414", tiers: [flat(0.1, 0.05, 0.1)] },
|
|
806
|
-
{ id: "glm-4-flashx", label: "GLM-4-FlashX
|
|
807
|
-
{ id: "glm-4-flash-250414", label: "GLM-4-Flash-250414
|
|
808
|
-
{ id: "glm-4-flash", label: "GLM-4-Flash
|
|
809
|
-
{ id: "glm-z1-flash", label: "GLM-Z1-Flash
|
|
810
|
-
// ---- Vision ----
|
|
793
|
+
{ id: "glm-4-flashx", label: "GLM-4-FlashX\uFF08\u540C 250414 \u7248\u4EF7\uFF09", tiers: [flat(0.1, 0.05, 0.1)] },
|
|
794
|
+
{ id: "glm-4-flash-250414", label: "GLM-4-Flash-250414\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
795
|
+
{ id: "glm-4-flash", label: "GLM-4-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
796
|
+
{ id: "glm-z1-flash", label: "GLM-Z1-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
811
797
|
{ id: "glm-ocr", label: "GLM-OCR", tiers: [flat(0.2, null, 0.2)] },
|
|
812
798
|
{
|
|
813
799
|
id: "glm-5v-turbo",
|
|
814
800
|
label: "GLM-5V-Turbo",
|
|
815
801
|
tiers: [
|
|
816
|
-
{ when: { inputLt: K32 }, input: 5, cache: 1.2, output: 22, note: "
|
|
817
|
-
{ when: { inputGte: K32 }, input: 7, cache: 1.8, output: 26, note: "
|
|
802
|
+
{ when: { inputLt: K32 }, input: 5, cache: 1.2, output: 22, note: "\u5165<32K" },
|
|
803
|
+
{ when: { inputGte: K32 }, input: 7, cache: 1.8, output: 26, note: "\u5165\u226532K" }
|
|
818
804
|
]
|
|
819
805
|
},
|
|
820
806
|
{
|
|
821
807
|
id: "glm-4.6v",
|
|
822
808
|
label: "GLM-4.6V",
|
|
823
809
|
tiers: [
|
|
824
|
-
{ when: { inputLt: K32 }, input: 1, cache: 0.2, output: 3, note: "
|
|
825
|
-
{ when: { inputGte: K32 }, input: 2, cache: 0.4, output: 6, note: "
|
|
810
|
+
{ when: { inputLt: K32 }, input: 1, cache: 0.2, output: 3, note: "\u5165<32K" },
|
|
811
|
+
{ when: { inputGte: K32 }, input: 2, cache: 0.4, output: 6, note: "\u516532K\u2013128K\uFF08\u8D85\u4E0A\u754C\u5E76\u5165\u9AD8\u6863\uFF09" }
|
|
826
812
|
]
|
|
827
813
|
},
|
|
828
814
|
{
|
|
829
815
|
id: "glm-4.6v-flashx",
|
|
830
816
|
label: "GLM-4.6V-FlashX",
|
|
831
817
|
tiers: [
|
|
832
|
-
{ when: { inputLt: K32 }, input: 0.15, cache: 0.03, output: 1.5, note: "
|
|
833
|
-
{ when: { inputGte: K32 }, input: 0.3, cache: 0.03, output: 3, note: "
|
|
818
|
+
{ when: { inputLt: K32 }, input: 0.15, cache: 0.03, output: 1.5, note: "\u5165<32K" },
|
|
819
|
+
{ when: { inputGte: K32 }, input: 0.3, cache: 0.03, output: 3, note: "\u516532K\u2013128K\uFF08\u8D85\u4E0A\u754C\u5E76\u5165\u9AD8\u6863\uFF09" }
|
|
834
820
|
]
|
|
835
821
|
},
|
|
836
|
-
{ id: "glm-4.6v-flash", label: "GLM-4.6V-Flash
|
|
822
|
+
{ id: "glm-4.6v-flash", label: "GLM-4.6V-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, 0, 0, "\u514D\u8D39")] },
|
|
837
823
|
{
|
|
838
824
|
id: "glm-4.5v",
|
|
839
825
|
label: "GLM-4.5V",
|
|
840
826
|
tiers: [
|
|
841
|
-
{ when: { inputLt: K32 }, input: 2, cache: 0.4, output: 6, note: "
|
|
842
|
-
{ when: { inputGte: K32 }, input: 4, cache: 0.8, output: 12, note: "
|
|
827
|
+
{ when: { inputLt: K32 }, input: 2, cache: 0.4, output: 6, note: "\u5165<32K" },
|
|
828
|
+
{ when: { inputGte: K32 }, input: 4, cache: 0.8, output: 12, note: "\u516532K\u201364K\uFF08\u8D85\u4E0A\u754C\u5E76\u5165\u9AD8\u6863\uFF09" }
|
|
843
829
|
]
|
|
844
830
|
},
|
|
845
831
|
{ id: "glm-4v-plus-0111", label: "GLM-4V-Plus-0111", tiers: [flat(4, 2, 4)] },
|
|
846
|
-
{ id: "glm-4v-plus", label: "GLM-4V-Plus
|
|
847
|
-
{ id: "glm-4v-flash", label: "GLM-4V-Flash
|
|
832
|
+
{ id: "glm-4v-plus", label: "GLM-4V-Plus\uFF08\u540C 0111 \u7248\u4EF7\uFF09", tiers: [flat(4, 2, 4)] },
|
|
833
|
+
{ id: "glm-4v-flash", label: "GLM-4V-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
848
834
|
{ id: "glm-4.1v-thinking-flashx", label: "GLM-4.1V-Thinking-FlashX", tiers: [flat(2, null, 2)] },
|
|
849
|
-
{ id: "glm-4.1v-thinking-flash", label: "GLM-4.1V-Thinking-Flash
|
|
850
|
-
|
|
851
|
-
{ id: "embedding-
|
|
852
|
-
{ id: "
|
|
853
|
-
{ id: "
|
|
854
|
-
{ id: "codegeex-4", label: "CodeGeeX-4", tiers: [flat(0.1, null, 0.1, "single-value")] }
|
|
835
|
+
{ id: "glm-4.1v-thinking-flash", label: "GLM-4.1V-Thinking-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
836
|
+
{ id: "embedding-3", label: "Embedding-3", tiers: [flat(0.5, null, 0.5, "\u5355\u503C\u4EF7\u76EE\xB7input \u8BA1")] },
|
|
837
|
+
{ id: "embedding-2", label: "Embedding-2", tiers: [flat(0.5, null, 0.5, "\u5355\u503C\u4EF7\u76EE\xB7input \u8BA1")] },
|
|
838
|
+
{ id: "rerank", label: "Rerank", tiers: [flat(0.8, null, 0.8, "\u5355\u503C\u4EF7\u76EE")] },
|
|
839
|
+
{ id: "codegeex-4", label: "CodeGeeX-4", tiers: [flat(0.1, null, 0.1, "\u5355\u503C\u4EF7\u76EE")] }
|
|
855
840
|
];
|
|
856
841
|
var findPrice = (model) => {
|
|
857
842
|
const m = model.trim().toLowerCase();
|
|
@@ -880,7 +865,7 @@ var priceUsage = (rows) => {
|
|
|
880
865
|
const accs = /* @__PURE__ */ new Map();
|
|
881
866
|
for (const r of rows) {
|
|
882
867
|
if (r.inputTokens === 0 && r.outputTokens === 0) continue;
|
|
883
|
-
const key = r.model === "" ? "
|
|
868
|
+
const key = r.model === "" ? "\uFF08\u672A\u8BB0\u5F55\u6A21\u578B\uFF09" : r.model;
|
|
884
869
|
let a = accs.get(key);
|
|
885
870
|
if (a === void 0) {
|
|
886
871
|
const p = findPrice(key);
|
|
@@ -956,10 +941,9 @@ CREATE TABLE IF NOT EXISTS prompt_usage (
|
|
|
956
941
|
note TEXT NOT NULL DEFAULT '',
|
|
957
942
|
model TEXT NOT NULL DEFAULT '',
|
|
958
943
|
input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
959
|
-
-- cached_tokens
|
|
960
|
-
|
|
961
|
-
--
|
|
962
|
-
-- syntax error and every store-level test in the repo went red)
|
|
944
|
+
-- cached_tokens\uFF1Az.ai \u53E3\u5F84\u7F13\u5B58\u547D\u4E2D\uFF08input \u5B50\u96C6\uFF0Cwf_66a9b632154d\uFF09
|
|
945
|
+
--\uFF08\u5341\u4E09\u8DD1 R1 \u987A\u624B\u4FEE\uFF1A\u539F JS \u98CE\u683C // \u6CE8\u91CA\u5199\u5728 SQL \u4E32\u5185\uFF0CSQLite \u4E0D\u8BA4\uFF0C
|
|
946
|
+
-- db.exec(MIGRATIONS) \u76F4\u63A5\u629B near "/": syntax error\uFF0C\u5168\u4ED3 store \u7EA7\u6D4B\u8BD5\u5C3D\u7EA2\uFF09
|
|
963
947
|
cached_tokens INTEGER NOT NULL DEFAULT 0,
|
|
964
948
|
output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
965
949
|
duration_ms INTEGER NOT NULL DEFAULT 0,
|
package/dist/juli-ledger.js
CHANGED
|
@@ -553,11 +553,9 @@ var createLedgerStore = (dbPath, deps = {}) => {
|
|
|
553
553
|
};
|
|
554
554
|
},
|
|
555
555
|
activeRunForSession: (session) => activeRunOf(session),
|
|
556
|
-
/**
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
* "literal backslash + any character", the pattern never matches — and
|
|
560
|
-
* dedup fails wholesale (09-07 incident). */
|
|
556
|
+
/** 活跃去重:同 dedup_key 且工作流仍在途 → 跳过重复建流。
|
|
557
|
+
* ⚠ ESCAPE '\' 必须与转义成对:message-id 几乎必含 `_`,漏写 ESCAPE 时
|
|
558
|
+
* `\_` 成了"字面反斜杠+任意字符",模式永不匹配——去重整体失效(09-07 事故)。 */
|
|
561
559
|
hasActiveDedup(key) {
|
|
562
560
|
const r = db.prepare(
|
|
563
561
|
`SELECT 1 FROM workflows WHERE status IN (${sqlInList(DEDUP_WINDOW_STATUSES)})
|
|
@@ -565,10 +563,8 @@ var createLedgerStore = (dbPath, deps = {}) => {
|
|
|
565
563
|
).get(dedupPattern(key));
|
|
566
564
|
return r !== void 0;
|
|
567
565
|
},
|
|
568
|
-
/**
|
|
569
|
-
*
|
|
570
|
-
* polling won't fetch it again. Retries go through step retry, not
|
|
571
|
-
* re-ingestion. */
|
|
566
|
+
/** 已摄取去重(轮询层):同 dedup_key 存在任何非 rejected 工作流 → 这封
|
|
567
|
+
* 邮件已被处理过(含 failed),轮询不再重复拉取。重试走步骤 retry,不走再摄取。 */
|
|
572
568
|
hasSeenDedup(key) {
|
|
573
569
|
const r = db.prepare(
|
|
574
570
|
`SELECT 1 FROM workflows WHERE status != 'rejected'
|
|
@@ -576,14 +572,11 @@ var createLedgerStore = (dbPath, deps = {}) => {
|
|
|
576
572
|
).get(dedupPattern(key));
|
|
577
573
|
return r !== void 0;
|
|
578
574
|
},
|
|
579
|
-
/**
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
* exact comparison: JSON-encode to the actually stored bytes; %/_/\ are
|
|
585
|
-
* escaped in pairs like dedupPattern (a message-id almost always contains
|
|
586
|
-
* `_`). */
|
|
575
|
+
/** 自回环守卫查询(2026-09-20 断点十三):message_id 是否命中本引擎已
|
|
576
|
+
* 发送记录——completed send 步的 output.message_id(email_sent 事件同源
|
|
577
|
+
* 落账)。进件层据此丢弃投递副本回灌(引擎给轮询邮箱自己发信的 echo)。
|
|
578
|
+
* LIKE 预筛 + 精确比对:JSON 编码取实际存储字节,%/_/\ 照 dedupPattern
|
|
579
|
+
* 成对转义(message-id 几乎必含 `_`)。 */
|
|
587
580
|
recordSentMessageId(messageId, meta) {
|
|
588
581
|
if (messageId === "") return;
|
|
589
582
|
db.prepare(
|
|
@@ -695,61 +688,59 @@ var PRICING_SOURCE = "https://docs.bigmodel.cn/cn/guide/start/pricing";
|
|
|
695
688
|
var PRICING_RETRIEVED_AT = "2026-10-06";
|
|
696
689
|
var K32 = 32e3;
|
|
697
690
|
var K200 = 200;
|
|
698
|
-
var flat = (input, cache, output, note = "
|
|
691
|
+
var flat = (input, cache, output, note = "\u7EDF\u4E00\u4EF7") => ({ when: {}, input, cache, output, note });
|
|
699
692
|
var BIGMODEL_PRICES = [
|
|
700
|
-
// ---- Flagship ----
|
|
701
693
|
{ id: "glm-5.3", label: "GLM-5.3", tiers: [flat(8, 2, 28)] },
|
|
702
694
|
{ id: "glm-5.3-flash", label: "GLM-5.3-Flash", tiers: [flat(0.8, 0.23, 2.8)] },
|
|
703
695
|
{ id: "glm-5.3-flashx", label: "GLM-5.3-FlashX", tiers: [flat(2, 0.57, 7)] },
|
|
704
|
-
// ---- Text ----
|
|
705
696
|
{ id: "glm-5.2", label: "GLM-5.2", tiers: [flat(8, 2, 28)] },
|
|
706
697
|
{
|
|
707
698
|
id: "glm-5.1",
|
|
708
699
|
label: "GLM-5.1",
|
|
709
700
|
tiers: [
|
|
710
|
-
{ when: { inputLt: K32 }, input: 6, cache: 1.3, output: 24, note: "
|
|
711
|
-
{ when: { inputGte: K32 }, input: 8, cache: 2, output: 28, note: "
|
|
701
|
+
{ when: { inputLt: K32 }, input: 6, cache: 1.3, output: 24, note: "\u5165<32K" },
|
|
702
|
+
{ when: { inputGte: K32 }, input: 8, cache: 2, output: 28, note: "\u5165\u226532K" }
|
|
712
703
|
]
|
|
713
704
|
},
|
|
714
705
|
{
|
|
715
706
|
id: "glm-5-turbo",
|
|
716
707
|
label: "GLM-5-Turbo",
|
|
717
708
|
tiers: [
|
|
718
|
-
{ when: { inputLt: K32 }, input: 5, cache: 1.2, output: 22, note: "
|
|
719
|
-
{ when: { inputGte: K32 }, input: 7, cache: 1.8, output: 26, note: "
|
|
709
|
+
{ when: { inputLt: K32 }, input: 5, cache: 1.2, output: 22, note: "\u5165<32K" },
|
|
710
|
+
{ when: { inputGte: K32 }, input: 7, cache: 1.8, output: 26, note: "\u5165\u226532K" }
|
|
720
711
|
]
|
|
721
712
|
},
|
|
722
713
|
{
|
|
723
714
|
id: "glm-5",
|
|
724
715
|
label: "GLM-5",
|
|
725
716
|
tiers: [
|
|
726
|
-
{ when: { inputLt: K32 }, input: 4, cache: 1, output: 18, note: "
|
|
727
|
-
{ when: { inputGte: K32 }, input: 6, cache: 1.5, output: 22, note: "
|
|
717
|
+
{ when: { inputLt: K32 }, input: 4, cache: 1, output: 18, note: "\u5165<32K" },
|
|
718
|
+
{ when: { inputGte: K32 }, input: 6, cache: 1.5, output: 22, note: "\u5165\u226532K" }
|
|
728
719
|
]
|
|
729
720
|
},
|
|
730
721
|
{
|
|
731
722
|
id: "glm-4.7",
|
|
732
723
|
label: "GLM-4.7",
|
|
733
724
|
tiers: [
|
|
734
|
-
{ when: { inputLt: K32, outputLt: K200 }, input: 2, cache: 0.4, output: 8, note: "
|
|
735
|
-
{ when: { inputLt: K32, outputGte: K200 }, input: 3, cache: 0.6, output: 14, note: "
|
|
736
|
-
{ when: { inputGte: K32 }, input: 4, cache: 0.8, output: 16, note: "
|
|
725
|
+
{ when: { inputLt: K32, outputLt: K200 }, input: 2, cache: 0.4, output: 8, note: "\u5165<32K\xB7\u51FA<0.2K" },
|
|
726
|
+
{ when: { inputLt: K32, outputGte: K200 }, input: 3, cache: 0.6, output: 14, note: "\u5165<32K\xB7\u51FA\u22650.2K" },
|
|
727
|
+
{ when: { inputGte: K32 }, input: 4, cache: 0.8, output: 16, note: "\u516532K\u2013200K" }
|
|
737
728
|
]
|
|
738
729
|
},
|
|
739
730
|
{
|
|
740
731
|
id: "glm-4.5-air",
|
|
741
732
|
label: "GLM-4.5-Air",
|
|
742
733
|
tiers: [
|
|
743
|
-
{ when: { inputLt: K32, outputLt: K200 }, input: 0.8, cache: 0.16, output: 2, note: "
|
|
744
|
-
{ when: { inputLt: K32, outputGte: K200 }, input: 0.8, cache: 0.16, output: 6, note: "
|
|
745
|
-
{ when: { inputGte: K32 }, input: 1.2, cache: 0.24, output: 8, note: "
|
|
734
|
+
{ when: { inputLt: K32, outputLt: K200 }, input: 0.8, cache: 0.16, output: 2, note: "\u5165<32K\xB7\u51FA<0.2K" },
|
|
735
|
+
{ when: { inputLt: K32, outputGte: K200 }, input: 0.8, cache: 0.16, output: 6, note: "\u5165<32K\xB7\u51FA\u22650.2K" },
|
|
736
|
+
{ when: { inputGte: K32 }, input: 1.2, cache: 0.24, output: 8, note: "\u516532K\u2013128K" }
|
|
746
737
|
]
|
|
747
738
|
},
|
|
748
739
|
{ id: "glm-4.7-flashx", label: "GLM-4.7-FlashX", tiers: [flat(0.5, 0.1, 3)] },
|
|
749
|
-
{ id: "glm-4.7-flash", label: "GLM-4.7-Flash
|
|
740
|
+
{ id: "glm-4.7-flash", label: "GLM-4.7-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, 0, 0, "\u514D\u8D39")] },
|
|
750
741
|
{ id: "glm-4-plus", label: "GLM-4-Plus", tiers: [flat(5, 2.5, 5)] },
|
|
751
742
|
{ id: "glm-4-air-250414", label: "GLM-4-Air-250414", tiers: [flat(0.5, 0.25, 0.5)] },
|
|
752
|
-
{ id: "glm-4-air", label: "GLM-4-Air
|
|
743
|
+
{ id: "glm-4-air", label: "GLM-4-Air\uFF08\u540C 250414 \u7248\u4EF7\uFF09", tiers: [flat(0.5, 0.25, 0.5)] },
|
|
753
744
|
{ id: "glm-4-airx", label: "GLM-4-AirX", tiers: [flat(10, null, 10)] },
|
|
754
745
|
{ id: "glm-4-long", label: "GLM-4-Long", tiers: [flat(1, 0.5, 1)] },
|
|
755
746
|
{ id: "glm-4-assistant", label: "GLM-4-Assistant", tiers: [flat(5, null, 5)] },
|
|
@@ -757,55 +748,53 @@ var BIGMODEL_PRICES = [
|
|
|
757
748
|
{ id: "glm-z1-airx", label: "GLM-Z1-AirX", tiers: [flat(5, null, 5)] },
|
|
758
749
|
{ id: "glm-z1-flashx", label: "GLM-Z1-FlashX", tiers: [flat(0.1, null, 0.1)] },
|
|
759
750
|
{ id: "glm-4-flashx-250414", label: "GLM-4-FlashX-250414", tiers: [flat(0.1, 0.05, 0.1)] },
|
|
760
|
-
{ id: "glm-4-flashx", label: "GLM-4-FlashX
|
|
761
|
-
{ id: "glm-4-flash-250414", label: "GLM-4-Flash-250414
|
|
762
|
-
{ id: "glm-4-flash", label: "GLM-4-Flash
|
|
763
|
-
{ id: "glm-z1-flash", label: "GLM-Z1-Flash
|
|
764
|
-
// ---- Vision ----
|
|
751
|
+
{ id: "glm-4-flashx", label: "GLM-4-FlashX\uFF08\u540C 250414 \u7248\u4EF7\uFF09", tiers: [flat(0.1, 0.05, 0.1)] },
|
|
752
|
+
{ id: "glm-4-flash-250414", label: "GLM-4-Flash-250414\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
753
|
+
{ id: "glm-4-flash", label: "GLM-4-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
754
|
+
{ id: "glm-z1-flash", label: "GLM-Z1-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
765
755
|
{ id: "glm-ocr", label: "GLM-OCR", tiers: [flat(0.2, null, 0.2)] },
|
|
766
756
|
{
|
|
767
757
|
id: "glm-5v-turbo",
|
|
768
758
|
label: "GLM-5V-Turbo",
|
|
769
759
|
tiers: [
|
|
770
|
-
{ when: { inputLt: K32 }, input: 5, cache: 1.2, output: 22, note: "
|
|
771
|
-
{ when: { inputGte: K32 }, input: 7, cache: 1.8, output: 26, note: "
|
|
760
|
+
{ when: { inputLt: K32 }, input: 5, cache: 1.2, output: 22, note: "\u5165<32K" },
|
|
761
|
+
{ when: { inputGte: K32 }, input: 7, cache: 1.8, output: 26, note: "\u5165\u226532K" }
|
|
772
762
|
]
|
|
773
763
|
},
|
|
774
764
|
{
|
|
775
765
|
id: "glm-4.6v",
|
|
776
766
|
label: "GLM-4.6V",
|
|
777
767
|
tiers: [
|
|
778
|
-
{ when: { inputLt: K32 }, input: 1, cache: 0.2, output: 3, note: "
|
|
779
|
-
{ when: { inputGte: K32 }, input: 2, cache: 0.4, output: 6, note: "
|
|
768
|
+
{ when: { inputLt: K32 }, input: 1, cache: 0.2, output: 3, note: "\u5165<32K" },
|
|
769
|
+
{ when: { inputGte: K32 }, input: 2, cache: 0.4, output: 6, note: "\u516532K\u2013128K\uFF08\u8D85\u4E0A\u754C\u5E76\u5165\u9AD8\u6863\uFF09" }
|
|
780
770
|
]
|
|
781
771
|
},
|
|
782
772
|
{
|
|
783
773
|
id: "glm-4.6v-flashx",
|
|
784
774
|
label: "GLM-4.6V-FlashX",
|
|
785
775
|
tiers: [
|
|
786
|
-
{ when: { inputLt: K32 }, input: 0.15, cache: 0.03, output: 1.5, note: "
|
|
787
|
-
{ when: { inputGte: K32 }, input: 0.3, cache: 0.03, output: 3, note: "
|
|
776
|
+
{ when: { inputLt: K32 }, input: 0.15, cache: 0.03, output: 1.5, note: "\u5165<32K" },
|
|
777
|
+
{ when: { inputGte: K32 }, input: 0.3, cache: 0.03, output: 3, note: "\u516532K\u2013128K\uFF08\u8D85\u4E0A\u754C\u5E76\u5165\u9AD8\u6863\uFF09" }
|
|
788
778
|
]
|
|
789
779
|
},
|
|
790
|
-
{ id: "glm-4.6v-flash", label: "GLM-4.6V-Flash
|
|
780
|
+
{ id: "glm-4.6v-flash", label: "GLM-4.6V-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, 0, 0, "\u514D\u8D39")] },
|
|
791
781
|
{
|
|
792
782
|
id: "glm-4.5v",
|
|
793
783
|
label: "GLM-4.5V",
|
|
794
784
|
tiers: [
|
|
795
|
-
{ when: { inputLt: K32 }, input: 2, cache: 0.4, output: 6, note: "
|
|
796
|
-
{ when: { inputGte: K32 }, input: 4, cache: 0.8, output: 12, note: "
|
|
785
|
+
{ when: { inputLt: K32 }, input: 2, cache: 0.4, output: 6, note: "\u5165<32K" },
|
|
786
|
+
{ when: { inputGte: K32 }, input: 4, cache: 0.8, output: 12, note: "\u516532K\u201364K\uFF08\u8D85\u4E0A\u754C\u5E76\u5165\u9AD8\u6863\uFF09" }
|
|
797
787
|
]
|
|
798
788
|
},
|
|
799
789
|
{ id: "glm-4v-plus-0111", label: "GLM-4V-Plus-0111", tiers: [flat(4, 2, 4)] },
|
|
800
|
-
{ id: "glm-4v-plus", label: "GLM-4V-Plus
|
|
801
|
-
{ id: "glm-4v-flash", label: "GLM-4V-Flash
|
|
790
|
+
{ id: "glm-4v-plus", label: "GLM-4V-Plus\uFF08\u540C 0111 \u7248\u4EF7\uFF09", tiers: [flat(4, 2, 4)] },
|
|
791
|
+
{ id: "glm-4v-flash", label: "GLM-4V-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
802
792
|
{ id: "glm-4.1v-thinking-flashx", label: "GLM-4.1V-Thinking-FlashX", tiers: [flat(2, null, 2)] },
|
|
803
|
-
{ id: "glm-4.1v-thinking-flash", label: "GLM-4.1V-Thinking-Flash
|
|
804
|
-
|
|
805
|
-
{ id: "embedding-
|
|
806
|
-
{ id: "
|
|
807
|
-
{ id: "
|
|
808
|
-
{ id: "codegeex-4", label: "CodeGeeX-4", tiers: [flat(0.1, null, 0.1, "single-value")] }
|
|
793
|
+
{ id: "glm-4.1v-thinking-flash", label: "GLM-4.1V-Thinking-Flash\uFF08\u514D\u8D39\uFF09", tiers: [flat(0, null, 0, "\u514D\u8D39\xB7\u7F13\u5B58\u4E0D\u652F\u6301")] },
|
|
794
|
+
{ id: "embedding-3", label: "Embedding-3", tiers: [flat(0.5, null, 0.5, "\u5355\u503C\u4EF7\u76EE\xB7input \u8BA1")] },
|
|
795
|
+
{ id: "embedding-2", label: "Embedding-2", tiers: [flat(0.5, null, 0.5, "\u5355\u503C\u4EF7\u76EE\xB7input \u8BA1")] },
|
|
796
|
+
{ id: "rerank", label: "Rerank", tiers: [flat(0.8, null, 0.8, "\u5355\u503C\u4EF7\u76EE")] },
|
|
797
|
+
{ id: "codegeex-4", label: "CodeGeeX-4", tiers: [flat(0.1, null, 0.1, "\u5355\u503C\u4EF7\u76EE")] }
|
|
809
798
|
];
|
|
810
799
|
var findPrice = (model) => {
|
|
811
800
|
const m = model.trim().toLowerCase();
|
|
@@ -834,7 +823,7 @@ var priceUsage = (rows) => {
|
|
|
834
823
|
const accs = /* @__PURE__ */ new Map();
|
|
835
824
|
for (const r of rows) {
|
|
836
825
|
if (r.inputTokens === 0 && r.outputTokens === 0) continue;
|
|
837
|
-
const key = r.model === "" ? "
|
|
826
|
+
const key = r.model === "" ? "\uFF08\u672A\u8BB0\u5F55\u6A21\u578B\uFF09" : r.model;
|
|
838
827
|
let a = accs.get(key);
|
|
839
828
|
if (a === void 0) {
|
|
840
829
|
const p = findPrice(key);
|
|
@@ -910,10 +899,9 @@ CREATE TABLE IF NOT EXISTS prompt_usage (
|
|
|
910
899
|
note TEXT NOT NULL DEFAULT '',
|
|
911
900
|
model TEXT NOT NULL DEFAULT '',
|
|
912
901
|
input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
913
|
-
-- cached_tokens
|
|
914
|
-
|
|
915
|
-
--
|
|
916
|
-
-- syntax error and every store-level test in the repo went red)
|
|
902
|
+
-- cached_tokens\uFF1Az.ai \u53E3\u5F84\u7F13\u5B58\u547D\u4E2D\uFF08input \u5B50\u96C6\uFF0Cwf_66a9b632154d\uFF09
|
|
903
|
+
--\uFF08\u5341\u4E09\u8DD1 R1 \u987A\u624B\u4FEE\uFF1A\u539F JS \u98CE\u683C // \u6CE8\u91CA\u5199\u5728 SQL \u4E32\u5185\uFF0CSQLite \u4E0D\u8BA4\uFF0C
|
|
904
|
+
-- db.exec(MIGRATIONS) \u76F4\u63A5\u629B near "/": syntax error\uFF0C\u5168\u4ED3 store \u7EA7\u6D4B\u8BD5\u5C3D\u7EA2\uFF09
|
|
917
905
|
cached_tokens INTEGER NOT NULL DEFAULT 0,
|
|
918
906
|
output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
919
907
|
duration_ms INTEGER NOT NULL DEFAULT 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juli-os/ledger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "juli-os L1 layer: the ledger of record for agent work — workflows, steps, case files, and token usage in one zero-dependency SQLite layer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|