@graview/tools 0.1.47 → 0.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/agent/tools.d.ts +5 -2
- package/dist/agent/tools.d.ts.map +1 -1
- package/dist/agent/tools.js +63 -16
- package/dist/agent/tools.js.map +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.d.ts.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +87 -1
- package/dist/cli.js.map +1 -1
- package/dist/conversation.js +2 -2
- package/dist/conversation.js.map +1 -1
- package/dist/decide.d.ts +1 -1
- package/dist/decide.d.ts.map +1 -1
- package/dist/decide.js +2 -2
- package/dist/decide.js.map +1 -1
- package/dist/derive.d.ts.map +1 -1
- package/dist/derive.js +8 -1
- package/dist/derive.js.map +1 -1
- package/dist/dev-ai.d.ts +2 -1
- package/dist/dev-ai.d.ts.map +1 -1
- package/dist/dev-ai.js +8 -6
- package/dist/dev-ai.js.map +1 -1
- package/dist/draft.d.ts +3 -1
- package/dist/draft.d.ts.map +1 -1
- package/dist/draft.js +9 -8
- package/dist/draft.js.map +1 -1
- package/dist/fast.d.ts +44 -0
- package/dist/fast.d.ts.map +1 -0
- package/dist/fast.js +2 -0
- package/dist/fast.js.map +1 -0
- package/dist/figure.js +1 -1
- package/dist/figure.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inline-ai.d.ts.map +1 -1
- package/dist/inline-ai.js +1 -1
- package/dist/inline-ai.js.map +1 -1
- package/dist/intelligence.d.ts +32 -2
- package/dist/intelligence.d.ts.map +1 -1
- package/dist/intelligence.js +3 -3
- package/dist/intelligence.js.map +1 -1
- package/dist/keep.d.ts.map +1 -1
- package/dist/keep.js +8 -3
- package/dist/keep.js.map +1 -1
- package/dist/local.d.ts +1 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +23 -18
- package/dist/local.js.map +1 -1
- package/dist/loop.d.ts +1 -1
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js.map +1 -1
- package/dist/providers/jev.d.ts +1 -36
- package/dist/providers/jev.d.ts.map +1 -1
- package/dist/providers/jev.js.map +1 -1
- package/dist/questions.js +2 -2
- package/dist/questions.js.map +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/seat-model.js +3 -3
- package/dist/seat-model.js.map +1 -1
- package/dist/suggest.d.ts +8 -8
- package/dist/suggest.d.ts.map +1 -1
- package/dist/suggest.js +2 -2
- package/dist/suggest.js.map +1 -1
- package/dist/tidy/asking.d.ts +51 -0
- package/dist/tidy/asking.d.ts.map +1 -0
- package/dist/tidy/asking.js +86 -0
- package/dist/tidy/asking.js.map +1 -0
- package/dist/tidy/away.d.ts +24 -0
- package/dist/tidy/away.d.ts.map +1 -0
- package/dist/tidy/away.js +24 -0
- package/dist/tidy/away.js.map +1 -0
- package/dist/tidy/blocking.d.ts +82 -0
- package/dist/tidy/blocking.d.ts.map +1 -0
- package/dist/tidy/blocking.js +260 -0
- package/dist/tidy/blocking.js.map +1 -0
- package/dist/tidy/dream.d.ts +117 -0
- package/dist/tidy/dream.d.ts.map +1 -0
- package/dist/tidy/dream.js +178 -0
- package/dist/tidy/dream.js.map +1 -0
- package/dist/tidy/judges.d.ts +109 -0
- package/dist/tidy/judges.d.ts.map +1 -0
- package/dist/tidy/judges.js +282 -0
- package/dist/tidy/judges.js.map +1 -0
- package/dist/tidy/judging.d.ts +51 -0
- package/dist/tidy/judging.d.ts.map +1 -0
- package/dist/tidy/judging.js +243 -0
- package/dist/tidy/judging.js.map +1 -0
- package/dist/tidy/policy.d.ts +18 -0
- package/dist/tidy/policy.d.ts.map +1 -0
- package/dist/tidy/policy.js +29 -0
- package/dist/tidy/policy.js.map +1 -0
- package/dist/tidy/system-one.d.ts +40 -0
- package/dist/tidy/system-one.d.ts.map +1 -0
- package/dist/tidy/system-one.js +49 -0
- package/dist/tidy/system-one.js.map +1 -0
- package/dist/tidy.d.ts +8 -0
- package/dist/tidy.d.ts.map +1 -0
- package/dist/tidy.js +23 -0
- package/dist/tidy.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { QUESTION_SET } from "./judging.js";
|
|
2
|
+
/** Answers kept in this process, the oldest let go past `limit` (2000 when unsaid). */
|
|
3
|
+
export function memoryDreamCache(limit = 2000) {
|
|
4
|
+
const kept = new Map();
|
|
5
|
+
return {
|
|
6
|
+
get: (key) => kept.get(key),
|
|
7
|
+
set(key, answers) {
|
|
8
|
+
kept.delete(key);
|
|
9
|
+
kept.set(key, answers);
|
|
10
|
+
while (kept.size > limit)
|
|
11
|
+
kept.delete(kept.keys().next().value);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** The cache a run uses when the host gives none: one per process, so a server's nightly run remembers the last. */
|
|
16
|
+
export const PROCESS_CACHE = memoryDreamCache();
|
|
17
|
+
/** SHA-256 of the text, in hex, where the platform has it; a 64-bit FNV-1a where it does not. */
|
|
18
|
+
async function hashOf(text) {
|
|
19
|
+
const subtle = globalThis.crypto?.subtle;
|
|
20
|
+
if (subtle) {
|
|
21
|
+
const digest = await subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
22
|
+
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
23
|
+
}
|
|
24
|
+
let hash = 0xcbf29ce484222325n;
|
|
25
|
+
for (const char of new TextEncoder().encode(text))
|
|
26
|
+
hash = ((hash ^ BigInt(char)) * 0x100000001b3n) & 0xffffffffffffffffn;
|
|
27
|
+
return hash.toString(16);
|
|
28
|
+
}
|
|
29
|
+
/** The key an ask's answers are kept by: the questions' version, the model, the state and the questions. */
|
|
30
|
+
export const cacheKeyOf = (model, ask) => hashOf(JSON.stringify([QUESTION_SET, model, ask.state, ask.questions]));
|
|
31
|
+
/** Ask each, a few at a time, within the budget, from the cache where it can. */
|
|
32
|
+
export async function askAll(model, asks, options = {}) {
|
|
33
|
+
const cache = options.cache === false ? undefined : (options.cache ?? PROCESS_CACHE);
|
|
34
|
+
const maxRequests = options.budget?.requests ?? 60;
|
|
35
|
+
const maxTokens = options.budget?.inputTokens ?? 200_000;
|
|
36
|
+
const answers = asks.map(() => undefined);
|
|
37
|
+
const usage = { requests: 0, cached: 0, questions: 0, inputTokens: 0, outputTokens: 0 };
|
|
38
|
+
let stopped;
|
|
39
|
+
let error;
|
|
40
|
+
let next = 0;
|
|
41
|
+
const worker = async () => {
|
|
42
|
+
while (next < asks.length && error === undefined) {
|
|
43
|
+
const at = next++;
|
|
44
|
+
const ask = asks[at];
|
|
45
|
+
const key = cache ? await cacheKeyOf(model.model, ask) : undefined;
|
|
46
|
+
const kept = key ? await cache.get(key) : undefined;
|
|
47
|
+
if (kept && Object.keys(ask.questions).every((question) => question in kept)) {
|
|
48
|
+
answers[at] = kept;
|
|
49
|
+
usage.cached++;
|
|
50
|
+
usage.questions += Object.keys(ask.questions).length;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
// A request is counted before it is sent, so six at once never pass the budget together.
|
|
54
|
+
const estimate = Math.ceil(JSON.stringify({ model: model.model, state: ask.state, questions: ask.questions }).length / 4);
|
|
55
|
+
if (usage.requests >= maxRequests) {
|
|
56
|
+
stopped ??= "requests";
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (usage.inputTokens + estimate > maxTokens) {
|
|
60
|
+
stopped ??= "tokens";
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
usage.requests++;
|
|
64
|
+
usage.inputTokens += estimate;
|
|
65
|
+
try {
|
|
66
|
+
const decided = await model.decide(ask.state, ask.questions);
|
|
67
|
+
// The provider's own count, where it gave one, replaces the estimate.
|
|
68
|
+
if (decided.usage.inputTokens > 0)
|
|
69
|
+
usage.inputTokens += decided.usage.inputTokens - estimate;
|
|
70
|
+
usage.outputTokens += decided.usage.outputTokens;
|
|
71
|
+
usage.questions += Object.keys(ask.questions).length;
|
|
72
|
+
answers[at] = decided.answers;
|
|
73
|
+
if (key)
|
|
74
|
+
await cache.set(key, decided.answers);
|
|
75
|
+
}
|
|
76
|
+
catch (failure) {
|
|
77
|
+
error ??= failure instanceof Error ? failure.message : String(failure);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
await Promise.all(Array.from({ length: Math.max(1, Math.min(options.concurrency ?? 6, asks.length)) }, worker));
|
|
82
|
+
const price = model.price;
|
|
83
|
+
const costUsd = price ? (usage.inputTokens / 1_000_000) * (price.inputPerMillion ?? 0) + (usage.outputTokens / 1_000_000) * (price.outputPerMillion ?? 0) : undefined;
|
|
84
|
+
return { answers, usage: { ...usage, ...(costUsd !== undefined ? { costUsd } : {}) }, ...(stopped ? { stopped } : {}), ...(error !== undefined ? { error } : {}) };
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=asking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asking.js","sourceRoot":"","sources":["../../src/tidy/asking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAY,MAAM,cAAc,CAAC;AAsBtD,uFAAuF;AACvF,MAAM,UAAU,gBAAgB,CAAC,KAAK,GAAG,IAAI;IAC3C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC7C,OAAO;QACL,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QAC3B,GAAG,CAAC,GAAG,EAAE,OAAO;YACd,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC,IAAI,GAAG,KAAK;gBAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC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E,CAAC,EAAE,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACrK,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AnySchema, Principal, Store } from "@graview/core";
|
|
2
|
+
import { type ActivityRow } from "@graview/core/tidying";
|
|
3
|
+
/** Since when: a position in the log (`seq`, the first op not yet seen) or a moment (`at`, ISO). */
|
|
4
|
+
export interface AwaySince {
|
|
5
|
+
readonly seq?: number;
|
|
6
|
+
readonly at?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WhileAway {
|
|
9
|
+
/** Suggestions waiting now, whenever they were made. */
|
|
10
|
+
readonly waiting: number;
|
|
11
|
+
/** Of those, the ones made since. */
|
|
12
|
+
readonly suggestedSince: number;
|
|
13
|
+
/** How many things the actor did on its own since, not counting what was taken back. */
|
|
14
|
+
readonly tidied: number;
|
|
15
|
+
/** Activity's digest rows since: each run of the actor's changes as one row. */
|
|
16
|
+
readonly digests: readonly Extract<ActivityRow, {
|
|
17
|
+
digest: unknown;
|
|
18
|
+
}>["digest"][];
|
|
19
|
+
/** "3 suggestions waiting · tidied 12 things while you were away", or undefined when there is nothing to say. */
|
|
20
|
+
readonly said: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** What the app's own actor did and suggested since `since`, as `principal` (or the seat a seat's store is of) may see it. */
|
|
23
|
+
export declare function whileAway<S extends AnySchema>(store: Store<S>, since: AwaySince, principal?: Principal): WhileAway;
|
|
24
|
+
//# sourceMappingURL=away.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"away.d.ts","sourceRoot":"","sources":["../../src/tidy/away.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAUnF,oGAAoG;AACpG,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,CAAC,WAAW,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;IACjF,iHAAiH;IACjH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,8HAA8H;AAC9H,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAoBlH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { foldDigests, suggestions } from "@graview/core/tidying";
|
|
2
|
+
/** What the app's own actor did and suggested since `since`, as `principal` (or the seat a seat's store is of) may see it. */
|
|
3
|
+
export function whileAway(store, since, principal) {
|
|
4
|
+
const seen = principal ? store.seenBy(principal) : store;
|
|
5
|
+
const after = (op) => (since.seq === undefined || op.seq >= since.seq) && (since.at === undefined || op.at > since.at);
|
|
6
|
+
const waitingNow = suggestions(seen);
|
|
7
|
+
const ops = seen.log.all();
|
|
8
|
+
const byId = new Map(ops.map((op) => [op.id, op]));
|
|
9
|
+
const seqOf = (id) => byId.get(id);
|
|
10
|
+
const suggestedSince = waitingNow.filter((one) => {
|
|
11
|
+
const op = seqOf(one.id);
|
|
12
|
+
return op !== undefined && after(op);
|
|
13
|
+
}).length;
|
|
14
|
+
const batches = seen.batches().filter((batch) => batch.ops.length > 0 && after(batch.ops[0]));
|
|
15
|
+
const digests = foldDigests(batches, (id) => byId.get(id)).flatMap((row) => ("digest" in row ? [row.digest] : []));
|
|
16
|
+
const tidied = digests.reduce((sum, digest) => sum + digest.things, 0);
|
|
17
|
+
const parts = [
|
|
18
|
+
waitingNow.length > 0 ? `${waitingNow.length === 1 ? "one suggestion" : `${waitingNow.length} suggestions`} waiting` : "",
|
|
19
|
+
tidied > 0 ? `tidied ${tidied === 1 ? "one thing" : `${tidied} things`} while you were away` : "",
|
|
20
|
+
].filter(Boolean);
|
|
21
|
+
const said = parts.length > 0 ? parts.join(" · ").replace(/^./, (first) => first.toUpperCase()) : undefined;
|
|
22
|
+
return { waiting: waitingNow.length, suggestedSince, tidied, digests, said };
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=away.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"away.js","sourceRoot":"","sources":["../../src/tidy/away.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAoB,MAAM,uBAAuB,CAAC;AA6BnF,8HAA8H;AAC9H,MAAM,UAAU,SAAS,CAAsB,KAAe,EAAE,KAAgB,EAAE,SAAqB;IACrG,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACzD,MAAM,KAAK,GAAG,CAAC,EAAiD,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,SAAS,IAAI,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;IACtK,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI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,GAAG;QACZ,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,cAAc,UAAU,CAAC,CAAC,CAAC,EAAE;QACzH,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,SAAS,sBAAsB,CAAC,CAAC,CAAC,EAAE;KAClG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5G,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type SearchRanker } from "@graview/core";
|
|
2
|
+
import { type JudgeContext } from "./judges.js";
|
|
3
|
+
type Node = {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
} & Record<string, unknown>;
|
|
7
|
+
/** Two records of one kind that may be one: the one that would stay, the one merged into it, and why they were paired. */
|
|
8
|
+
export interface PairBlock {
|
|
9
|
+
readonly kind: string;
|
|
10
|
+
readonly keeper: Node;
|
|
11
|
+
readonly other: Node;
|
|
12
|
+
/** Fields both fill and that name one thing (an email, a code, a value they share): asked one by one. */
|
|
13
|
+
readonly keys: readonly string[];
|
|
14
|
+
/** Words a person reads: "both have the word “acme”". */
|
|
15
|
+
readonly evidence: readonly string[];
|
|
16
|
+
readonly strength: number;
|
|
17
|
+
}
|
|
18
|
+
/** A far record a relation might point to, and why it was put forward. */
|
|
19
|
+
export interface TargetBlock {
|
|
20
|
+
readonly node: Node;
|
|
21
|
+
/** "its notes say “Harbor Catering”", "they share the word “harbor”", "the host's search calls it near". */
|
|
22
|
+
readonly evidence: string;
|
|
23
|
+
/** Whether the record's own text names it. */
|
|
24
|
+
readonly mentioned: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** One relation of a record to ask about: the act that links it, and the far records to choose among. */
|
|
27
|
+
export interface LinkBlock {
|
|
28
|
+
readonly relation: string;
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
/** An empty one-link relation (`missing-links`), rather than a link the record's text names (`links`). */
|
|
31
|
+
readonly missing: boolean;
|
|
32
|
+
readonly act: {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly to: string;
|
|
35
|
+
};
|
|
36
|
+
readonly targets: readonly TargetBlock[];
|
|
37
|
+
}
|
|
38
|
+
/** One empty choice field of a record, and the act that writes it. */
|
|
39
|
+
export interface FillBlock {
|
|
40
|
+
readonly field: string;
|
|
41
|
+
readonly options: readonly string[];
|
|
42
|
+
readonly description?: string;
|
|
43
|
+
readonly writes: {
|
|
44
|
+
readonly mutation: string;
|
|
45
|
+
readonly arg: string;
|
|
46
|
+
readonly subjectArg: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Everything one record is asked about, in one request. */
|
|
50
|
+
export interface RecordBlock {
|
|
51
|
+
readonly node: Node;
|
|
52
|
+
/** Present when it is old enough to set aside: how many days unchanged, and what its declaration says of it. */
|
|
53
|
+
readonly archive?: {
|
|
54
|
+
readonly days: number;
|
|
55
|
+
readonly why?: string;
|
|
56
|
+
};
|
|
57
|
+
readonly fills: readonly FillBlock[];
|
|
58
|
+
readonly links: readonly LinkBlock[];
|
|
59
|
+
}
|
|
60
|
+
export interface Blocks {
|
|
61
|
+
readonly pairs: readonly PairBlock[];
|
|
62
|
+
readonly records: readonly RecordBlock[];
|
|
63
|
+
}
|
|
64
|
+
/** What blocking may find, and how much of it. */
|
|
65
|
+
export interface BlockingOptions {
|
|
66
|
+
/** The judges' names a run uses: only their families are found. */
|
|
67
|
+
readonly families: ReadonlySet<string>;
|
|
68
|
+
/** The host's ranker (`HostAi.near`): records it calls near are paired too. */
|
|
69
|
+
readonly near?: SearchRanker;
|
|
70
|
+
/** At most this many pairs a run. 40 when unsaid. */
|
|
71
|
+
readonly maxPairs?: number;
|
|
72
|
+
/** At most this many records a run. 60 when unsaid. */
|
|
73
|
+
readonly maxRecords?: number;
|
|
74
|
+
/** At most this many far records a relation chooses among. 8 when unsaid. */
|
|
75
|
+
readonly maxTargets?: number;
|
|
76
|
+
}
|
|
77
|
+
/** A text's telling words: folded, three letters or more, the stop words out. */
|
|
78
|
+
export declare function wordsOf(text: string): string[];
|
|
79
|
+
/** What a run would ask a model about: pairs that may be one, and records with something to judge. */
|
|
80
|
+
export declare function blocksOf(context: JudgeContext, options: BlockingOptions): Promise<Blocks>;
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=blocking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocking.d.ts","sourceRoot":"","sources":["../../src/tidy/blocking.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAK1F,OAAO,EAA8F,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAa5I,KAAK,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErF,0HAA0H;AAC1H,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,C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QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,gHAAgH;IAChH,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;CAC1C;AAED,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAOD,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAI9C;AAiOD,sGAAsG;AACtG,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAK/F"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { humanizeField, nameKey } from "@graview/core";
|
|
2
|
+
import { formFields } from "@graview/core/forms";
|
|
3
|
+
import { fold } from "@graview/core/search";
|
|
4
|
+
import { tidyingOf } from "@graview/core/tidying";
|
|
5
|
+
import { questionsForKind } from "../questions.js";
|
|
6
|
+
import { actNamed, connectOf, fieldsOf, finishedOf, KEY_FIELD, keeperOf, lastMoved, mayTouch, named } from "./judges.js";
|
|
7
|
+
/** Words that say nothing about which thing it is: articles, joins, a company's legal form. */
|
|
8
|
+
const STOP = new Set("the and for with from into onto about this that these those your our their its are was were has have had not but all any can will per via inc incorporated corp corporation company llc ltd limited group plc gmbh".split(" "));
|
|
9
|
+
/** A text's telling words: folded, three letters or more, the stop words out. */
|
|
10
|
+
export function wordsOf(text) {
|
|
11
|
+
return fold(text)
|
|
12
|
+
.split(" ")
|
|
13
|
+
.filter((word) => word.length >= 3 && !STOP.has(word));
|
|
14
|
+
}
|
|
15
|
+
/** Whether `inside` holds `words` as whole words, folded. */
|
|
16
|
+
const holds = (inside, words) => words.length > 0 && ` ${inside} `.includes(` ${words} `);
|
|
17
|
+
/** A record's own text, field by field: its string fields the declaration does not hide. */
|
|
18
|
+
function textsOf(schema, node) {
|
|
19
|
+
const hidden = new Set(schema.tryDefinition(node.kind)?.display?.hide ?? []);
|
|
20
|
+
return fieldsOf(schema, node.kind).flatMap((field) => {
|
|
21
|
+
const value = node[field];
|
|
22
|
+
return !hidden.has(field) && typeof value === "string" && value.trim() ? [{ field, text: value }] : [];
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** A kind's free-text fields: not a choice, a date or a number, whose shared value says nothing of which record it is. */
|
|
26
|
+
const freeText = (schema, kind) => {
|
|
27
|
+
const definition = schema.tryDefinition(kind);
|
|
28
|
+
return new Set(definition ? formFields(definition.fields).filter((field) => field.control === "text" && !("long" in field && field.long) && !("markdown" in field && field.markdown)).map((field) => field.name) : []);
|
|
29
|
+
};
|
|
30
|
+
/** The fields a short value of which names one thing — an email, a phone, a code: free text, not the label, not prose. */
|
|
31
|
+
const valueFields = (schema, node, label, free) => textsOf(schema, node).filter(({ field, text }) => free.has(field) && field !== label && text.length <= 80 && nameKey(text).length >= 3 && nameKey(text) !== nameKey(named(schema, node)));
|
|
32
|
+
/** The field a kind is named by, when it is one field: `label`, else `name` or `title`. */
|
|
33
|
+
const labelField = (schema, kind) => ["label", "name", "title"].find((field) => fieldsOf(schema, kind).includes(field));
|
|
34
|
+
/** Same-kind pairs that may be one record. */
|
|
35
|
+
async function pairsOf(context, options) {
|
|
36
|
+
const { store } = context;
|
|
37
|
+
const schema = store.schema;
|
|
38
|
+
const found = [];
|
|
39
|
+
for (const definition of schema.definitions) {
|
|
40
|
+
const kind = definition.kind;
|
|
41
|
+
if (definition.archives === false || !actNamed(store, `merge-${kind}`) || tidyingOf(schema, kind) === "never")
|
|
42
|
+
continue;
|
|
43
|
+
const records = store.graph.nodesOfKind(kind).filter((node) => mayTouch(context, node));
|
|
44
|
+
if (records.length < 2)
|
|
45
|
+
continue;
|
|
46
|
+
const label = labelField(schema, kind);
|
|
47
|
+
const byPair = new Map();
|
|
48
|
+
const pair = (a, b, strength, evidence, key) => {
|
|
49
|
+
if (a.id === b.id)
|
|
50
|
+
return;
|
|
51
|
+
const [first, second] = a.id < b.id ? [a, b] : [b, a];
|
|
52
|
+
const id = `${first.id}\u0000${second.id}`;
|
|
53
|
+
const was = byPair.get(id) ?? { a: first, b: second, strength: 0, evidence: [], keys: new Set() };
|
|
54
|
+
was.strength += strength;
|
|
55
|
+
if (!was.evidence.includes(evidence))
|
|
56
|
+
was.evidence.push(evidence);
|
|
57
|
+
if (key)
|
|
58
|
+
was.keys.add(key);
|
|
59
|
+
byPair.set(id, was);
|
|
60
|
+
};
|
|
61
|
+
// Telling words in the name and the key fields; a word half the kind shares tells nothing.
|
|
62
|
+
const index = new Map();
|
|
63
|
+
const wordSets = new Map();
|
|
64
|
+
for (const node of records) {
|
|
65
|
+
// A key value (an email, a code) is one word, whole: its domain alone says nothing.
|
|
66
|
+
const keys = fieldsOf(schema, kind).filter((field) => KEY_FIELD.test(field) && typeof node[field] === "string" && String(node[field]).trim()).map((field) => nameKey(String(node[field])));
|
|
67
|
+
const words = new Set([...wordsOf(named(schema, node)), ...keys]);
|
|
68
|
+
wordSets.set(node.id, words);
|
|
69
|
+
for (const word of words)
|
|
70
|
+
index.set(word, [...(index.get(word) ?? []), node]);
|
|
71
|
+
}
|
|
72
|
+
const common = Math.max(4, Math.ceil(records.length * 0.25));
|
|
73
|
+
for (const [word, holders] of index) {
|
|
74
|
+
if (holders.length < 2 || holders.length > common)
|
|
75
|
+
continue;
|
|
76
|
+
for (let i = 0; i < holders.length; i++)
|
|
77
|
+
for (let j = i + 1; j < holders.length; j++) {
|
|
78
|
+
const a = wordSets.get(holders[i].id);
|
|
79
|
+
const b = wordSets.get(holders[j].id);
|
|
80
|
+
const shared = [...a].filter((one) => b.has(one)).length;
|
|
81
|
+
// Each shared word adds 1 / the words between them, so a pair sums to its Jaccard.
|
|
82
|
+
pair(holders[i], holders[j], 1 / (a.size + b.size - shared), `both have the word “${word}”`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// A short value both hold: an email, a phone, a website, a code.
|
|
86
|
+
const byValue = new Map();
|
|
87
|
+
const free = freeText(schema, kind);
|
|
88
|
+
for (const node of records)
|
|
89
|
+
for (const { field, text } of valueFields(schema, node, label, free)) {
|
|
90
|
+
const key = `${field}\u0000${nameKey(text)}`;
|
|
91
|
+
const was = byValue.get(key) ?? { field, nodes: [] };
|
|
92
|
+
was.nodes.push(node);
|
|
93
|
+
byValue.set(key, was);
|
|
94
|
+
}
|
|
95
|
+
for (const { field, nodes } of byValue.values()) {
|
|
96
|
+
if (nodes.length < 2 || nodes.length > common)
|
|
97
|
+
continue;
|
|
98
|
+
for (let i = 0; i < nodes.length; i++)
|
|
99
|
+
for (let j = i + 1; j < nodes.length; j++)
|
|
100
|
+
pair(nodes[i], nodes[j], 1, `both have the same ${field}`, field);
|
|
101
|
+
}
|
|
102
|
+
// The host's ranker, asked of each record's name over the rest of its kind.
|
|
103
|
+
if (options.near) {
|
|
104
|
+
for (const node of records.slice(0, 50)) {
|
|
105
|
+
const others = records.filter((one) => one.id !== node.id).map((one) => ({ id: one.id, kind, label: named(schema, one), texts: textsOf(schema, one).map(({ field, text }) => ({ field, reading: field, text })) }));
|
|
106
|
+
let scores = [];
|
|
107
|
+
try {
|
|
108
|
+
scores = await options.near(named(schema, node), others);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
scores = [];
|
|
112
|
+
}
|
|
113
|
+
for (const score of scores) {
|
|
114
|
+
const other = records.find((one) => one.id === score.id);
|
|
115
|
+
if (other && score.score >= 0.5)
|
|
116
|
+
pair(node, other, score.score, "the host's search calls them near");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (const { a, b, strength, evidence, keys } of byPair.values()) {
|
|
121
|
+
const keeper = keeperOf(store, [a, b], context.touched);
|
|
122
|
+
const other = keeper.id === a.id ? b : a;
|
|
123
|
+
const keyFields = new Set([...keys, ...fieldsOf(schema, kind).filter((field) => KEY_FIELD.test(field) && typeof a[field] === "string" && typeof b[field] === "string" && String(a[field]).trim() && String(b[field]).trim())]);
|
|
124
|
+
if (label)
|
|
125
|
+
keyFields.delete(label);
|
|
126
|
+
found.push({ kind, keeper, other, keys: [...keyFields], evidence, strength });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return found.sort((a, b) => b.strength - a.strength).slice(0, options.maxPairs ?? 40);
|
|
130
|
+
}
|
|
131
|
+
/** The far records a record might link to through one relation, likeliest first. */
|
|
132
|
+
async function targetsOf(context, node, targets, missing, options) {
|
|
133
|
+
const schema = context.store.schema;
|
|
134
|
+
const texts = textsOf(schema, node);
|
|
135
|
+
const own = fold(named(schema, node));
|
|
136
|
+
const said = texts.map(({ field, text }) => ({ field, text: fold(text) }));
|
|
137
|
+
const ownWords = new Set(wordsOf(texts.map(({ text }) => text).join(" ")));
|
|
138
|
+
const out = new Map();
|
|
139
|
+
const put = (far, evidence, weight, mentioned) => {
|
|
140
|
+
const was = out.get(far.id);
|
|
141
|
+
if (!was || was.weight < weight)
|
|
142
|
+
out.set(far.id, { node: far, evidence, weight, mentioned });
|
|
143
|
+
};
|
|
144
|
+
for (const far of targets) {
|
|
145
|
+
const name = fold(named(schema, far));
|
|
146
|
+
if (name.replace(/ /g, "").length < 3 || name === own)
|
|
147
|
+
continue;
|
|
148
|
+
// Its whole name in the record's text.
|
|
149
|
+
const whole = said.find(({ text }) => holds(text, name));
|
|
150
|
+
if (whole) {
|
|
151
|
+
put(far, `its ${humanizeField(whole.field).toLowerCase()} says “${named(schema, far)}”`, 3, true);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
// One of its telling words, or one of its key values, in the record's text.
|
|
155
|
+
const aliases = [...wordsOf(named(schema, far)).filter((word) => word.length >= 4), ...fieldsOf(schema, far.kind).filter((field) => KEY_FIELD.test(field) && typeof far[field] === "string").map((field) => fold(String(far[field])))];
|
|
156
|
+
const alias = aliases.find((word) => said.some(({ text }) => holds(text, word)));
|
|
157
|
+
if (alias) {
|
|
158
|
+
put(far, `its text says “${alias}”`, 2, true);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (!missing)
|
|
162
|
+
continue;
|
|
163
|
+
// For an empty one-link relation, a word or a value the two share is enough to ask.
|
|
164
|
+
const farWords = wordsOf([named(schema, far), ...textsOf(schema, far).map(({ text }) => text)].join(" "));
|
|
165
|
+
const shared = farWords.find((word) => ownWords.has(word));
|
|
166
|
+
if (shared)
|
|
167
|
+
put(far, `they share the word “${shared}”`, 1, false);
|
|
168
|
+
}
|
|
169
|
+
if (missing && options.near && out.size < (options.maxTargets ?? 8)) {
|
|
170
|
+
try {
|
|
171
|
+
const scores = await options.near(named(schema, node), targets.map((far) => ({ id: far.id, kind: far.kind, label: named(schema, far), texts: textsOf(schema, far).map(({ field, text }) => ({ field, reading: field, text })) })));
|
|
172
|
+
for (const score of scores) {
|
|
173
|
+
const far = targets.find((one) => one.id === score.id);
|
|
174
|
+
if (far && score.score >= 0.5)
|
|
175
|
+
put(far, "the host's search calls it near", score.score, false);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// A ranker that fails puts nothing forward.
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return [...out.values()].sort((a, b) => b.weight - a.weight).slice(0, options.maxTargets ?? 8).map(({ node: far, evidence, mentioned }) => ({ node: far, evidence, mentioned }));
|
|
183
|
+
}
|
|
184
|
+
/** What each record is asked about: set aside, an empty choice, a link its text names, an empty one-link relation. */
|
|
185
|
+
async function recordsOf(context, options) {
|
|
186
|
+
const { store } = context;
|
|
187
|
+
const schema = store.schema;
|
|
188
|
+
const today = new Date(context.now).toISOString().slice(0, 10);
|
|
189
|
+
const wants = (family) => options.families.has(family);
|
|
190
|
+
const found = [];
|
|
191
|
+
for (const definition of schema.definitions) {
|
|
192
|
+
const kind = definition.kind;
|
|
193
|
+
if (tidyingOf(schema, kind) === "never")
|
|
194
|
+
continue;
|
|
195
|
+
const archives = wants("archive") && definition.archives !== false && actNamed(store, `archive-${kind}`) !== undefined;
|
|
196
|
+
const finished = archives ? finishedOf(schema, kind, today) : undefined;
|
|
197
|
+
const choices = wants("categorize")
|
|
198
|
+
? questionsForKind(store, kind).flatMap((question) => {
|
|
199
|
+
if (question.about !== "field" || !question.writes || question.question.type !== "choice")
|
|
200
|
+
return [];
|
|
201
|
+
const field = formFields(definition.fields).find((one) => one.name === question.field);
|
|
202
|
+
return field?.control === "choice" && field.optional && field.options?.length ? [{ field: field.name, options: field.options, writes: question.writes, instructions: question.question.instructions }] : [];
|
|
203
|
+
})
|
|
204
|
+
: [];
|
|
205
|
+
const relations = Object.entries(definition.edges ?? {}).flatMap(([relation, edge]) => {
|
|
206
|
+
if (edge.acts === "none" || tidyingOf(schema, kind) === "no-links" || tidyingOf(schema, kind, relation) === "never")
|
|
207
|
+
return [];
|
|
208
|
+
const kinds = (edge.to === "*" ? schema.definitions.map((one) => one.kind) : edge.to).filter((target) => tidyingOf(schema, target) !== "never" && tidyingOf(schema, target) !== "no-links");
|
|
209
|
+
const act = connectOf(store, kind, relation, kinds);
|
|
210
|
+
return act ? [{ relation, edge, kinds, act }] : [];
|
|
211
|
+
});
|
|
212
|
+
for (const node of store.graph.nodesOfKind(kind)) {
|
|
213
|
+
if (!mayTouch(context, node))
|
|
214
|
+
continue;
|
|
215
|
+
let archive;
|
|
216
|
+
if (archives) {
|
|
217
|
+
const moved = lastMoved(schema, node, context.touched);
|
|
218
|
+
const days = moved === undefined ? -1 : Math.floor((context.now - moved) / 86_400_000);
|
|
219
|
+
if (days >= context.olderThanDays) {
|
|
220
|
+
const why = finished?.(node);
|
|
221
|
+
archive = { days, ...(why ? { why } : {}) };
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const fills = choices.filter(({ field }) => node[field] === undefined || node[field] === null || node[field] === "").map(({ field, options: values, writes }) => {
|
|
225
|
+
const description = definition.fields.shape?.[field]?.description;
|
|
226
|
+
return { field, options: values, writes, ...(description ? { description } : {}) };
|
|
227
|
+
});
|
|
228
|
+
const links = [];
|
|
229
|
+
for (const { relation, edge, kinds, act } of relations) {
|
|
230
|
+
const linked = new Set(store.graph.out(node.id, relation).map((one) => one.id));
|
|
231
|
+
const missing = edge.cardinality === "one";
|
|
232
|
+
if (missing && linked.size > 0)
|
|
233
|
+
continue;
|
|
234
|
+
if (!wants(missing ? "missing-links" : "links"))
|
|
235
|
+
continue;
|
|
236
|
+
const pool = kinds.flatMap((target) => store.graph.nodesOfKind(target)).filter((far) => far.id !== node.id && !linked.has(far.id) && mayTouch(context, far));
|
|
237
|
+
const targets = await targetsOf(context, node, pool, missing, options);
|
|
238
|
+
if (targets.length > 0)
|
|
239
|
+
links.push({ relation, ...(edge.description ? { description: edge.description } : {}), missing, act, targets });
|
|
240
|
+
}
|
|
241
|
+
if (!archive && fills.length === 0 && links.length === 0)
|
|
242
|
+
continue;
|
|
243
|
+
// A record its declaration says is finished, then one that names another, comes first.
|
|
244
|
+
const weight = (archive?.why ? 3 : archive ? 1 : 0) + links.filter((link) => link.targets.some((target) => target.mentioned)).length * 2 + links.length + fills.length;
|
|
245
|
+
found.push({ node, ...(archive ? { archive } : {}), fills, links, weight });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return found
|
|
249
|
+
.sort((a, b) => b.weight - a.weight)
|
|
250
|
+
.slice(0, options.maxRecords ?? 60)
|
|
251
|
+
.map(({ weight: _weight, ...block }) => block);
|
|
252
|
+
}
|
|
253
|
+
/** What a run would ask a model about: pairs that may be one, and records with something to judge. */
|
|
254
|
+
export async function blocksOf(context, options) {
|
|
255
|
+
return {
|
|
256
|
+
pairs: options.families.has("duplicates") ? await pairsOf(context, options) : [],
|
|
257
|
+
records: await recordsOf(context, options),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=blocking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocking.js","sourceRoot":"","sources":["../../src/tidy/blocking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAqC,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAqB,MAAM,aAAa,CAAC;AAkF5I,+FAA+F;AAC/F,MAAM,IAAI,GAAG,IAAI,GAAG,CAClB,oNAAoN,CAAC,KAAK,CAAC,GAAG,CAAC,CAChO,CAAC;AAEF,iFAAiF;AACjF,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC;SACd,KAAK,CAAC,GAAG,C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