hippo-memory 3.2.0 → 3.2.2
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/base/memory/rule-replaces.d.ts +10 -0
- package/dist/base/memory/rule-replaces.js +14 -0
- package/dist/base/ports/store/capture.d.ts +3 -0
- package/dist/base/ports/store/types.d.ts +4 -2
- package/dist/base/util/version.d.ts +1 -1
- package/dist/base/util/version.js +1 -1
- package/dist/infra/anthropic-llm.js +4 -2
- package/dist/store/sqlite/capture/captures.js +34 -8
- package/dist/store/sqlite/entries/entry-writes.d.ts +5 -0
- package/dist/store/sqlite/entries/entry-writes.js +13 -0
- package/dist/store/sqlite/recall/candidates.js +4 -0
- package/dist/store/sqlite/sharing/copy-rows.d.ts +3 -0
- package/dist/store/sqlite/sharing/copy-rows.js +2 -1
- package/dist/surface/capture/command.d.ts +6 -2
- package/dist/surface/capture/command.js +57 -38
- package/dist/surface/capture/extract.d.ts +7 -1
- package/dist/surface/capture/extract.js +29 -11
- package/dist-ui/assets/index-CHXQD8Lk.css +1 -0
- package/dist-ui/assets/index-Q9SY-1Bj.js +1 -0
- package/dist-ui/assets/react-O0ULxr_i.js +9 -0
- package/dist-ui/index.html +3 -3
- package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
- package/extensions/openclaw-plugin/package.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -2
- package/dist-ui/assets/index-DWo8WuPW.js +0 -33
- package/dist-ui/assets/index-dFloKRVr.css +0 -1
- package/dist-ui/assets/react-BZPdts19.js +0 -17
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MemoryEntry } from './entry.js';
|
|
2
|
+
type HeldCopy = Partial<Pick<MemoryEntry, 'source' | 'pinned' | 'tags' | 'originProject' | 'supersededBy'>> & {
|
|
3
|
+
confidence?: string;
|
|
4
|
+
};
|
|
5
|
+
/** Whether a stated rule replaces this held copy: a live, observed capture row of `ruleProject`
|
|
6
|
+
* (the rule's project names), unpinned or pinned without the user-rule tag. Any other copy stops
|
|
7
|
+
* the rule, so a replayed transcript revives nothing and no project loses its row. */
|
|
8
|
+
export declare function ruleReplaces(row: HeldCopy, ruleProject: readonly string[]): boolean;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=rule-replaces.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Not in same-text because it reads the user-rule tag, and base/util may not import base/memory.
|
|
2
|
+
import { USER_RULE_TAG } from './entry.js';
|
|
3
|
+
/** Whether a stated rule replaces this held copy: a live, observed capture row of `ruleProject`
|
|
4
|
+
* (the rule's project names), unpinned or pinned without the user-rule tag. Any other copy stops
|
|
5
|
+
* the rule, so a replayed transcript revives nothing and no project loses its row. */
|
|
6
|
+
export function ruleReplaces(row, ruleProject) {
|
|
7
|
+
return ((row.pinned !== true || (row.tags !== undefined && !row.tags.includes(USER_RULE_TAG))) &&
|
|
8
|
+
row.source === 'capture' &&
|
|
9
|
+
Boolean(row.originProject) &&
|
|
10
|
+
ruleProject.includes(row.originProject ?? '') &&
|
|
11
|
+
row.supersededBy == null &&
|
|
12
|
+
row.confidence === 'observed');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=rule-replaces.js.map
|
|
@@ -38,6 +38,9 @@ export interface CaptureDedup {
|
|
|
38
38
|
readonly tenantId: TenantId;
|
|
39
39
|
readonly project?: readonly string[];
|
|
40
40
|
readonly everyScope?: boolean;
|
|
41
|
+
/** The names of the project a stated rule is written for: a held copy of one of them gives way
|
|
42
|
+
* to the rule. None replaces nothing. */
|
|
43
|
+
readonly ruleProject?: readonly string[];
|
|
41
44
|
}
|
|
42
45
|
/** Each method opens hippo.db with the hook's wait, so a busy store costs the hook a bounded
|
|
43
46
|
* delay. */
|
|
@@ -112,8 +112,10 @@ export interface AuditEvent {
|
|
|
112
112
|
targetId: string | null;
|
|
113
113
|
metadata: JsonObject;
|
|
114
114
|
}
|
|
115
|
-
/** A stored text the capture dedup reads; `pinned`
|
|
116
|
-
export type HeldText = Pick<MemoryEntry, 'content' | 'source' | 'originProject'> & Partial<Pick<MemoryEntry, 'pinned'
|
|
115
|
+
/** A stored text the capture dedup reads; `pinned` and `tags` are optional so an adapter that omits them still fits. */
|
|
116
|
+
export type HeldText = Pick<MemoryEntry, 'content' | 'source' | 'originProject'> & Partial<Pick<MemoryEntry, 'pinned' | 'tags' | 'id' | 'supersededBy'>> & {
|
|
117
|
+
confidence?: string;
|
|
118
|
+
};
|
|
117
119
|
/** One project name, or every name a project's rows carry. */
|
|
118
120
|
export type OriginFilter = string | readonly string[];
|
|
119
121
|
/** The api_keys fields a tenant, revocation, rank or self-service ownership check reads. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Single source of truth for the package version, written by scripts/sync-version.mjs; never
|
|
3
3
|
* edit by hand. Read by the db rollback guard, /health, MCP. A constant, not a runtime
|
|
4
4
|
* package.json read: the published bundle may lack package.json on a path ESM can resolve. */
|
|
5
|
-
export declare const PACKAGE_VERSION = "3.2.
|
|
5
|
+
export declare const PACKAGE_VERSION = "3.2.2";
|
|
6
6
|
/** The floor a store takes on its first expiring key: the first release with schema v53, set by
|
|
7
7
|
* hand in that release; scripts/checks/check-expiring-keys-floor.mjs gates it. */
|
|
8
8
|
export declare const EXPIRING_KEYS_MIN_BINARY = "1.64.0";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Single source of truth for the package version, written by scripts/sync-version.mjs; never
|
|
3
3
|
* edit by hand. Read by the db rollback guard, /health, MCP. A constant, not a runtime
|
|
4
4
|
* package.json read: the published bundle may lack package.json on a path ESM can resolve. */
|
|
5
|
-
export const PACKAGE_VERSION = '3.2.
|
|
5
|
+
export const PACKAGE_VERSION = '3.2.2';
|
|
6
6
|
/** The floor a store takes on its first expiring key: the first release with schema v53, set by
|
|
7
7
|
* hand in that release; scripts/checks/check-expiring-keys-floor.mjs gates it. */
|
|
8
8
|
export const EXPIRING_KEYS_MIN_BINARY = '1.64.0';
|
|
@@ -13,9 +13,11 @@ const DEFAULT_MODEL = 'claude-sonnet-4-6';
|
|
|
13
13
|
// The error body names the cause (bad key, no credit, unknown model) in its first line or two.
|
|
14
14
|
const ERROR_SNIPPET_CHARS = 256;
|
|
15
15
|
const UTF8_MAX_BYTES_PER_CHAR = 4;
|
|
16
|
-
/** The first
|
|
16
|
+
/** The first text block's text, trimmed; empty when the reply has no such block. A thinking
|
|
17
|
+
* model puts its thinking block first. */
|
|
17
18
|
function firstText(reply) {
|
|
18
|
-
const
|
|
19
|
+
const blocks = Array.isArray(reply.content) ? reply.content : [];
|
|
20
|
+
const first = blocks.find((block) => isJsonObject(block) && isJsonString(block.text));
|
|
19
21
|
const text = isJsonObject(first) ? first.text : undefined;
|
|
20
22
|
return isJsonString(text) ? text.trim() : '';
|
|
21
23
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// hippo.db's Captures: the whole batch on one handle, opened with openStore since a write sets up
|
|
2
2
|
// the mirror folders.
|
|
3
3
|
import { withWriteScope } from '../../../db/index.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { USER_RULE_TAG } from '../../../base/memory/entry.js';
|
|
5
|
+
import { duplicateKey, heldTextKeys, storedTextKeys } from '../../../base/util/same-text.js';
|
|
6
|
+
import { ruleReplaces } from '../../../base/memory/rule-replaces.js';
|
|
7
|
+
import { CLI_ACTOR } from '../../../base/scope/actor.js';
|
|
8
|
+
import { supersedeInTx, writeEntryMirrors } from '../entries/entry-writes.js';
|
|
6
9
|
import { stampOriginProject } from '../entries/entry-row.js';
|
|
7
10
|
import { gatedWrite } from './gated-write.js';
|
|
8
11
|
import { updateStatsOn } from '../entries/index-and-stats.js';
|
|
@@ -10,29 +13,52 @@ import { listTextsHolding } from '../recall/candidates.js';
|
|
|
10
13
|
import { EVERY_SCOPE } from '../runtime/rule-sql.js';
|
|
11
14
|
import { openStore } from '../runtime/handles.js';
|
|
12
15
|
import { bound, skipEmpty } from '../runtime/bound.js';
|
|
13
|
-
/** The
|
|
14
|
-
function
|
|
16
|
+
/** The rows under `dedup` that may hold an entry's text. */
|
|
17
|
+
function heldRows(db, entries, dedup) {
|
|
15
18
|
const texts = entries.map((entry) => entry.content);
|
|
16
19
|
const admit = dedup.everyScope ? EVERY_SCOPE : undefined;
|
|
17
|
-
return
|
|
20
|
+
return listTextsHolding(db, { tenantId: dedup.tenantId, texts, project: dedup.project, admit });
|
|
21
|
+
}
|
|
22
|
+
/** The caller's rule project names when the stamped rule carries one of them, else none. */
|
|
23
|
+
function ruleProjectNames(rule, dedup) {
|
|
24
|
+
const origin = rule.originProject;
|
|
25
|
+
return origin && dedup.ruleProject?.includes(origin) ? dedup.ruleProject : [];
|
|
26
|
+
}
|
|
27
|
+
/** The ids of the held copies of the stamped rule's text that the rule replaces. */
|
|
28
|
+
function copiesTheRuleReplaces(rows, rule, project) {
|
|
29
|
+
const key = duplicateKey(rule.content);
|
|
30
|
+
return rows.flatMap(({ id, ...row }) => id !== undefined && ruleReplaces(row, project) && heldTextKeys(row).includes(key) ? [id] : []);
|
|
18
31
|
}
|
|
19
32
|
/** One outcome per entry, in order, in one transaction that reads the caller's dedup again
|
|
20
33
|
* first, so a text another writer stored since that read is skipped; mirrors and stats follow
|
|
21
34
|
* the commit. */
|
|
22
35
|
function writeCapturedEntries(db, files, entries, opts) {
|
|
23
36
|
const written = [];
|
|
37
|
+
const actor = opts.actor ?? CLI_ACTOR;
|
|
24
38
|
const outcomes = withWriteScope(db, 'capture_write', () => {
|
|
25
|
-
const
|
|
39
|
+
const rows = heldRows(db, entries, opts.dedup);
|
|
40
|
+
const held = storedTextKeys(rows);
|
|
26
41
|
return entries.map((entry) => {
|
|
27
|
-
|
|
42
|
+
const stamped = stampOriginProject(files, entry);
|
|
43
|
+
// A stated rule replaces an unpinned or untagged-pin capture copy of its own project, which
|
|
44
|
+
// would hide it from the hooks.
|
|
45
|
+
const project = entry.tags.includes(USER_RULE_TAG)
|
|
46
|
+
? ruleProjectNames(stamped, opts.dedup)
|
|
47
|
+
: null;
|
|
48
|
+
const stops = project ? storedTextKeys(rows.filter((r) => !ruleReplaces(r, project))) : held;
|
|
49
|
+
if (stops.has(duplicateKey(entry.content)))
|
|
28
50
|
return 'skipped';
|
|
29
51
|
// One rejected entry must not abort the rest of this capture's entries.
|
|
30
|
-
const stamped = stampOriginProject(files, entry);
|
|
31
52
|
const outcome = gatedWrite(db, files, stamped, { actor: opts.actor });
|
|
32
53
|
if (outcome === 'skipped:rejected')
|
|
33
54
|
return 'rejected';
|
|
34
55
|
if (outcome !== 'written')
|
|
35
56
|
return 'skipped';
|
|
57
|
+
if (project) {
|
|
58
|
+
for (const id of copiesTheRuleReplaces(rows, stamped, project)) {
|
|
59
|
+
supersedeInTx(db, { tenantId: stamped.tenantId, id, newId: stamped.id, actor });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
36
62
|
written.push(stamped);
|
|
37
63
|
return 'captured';
|
|
38
64
|
});
|
|
@@ -106,6 +106,11 @@ interface SupersedeEntryOptions {
|
|
|
106
106
|
}
|
|
107
107
|
/** Marks `id` superseded by `newId`; false when another writer superseded it first. */
|
|
108
108
|
export declare function supersedeEntry(db: DatabaseSyncLike, { tenantId, id, newId }: SupersedeEntryOptions): boolean;
|
|
109
|
+
/** Marks `id` superseded by `newId` in the caller's transaction, with the supersede audit row and
|
|
110
|
+
* its summary parent's dirty mark; false when the row is gone or another writer got there first. */
|
|
111
|
+
export declare function supersedeInTx(db: DatabaseSyncLike, { tenantId, id, newId, actor }: SupersedeEntryOptions & {
|
|
112
|
+
actor: string;
|
|
113
|
+
}): boolean;
|
|
109
114
|
/** Each call on its own handle; mirrors and the forgotten counter follow the commit, so a
|
|
110
115
|
* rolled-back write leaves neither. */
|
|
111
116
|
export declare function sqliteEntryWrites({ on, files }: Handles): EntryWrites;
|
|
@@ -294,6 +294,19 @@ export function supersedeEntry(db, { tenantId, id, newId }) {
|
|
|
294
294
|
const result = cachedStatement(db, `UPDATE memories SET superseded_by = ? WHERE id = ? AND tenant_id = ? AND superseded_by IS NULL`).run(newId, id, tenantId);
|
|
295
295
|
return Number(result.changes ?? 0) !== 0;
|
|
296
296
|
}
|
|
297
|
+
/** Marks `id` superseded by `newId` in the caller's transaction, with the supersede audit row and
|
|
298
|
+
* its summary parent's dirty mark; false when the row is gone or another writer got there first. */
|
|
299
|
+
export function supersedeInTx(db, { tenantId, id, newId, actor }) {
|
|
300
|
+
const won = cachedStatement(db, 'UPDATE memories SET superseded_by = ? WHERE id = ? AND tenant_id = ? AND superseded_by IS NULL ' +
|
|
301
|
+
'RETURNING dag_parent_id').get(newId, id, tenantId);
|
|
302
|
+
if (!won)
|
|
303
|
+
return false;
|
|
304
|
+
if (won.dag_parent_id) {
|
|
305
|
+
markSummaryDirtyInTx(db, { summaryId: won.dag_parent_id, tenantId, actor });
|
|
306
|
+
}
|
|
307
|
+
appendAuditEvents(db, [{ tenantId, actor, op: 'supersede', targetId: id, metadata: { newId } }]);
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
297
310
|
/** Each call on its own handle; mirrors and the forgotten counter follow the commit, so a
|
|
298
311
|
* rolled-back write leaves neither. */
|
|
299
312
|
export function sqliteEntryWrites({ on, files }) {
|
|
@@ -295,10 +295,14 @@ export function listTextsHolding(db, { tenantId, texts, project, admit = TEAM_VI
|
|
|
295
295
|
const byId = new Map();
|
|
296
296
|
for (const row of rowsHoldingTexts(db, { tenantId, filter }, texts)) {
|
|
297
297
|
byId.set(row.id, {
|
|
298
|
+
id: row.id,
|
|
298
299
|
content: row.content,
|
|
299
300
|
source: row.source,
|
|
300
301
|
originProject: row.origin_project,
|
|
301
302
|
pinned: row.pinned === 1,
|
|
303
|
+
tags: parseJsonArray(row.tags_json),
|
|
304
|
+
supersededBy: row.superseded_by,
|
|
305
|
+
confidence: row.confidence,
|
|
302
306
|
});
|
|
303
307
|
}
|
|
304
308
|
return [...byId.values()];
|
|
@@ -10,6 +10,9 @@ export type CopyDbRow = {
|
|
|
10
10
|
source: string;
|
|
11
11
|
origin_project: string | null;
|
|
12
12
|
pinned: number;
|
|
13
|
+
tags_json: string | null;
|
|
14
|
+
superseded_by: string | null;
|
|
15
|
+
confidence: string;
|
|
13
16
|
};
|
|
14
17
|
/** Which rows of the tenant a copy read looks at: `filter` adds predicates, each written ` AND
|
|
15
18
|
* ...`. */
|
|
@@ -33,7 +33,8 @@ const MAY_HOLD_COPY_SQL = `(${bareTextSql('content')} IN (SELECT value FROM json
|
|
|
33
33
|
function copyChunk(db, read, texts, phrases) {
|
|
34
34
|
const tenant = tenantAnd(read.tenantId, phrases ? TENANT_IS : 'tenant_id = ?');
|
|
35
35
|
const bares = JSON.stringify([...new Set(texts.map(bareText))]);
|
|
36
|
-
return cachedStatement(db, `SELECT id, tenant_id, content, source, origin_project, pinned
|
|
36
|
+
return cachedStatement(db, `SELECT id, tenant_id, content, source, origin_project, pinned, tags_json, superseded_by, confidence ` +
|
|
37
|
+
`FROM memories ` +
|
|
37
38
|
`WHERE ${phrases ? IN_PHRASE_HITS : '1'}` +
|
|
38
39
|
`${tenant.sql}${read.filter.sql} AND ${MAY_HOLD_COPY_SQL}`).all(...(phrases ? [phrases.join(' OR ')] : []), ...tenant.params, ...read.filter.params, bares, bares);
|
|
39
40
|
}
|
|
@@ -46,11 +46,15 @@ export interface CaptureTarget {
|
|
|
46
46
|
}
|
|
47
47
|
export declare function runCapture(target: CaptureTarget, options: CaptureOptions): Promise<void>;
|
|
48
48
|
/** The items with `scrub` applied to each text, as a path stores them; scrubbing can make two
|
|
49
|
-
* items one, and the first stays. */
|
|
49
|
+
* items one, and the first stays unless a later one is the person's rule. */
|
|
50
50
|
export declare function scrubbedItems(items: readonly ExtractedItem[], scrub: (text: string) => string): ExtractedItem[];
|
|
51
51
|
/** Held keys, each twin's clean text too when a held row has its old text and repair keeps that
|
|
52
52
|
* row: a pinned row, or one whose text is no certain defect. */
|
|
53
53
|
export declare function heldKeysOf(rows: readonly HeldText[], twins: readonly BoldTwin[]): Set<string>;
|
|
54
|
+
/** The held keys that also stop a stated rule written for `ruleProject` (its names): every copy
|
|
55
|
+
* but one the store's write replaces, which holds the rule's exact text, so a bold twin still
|
|
56
|
+
* stops it. */
|
|
57
|
+
export declare function ruleHeldKeysOf(rows: readonly HeldText[], twins: readonly BoldTwin[], ruleProject: readonly string[]): Set<string>;
|
|
54
58
|
export interface CaptureTally {
|
|
55
59
|
captured: number;
|
|
56
60
|
skipped: number;
|
|
@@ -80,5 +84,5 @@ export interface ConfiguredStore {
|
|
|
80
84
|
}
|
|
81
85
|
/** Writes each new text once; a repeat of a captured text in the same batch counts as skipped,
|
|
82
86
|
* as a held one does. */
|
|
83
|
-
export declare function captureExtractedItems({ store, config, embed }: ConfiguredStore, options: CaptureWriteOptions, extracted: readonly ExtractedItem[], keys: Set<string>): Promise<CaptureTally>;
|
|
87
|
+
export declare function captureExtractedItems({ store, config, embed }: ConfiguredStore, options: CaptureWriteOptions, extracted: readonly ExtractedItem[], keys: Set<string>, ruleKeys?: ReadonlySet<string>): Promise<CaptureTally>;
|
|
84
88
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -2,6 +2,7 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { createMemory, Layer, USER_RULE_TAG } from '../../base/memory/entry.js';
|
|
4
4
|
import { duplicateKey, storedTextKeys } from '../../base/util/same-text.js';
|
|
5
|
+
import { ruleReplaces } from '../../base/memory/rule-replaces.js';
|
|
5
6
|
import { isCertainReason, storedDefect } from '../../base/memory/memory-quality.js';
|
|
6
7
|
import { maskEmails, redactSecretsStrict } from '../../base/util/secret-detect.js';
|
|
7
8
|
import { projectId, projectNames } from '../../base/scope/project-identity.js';
|
|
@@ -9,7 +10,7 @@ import { isInitialized } from '../../host/project-identity.js';
|
|
|
9
10
|
import { errorMessage, log, errorFields } from '../../base/util/log.js';
|
|
10
11
|
import { teeStdStreams } from '../../host/stream-tee.js';
|
|
11
12
|
import { ALL_TENANTS } from '../../base/util/tenant.js';
|
|
12
|
-
import { boldTwins, extractFromTexts } from './extract.js';
|
|
13
|
+
import { boldTwins, extractFromTexts, isStatedRule, oncePerText, } from './extract.js';
|
|
13
14
|
import { collectSessionTurns, sessionTail, resolveLastSessionTranscript, } from './transcript.js';
|
|
14
15
|
import { PRIVATE_DIR } from '../../host/private-dir.js';
|
|
15
16
|
import { evalClock } from '../../infra/eval-switches.js';
|
|
@@ -81,66 +82,79 @@ async function runCaptureCore(target, options) {
|
|
|
81
82
|
console.log('No actionable items found in the input.');
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
85
|
+
const dedup = await captureDedup(target.store.folderFiles, options);
|
|
86
|
+
const held = await storedKeysInView(target.store, dedup, extracted, boldTwins(scrubbed, scrub));
|
|
87
|
+
printCaptureTally(options, await captureFromCli(target, options, dedup, extracted, held));
|
|
86
88
|
}
|
|
87
|
-
async function captureFromCli({ store, config, embed }, options, extracted, keys) {
|
|
89
|
+
async function captureFromCli({ store, config, embed }, options, dedup, extracted, { keys, ruleKeys }) {
|
|
88
90
|
const writeOpts = {
|
|
89
91
|
tenantId: options.global ? undefined : options.tenantId,
|
|
90
92
|
originProject: options.originProject,
|
|
91
93
|
lean: false,
|
|
92
|
-
dedup
|
|
94
|
+
dedup,
|
|
93
95
|
now: evalClock()(),
|
|
94
96
|
};
|
|
95
97
|
if (!options.dryRun) {
|
|
96
|
-
return captureExtractedItems({ store, config, embed }, writeOpts, extracted, keys);
|
|
98
|
+
return captureExtractedItems({ store, config, embed }, writeOpts, extracted, keys, ruleKeys);
|
|
97
99
|
}
|
|
98
|
-
return previewCapture({ store, config }, writeOpts, extracted, keys);
|
|
100
|
+
return previewCapture({ store, config }, writeOpts, extracted, keys, ruleKeys);
|
|
99
101
|
}
|
|
100
102
|
/** The items with `scrub` applied to each text, as a path stores them; scrubbing can make two
|
|
101
|
-
* items one, and the first stays. */
|
|
103
|
+
* items one, and the first stays unless a later one is the person's rule. */
|
|
102
104
|
export function scrubbedItems(items, scrub) {
|
|
103
|
-
|
|
104
|
-
return items
|
|
105
|
-
.map((item) => ({ ...item, content: scrub(item.content) }))
|
|
106
|
-
.filter((item) => {
|
|
107
|
-
const key = duplicateKey(item.content);
|
|
108
|
-
if (seen.has(key))
|
|
109
|
-
return false;
|
|
110
|
-
seen.add(key);
|
|
111
|
-
return true;
|
|
112
|
-
});
|
|
105
|
+
return oncePerText(items.map((item) => ({ ...item, content: scrub(item.content) })));
|
|
113
106
|
}
|
|
114
107
|
/** Held keys, each twin's clean text too when a held row has its old text and repair keeps that
|
|
115
108
|
* row: a pinned row, or one whose text is no certain defect. */
|
|
116
109
|
export function heldKeysOf(rows, twins) {
|
|
110
|
+
const keys = storedTextKeys(rows);
|
|
111
|
+
for (const key of twinKeys(rows, twins))
|
|
112
|
+
keys.add(key);
|
|
113
|
+
return keys;
|
|
114
|
+
}
|
|
115
|
+
/** The held keys that also stop a stated rule written for `ruleProject` (its names): every copy
|
|
116
|
+
* but one the store's write replaces, which holds the rule's exact text, so a bold twin still
|
|
117
|
+
* stops it. */
|
|
118
|
+
export function ruleHeldKeysOf(rows, twins, ruleProject) {
|
|
119
|
+
const keys = storedTextKeys(rows.filter((row) => !ruleReplaces(row, ruleProject)));
|
|
120
|
+
for (const key of twinKeys(rows, twins))
|
|
121
|
+
keys.add(key);
|
|
122
|
+
return keys;
|
|
123
|
+
}
|
|
124
|
+
function twinKeys(rows, twins) {
|
|
117
125
|
const keys = storedTextKeys(rows);
|
|
118
126
|
const pinned = storedTextKeys(rows.filter((row) => row.pinned));
|
|
119
|
-
|
|
127
|
+
return twins
|
|
120
128
|
.filter(({ old }) => (isCertainReason(storedDefect(old)) ? pinned : keys).has(duplicateKey(old)))
|
|
121
129
|
.map((twin) => duplicateKey(twin.clean));
|
|
122
|
-
for (const key of clean)
|
|
123
|
-
keys.add(key);
|
|
124
|
-
return keys;
|
|
125
130
|
}
|
|
126
131
|
// Dedup only against rows this capture's reader sees: another tenant's or project's rows are
|
|
127
132
|
// hidden, so they must not stop its own copy.
|
|
128
|
-
async function storedKeysInView(store,
|
|
129
|
-
const { tenantId, ...filter } = captureDedup(options);
|
|
133
|
+
async function storedKeysInView(store, { tenantId, project, everyScope, ruleProject = [] }, extracted, twins) {
|
|
130
134
|
// The lookup matches stored text exactly, so it also asks for the lines as capture once stored them.
|
|
131
135
|
const texts = [...extracted.map((item) => item.content), ...twins.map((twin) => twin.old)];
|
|
132
|
-
|
|
136
|
+
const rows = await store.captures.textsHolding(tenantId, texts, { project, everyScope });
|
|
137
|
+
return { keys: heldKeysOf(rows, twins), ruleKeys: ruleHeldKeysOf(rows, twins, ruleProject) };
|
|
133
138
|
}
|
|
134
139
|
/** The rows a capture's dedup reads, as data, so the store's write can read them again in its
|
|
135
|
-
* own transaction. */
|
|
136
|
-
function captureDedup(options) {
|
|
140
|
+
* own transaction, and the project a stated rule is written for. */
|
|
141
|
+
async function captureDedup(folderFiles, options) {
|
|
137
142
|
const tenantId = options.global ? ALL_TENANTS : options.tenantId;
|
|
138
143
|
const origin = options.originProject;
|
|
139
144
|
// classifyOriginProject in SQL: a project with no id sees every row, any other its own names and
|
|
140
145
|
// user-global rows.
|
|
141
|
-
if (origin
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
if (origin !== undefined && projectId(origin) !== '') {
|
|
147
|
+
const names = projectNames(origin);
|
|
148
|
+
return { tenantId, everyScope: true, project: names, ruleProject: names };
|
|
149
|
+
}
|
|
150
|
+
const ruleProject = origin === undefined ? await stampedProject(folderFiles) : [];
|
|
151
|
+
return { tenantId, everyScope: true, ruleProject };
|
|
152
|
+
}
|
|
153
|
+
/** The names of the project the store stamps on a row that names none: none for a shared or a
|
|
154
|
+
* user-global store. */
|
|
155
|
+
async function stampedProject(folderFiles) {
|
|
156
|
+
const { shared, project } = await folderFiles.home();
|
|
157
|
+
return shared || projectId(project) === '' ? [] : projectNames(project);
|
|
144
158
|
}
|
|
145
159
|
function printCaptureTally(options, { captured, skipped, rejected }) {
|
|
146
160
|
const prefix = options.dryRun ? '[dry-run] ' : '';
|
|
@@ -203,12 +217,12 @@ function readSessionTexts(options) {
|
|
|
203
217
|
}
|
|
204
218
|
/** One entry per new text: building can throw, so a held text or a repeat within the batch is
|
|
205
219
|
* never built. */
|
|
206
|
-
function planCapture(extracted,
|
|
220
|
+
function planCapture(extracted, isHeld, build) {
|
|
207
221
|
const plan = { entries: [], keys: [], slots: [] };
|
|
208
222
|
const firstSlot = new Map();
|
|
209
223
|
for (const item of extracted) {
|
|
210
224
|
const key = duplicateKey(item.content);
|
|
211
|
-
let slot =
|
|
225
|
+
let slot = isHeld(item, key) ? -1 : firstSlot.get(key);
|
|
212
226
|
if (slot === undefined) {
|
|
213
227
|
slot = plan.entries.push(build(item)) - 1;
|
|
214
228
|
plan.keys.push(key);
|
|
@@ -218,10 +232,14 @@ function planCapture(extracted, held, build) {
|
|
|
218
232
|
}
|
|
219
233
|
return plan;
|
|
220
234
|
}
|
|
235
|
+
/** Whether a held text stops `item`: any copy stops a note, only a `ruleKeys` copy a stated rule. */
|
|
236
|
+
function heldCheck(keys, ruleKeys) {
|
|
237
|
+
return (item, key) => (isStatedRule(item) ? ruleKeys : keys).has(key);
|
|
238
|
+
}
|
|
221
239
|
/** Writes each new text once; a repeat of a captured text in the same batch counts as skipped,
|
|
222
240
|
* as a held one does. */
|
|
223
|
-
export async function captureExtractedItems({ store, config, embed }, options, extracted, keys) {
|
|
224
|
-
const plan = planCapture(extracted, keys, (item) => captureEntry(item, options, config.defaultHalfLifeDays));
|
|
241
|
+
export async function captureExtractedItems({ store, config, embed }, options, extracted, keys, ruleKeys = keys) {
|
|
242
|
+
const plan = planCapture(extracted, heldCheck(keys, ruleKeys), (item) => captureEntry(item, options, config.defaultHalfLifeDays));
|
|
225
243
|
const { actor, lean, dedup } = options;
|
|
226
244
|
const outcomes = await store.captures.write(plan.entries, { actor, lean, dedup });
|
|
227
245
|
const tally = { captured: 0, skipped: 0, rejected: 0 };
|
|
@@ -242,16 +260,17 @@ export async function captureExtractedItems({ store, config, embed }, options, e
|
|
|
242
260
|
}
|
|
243
261
|
/** A dry run asks the store the same rejected-value question the write's gate does, so a
|
|
244
262
|
* tombstoned item previews as rejected rather than captured. */
|
|
245
|
-
async function previewCapture({ store: { rejections }, config }, options, extracted, keys) {
|
|
263
|
+
async function previewCapture({ store: { rejections }, config }, options, extracted, keys, ruleKeys) {
|
|
246
264
|
const tally = { captured: 0, skipped: 0, rejected: 0 };
|
|
247
|
-
const
|
|
265
|
+
const held = heldCheck(keys, ruleKeys);
|
|
266
|
+
const fresh = extracted.filter((item) => !held(item, duplicateKey(item.content)));
|
|
248
267
|
const refused = await rejections.refusedAmong(fresh.map((item) => {
|
|
249
268
|
const entry = captureEntry(item, options, config.defaultHalfLifeDays);
|
|
250
269
|
return { tenantId: entry.tenantId, entryId: entry.id, content: entry.content };
|
|
251
270
|
}));
|
|
252
271
|
let next = 0;
|
|
253
272
|
for (const item of extracted) {
|
|
254
|
-
if (
|
|
273
|
+
if (held(item, duplicateKey(item.content))) {
|
|
255
274
|
tally.skipped++;
|
|
256
275
|
console.log(` [skip] (${item.category}) ${item.content.slice(0, 80)}`);
|
|
257
276
|
}
|
|
@@ -272,7 +291,7 @@ function captureEntry(item, options, baseHalfLifeDays) {
|
|
|
272
291
|
// 'default'. A rule the person stated is pinned, so it injects even when a later prompt shares
|
|
273
292
|
// none of its words. SHORTCUT: every stated rule pins; cap or age these pins if a store's pins
|
|
274
293
|
// outgrow the hook budget. The from-user tag marks the same pin as the person's rule for the hooks.
|
|
275
|
-
const stated = item
|
|
294
|
+
const stated = isStatedRule(item);
|
|
276
295
|
const created = createMemory(item.content, {
|
|
277
296
|
layer: Layer.Episodic,
|
|
278
297
|
tags: stated ? [...item.tags, USER_RULE_TAG] : item.tags,
|
|
@@ -5,8 +5,14 @@ export interface ExtractedItem {
|
|
|
5
5
|
/** A person said it, not the agent: capture pins a rule that carries this. */
|
|
6
6
|
fromUser?: boolean;
|
|
7
7
|
}
|
|
8
|
+
/** A rule the person stated: capture pins it and tags it as theirs. */
|
|
9
|
+
export declare function isStatedRule(item: ExtractedItem): boolean;
|
|
10
|
+
/** Each text once, where its first copy stood; a later copy that is the person's rule replaces a
|
|
11
|
+
* first copy that is not, so a preference restated in a reply keeps its rule status. */
|
|
12
|
+
export declare function oncePerText(items: readonly ExtractedItem[], admit?: (item: ExtractedItem) => boolean): ExtractedItem[];
|
|
8
13
|
/** Captures complete supported statements, each text parsed alone so a fence or heading in one never reaches the next.
|
|
9
|
-
* The first `userTexts` texts are a person's own words; on a repeat their copy wins, so it keeps `fromUser
|
|
14
|
+
* The first `userTexts` texts are a person's own words; on a repeat their copy wins, so it keeps `fromUser`,
|
|
15
|
+
* and a copy that is their rule wins over one that is not.
|
|
10
16
|
* From `firstFollowUp` on, those words answer the agent's work, so a statement in them can be the person's rule. */
|
|
11
17
|
export declare function extractFromTexts(texts: readonly string[], userTexts?: number, firstFollowUp?: number): ExtractedItem[];
|
|
12
18
|
/** A text an older capture, which kept every bold marker, stored for a line, and what capture
|
|
@@ -2,6 +2,28 @@ import { duplicateKey } from '../../base/util/same-text.js';
|
|
|
2
2
|
import { assessAutomaticMemory, asideCloseOffset, QUOTE_MARK, } from '../../base/memory/memory-quality.js';
|
|
3
3
|
import { ERROR_TAG } from '../../base/memory/entry.js';
|
|
4
4
|
import { blankCodeSpans, strongMarkers } from '../../base/memory/markdown-delimiters.js';
|
|
5
|
+
/** A rule the person stated: capture pins it and tags it as theirs. */
|
|
6
|
+
export function isStatedRule(item) {
|
|
7
|
+
return item.fromUser === true && item.category === 'rule';
|
|
8
|
+
}
|
|
9
|
+
/** Each text once, where its first copy stood; a later copy that is the person's rule replaces a
|
|
10
|
+
* first copy that is not, so a preference restated in a reply keeps its rule status. */
|
|
11
|
+
export function oncePerText(items, admit = () => true) {
|
|
12
|
+
const kept = [];
|
|
13
|
+
const slot = new Map();
|
|
14
|
+
for (const item of items) {
|
|
15
|
+
const key = duplicateKey(item.content);
|
|
16
|
+
const at = slot.get(key);
|
|
17
|
+
if (at === undefined) {
|
|
18
|
+
if (admit(item))
|
|
19
|
+
slot.set(key, kept.push(item) - 1);
|
|
20
|
+
}
|
|
21
|
+
else if (isStatedRule(item) && !isStatedRule(kept[at]) && admit(item)) {
|
|
22
|
+
kept[at] = item;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return kept;
|
|
26
|
+
}
|
|
5
27
|
const DECISION_PATTERNS = [
|
|
6
28
|
/\b(?:we(?:'ve| have)?|i(?:'ve| have)?|let's)\s+decid(?:ed|e)\b/i,
|
|
7
29
|
/\b(?:let's|we(?:'ll| will| should)?)\s+(?:go with|do|use|try|build|implement|switch to)\b/i,
|
|
@@ -44,12 +66,15 @@ const FENCE_OPEN = /^(?:(?:[-*]|\d+\.)\s+)?(`{3,}|~{3,})(.*)$/;
|
|
|
44
66
|
const FENCE_CLOSE = /^(`{3,}|~{3,})\s*$/;
|
|
45
67
|
// Inline code and abbreviation dots never end a sentence; "etc." does when a capital follows.
|
|
46
68
|
const NO_BREAK = /(`+)[^`\n]+\1|\b(?:[Ee]\.g|[Ii]\.e|[Vv]s|[Cc]f)\.|\betc\.(?=\s+[a-z])/g;
|
|
69
|
+
// Pasted text is not the speaker's own; an unclosed block runs to the end.
|
|
70
|
+
const PASTED_BLOCK = /<pasted_content\b[^>]*>[\s\S]*?(?:<\/pasted_content>|$)/g;
|
|
47
71
|
/** CommonMark fences: a backtick run with a backtick after it is inline code, and only a bare
|
|
48
72
|
* run as long closes. */
|
|
49
73
|
function proseOnly(text) {
|
|
50
74
|
let fence = null;
|
|
51
75
|
let afterProse = false;
|
|
52
76
|
return text
|
|
77
|
+
.replace(PASTED_BLOCK, '\n')
|
|
53
78
|
.split('\n')
|
|
54
79
|
.map((line) => {
|
|
55
80
|
const trimmed = line.trimStart();
|
|
@@ -348,19 +373,12 @@ function extractSourced(text, cuts, followUp = false) {
|
|
|
348
373
|
return found;
|
|
349
374
|
}
|
|
350
375
|
/** Captures complete supported statements, each text parsed alone so a fence or heading in one never reaches the next.
|
|
351
|
-
* The first `userTexts` texts are a person's own words; on a repeat their copy wins, so it keeps `fromUser
|
|
376
|
+
* The first `userTexts` texts are a person's own words; on a repeat their copy wins, so it keeps `fromUser`,
|
|
377
|
+
* and a copy that is their rule wins over one that is not.
|
|
352
378
|
* From `firstFollowUp` on, those words answer the agent's work, so a statement in them can be the person's rule. */
|
|
353
379
|
export function extractFromTexts(texts, userTexts = 0, firstFollowUp = userTexts) {
|
|
354
|
-
const
|
|
355
|
-
return
|
|
356
|
-
.flatMap((text, i) => extractSourced(text, boldPairs, i >= firstFollowUp && i < userTexts).map(({ item }) => i < userTexts ? { ...item, fromUser: true } : item))
|
|
357
|
-
.filter((item) => {
|
|
358
|
-
const key = duplicateKey(item.content);
|
|
359
|
-
if (seen.has(key) || !assessAutomaticMemory(item.content).accepted)
|
|
360
|
-
return false;
|
|
361
|
-
seen.add(key);
|
|
362
|
-
return true;
|
|
363
|
-
});
|
|
380
|
+
const items = texts.flatMap((text, i) => extractSourced(text, boldPairs, i >= firstFollowUp && i < userTexts).map(({ item }) => i < userTexts ? { ...item, fromUser: true } : item));
|
|
381
|
+
return oncePerText(items, (item) => assessAutomaticMemory(item.content).accepted);
|
|
364
382
|
}
|
|
365
383
|
function trackOf(items) {
|
|
366
384
|
return { items, ends: items.map(({ to }) => to) };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@font-face{font-family:IBM Plex Sans;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2)format("woff2"),url(/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff)format("woff")}@font-face{font-family:IBM Plex Sans;font-style:normal;font-display:swap;font-weight:500;src:url(/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2)format("woff2"),url(/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff)format("woff")}@font-face{font-family:IBM Plex Sans;font-style:normal;font-display:swap;font-weight:600;src:url(/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2)format("woff2"),url(/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff)format("woff")}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2)format("woff2"),url(/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff)format("woff")}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:500;src:url(/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2)format("woff2"),url(/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff)format("woff")}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:600;src:url(/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2)format("woff2"),url(/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff)format("woff")}:root{--bg:#f3f5f8;--surface:#fff;--line:#e1e5eb;--line-2:#cbd2db;--text:#111827;--text-2:#3f4856;--text-3:#5b6574;--accent:#2f6fed;--accent-ink:#1f55c9;--accent-weak:#eaf1fe;--risk:#b5451b;--risk-weak:#fff1e8;--sans:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;--mono:"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace}*{box-sizing:border-box}[hidden]{display:none!important}html,body,#root{height:100%;margin:0}body{font:14px/1.45 var(--sans);color:var(--text);background:var(--bg);font-variant-numeric:tabular-nums;-webkit-font-smoothing:antialiased;overflow:hidden}button,select,input{font:inherit;color:inherit}button{cursor:pointer}button:disabled{cursor:not-allowed;opacity:.5}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.mono{font-family:var(--mono)}.sr-only{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;margin:-1px;overflow:hidden;position:absolute!important}.ell{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}.app{flex-direction:column;height:100%;display:flex}.top{border-bottom:1px solid var(--line);z-index:40;background:#fff;flex:none;align-items:center;gap:12px;height:64px;padding:0 16px;display:flex;position:relative}.top-right{flex:none;align-items:center;gap:12px;margin-left:auto;display:flex}.top-break{display:none}.updated{font:12px var(--mono);color:var(--text-3);white-space:nowrap}.brand{letter-spacing:-.01em;flex:none;align-items:center;gap:8px;font-size:16px;font-weight:600;display:flex}.brand small{color:var(--text-3);border-left:1px solid var(--line);padding-left:8px;font-size:12px;font-weight:500}.ctl{border:1px solid var(--line-2);background:#fff;border-radius:6px;height:44px;padding:0 12px}select.ctl{appearance:none;cursor:pointer;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%233f4856' stroke-width='1.5'/%3E%3C/svg%3E") right 12px center no-repeat;padding-right:30px}.crumbs{flex:auto;min-width:0}.crumbs ol{align-items:center;min-width:0;margin:0;padding:0;list-style:none;display:flex}.crumbs li{flex:0 auto;align-items:center;min-width:0;display:flex}.crumbs li:first-child{flex:none}.crumbs li+li:before{content:"/";color:var(--text-3);flex:none;padding:0 6px}.crumbs button{min-width:44px;height:44px;color:var(--accent-ink);text-underline-offset:3px;background:0 0;border:0;max-width:240px;padding:0 4px;-webkit-text-decoration:underline #a9c0f0;text-decoration:underline #a9c0f0}.crumbs .cur{max-width:260px;padding:0 4px;font-weight:500}.search{flex:0 280px;min-width:150px;position:relative}.search input{width:100%;padding-left:34px;padding-right:34px}.search input::placeholder{color:var(--text-3)}.search svg{pointer-events:none;position:absolute;top:50%;left:11px;transform:translateY(-50%)}.search kbd{font:12px var(--mono);color:var(--text-3);border:1px solid var(--line-2);background:#f7f8fa;border-radius:4px;padding:0 5px;position:absolute;top:50%;right:10px;transform:translateY(-50%)}.qlist{border:1px solid var(--line-2);z-index:60;background:#fff;border-radius:8px;width:max(100%,340px);padding:4px;position:absolute;top:50px;left:0;box-shadow:0 12px 32px #1118271f}.qlist .opt{cursor:pointer;border-radius:6px;align-items:center;gap:8px;min-height:44px;padding:0 10px;display:flex}.qlist .opt[aria-selected=true]{background:var(--accent-weak)}.qlist .opt .k{color:var(--text-3);flex:none;width:56px;font-size:12px}.qlist .opt .n{font:12px var(--mono);color:var(--text-2);flex:none;margin-left:auto}.qlist .none{color:var(--text-2);padding:12px 10px}.qlist .sum{color:var(--text-3);border-bottom:1px solid var(--line);margin-bottom:4px;padding:6px 10px 4px;font-size:12px}.seg{border:1px solid var(--line-2);background:#fff;border-radius:6px;display:inline-flex;overflow:hidden}.seg button{min-width:52px;height:44px;font:13px var(--mono);color:var(--text-2);background:#fff;border:0;padding:0 12px}.seg button+button{border-left:1px solid var(--line)}.seg button[aria-pressed=true],.seg button[aria-checked=true]{background:var(--accent-weak);color:var(--accent-ink);font-weight:500}.seg.txt button{font-family:var(--sans)}.zoomctl button{min-width:44px;font:500 16px var(--mono);padding:0 10px}.zoomctl button.fit{font:500 13px var(--sans)}main{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative}main>:last-child{flex:auto;min-height:0}.view{flex-direction:column;flex:auto;gap:16px;min-width:0;min-height:0;padding:16px 16px 28px;display:flex;position:relative}.card{border:1px solid var(--line);background:#fff;border-radius:8px;flex-direction:column;min-width:0;min-height:0;display:flex;position:relative}.card.grow{flex:auto}.card-h{border-bottom:1px solid var(--line);align-items:center;gap:8px;min-width:0;min-height:61px;padding:8px 8px 8px 16px;display:flex}.card-h h2{flex:none;margin:0;font-size:14px;font-weight:600}.card-h .sub{color:var(--text-3);min-width:0;font-size:12px}.spacer{flex:auto}.notice{border:1px solid var(--line-2);background:#fff;border-radius:6px;flex:none;align-items:center;gap:8px;min-height:44px;margin:12px 16px 0;padding:0 4px 0 12px;display:flex}.view .notice{margin:0}.kpis{border:1px solid var(--line);background:#fff;border-radius:8px;flex:none;grid-template-columns:repeat(5,minmax(0,1fr));display:grid}.kpi{border-left:1px solid var(--line);grid-template-rows:auto auto auto;grid-template-columns:minmax(0,1fr) auto;column-gap:8px;min-width:0;padding:12px 16px;display:grid}.kpi:first-child{border-left:0}.kpi .l{color:var(--text-2);grid-column:1/-1;font-size:12px}.kpi .v{font:500 22px/1.2 var(--mono);letter-spacing:-.02em}.kpi .d{font:12px var(--mono);color:var(--text-3);white-space:nowrap;text-overflow:ellipsis;grid-column:1/-1;margin-top:2px;overflow:hidden}.kpi svg{grid-area:2/2;align-self:end;width:84px;height:28px}.skel{background:var(--line);border-radius:4px}.kpi .skel{grid-column:1/-1}.skel-l{width:60%;height:12px}.skel-v{width:40%;height:22px;margin-top:6px}.skel-d{width:80%;height:12px;margin-top:6px}.skel-map{width:70%;max-width:560px;height:50%}.skel-row{height:44px}.ov-body{flex:auto;grid-template-columns:minmax(0,1fr) 272px;gap:16px;min-height:0;display:grid}.map-region,.map-wrap{flex:auto;min-height:0;position:relative}.map-region .map-wrap{position:absolute;inset:0}.map-wrap canvas{cursor:pointer;touch-action:pan-y;width:100%;height:100%;display:block;position:absolute;inset:0}.map-wrap canvas:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}.state{text-align:center;color:var(--text-2);background:#fff;border-radius:8px;flex-direction:column;justify-content:center;align-items:center;gap:8px;padding:24px;display:flex;position:absolute;inset:0}.state h3{color:var(--text);margin:0;font-size:16px}.state p{max-width:360px;margin:0}.banner{border:1px solid var(--line-2);z-index:5;background:#fff;border-radius:6px;align-items:center;gap:8px;padding:0 4px 0 12px;display:flex;position:absolute;top:12px;left:12px;box-shadow:0 2px 8px #11182714}.rail{overflow:auto}.rail section{border-bottom:1px solid var(--line);padding:12px 16px}.rail section:last-child{border-bottom:0}.rail h3{color:var(--text-2);text-transform:uppercase;letter-spacing:.04em;margin:0 0 8px;font-size:12px;font-weight:600}.ramp{border:1px solid var(--line);background:linear-gradient(90deg,#e8edf4 0%,#fbe3cf 16.7%,#f9bf8f 33.3%,#f29256 50%,#dc652f 66.7%,#b5451b 83.3%,#83300f 100%);border-radius:2px;height:10px}.ramp-t{font:12px var(--mono);color:var(--text-3);justify-content:space-between;margin-top:4px;display:flex}.lg{color:var(--text-2);align-items:center;gap:8px;margin-top:8px;font-size:12px;display:flex}.lg.tight{margin-top:2px}.sw{border-radius:2px;flex:none;width:12px;height:12px;display:inline-block}.sw.hatch{background:repeating-linear-gradient(135deg,#111827 0 1.5px,#fff 1.5px 4px);border:1px solid #111827}.swatch{border:1px solid var(--line-2);vertical-align:-1px;margin-right:6px}.swatch-sm{vertical-align:-1px;width:10px;height:10px;margin-right:6px}.lg-grid{grid-template-columns:1fr 1fr;gap:4px 12px;display:grid}.ra{text-align:left;border:0;border-top:1px solid var(--line);background:0 0;align-items:center;gap:8px;width:100%;min-height:44px;padding:4px 4px 4px 0;display:flex}.ra:first-of-type{border-top:0}.ra .nm{min-width:0;color:var(--accent-ink);flex:1;font-weight:500}.ra .mt{font:12px var(--mono);color:var(--text-2);text-align:right;flex:none}.ra .chev{color:var(--text-3);flex:none}.ra:hover{background:#f7f9fc}.muted{color:var(--text-3);font-size:12px}.vt-wrap{flex-direction:column;flex:auto;min-width:0;min-height:0;display:flex;position:relative}.vt{flex:auto;min-width:0;min-height:0;position:relative;overflow:auto}.vt:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}.vt-head,.vt-tr{grid-template-columns:var(--cols);align-items:center;min-width:0;display:grid}.vt-head{border-bottom:1px solid var(--line);z-index:2;background:#fafbfc;position:sticky;top:0}.vt-th{min-width:0}.vt-th button,.vt-th span.h{width:100%;height:44px;color:var(--text-2);text-align:left;white-space:nowrap;background:0 0;border:0;align-items:center;gap:4px;padding:0 12px;font-size:12px;font-weight:600;display:flex}.vt-th.r button,.vt-th.r span.h{justify-content:flex-end}.vt-th .ar{color:var(--accent-ink);width:10px;font-size:12px}.vt-sp{width:100%;position:relative}.vt-tr{cursor:pointer;border-bottom:1px solid #eef0f3;height:44px;position:absolute;left:0;right:0}.vt-tr:hover{background:#f7f9fc}.vt-tr.act{background:var(--accent-weak);box-shadow:inset 3px 0 0 var(--accent)}.vt-tr.sel{background:#dfe9fd}.c{text-overflow:ellipsis;white-space:nowrap;min-width:0;padding:0 12px;font-size:13px;overflow:hidden}.c.r{text-align:right}.c.n{font:12.5px var(--mono)}.c.lnk{color:var(--accent-ink);font-weight:500}.c .tag{font:12px var(--mono);color:var(--text-3);margin-left:6px}.vt-empty{pointer-events:none;color:var(--text-2);text-align:center;justify-content:center;align-items:center;padding:16px;display:flex;position:absolute;inset:0}.vt-empty :is(button,a){pointer-events:auto}.bar{vertical-align:middle;background:#e9edf2;border-radius:3px;width:44px;height:6px;margin-right:8px;display:inline-block;position:relative;overflow:hidden}.bar i{background:var(--accent);border-radius:3px;position:absolute;top:0;bottom:0;left:0}.bar.risk i{background:#e8590c}.shape{vertical-align:-1px;margin-right:6px;display:inline-block}.flag{font:12px var(--mono);vertical-align:1px;border:1px solid;border-radius:3px;margin-right:6px;padding:1px 5px;display:inline-block}.flag.pin{color:#1e3a8a;background:#eef3fe;border-color:#b9c8f3}.flag.cf{color:#7c2d12;background:var(--risk-weak);border-color:#f3c3a3}.flag.wr{color:#5b6574;background:#f4f5f7;border-color:#d4d9e0;text-decoration:line-through}.stale{color:var(--risk)}.btn{border:1px solid var(--line-2);white-space:nowrap;background:#fff;border-radius:6px;flex:none;align-items:center;gap:8px;height:44px;padding:0 16px;font-weight:500;display:inline-flex}.btn:hover{background:#f7f9fc}.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}.btn.primary:hover{background:#2462dc}.btn.quiet{color:var(--accent-ink);background:0 0;border-color:#0000;padding:0 10px}.btn.danger{color:#9f1d1d}.btn.sm{height:44px;padding:0 12px;font-size:13px}.icon-btn{width:44px;height:44px;color:var(--text-2);background:0 0;border:0;border-radius:6px;font-size:20px}.icon-btn:hover{background:#f3f5f8}.pv-h1{letter-spacing:-.01em;margin:0;font-size:20px;font-weight:600}.pv-head{flex:none;align-items:center;gap:16px;min-width:0;display:flex}.pv-title{flex:auto;min-width:0}.pv-title h1{letter-spacing:-.01em;margin:0;font-size:20px;font-weight:600}.pv-meta{font:12px var(--mono);color:var(--text-2);margin-top:2px}.pv-grid{flex:auto;grid-template-rows:clamp(210px,31vh,290px) minmax(0,1fr);grid-template-columns:minmax(0,1.75fr) minmax(280px,1fr);gap:16px;min-height:0;display:grid}.tbl-card{grid-column:1/-1}.sc-wrap{flex:auto;min-height:0;position:relative}.sc-wrap canvas{touch-action:pan-y;width:100%;height:100%;display:block;position:absolute;inset:0}.sc-wrap canvas.ov{cursor:crosshair}.tog{border:1px solid var(--line-2);height:44px;color:var(--text-2);white-space:nowrap;background:#fff;border-radius:6px;justify-content:center;align-items:center;gap:6px;min-width:44px;padding:0 10px;font-size:12.5px;display:inline-flex}.tog[aria-pressed=true]{color:var(--text);background:#f5f8ff;border-color:#9fb6ea}.tog.layer[aria-pressed=false]{text-decoration:line-through}.tog .n{font:12px var(--mono);color:var(--text-3)}.chips{flex-wrap:nowrap;gap:4px;min-width:0;display:flex}.chip{border:1px solid var(--line-2);height:44px;color:var(--text-2);white-space:nowrap;background:#fff;border-radius:22px;padding:0 12px;font-size:13px}.chip .n{font:12px var(--mono);color:var(--text-3);margin-left:4px}.chip[aria-pressed=true]{background:var(--text);border-color:var(--text);color:#fff}.chip[aria-pressed=true] .n{color:#cfd6e0}.decay{flex-direction:column;gap:6px;padding:12px 16px;display:flex;overflow:hidden}.dgrid{grid-template-columns:62px minmax(40px,1fr) 58px 58px 58px;align-items:center;gap:0 8px;display:grid}.dgrid .hd{color:var(--text-3);text-align:right;justify-content:flex-end;align-items:center;gap:4px;padding-bottom:4px;font-size:12px;display:flex}.dgrid .rl{color:var(--text-2);align-items:center;height:34px;font-size:12.5px;display:flex}.dgrid .nv{font:12px var(--mono);text-align:right}.dbar{background:#eef0f3;border-radius:2px;height:14px;display:flex;overflow:hidden}.dbar i{height:100%;display:block}.dnote{color:var(--text-2);border-top:1px solid var(--line);margin-top:6px;padding-top:8px;font-size:12px}.dnote b{font:500 12px var(--mono);color:var(--text)}.drawer{border-left:1px solid var(--line-2);z-index:35;visibility:hidden;background:#fff;flex-direction:column;width:min(440px,100vw);transition:transform .18s,visibility 0s linear .18s;display:flex;position:fixed;top:64px;bottom:0;right:0;transform:translate(100%);box-shadow:-12px 0 32px #1118271a}.drawer.open{visibility:visible;transition:transform .18s;transform:none}.dr-h{border-bottom:1px solid var(--line);align-items:center;gap:8px;min-height:61px;padding:8px 8px 8px 20px;display:flex}.dr-h h2{flex:1;min-width:0;margin:0;font-size:14px;font-weight:600}.dr-h h2:focus{outline:none}.dr-h h2 .mono{color:var(--text-3);margin-left:6px;font-size:12px;font-weight:400}.dr-b{flex-direction:column;gap:16px;padding:20px;display:flex;overflow:auto}.dr-content{margin:0;font-size:16px;line-height:1.5}.dr-flags{flex-wrap:wrap;gap:6px;display:flex}.dr-flags span{font:12px var(--mono);color:var(--text-2);border:1px solid var(--line);background:#f3f5f8;border-radius:4px;padding:2px 8px}.dr-act{flex-wrap:wrap;gap:8px;display:flex}.dr-f{border-top:1px solid var(--line);grid-template-columns:140px minmax(0,1fr);margin:0;display:grid}.dr-f dt,.dr-f dd{border-bottom:1px solid #eef0f3;margin:0;padding:7px 0;font-size:13px}.dr-f dt{color:var(--text-2)}.dr-f dd{font-family:var(--mono);overflow-wrap:anywhere;font-size:12.5px}.cfbox{background:#fffaf6;border:1px solid #f3c3a3;border-radius:8px;flex-direction:column;gap:8px;padding:12px;display:flex}.cfbox h3{margin:0;font-size:13px}.cfbox .oth{border-left:3px solid #e8590c;padding-left:10px;font-size:13.5px}.cfbox .why{color:var(--text-2);font-size:12px}.cfbox .row{flex-wrap:wrap;gap:8px;display:flex}.tip{z-index:70;pointer-events:none;color:#fff;background:#111827;border-radius:6px;max-width:320px;padding:8px 10px;font-size:12px;line-height:1.4;position:fixed;box-shadow:0 8px 24px #0000002e}.tip b{font-weight:600}.tip .m{font-family:var(--mono);color:#cbd5e1;font-size:12px}.tip.closable{pointer-events:auto;padding-right:44px}.tip-close{color:#fff;background:0 0;border:0;width:44px;height:44px;font-size:20px;position:absolute;top:0;right:0}.toast{color:#fff;z-index:80;background:#111827;border-radius:8px;align-items:center;gap:8px;min-height:48px;padding:0 4px 0 16px;font-size:13px;display:flex;position:fixed;bottom:36px;left:50%;transform:translate(-50%);box-shadow:0 8px 24px #0003}.toast button{color:#a9c4ff;background:0 0;border:0;height:44px;padding:0 12px;font-weight:600}.sheet-handle{touch-action:none;flex:none;justify-content:center;align-items:center;height:28px;display:flex}.sheet-grip{background:var(--line-2);border-radius:2px;width:40px;height:4px}@media (max-width:1240px){.brand small{display:none}.ov-body{grid-template-columns:minmax(0,1fr) 232px}.search{flex-basis:220px}}@media (max-width:760px){.top{flex-wrap:wrap;gap:4px 8px;height:auto;padding:4px 8px}.top-right{display:contents}.brand{order:1}.brand span,.brand small,.search kbd{display:none}.top>.spacer{order:2}.view-switch{order:3}.top .btn{order:4;padding:0 12px}.top .btn.icon{justify-content:center;width:44px;padding:0}.top .btn[aria-busy=true]{opacity:.6}.top-break{flex:0 0 100%;order:5;height:0;display:block}.search{flex:100%;order:6;min-width:0}.search input{padding-right:8px}.view{padding:12px 12px 32px;overflow:auto}.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.kpis-range{grid-column:1/-1;padding:8px 12px}.kpis-range .range{width:100%}.kpi{border-top:1px solid var(--line)}.kpi:nth-child(2n){border-left:0}.kpi:last-child:nth-child(2n){grid-column:1/-1}.kpi .v{font-size:18px}.card-h{flex-wrap:wrap}.card-h .sub{display:none}.ov-body,.pv-grid{flex:none;grid-template-rows:none;grid-template-columns:minmax(0,1fr)}#mapcard{height:50vh;min-height:320px}.pv-grid>.card:first-child{height:320px}.tbl-card{height:70vh;min-height:400px}.pv-head{flex-wrap:wrap;gap:8px}.pv-title{flex-basis:100%;order:-1}.chips{flex-wrap:wrap}.vt-head,.vt-tr{grid-template-columns:minmax(0,1fr) 108px}.vt-head>:nth-child(n+3),.vt-tr>:nth-child(n+3){display:none}.drawer{border-left:0;border-top:1px solid var(--line-2);border-radius:12px 12px 0 0;width:100%;max-height:85vh;top:auto;left:0;right:0;transform:translateY(100%)}.drawer.open{transform:none}}.sc-wrap canvas.ov.brushing{touch-action:none}.sc-foot{flex-direction:column;flex:none;gap:4px;padding:4px 16px 8px;display:flex}.dens-ramp{border:1px solid var(--line-2);border-radius:2px;width:64px;height:10px;display:inline-block}.sc-filter summary{cursor:pointer;min-height:44px;color:var(--accent-ink);align-items:center;font-size:13px;display:flex}.brush-fields{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;display:grid}.brush-fields label{color:var(--text-2);flex-direction:column;gap:4px;font-size:12px;display:flex}.brush-fields input{width:100%;font:13px var(--mono)}.decay h2{margin:0 0 4px;font-size:14px;font-weight:600}.skel-cell{width:70%;height:12px;display:block}.row-err{color:#9f1d1d;grid-column:1/-1;align-items:center;gap:8px;display:flex}.flag.ok{color:#14532d;background:#eefaf1;border-color:#b7dcc2}.flag.wk{color:#5b6574;background:#f4f5f7;border-color:#d4d9e0}.vt-tr.forgetting,.mc-row.forgetting{opacity:.55;text-decoration:line-through}.dr-pair{display:contents}.mc{flex-direction:column;flex:auto;min-height:0;display:flex}.mc-bar{border-bottom:1px solid var(--line);color:var(--text-2);flex:none;align-items:center;gap:8px;padding:8px 12px;font-size:13px;display:flex}.mc-row{cursor:pointer;border-bottom:1px solid #eef0f3;flex-direction:column;justify-content:center;gap:6px;padding:0 12px;display:flex;position:absolute;left:0;right:0}.mc-row.act{background:var(--accent-weak);box-shadow:inset 3px 0 0 var(--accent)}.mc-row.sel{background:#dfe9fd}.mc-text{white-space:nowrap;text-overflow:ellipsis;font-size:14px;overflow:hidden}.mc-meta{color:var(--text-2);white-space:nowrap;align-items:center;gap:8px;min-width:0;font-size:12px;display:flex;overflow:hidden}.mc-meta .shape,.mc-meta .flag{margin-right:0}@media (max-width:760px){.pv-top{flex:none;align-items:center;gap:8px;min-width:0;display:flex}.pv-grid>.card:first-child{height:auto}.sc-wrap{flex:none;height:220px}.brush-fields{grid-template-columns:repeat(2,minmax(0,1fr))}.toast{max-width:calc(100vw - 16px);top:8px;bottom:auto}}
|