@morlay/session-rdb 0.0.21-alpha.8 → 0.0.21-alpha.9

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.
@@ -1,7 +1,10 @@
1
- import { C as postgresTableDefs, T as WriteGuard, a as EVENT_ENCODING, c as eventDimensions, i as DEFAULT_BUSY_TIMEOUT_MS, r as createStorageRepository, t as SqliteBackend, w as toPostgresSchema } from "./sqlite-ChM_sHAG.mjs";
2
- import { A as registerSessionUsage, C as COUNTED_EVENT_TYPES, D as addTotals, E as addTokenTotals, O as emptyTotals, S as usageRowOf, T as addActivityTotals, _ as sessionConflictRow, b as titleOfEventData, g as sealOwnEvents, h as scanRows, k as localDayKey, m as rowToMeta, r as needsShapeAdoption, u as repairReadView, v as sessionInsertRow, w as addActivityCount, x as toJsonlArtifact } from "./log-DTcvsMz7.mjs";
3
- import { c as isLegacyVersion, o as adoptLegacyRows, s as convertLegacyRows, t as SessionBranchRdb } from "./branch-7eOh_tbO.mjs";
1
+ import { C as postgresTableDefs, T as WriteGuard, a as EVENT_ENCODING, c as eventDimensions, i as DEFAULT_BUSY_TIMEOUT_MS, r as createStorageRepository, t as SqliteBackend, w as toPostgresSchema } from "./sqlite-SCiSnwaz.mjs";
2
+ import { COUNTED_EVENT_TYPES, addActivityCount, addActivityTotals, addTokenTotals, addTotals, emptyTotals, localDayKey, registerSessionUsage } from "./usage.mjs";
3
+ import { S as usageRowOf, _ as sessionConflictRow, b as titleOfEventData, g as sealOwnEvents, h as scanRows, m as rowToMeta, r as needsShapeAdoption, u as repairReadView, v as sessionInsertRow, x as toJsonlArtifact } from "./log-BWVFYAh5.mjs";
4
+ import { c as isLegacyVersion, o as adoptLegacyRows, s as convertLegacyRows, t as SessionBranchRdb } from "./branch-D4nVzQQM.mjs";
4
5
  import { registerSessionImport } from "./import.mjs";
6
+ import { registerSessionExport } from "./export.mjs";
7
+ import { registerSessionGc } from "./gc.mjs";
5
8
  import z from "@deepseek-ai/schemastery";
6
9
  import { randomUUID } from "node:crypto";
7
10
  import { Pool } from "pg";
@@ -14,7 +17,6 @@ import { readdir } from "node:fs/promises";
14
17
  import { fileURLToPath } from "node:url";
15
18
  import { migrate } from "drizzle-orm/node-postgres/migrator";
16
19
  import { balanceRewindPrefix } from "@morlay/session-branch";
17
- import { strToU8, zip } from "fflate";
18
20
  import { SessionQueryEngine, SessionQueryError } from "@deepseek-ai/dsh-session-query";
19
21
  import { StorageError, storageBackendServiceKey } from "@deepseek-ai/dsh-storage";
20
22
  import { Service } from "@deepseek-ai/cordis";
@@ -703,130 +705,6 @@ function registerSessionDeletion(ctx, persistence) {
703
705
  });
704
706
  }
705
707
  //#endregion
706
- //#region src/export.ts
707
- const SESSION_EXPORT_PATH = "/api/session.export";
708
- /** 文件名只保留安全字符:会话 id 来自请求体,会写进 Content-Disposition。 */
709
- function safeFilename(sessionId) {
710
- return sessionId.replace(/[^A-Za-z0-9._-]/gu, "_");
711
- }
712
- /** fflate 只给回调式异步 API(同步变体被 node/no-sync 禁止)。 */
713
- function zipBytes(files) {
714
- return new Promise((resolve, reject) => {
715
- zip(files, (error, data) => {
716
- if (error === null) resolve(data);
717
- else reject(error);
718
- });
719
- });
720
- }
721
- /** 导出通道:直接把会话日志打成 zip 响应体,与导入通道读同一份 artifact。 */
722
- function registerSessionExport(ctx, persistence) {
723
- ctx.inject(["webServer", "connection"], (webCtx) => {
724
- const webServer = webCtx.webServer;
725
- const connection = webCtx.get("connection");
726
- return webCtx.effect(() => webServer.register({
727
- kind: "exact",
728
- path: SESSION_EXPORT_PATH,
729
- handler: async (req, res) => {
730
- const rejection = connection.requestRejection(req);
731
- if (rejection !== void 0) {
732
- res.writeHead(rejection);
733
- res.end(rejection === 401 ? "unauthorized" : "forbidden");
734
- return;
735
- }
736
- if (req.method !== "POST") {
737
- res.writeHead(405, { "content-type": "application/json" });
738
- res.end(JSON.stringify({ error: "method not allowed" }));
739
- return;
740
- }
741
- const chunks = [];
742
- for await (const chunk of req) chunks.push(chunk);
743
- let envelope;
744
- try {
745
- envelope = JSON.parse(Buffer.concat(chunks).toString("utf8"));
746
- } catch {
747
- res.writeHead(400, { "content-type": "application/json" });
748
- res.end(JSON.stringify({ error: "request body is not JSON" }));
749
- return;
750
- }
751
- if (typeof envelope.sessionId !== "string" || envelope.sessionId === "") {
752
- res.writeHead(400, { "content-type": "application/json" });
753
- res.end(JSON.stringify({ error: "missing sessionId field" }));
754
- return;
755
- }
756
- const sessionId = envelope.sessionId;
757
- try {
758
- const raw = await persistence.readRaw(sessionId);
759
- if (raw === void 0) {
760
- res.writeHead(404, { "content-type": "application/json" });
761
- res.end(JSON.stringify({ error: `session "${sessionId}" not found` }));
762
- return;
763
- }
764
- const zipFile = await zipBytes({ [raw.filename]: strToU8(raw.content) });
765
- res.writeHead(200, {
766
- "content-type": "application/zip",
767
- "content-length": String(zipFile.byteLength),
768
- "content-disposition": `attachment; filename="${safeFilename(sessionId)}.zip"`
769
- });
770
- res.end(Buffer.from(zipFile));
771
- } catch (error) {
772
- res.writeHead(500, { "content-type": "application/json" });
773
- res.end(JSON.stringify({ error: error instanceof Error ? error.message : "session export failed" }));
774
- }
775
- }
776
- }), `session-rdb: ${SESSION_EXPORT_PATH} route`);
777
- });
778
- }
779
- //#endregion
780
- //#region src/gc.ts
781
- const SESSION_GC_PATH = "/api/session.gc";
782
- /** 让所有运行中的 agent 先退场:GC 要重写事件表,运行中的写路径必须停下来。 */
783
- async function stopRunningAgents(ctx) {
784
- const running = ctx.get("agents")?.list() ?? [];
785
- for (const agent of running) agent.cancel?.({ kind: "user" }, { keepInbox: true });
786
- await Promise.all(running.map((agent) => agent.whenIdle()));
787
- return running.length;
788
- }
789
- /** GC 通道:停 agent → 回收孤儿事件行 → VACUUM,一次请求完成。 */
790
- function registerSessionGc(ctx, persistence) {
791
- ctx.inject(["webServer", "connection"], (webCtx) => {
792
- const webServer = webCtx.webServer;
793
- const connection = webCtx.get("connection");
794
- return webCtx.effect(() => webServer.register({
795
- kind: "exact",
796
- path: SESSION_GC_PATH,
797
- handler: async (req, res) => {
798
- const rejection = connection.requestRejection(req);
799
- if (rejection !== void 0) {
800
- res.writeHead(rejection);
801
- res.end(rejection === 401 ? "unauthorized" : "forbidden");
802
- return;
803
- }
804
- if (req.method !== "POST") {
805
- res.writeHead(405, { "content-type": "application/json" });
806
- res.end(JSON.stringify({ error: "method not allowed" }));
807
- return;
808
- }
809
- try {
810
- const stoppedAgents = await stopRunningAgents(webCtx);
811
- const orphanSessions = await persistence.collectOrphanSessions();
812
- const orphanEvents = await persistence.collectOrphans();
813
- await persistence.vacuum();
814
- res.writeHead(200, { "content-type": "application/json" });
815
- res.end(JSON.stringify({
816
- orphanSessions,
817
- orphanEvents,
818
- stoppedAgents,
819
- vacuumed: true
820
- }));
821
- } catch (error) {
822
- res.writeHead(500, { "content-type": "application/json" });
823
- res.end(JSON.stringify({ error: error instanceof Error ? error.message : "gc failed" }));
824
- }
825
- }
826
- }), `session-rdb: ${SESSION_GC_PATH} route`);
827
- });
828
- }
829
- //#endregion
830
708
  //#region src/rows.ts
831
709
  /**
832
710
  * 管理面的会话列表:**我们自己的**一条路由(完整语料,含归档),与官方 `session/list` 分开。
@@ -1548,38 +1426,62 @@ var RdbSessionHandle = class RdbSessionHandle {
1548
1426
  }
1549
1427
  static LIVE_WRITE_BATCH_MAX_DELAY_MS = 200;
1550
1428
  };
1429
+ /**
1430
+ * 本地化说明:`description()` 的类型签名只声明 `string`,而 meta 本身接受 `Dict<string>`
1431
+ * (`vendor/schemastery/src/index.ts` 的 `mergeDesc` 就是按字典合并的),所以这里只做一次类型放行。
1432
+ */
1433
+ const localized = (text) => text;
1434
+ /** 投影 checkpoint 的写回节流:两个分支共用。 */
1435
+ const projectionCacheSchema = z.object({
1436
+ writeEveryEvents: z.natural().min(1).default(DEFAULT_PROJECTION_WRITE_EVERY_EVENTS).description(localized({
1437
+ zh: "每累计这么多事件写回一次投影 checkpoint。",
1438
+ en: "Write the projection checkpoint back after this many events."
1439
+ })),
1440
+ writeIntervalMs: z.natural().min(1).default(DEFAULT_PROJECTION_WRITE_INTERVAL_MS).description(localized({
1441
+ zh: "距离上次写回超过这个间隔(毫秒)时也写一次。",
1442
+ en: "Also write back when this many ms passed since the last one."
1443
+ }))
1444
+ }).default({
1445
+ writeEveryEvents: DEFAULT_PROJECTION_WRITE_EVERY_EVENTS,
1446
+ writeIntervalMs: DEFAULT_PROJECTION_WRITE_INTERVAL_MS
1447
+ });
1551
1448
  var SessionPersistenceRdb = class extends SessionPersistence {
1552
- config;
1553
1449
  static inject = ["sessions"];
1554
1450
  static Config = z.union([z.object({
1555
1451
  type: z.const("sqlite"),
1556
- path: z.string().required(),
1452
+ path: z.string().required().description(localized({
1453
+ zh: "SQLite 数据库文件路径;`:memory:` 是内存库(进程结束即丢)。",
1454
+ en: "SQLite database file path; `:memory:` keeps it in memory and loses it with the process."
1455
+ })),
1557
1456
  journalMode: z.union([
1558
1457
  "wal",
1559
1458
  "delete",
1560
1459
  "truncate",
1561
1460
  "persist"
1562
- ]).default("wal"),
1563
- busyTimeout: z.number().step(1).min(0).default(DEFAULT_BUSY_TIMEOUT_MS),
1564
- projectionCache: z.object({
1565
- writeEveryEvents: z.natural().min(1).default(DEFAULT_PROJECTION_WRITE_EVERY_EVENTS),
1566
- writeIntervalMs: z.natural().min(1).default(DEFAULT_PROJECTION_WRITE_INTERVAL_MS)
1567
- }).default({
1568
- writeEveryEvents: DEFAULT_PROJECTION_WRITE_EVERY_EVENTS,
1569
- writeIntervalMs: DEFAULT_PROJECTION_WRITE_INTERVAL_MS
1570
- })
1461
+ ]).default("wal").description(localized({
1462
+ zh: "SQLite 日志模式;默认 wal(并发读最好)。",
1463
+ en: "SQLite journal mode; `wal` by default (best concurrent reads)."
1464
+ })),
1465
+ busyTimeout: z.number().step(1).min(0).default(DEFAULT_BUSY_TIMEOUT_MS).description(localized({
1466
+ zh: "写锁冲突时的忙等超时(毫秒)。",
1467
+ en: "Busy timeout in ms while a write lock is contended."
1468
+ })),
1469
+ projectionCache: projectionCacheSchema
1571
1470
  }), z.object({
1572
1471
  type: z.const("postgres"),
1573
- connectionString: z.string().required(),
1574
- schema: z.string().default("public"),
1575
- projectionCache: z.object({
1576
- writeEveryEvents: z.natural().min(1).default(DEFAULT_PROJECTION_WRITE_EVERY_EVENTS),
1577
- writeIntervalMs: z.natural().min(1).default(DEFAULT_PROJECTION_WRITE_INTERVAL_MS)
1578
- }).default({
1579
- writeEveryEvents: DEFAULT_PROJECTION_WRITE_EVERY_EVENTS,
1580
- writeIntervalMs: DEFAULT_PROJECTION_WRITE_INTERVAL_MS
1581
- })
1582
- })]);
1472
+ connectionString: z.string().required().description(localized({
1473
+ zh: "PostgreSQL 连接串(含库名与凭证)。",
1474
+ en: "PostgreSQL connection string (database and credentials)."
1475
+ })),
1476
+ schema: z.string().default("public").description(localized({
1477
+ zh: "库内的 schema 名;默认 public。",
1478
+ en: "Schema name inside the database; `public` by default."
1479
+ })),
1480
+ projectionCache: projectionCacheSchema
1481
+ })]).description(localized({
1482
+ zh: "会话持久化后端:改这里的连接参数会在这一行重挂时生效(Loader 会重装被改的行)。",
1483
+ en: "Session persistence backend: edits apply when this row is remounted (the Loader re-installs changed rows)."
1484
+ })).volatile();
1583
1485
  name = "session-rdb";
1584
1486
  tracker = new RdbBackendTracker(this.name);
1585
1487
  backend;
@@ -1589,10 +1491,12 @@ var SessionPersistenceRdb = class extends SessionPersistence {
1589
1491
  reuseEventIds = /* @__PURE__ */ new Map();
1590
1492
  liveBuffers = /* @__PURE__ */ new Map();
1591
1493
  liveReady = /* @__PURE__ */ new Map();
1494
+ /** 本次装配用的配置快照(整段 Config 是 volatile,重挂会给新的)。 */
1495
+ config;
1592
1496
  constructor(ctx, config, injectedBackend) {
1593
1497
  super(ctx);
1594
- this.config = config;
1595
- this.backend = injectedBackend ?? createBackend(config);
1498
+ this.config = config.get();
1499
+ this.backend = injectedBackend ?? createBackend(this.config);
1596
1500
  this.ready = this.init();
1597
1501
  this.installLiveRouting(ctx);
1598
1502
  new SessionBranchRdb(this.ctx);
@@ -1,4 +1,4 @@
1
- import { $ as eventDimensions, A as SessionRow, D as SessionCountBucket, E as EventRow, J as EventKind, K as DEFAULT_BUSY_TIMEOUT_MS, M as UsageAggregate, O as SessionListRowsPage, Q as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, T as BackendTx, X as JournalMode, Y as EventRole, Z as SCHEMA_VERSION, at as tSessionCounts, ct as tSessionUsage, dt as tWorkspaceSessions, et as eventKind, ft as tWorkspaceState, ht as StorageRepository, it as tSchemaMeta, j as SessionUsageBucket, k as SessionListRowsQuery, lt as tSessions, mt as WriteGuard, nt as tEvents, ot as tSessionEvents, pt as tWorkspaces, q as EVENT_ENCODING, rt as tPersistenceState, st as tSessionProjcacheRows, tt as tEventUsage, ut as tStorageUnits, w as Backend } from "./log-BbleqD1M.mjs";
1
+ import { A as SessionRow, At as tWorkspaceState, Ct as tSessionCounts, D as SessionCountBucket, Dt as tSessions, E as EventRow, Et as tSessionUsage, I as UsageAggregate, Mt as WriteGuard, Nt as StorageRepository, O as SessionListRowsPage, Ot as tStorageUnits, St as tSchemaMeta, T as BackendTx, Tt as tSessionProjcacheRows, _t as eventDimensions, bt as tEvents, dt as EVENT_ENCODING, ft as EventKind, gt as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, ht as SCHEMA_VERSION, j as SessionUsageBucket, jt as tWorkspaces, k as SessionListRowsQuery, kt as tWorkspaceSessions, mt as JournalMode, pt as EventRole, ut as DEFAULT_BUSY_TIMEOUT_MS, vt as eventKind, w as Backend, wt as tSessionEvents, xt as tPersistenceState, yt as tEventUsage } from "./log-CUjKQbOR.mjs";
2
2
  import { SessionId } from "@deepseek-ai/dsh-session";
3
3
  import { DatabaseSync } from "node:sqlite";
4
4
  //#region src/sqlite.d.ts
package/dist/storage.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { S as tWorkspaces, T as WriteGuard, _ as tSessionUsage, a as EVENT_ENCODING, b as tWorkspaceSessions, c as eventDimensions, d as tEvents, f as tPersistenceState, g as tSessionProjcacheRows, h as tSessionEvents, i as DEFAULT_BUSY_TIMEOUT_MS, l as eventKind, m as tSessionCounts, n as openDatabase, o as SCHEMA_VERSION, p as tSchemaMeta, s as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, t as SqliteBackend, u as tEventUsage, v as tSessions, x as tWorkspaceState, y as tStorageUnits } from "./sqlite-ChM_sHAG.mjs";
1
+ import { S as tWorkspaces, T as WriteGuard, _ as tSessionUsage, a as EVENT_ENCODING, b as tWorkspaceSessions, c as eventDimensions, d as tEvents, f as tPersistenceState, g as tSessionProjcacheRows, h as tSessionEvents, i as DEFAULT_BUSY_TIMEOUT_MS, l as eventKind, m as tSessionCounts, n as openDatabase, o as SCHEMA_VERSION, p as tSchemaMeta, s as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, t as SqliteBackend, u as tEventUsage, v as tSessions, x as tWorkspaceState, y as tStorageUnits } from "./sqlite-SCiSnwaz.mjs";
2
2
  export { DEFAULT_BUSY_TIMEOUT_MS, EVENT_ENCODING, SCHEMA_VERSION, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, SqliteBackend, WriteGuard, eventDimensions, eventKind, openDatabase, tEventUsage, tEvents, tPersistenceState, tSchemaMeta, tSessionCounts, tSessionEvents, tSessionProjcacheRows, tSessionUsage, tSessions, tStorageUnits, tWorkspaceSessions, tWorkspaceState, tWorkspaces };
@@ -1,4 +1,4 @@
1
- import { H as truncateLiveSession } from "./log-BbleqD1M.mjs";
1
+ import { ot as truncateLiveSession } from "./log-CUjKQbOR.mjs";
2
2
  import { SessionPersistence } from "@deepseek-ai/dsh-session-persistence";
3
3
  import { Session, SessionEvent, SessionHeader, SessionId } from "@deepseek-ai/dsh-session";
4
4
  import { Context, Fiber } from "@deepseek-ai/cordis";
package/dist/testing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as truncateLiveSession } from "./branch-7eOh_tbO.mjs";
1
+ import { a as truncateLiveSession } from "./branch-D4nVzQQM.mjs";
2
2
  import { SessionAlreadyExistsError, SessionAlreadyOwnedError, SessionFormatUnsupportedError, SessionHandleClosedError, SessionPersistenceNotFoundError, SessionReadOnlyError } from "@deepseek-ai/dsh-session-persistence";
3
3
  import SessionStore, { SESSION_FORMAT_VERSION, SessionId, SessionLogOffset, SessionSeq } from "@deepseek-ai/dsh-session";
4
4
  import { Context } from "@deepseek-ai/cordis";
@@ -6,7 +6,7 @@ import { MessageId, createUserMessage, freezeMessage } from "@deepseek-ai/dsh-ll
6
6
  //#region \0rolldown/runtime.js
7
7
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
8
8
  //#endregion
9
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/tinyrainbow.Ht9iggcq.js
9
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/tinyrainbow.Ht9iggcq.js
10
10
  var b$1 = {
11
11
  reset: [0, 0],
12
12
  bold: [
@@ -58,16 +58,16 @@ var b$1 = {
58
58
  bgCyanBright: [106, 49],
59
59
  bgWhiteBright: [107, 49]
60
60
  };
61
- function i$1(e) {
61
+ function i(e) {
62
62
  return String(e);
63
63
  }
64
- i$1.open = "";
65
- i$1.close = "";
64
+ i.open = "";
65
+ i.close = "";
66
66
  function B() {
67
67
  let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", l = (e == null ? void 0 : e.argv) || [];
68
68
  return !("NO_COLOR" in r || l.includes("--no-color")) && ("FORCE_COLOR" in r || l.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
69
69
  }
70
- function C({ force: e } = {}) {
70
+ function C$1({ force: e } = {}) {
71
71
  let r = e || B(), a = (t, o, u, n) => {
72
72
  let g = "", s = 0;
73
73
  do
@@ -83,13 +83,13 @@ function C({ force: e } = {}) {
83
83
  }, c = { isColorSupported: r }, f = (t) => `\x1B[${t}m`;
84
84
  for (let t in b$1) {
85
85
  let o = b$1[t];
86
- c[t] = r ? l(f(o[0]), f(o[1]), o[2]) : i$1;
86
+ c[t] = r ? l(f(o[0]), f(o[1]), o[2]) : i;
87
87
  }
88
88
  return c;
89
89
  }
90
- var y$1 = C();
90
+ var y$1 = C$1();
91
91
  //#endregion
92
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/index.M2dsQ_UQ.js
92
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/index.M2dsQ_UQ.js
93
93
  function _mergeNamespaces$1(n, m) {
94
94
  m.forEach(function(e) {
95
95
  e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
@@ -988,7 +988,7 @@ const plugins = {
988
988
  Error: ErrorPlugin
989
989
  };
990
990
  //#endregion
991
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/display.pkpxlVcY.js
991
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/display.pkpxlVcY.js
992
992
  const { AsymmetricMatcher: AsymmetricMatcher$3, DOMCollection: DOMCollection$2, DOMElement: DOMElement$2, Immutable: Immutable$2, ReactElement: ReactElement$2, ReactTestComponent: ReactTestComponent$2 } = plugins;
993
993
  const PLUGINS$2 = [
994
994
  ReactTestComponent$2,
@@ -1449,7 +1449,7 @@ const isAbsolute = function(p) {
1449
1449
  return _IS_ABSOLUTE_RE.test(p);
1450
1450
  };
1451
1451
  //#endregion
1452
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/source-map.BH0bbrs9.js
1452
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/source-map.BH0bbrs9.js
1453
1453
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1454
1454
  function getDefaultExportFromCjs(x) {
1455
1455
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -2232,7 +2232,7 @@ function getOriginalPosition(map, needle) {
2232
2232
  return result;
2233
2233
  }
2234
2234
  //#endregion
2235
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/task-utils.js
2235
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/task-utils.js
2236
2236
  /* @__NO_SIDE_EFFECTS__ */
2237
2237
  function getNames(task) {
2238
2238
  const names = [task.name];
@@ -2249,7 +2249,7 @@ function createTaskName(names, separator = " > ") {
2249
2249
  return names.filter((name) => name !== void 0).join(separator);
2250
2250
  }
2251
2251
  //#endregion
2252
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/run.C5UmxDPh.js
2252
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/run.C5UmxDPh.js
2253
2253
  /**
2254
2254
  * Diff Match and Patch
2255
2255
  * Copyright 2018 The diff-match-patch Authors.
@@ -4900,7 +4900,7 @@ async function finishSendTasksUpdate(runner) {
4900
4900
  await Promise.all(pendingTasksUpdates);
4901
4901
  }
4902
4902
  //#endregion
4903
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/utils.DYj33du9.js
4903
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/utils.DYj33du9.js
4904
4904
  const NAME_WORKER_STATE = "__vitest_worker__";
4905
4905
  function getWorkerState() {
4906
4906
  const workerState = globalThis[NAME_WORKER_STATE];
@@ -4926,12 +4926,13 @@ function resetModules(modules, resetMocks = false) {
4926
4926
  });
4927
4927
  }
4928
4928
  //#endregion
4929
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/spy.DQ0ZsPbi.js
4929
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/spy.KLHgXex_.js
4930
4930
  function isMockFunction(fn) {
4931
4931
  return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
4932
4932
  }
4933
4933
  const MOCK_RESTORE = /* @__PURE__ */ new Set();
4934
4934
  const DIRTY_MOCK_STATES = /* @__PURE__ */ new Set();
4935
+ const addDirtyMock = DIRTY_MOCK_STATES.add.bind(DIRTY_MOCK_STATES);
4935
4936
  const REGISTERED_MOCKS = /* @__PURE__ */ new Set();
4936
4937
  const MOCK_FINALIZER = new FinalizationRegistry((ref) => {
4937
4938
  REGISTERED_MOCKS.delete(ref);
@@ -5164,8 +5165,8 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
5164
5165
  const noopImplementation = function() {};
5165
5166
  const prototypeMock = prototypeState && MOCKS_BY_STATE.get(prototypeState);
5166
5167
  const namedObject = { [name]: (function(...args) {
5167
- DIRTY_MOCK_STATES.add(namedObject[name]);
5168
- if (prototypeMock) DIRTY_MOCK_STATES.add(prototypeMock);
5168
+ addDirtyMock(namedObject[name]);
5169
+ if (prototypeMock) addDirtyMock(prototypeMock);
5169
5170
  registerCalls(args, state, prototypeState);
5170
5171
  registerInvocationOrder(invocationCallCounter++, state, prototypeState);
5171
5172
  const result = {
@@ -8322,7 +8323,7 @@ function use(fn) {
8322
8323
  }
8323
8324
  __name(use, "use");
8324
8325
  //#endregion
8325
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/plugins.Cigb0uSy.js
8326
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/plugins.Cigb0uSy.js
8326
8327
  const serialize$1 = (val, config, indentation, depth, refs, printer) => {
8327
8328
  const name = val.getMockName();
8328
8329
  const nameString = name === "vi.fn()" ? "" : ` ${name}`;
@@ -8355,7 +8356,7 @@ function getSerializers() {
8355
8356
  return PLUGINS;
8356
8357
  }
8357
8358
  //#endregion
8358
- //#region ../../../node_modules/.pnpm/vitest@5.0.1_@opentelemetry+api@1.9.1_@types+node@26.6.2_happy-dom@20.14.5_jsdom@30.1.1_5c5cec99992ade60b7d45a9d0ac17da3/node_modules/vitest/dist/chunks/offset.Dy-5Fdfn.js
8359
+ //#region ../../../node_modules/.pnpm/vitest@5.0.2_@opentelemetry+api@1.9.1_@types+node@26.6.3_happy-dom@20.14.5_jsdom@30.1.1_5bd35cff0016eb681427af506a019366/node_modules/vitest/dist/chunks/offset.Dy-5Fdfn.js
8359
8360
  const lineSplitRE = /\r?\n/;
8360
8361
  function positionToOffset(source, lineNumber, columnNumber) {
8361
8362
  const lines = source.split(lineSplitRE);
@@ -8380,18 +8381,27 @@ function offsetToLineNumber(source, offset) {
8380
8381
  }
8381
8382
  Object.freeze(() => {});
8382
8383
  globalThis.Event;
8383
- function r(e = globalThis) {
8384
+ (async () => {}).constructor;
8385
+ function m(e = globalThis) {
8384
8386
  let t = "unknown", n = "unknown";
8385
- return e.Bun || e.process && e.process.versions?.bun ? (t = "bun", n = e.Bun.version || "unknown") : e.Deno ? (t = "deno", n = e.Deno.version?.deno ?? "unknown") : e.process && e.process.release?.name === "node" ? (t = "node", n = e.process.versions?.node ?? "unknown") : e.HermesInternal ? (t = "hermes", n = e.HermesInternal.getRuntimeProperties?.()["OSS Release Version"] ?? "unknown") : i(e) && e.navigator.userAgent === "Cloudflare-Workers" ? t = "workerd" : i(e) && e.navigator.userAgent.toLowerCase().startsWith("quickjs-ng") ? (t = "quickjs-ng", n = e.navigator.userAgent.split("/")[1] ?? "unknown") : typeof e.Netlify == "object" ? t = "netlify" : typeof e.EdgeRuntime == "string" ? t = "edge-light" : e.__lagon__ ? t = "lagon" : e.fastly ? t = "fastly" : e.$262 && e.lockdown && e.AsyncDisposableStack ? t = "moddable" : e.d8 ? (t = "v8", n = typeof e.version == "function" ? e.version() : "unknown") : e.inIon && e.performance && e.performance.mozMemory ? t = "spidermonkey" : typeof e.$ == "object" && e.$ !== null && "IsHTMLDDA" in e.$ ? t = "jsc" : e.window && e.navigator && (t = "browser"), {
8387
+ if (e.Bun || e.process && e.process.versions?.bun) {
8388
+ t = "bun";
8389
+ let r = e.Bun?.version;
8390
+ if (r) n = r;
8391
+ else {
8392
+ let t = e.process?.versions?.bun;
8393
+ t && (n = t);
8394
+ }
8395
+ } else e.Deno ? (t = "deno", n = e.Deno.version?.deno ?? "unknown") : e.process && e.process.release?.name === "node" ? (t = "node", n = e.process.versions?.node ?? "unknown") : e.HermesInternal ? (t = "hermes", n = e.HermesInternal.getRuntimeProperties?.()["OSS Release Version"] ?? "unknown") : h(e) && e.navigator.userAgent === "Cloudflare-Workers" ? t = "workerd" : h(e) && e.navigator.userAgent.toLowerCase().startsWith("quickjs-ng") ? (t = "quickjs-ng", n = e.navigator.userAgent.split("/")[1] ?? "unknown") : typeof e.Netlify == "object" ? t = "netlify" : typeof e.EdgeRuntime == "string" ? t = "edge-light" : e.__lagon__ ? t = "lagon" : e.fastly ? t = "fastly" : e.$262 && e.lockdown && e.AsyncDisposableStack ? t = "moddable" : e.d8 ? (t = "v8", n = typeof e.version == "function" ? e.version() : "unknown") : e.inIon && e.performance && e.performance.mozMemory ? t = "spidermonkey" : typeof e.$ == "object" && e.$ !== null && "IsHTMLDDA" in e.$ ? t = "jsc" : e.window && e.navigator && (t = "browser");
8396
+ return {
8386
8397
  runtime: t,
8387
8398
  version: n
8388
8399
  };
8389
8400
  }
8390
- function i(e = globalThis) {
8401
+ function h(e = globalThis) {
8391
8402
  return typeof e.navigator == "object" && e.navigator !== null && typeof e.navigator.userAgent == "string";
8392
8403
  }
8393
- const { runtime: a, version: o } = r();
8394
- (async () => {}).constructor;
8404
+ const { runtime: g, version: _ } = m();
8395
8405
  globalThis.performance.now.bind(globalThis.performance);
8396
8406
  globalThis.process?.hrtime?.bigint.bind(globalThis.process?.hrtime);
8397
8407
  globalThis.Bun?.nanoseconds;
@@ -8687,7 +8697,7 @@ function memo(fn) {
8687
8697
  };
8688
8698
  }
8689
8699
  async function saveInlineSnapshots(environment, snapshots) {
8690
- const MagicString = (await import("./dist-vIVO6bA-.mjs")).default;
8700
+ const MagicString = (await import("./dist-DHer1cql.mjs")).default;
8691
8701
  const files = new Set(snapshots.map((i) => i.file));
8692
8702
  await Promise.all(Array.from(files).map(async (file) => {
8693
8703
  const snaps = snapshots.filter((i) => i.file === file);
@@ -9586,8 +9596,9 @@ function asymmetricMatch(a, b, customTesters) {
9586
9596
  const asymmetricA = isAsymmetric(a);
9587
9597
  const asymmetricB = isAsymmetric(b);
9588
9598
  if (asymmetricA && asymmetricB) return;
9589
- if (asymmetricA) return a.asymmetricMatch(b, customTesters);
9590
- if (asymmetricB) return b.asymmetricMatch(a, customTesters);
9599
+ const testers = customTesters.filter((tester) => !isSubsetEqualityTester(tester));
9600
+ if (asymmetricA) return a.asymmetricMatch(b, testers);
9601
+ if (asymmetricB) return b.asymmetricMatch(a, testers);
9591
9602
  }
9592
9603
  function isError(value) {
9593
9604
  if (typeof Error.isError === "function") return Error.isError(value);
@@ -9790,9 +9801,17 @@ function hasPropertyInObject(object, key) {
9790
9801
  function isObjectWithKeys(a) {
9791
9802
  return isObject(a) && !isError(a) && !Array.isArray(a) && !(a instanceof Date) && !(a instanceof Set) && !(a instanceof Map);
9792
9803
  }
9804
+ const subsetEqualityTesters = /* @__PURE__ */ new WeakSet();
9805
+ function registerSubsetEqualityTester(tester) {
9806
+ subsetEqualityTesters.add(tester);
9807
+ return tester;
9808
+ }
9809
+ function isSubsetEqualityTester(tester) {
9810
+ return tester === subsetEquality || subsetEqualityTesters.has(tester);
9811
+ }
9793
9812
  function subsetEquality(object, subset, customTesters = []) {
9794
9813
  const filteredCustomTesters = customTesters.filter((t) => t !== subsetEquality);
9795
- const subsetEqualityWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => (object, subset) => {
9814
+ const subsetEqualityWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => registerSubsetEqualityTester((object, subset) => {
9796
9815
  if (!isObjectWithKeys(subset)) return;
9797
9816
  return Object.keys(subset).every((key) => {
9798
9817
  if (subset[key] != null && typeof subset[key] === "object") {
@@ -9803,7 +9822,7 @@ function subsetEquality(object, subset, customTesters = []) {
9803
9822
  seenReferences.delete(subset[key]);
9804
9823
  return result;
9805
9824
  });
9806
- };
9825
+ });
9807
9826
  return subsetEqualityWithContext()(object, subset);
9808
9827
  }
9809
9828
  function typeEquality(a, b) {
@@ -0,0 +1,2 @@
1
+ import { B as UsageTokenTotals, F as UsageActivityTotals, G as addTotals, H as addActivityCount, I as UsageAggregate, J as registerSessionUsage, K as emptyTotals, L as UsageBucket, M as COUNTED_EVENT_TYPES, N as SESSION_USAGE_PATH, P as SessionUsageReport, R as UsageRangeKey, U as addActivityTotals, V as UsageTotals, W as addTokenTotals, Y as resolveUsageSince, q as localDayKey, z as UsageSessionRow } from "./log-CUjKQbOR.mjs";
2
+ export { COUNTED_EVENT_TYPES, SESSION_USAGE_PATH, SessionUsageReport, UsageActivityTotals, UsageAggregate, UsageBucket, UsageRangeKey, UsageSessionRow, UsageTokenTotals, UsageTotals, addActivityCount, addActivityTotals, addTokenTotals, addTotals, emptyTotals, localDayKey, registerSessionUsage, resolveUsageSince };