@graview/tools 0.1.48 → 0.1.50
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/not-now.d.ts +12 -0
- package/dist/agent/not-now.d.ts.map +1 -0
- package/dist/agent/not-now.js +132 -0
- package/dist/agent/not-now.js.map +1 -0
- package/dist/agent/tools.d.ts +3 -2
- package/dist/agent/tools.d.ts.map +1 -1
- package/dist/agent/tools.js +48 -12
- package/dist/agent/tools.js.map +1 -1
- package/dist/agent/untrusted.d.ts.map +1 -1
- package/dist/agent/untrusted.js +3 -2
- package/dist/agent/untrusted.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 +91 -4
- package/dist/cli.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.js +1 -1
- 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 +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- 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 +1 -1
- package/dist/intelligence.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.d.ts +1 -1
- package/dist/seat-model.js +4 -4
- 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,51 @@
|
|
|
1
|
+
import { type AnySchema, type Store } from "@graview/core";
|
|
2
|
+
import { type Question } from "../questions.js";
|
|
3
|
+
import type { Blocks, PairBlock, RecordBlock } from "./blocking.js";
|
|
4
|
+
import { type Candidate } from "./judges.js";
|
|
5
|
+
import type { Severity } from "./policy.js";
|
|
6
|
+
import { type SystemOneAnswer } from "./system-one.js";
|
|
7
|
+
/** The questions' version: a change to their words changes every cache key, so nothing is read back from the old ones. */
|
|
8
|
+
export declare const QUESTION_SET = "dream-questions/1";
|
|
9
|
+
/** "None of these": the option that keeps a Choice from being made to pick. */
|
|
10
|
+
export declare const NONE_OF_THESE = "none of these";
|
|
11
|
+
/** "None fits": the option that keeps an empty choice empty. */
|
|
12
|
+
export declare const NONE_FITS = "none fits";
|
|
13
|
+
/** A judgment the model made: a change it would make (with how sure), or one it let go. */
|
|
14
|
+
export interface Judgment extends Candidate {
|
|
15
|
+
readonly severity: Severity;
|
|
16
|
+
/** The answering model. */
|
|
17
|
+
readonly model: string;
|
|
18
|
+
/** Two options nearly as likely: never made unasked. */
|
|
19
|
+
readonly split?: boolean;
|
|
20
|
+
/** The model chose none, or was not sure enough to say anything. */
|
|
21
|
+
readonly none?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** One request: the state, its questions, what it covers, and how its answers read back. */
|
|
24
|
+
export interface Ask {
|
|
25
|
+
/** The families and records it judges, so the floor does not judge them again: "duplicates:a|b", "links:x". */
|
|
26
|
+
readonly covers: readonly string[];
|
|
27
|
+
readonly state: Readonly<Record<string, unknown>>;
|
|
28
|
+
readonly questions: Readonly<Record<string, Question>>;
|
|
29
|
+
read(answers: Readonly<Record<string, SystemOneAnswer>>, model: string): readonly Judgment[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* TWO RECORDS THAT MAY BE ONE. A Score — different, related but distinct,
|
|
33
|
+
* the same thing — and a Noul for the name and each key field both fill,
|
|
34
|
+
* in one request. The Score is the judgment; a key the model says differs
|
|
35
|
+
* (two emails, two codes) keeps the merge to a person's word.
|
|
36
|
+
*/
|
|
37
|
+
export declare function pairAsk(store: Store<AnySchema>, pair: PairBlock): Ask;
|
|
38
|
+
/**
|
|
39
|
+
* ONE RECORD, EVERYTHING ABOUT IT. Whether it is finished or no longer
|
|
40
|
+
* relevant (a Noul, with its state, how long unchanged and how its kind
|
|
41
|
+
* says it is finished); for each empty choice, which option fits, or none
|
|
42
|
+
* (a Choice); for each relation, which of the likeliest far records it
|
|
43
|
+
* means, or none of these (a Choice — select, never generate; the
|
|
44
|
+
* relation is always one the app declares).
|
|
45
|
+
*/
|
|
46
|
+
export declare function recordAsk(store: Store<AnySchema>, block: RecordBlock): Ask;
|
|
47
|
+
/** Every request a run would make, pairs first. */
|
|
48
|
+
export declare const asksOf: (store: Store<AnySchema>, blocks: Blocks) => Ask[];
|
|
49
|
+
/** The key a floor candidate is covered by, so a judgment the model made is not made again by the judges' rules. */
|
|
50
|
+
export declare function coverOf(candidate: Candidate): string;
|
|
51
|
+
//# sourceMappingURL=judging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judging.d.ts","sourceRoot":"","sources":["../../src/tidy/judging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,KAAK,SAAS,EAAqB,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAE5H,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpE,OAA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EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG,GAAG,CAkH1E;AAED,mDAAmD;AACnD,eAAO,MAAM,MAAM,GAAI,OAAO,KAAK,CAAC,SAAS,CAAC,EAAE,QAAQ,MAAM,KAAG,GAAG,EAAwH,CAAC;AAE7L,oHAAoH;AACpH,wBAAgB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAIpD"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { humanizeField, nounOf, pluralOf, withArticle } from "@graview/core";
|
|
2
|
+
import { districtState } from "@graview/core/city";
|
|
3
|
+
import { nodeState } from "../questions.js";
|
|
4
|
+
import { named, noun } from "./judges.js";
|
|
5
|
+
import { choiceOf, modelWord, noulOf, scoreOf } from "./system-one.js";
|
|
6
|
+
/** The questions' version: a change to their words changes every cache key, so nothing is read back from the old ones. */
|
|
7
|
+
export const QUESTION_SET = "dream-questions/1";
|
|
8
|
+
/** "None of these": the option that keeps a Choice from being made to pick. */
|
|
9
|
+
export const NONE_OF_THESE = "none of these";
|
|
10
|
+
/** "None fits": the option that keeps an empty choice empty. */
|
|
11
|
+
export const NONE_FITS = "none fits";
|
|
12
|
+
const quote = (text) => `“${text}”`;
|
|
13
|
+
const two = (value) => value.toFixed(2);
|
|
14
|
+
/** A record as the model reads it: its kind, its name, its fields as the actor may see them, what it is joined to. No id. */
|
|
15
|
+
function recordState(store, node) {
|
|
16
|
+
const { id: _id, "what the kind is": _kind, ...state } = (nodeState(store, node.id) ?? { kind: node.kind, label: named(store.schema, node) });
|
|
17
|
+
return state;
|
|
18
|
+
}
|
|
19
|
+
/** What a kind is, in the declaration's words. */
|
|
20
|
+
function kindState(schema, kind) {
|
|
21
|
+
const definition = schema.tryDefinition(kind);
|
|
22
|
+
const state = districtState(schema, kind);
|
|
23
|
+
const done = state ? state.values.filter((_, at) => state.tiers[at] === "done") : [];
|
|
24
|
+
const lifecycle = definition?.lifecycle;
|
|
25
|
+
const finishedWhen = lifecycle
|
|
26
|
+
? lifecycle.retired === "date"
|
|
27
|
+
? `once its ${humanizeField(lifecycle.field).toLowerCase()} has passed`
|
|
28
|
+
: `when its ${humanizeField(lifecycle.field).toLowerCase()} retires it`
|
|
29
|
+
: done.length > 0
|
|
30
|
+
? `when its ${humanizeField(state.field).toLowerCase()} is ${done.map(quote).join(" or ")}`
|
|
31
|
+
: undefined;
|
|
32
|
+
return {
|
|
33
|
+
name: nounOf(definition, kind),
|
|
34
|
+
...(definition?.description ? { "what it is": definition.description } : {}),
|
|
35
|
+
...(finishedWhen ? { "finished when": finishedWhen } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** How long unchanged, in words that stay the same from one night to the next. */
|
|
39
|
+
const ageOf = (days) => (days >= 365 ? "over a year" : days >= 180 ? "over six months" : days >= 90 ? "over three months" : days >= 30 ? "over a month" : `${days} days`);
|
|
40
|
+
/** The key a question takes from a field or relation name: letters, digits and underscores. */
|
|
41
|
+
const keyOf = (prefix, name) => `${prefix}_${name.replace(/[^A-Za-z0-9_]+/g, "_")}`;
|
|
42
|
+
/** Option names a model reads — each far record's name — made unique. */
|
|
43
|
+
function optionNames(names) {
|
|
44
|
+
const seen = new Map();
|
|
45
|
+
return names.map((name) => {
|
|
46
|
+
const count = (seen.get(name) ?? 0) + 1;
|
|
47
|
+
seen.set(name, count);
|
|
48
|
+
return count === 1 && name !== NONE_OF_THESE ? name : `${name} (${count})`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* TWO RECORDS THAT MAY BE ONE. A Score — different, related but distinct,
|
|
53
|
+
* the same thing — and a Noul for the name and each key field both fill,
|
|
54
|
+
* in one request. The Score is the judgment; a key the model says differs
|
|
55
|
+
* (two emails, two codes) keeps the merge to a person's word.
|
|
56
|
+
*/
|
|
57
|
+
export function pairAsk(store, pair) {
|
|
58
|
+
const schema = store.schema;
|
|
59
|
+
const one = noun(schema, pair.kind);
|
|
60
|
+
const many = pluralOf(schema, pair.kind);
|
|
61
|
+
const first = named(schema, pair.other);
|
|
62
|
+
const second = named(schema, pair.keeper);
|
|
63
|
+
const questions = {
|
|
64
|
+
same_thing: {
|
|
65
|
+
type: "score",
|
|
66
|
+
instructions: `Are “first” and “second” the same ${one}, entered twice? Judge from what each record says.`,
|
|
67
|
+
criteria: [`Different ${many}: alike only in passing.`, `Related but distinct: connected ${many}, still two of them.`, `The same ${one}, entered twice.`],
|
|
68
|
+
},
|
|
69
|
+
same_name: {
|
|
70
|
+
type: "noul",
|
|
71
|
+
instructions: `Do “first” and “second” have the same name, written two ways?`,
|
|
72
|
+
criteria: { true: "One name, written two ways.", false: "Two different names." },
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
for (const field of pair.keys) {
|
|
76
|
+
questions[keyOf("same", field)] = {
|
|
77
|
+
type: "noul",
|
|
78
|
+
instructions: `Do “first” and “second” have the same ${humanizeField(field).toLowerCase()}, perhaps written two ways?`,
|
|
79
|
+
criteria: { true: `One ${humanizeField(field).toLowerCase()}.`, false: `Two different ${humanizeField(field).toLowerCase()} values.` },
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
covers: [`duplicates:${[pair.other.id, pair.keeper.id].sort().join("|")}`],
|
|
84
|
+
state: { kind: kindState(schema, pair.kind), first: recordState(store, pair.other), second: recordState(store, pair.keeper) },
|
|
85
|
+
questions,
|
|
86
|
+
read(answers, model) {
|
|
87
|
+
const same = scoreOf(answers["same_thing"], 3);
|
|
88
|
+
if (same === undefined)
|
|
89
|
+
return [];
|
|
90
|
+
const keys = pair.keys.map((field) => ({ field, p: noulOf(answers[keyOf("same", field)]) })).filter((one) => one.p !== undefined);
|
|
91
|
+
const name = noulOf(answers["same_name"]);
|
|
92
|
+
const nouls = [...keys.map((one) => one.p), ...(name === undefined ? [] : [name])];
|
|
93
|
+
let confidence = nouls.length > 0 ? (2 * same + nouls.reduce((sum, p) => sum + p, 0) / nouls.length) / 3 : same;
|
|
94
|
+
// A key the model says differs: never merged unasked.
|
|
95
|
+
const differs = keys.find((one) => one.p < 0.2);
|
|
96
|
+
if (differs)
|
|
97
|
+
confidence = Math.min(confidence, 0.5);
|
|
98
|
+
confidence = Math.round(confidence * 100) / 100;
|
|
99
|
+
const agreed = keys.filter((one) => one.p >= 0.8).map((one) => `the same ${humanizeField(one.field).toLowerCase()}`);
|
|
100
|
+
const basis = [
|
|
101
|
+
`${modelWord(model)}: ${two(confidence)} that ${quote(first)} and ${quote(second)} are the same ${one}`,
|
|
102
|
+
agreed.length > 0 ? ` (${agreed.join(", ")})` : "",
|
|
103
|
+
differs ? `, though their ${humanizeField(differs.field).toLowerCase()} differs` : "",
|
|
104
|
+
].join("");
|
|
105
|
+
return [{ judge: "duplicates", severity: "merge", model, calls: [{ name: `merge-${pair.kind}`, args: { id: pair.other.id, into: pair.keeper.id } }], basis, confidence, about: [pair.other.id, pair.keeper.id] }];
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* ONE RECORD, EVERYTHING ABOUT IT. Whether it is finished or no longer
|
|
111
|
+
* relevant (a Noul, with its state, how long unchanged and how its kind
|
|
112
|
+
* says it is finished); for each empty choice, which option fits, or none
|
|
113
|
+
* (a Choice); for each relation, which of the likeliest far records it
|
|
114
|
+
* means, or none of these (a Choice — select, never generate; the
|
|
115
|
+
* relation is always one the app declares).
|
|
116
|
+
*/
|
|
117
|
+
export function recordAsk(store, block) {
|
|
118
|
+
const schema = store.schema;
|
|
119
|
+
const node = block.node;
|
|
120
|
+
const one = noun(schema, node.kind);
|
|
121
|
+
const name = named(schema, node);
|
|
122
|
+
const questions = {};
|
|
123
|
+
const state = { kind: kindState(schema, node.kind), record: recordState(store, node) };
|
|
124
|
+
const covers = [];
|
|
125
|
+
const readers = [];
|
|
126
|
+
if (block.archive) {
|
|
127
|
+
covers.push(`archive:${node.id}`);
|
|
128
|
+
// Said coarsely, so tomorrow's run asks the same question and its answer is kept.
|
|
129
|
+
const age = ageOf(block.archive.days);
|
|
130
|
+
state["unchanged for"] = age;
|
|
131
|
+
questions["finished"] = {
|
|
132
|
+
type: "noul",
|
|
133
|
+
instructions: `Is this ${one} finished, or no longer relevant, so it can be set aside (archived, kept but out of the lists)? It has been unchanged for ${age}.`,
|
|
134
|
+
criteria: { true: "Finished or no longer relevant: setting it aside loses nothing anyone is using.", false: "Still open, still in use, or likely to be needed soon." },
|
|
135
|
+
};
|
|
136
|
+
const days = block.archive.days;
|
|
137
|
+
const why = block.archive.why;
|
|
138
|
+
readers.push((answers, model) => {
|
|
139
|
+
const p = noulOf(answers["finished"]);
|
|
140
|
+
if (p === undefined)
|
|
141
|
+
return undefined;
|
|
142
|
+
return {
|
|
143
|
+
judge: "archive",
|
|
144
|
+
severity: "archive",
|
|
145
|
+
model,
|
|
146
|
+
calls: [{ name: `archive-${node.kind}`, args: { id: node.id } }],
|
|
147
|
+
basis: `${modelWord(model)}: ${two(p)} that ${quote(name)} is finished or no longer relevant (${why ? `${why}, ` : ""}unchanged for ${days} days)`,
|
|
148
|
+
confidence: p,
|
|
149
|
+
about: [node.id],
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
for (const fill of block.fills) {
|
|
154
|
+
covers.push(`categorize:${node.id}:${fill.field}`);
|
|
155
|
+
const key = keyOf("fill", fill.field);
|
|
156
|
+
const words = humanizeField(fill.field).toLowerCase();
|
|
157
|
+
const criteria = {};
|
|
158
|
+
for (const option of fill.options)
|
|
159
|
+
criteria[option] = null;
|
|
160
|
+
criteria[NONE_FITS] = `No ${words} plainly fits; leave it empty.`;
|
|
161
|
+
questions[key] = {
|
|
162
|
+
type: "choice",
|
|
163
|
+
instructions: `Which ${words} is this ${one}?${fill.description ? ` ${fill.description}` : ""} Choose “${NONE_FITS}” unless the record plainly says.`,
|
|
164
|
+
criteria,
|
|
165
|
+
};
|
|
166
|
+
readers.push((answers, model) => {
|
|
167
|
+
const chosen = choiceOf(answers[key]);
|
|
168
|
+
if (!chosen)
|
|
169
|
+
return undefined;
|
|
170
|
+
const none = chosen.choice === NONE_FITS || !fill.options.includes(chosen.choice);
|
|
171
|
+
return {
|
|
172
|
+
judge: "categorize",
|
|
173
|
+
severity: "categorize",
|
|
174
|
+
model,
|
|
175
|
+
calls: none ? [] : [{ name: fill.writes.mutation, args: { [fill.writes.subjectArg]: node.id, [fill.writes.arg]: chosen.choice } }],
|
|
176
|
+
basis: none ? `${modelWord(model)}: no ${words} plainly fits ${quote(name)} (${two(chosen.confidence)})` : `${modelWord(model)}: ${two(chosen.confidence)} that the ${words} of ${quote(name)} is ${quote(chosen.choice)}`,
|
|
177
|
+
confidence: chosen.confidence,
|
|
178
|
+
about: [node.id],
|
|
179
|
+
split: chosen.margin < 0.15,
|
|
180
|
+
...(none ? { none: true } : {}),
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const candidates = {};
|
|
185
|
+
for (const link of block.links) {
|
|
186
|
+
const judge = link.missing ? "missing-links" : "links";
|
|
187
|
+
covers.push(`links:${node.id}`);
|
|
188
|
+
const key = keyOf("link", link.relation);
|
|
189
|
+
const words = humanizeField(link.relation).toLowerCase();
|
|
190
|
+
const options = optionNames(link.targets.map((target) => named(schema, target.node)));
|
|
191
|
+
const byOption = new Map(options.map((option, at) => [option, link.targets[at]]));
|
|
192
|
+
const criteria = {};
|
|
193
|
+
link.targets.forEach((target, at) => {
|
|
194
|
+
criteria[options[at]] = `${withArticle(noun(schema, target.node.kind))}: ${named(schema, target.node)}`;
|
|
195
|
+
});
|
|
196
|
+
criteria[NONE_OF_THESE] = "None of these is meant; leave it as it is.";
|
|
197
|
+
candidates[key] = Object.fromEntries(link.targets.map((target, at) => [options[at], recordState(store, target.node)]));
|
|
198
|
+
questions[key] = {
|
|
199
|
+
type: "choice",
|
|
200
|
+
instructions: `This ${one}'s “${words}”${link.description ? ` (${link.description})` : ""}: which of the candidates does the record mean? Choose one only if the record plainly means it; otherwise “${NONE_OF_THESE}”.`,
|
|
201
|
+
criteria,
|
|
202
|
+
};
|
|
203
|
+
readers.push((answers, model) => {
|
|
204
|
+
const chosen = choiceOf(answers[key]);
|
|
205
|
+
if (!chosen)
|
|
206
|
+
return undefined;
|
|
207
|
+
const target = byOption.get(chosen.choice);
|
|
208
|
+
const calls = target ? [{ name: link.act.name, args: { id: node.id, [link.act.to]: target.node.id } }] : [];
|
|
209
|
+
return {
|
|
210
|
+
judge,
|
|
211
|
+
severity: "link",
|
|
212
|
+
model,
|
|
213
|
+
calls,
|
|
214
|
+
basis: target
|
|
215
|
+
? `${modelWord(model)}: ${two(chosen.confidence)} that the ${words} of ${quote(name)} is ${quote(named(schema, target.node))} (${target.evidence})`
|
|
216
|
+
: `${modelWord(model)}: none of the candidates is the ${words} of ${quote(name)} (${two(chosen.confidence)})`,
|
|
217
|
+
confidence: chosen.confidence,
|
|
218
|
+
about: target ? [node.id, target.node.id] : [node.id],
|
|
219
|
+
split: chosen.margin < 0.15,
|
|
220
|
+
...(target ? {} : { none: true }),
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
if (Object.keys(candidates).length > 0)
|
|
225
|
+
state["candidates"] = candidates;
|
|
226
|
+
return {
|
|
227
|
+
covers,
|
|
228
|
+
state,
|
|
229
|
+
questions,
|
|
230
|
+
read: (answers, model) => readers.flatMap((reader) => reader(answers, model) ?? []),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/** Every request a run would make, pairs first. */
|
|
234
|
+
export const asksOf = (store, blocks) => [...blocks.pairs.map((pair) => pairAsk(store, pair)), ...blocks.records.map((record) => recordAsk(store, record))];
|
|
235
|
+
/** The key a floor candidate is covered by, so a judgment the model made is not made again by the judges' rules. */
|
|
236
|
+
export function coverOf(candidate) {
|
|
237
|
+
if (candidate.judge === "duplicates")
|
|
238
|
+
return `duplicates:${[...candidate.about].sort().join("|")}`;
|
|
239
|
+
if (candidate.judge === "links" || candidate.judge === "missing-links")
|
|
240
|
+
return `links:${candidate.about[0]}`;
|
|
241
|
+
return `${candidate.judge}:${candidate.about[0]}`;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=judging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judging.js","sourceRoot":"","sources":["../../src/tidy/judging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAiD,MAAM,eAAe,CAAC;AAC5H,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAwB,MAAM,iBAAiB,CAAC;AAc7F,0HAA0H;AAC1H,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAC7C,gEAAgE;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AAsBrC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC;AAC5C,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhD,6HAA6H;AAC7H,SAAS,WAAW,CAAC,KAAuB,EAAE,IAAU;IACtD,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC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,CAAC,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** How much a change would undo: a merge, an archive, a link made, a choice filled in. */
|
|
2
|
+
export type Severity = "merge" | "archive" | "link" | "categorize";
|
|
3
|
+
/** At least `act` sure: may be made unasked (where the host allows). At least `ask`: suggested. Below: dropped. */
|
|
4
|
+
export interface Band {
|
|
5
|
+
readonly act: number;
|
|
6
|
+
readonly ask: number;
|
|
7
|
+
}
|
|
8
|
+
/** The bands a dream uses unless the host says others. */
|
|
9
|
+
export declare const BANDS: Readonly<Record<Severity, Band>>;
|
|
10
|
+
/** What becomes of one judgment: made, put to a person, or let go. */
|
|
11
|
+
export type Route = "act" | "ask" | "drop";
|
|
12
|
+
/**
|
|
13
|
+
* Where a confidence goes for a change of this severity. A split choice —
|
|
14
|
+
* two options nearly as likely — is never made unasked, however sure its
|
|
15
|
+
* top option.
|
|
16
|
+
*/
|
|
17
|
+
export declare function routeOf(confidence: number, severity: Severity, bands?: Partial<Record<Severity, Partial<Band>>>, split?: boolean): Route;
|
|
18
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/tidy/policy.ts"],"names":[],"mappings":"AAWA,0FAA0F;AAC1F,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;AAEnE,mHAAmH;AACnH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,0DAA0D;AAC1D,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAKlD,CAAC;AAEF,sEAAsE;AACtE,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,KAAK,UAAQ,GAAG,KAAK,CAI1I"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* WHAT A CONFIDENCE BECOMES, BY HOW MUCH THE CHANGE WOULD UNDO. The model
|
|
3
|
+
* says how sure; code says what that is enough for. Above a severity's
|
|
4
|
+
* `act`, the change may be made unasked — and only if the host let the
|
|
5
|
+
* actor apply that sure a change (`applyAtLeast`); between `ask` and
|
|
6
|
+
* `act`, a person is asked (a suggestion); below `ask`, it is dropped, and
|
|
7
|
+
* nobody is bothered. A merge folds two records into one, so it is held
|
|
8
|
+
* to more than setting a record aside, which is held to more than a link
|
|
9
|
+
* or a filled-in choice, which a person undoes with a press.
|
|
10
|
+
*/
|
|
11
|
+
/** The bands a dream uses unless the host says others. */
|
|
12
|
+
export const BANDS = {
|
|
13
|
+
merge: { act: 0.9, ask: 0.5 },
|
|
14
|
+
archive: { act: 0.85, ask: 0.55 },
|
|
15
|
+
link: { act: 0.8, ask: 0.45 },
|
|
16
|
+
categorize: { act: 0.8, ask: 0.45 },
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Where a confidence goes for a change of this severity. A split choice —
|
|
20
|
+
* two options nearly as likely — is never made unasked, however sure its
|
|
21
|
+
* top option.
|
|
22
|
+
*/
|
|
23
|
+
export function routeOf(confidence, severity, bands = {}, split = false) {
|
|
24
|
+
const band = { ...BANDS[severity], ...(bands[severity] ?? {}) };
|
|
25
|
+
if (confidence >= band.act && !split)
|
|
26
|
+
return "act";
|
|
27
|
+
return confidence >= band.ask ? "ask" : "drop";
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/tidy/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,KAAK,GAAqC;IACrD,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;IAC7B,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE;IACjC,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE;IAC7B,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE;CACpC,CAAC;AAKF;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,UAAkB,EAAE,QAAkB,EAAE,QAAkD,EAAE,EAAE,KAAK,GAAG,KAAK;IACjI,MAAM,IAAI,GAAG,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;IAChE,IAAI,UAAU,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACnD,OAAO,UAAU,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SearchRanker } from "@graview/core";
|
|
2
|
+
import type { AiPrice, HostAi } from "../ai.js";
|
|
3
|
+
import type { Answer, Decide } from "../fast.js";
|
|
4
|
+
/** A typed answer: a Choice, a Noul or a Score, with its probabilities. */
|
|
5
|
+
export type SystemOneAnswer = Answer;
|
|
6
|
+
/** One state and a map of typed questions in; typed answers and the call's usage out. */
|
|
7
|
+
export type SystemOneDecide = Decide;
|
|
8
|
+
/** The model a dream asks: its name, as lineage says it, its decide, and its price when the host knows it. */
|
|
9
|
+
export interface DreamModel {
|
|
10
|
+
/** "jev-latest": what the lineage and the report name. */
|
|
11
|
+
readonly model: string;
|
|
12
|
+
readonly decide: SystemOneDecide;
|
|
13
|
+
readonly price?: AiPrice;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The model a dream asks, from what the host lent: `model` when given, else
|
|
17
|
+
* the host's Fast slot, else its `decide` under its name. Nothing when the
|
|
18
|
+
* host said AI is off or lent no System One model: the dream then stands on
|
|
19
|
+
* its judges alone.
|
|
20
|
+
*/
|
|
21
|
+
export declare function systemOneOf(model: DreamModel | undefined, ai: HostAi | undefined): DreamModel | undefined;
|
|
22
|
+
/** The host's ranker for near records, when it lent one and AI is on. */
|
|
23
|
+
export declare const nearOf: (ai: HostAi | undefined) => SearchRanker | undefined;
|
|
24
|
+
/** The model as a basis names it: "Jev" for any Jev, else its own name. */
|
|
25
|
+
export declare const modelWord: (model: string) => string;
|
|
26
|
+
/** How sure a Noul is that its statement holds: its probability. */
|
|
27
|
+
export declare function noulOf(answer: SystemOneAnswer | undefined): number | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* A Score as 0 to 1: its expected level over the levels it was asked on,
|
|
30
|
+
* "the same thing" at the top. From its probabilities when it sent them,
|
|
31
|
+
* else from the score itself.
|
|
32
|
+
*/
|
|
33
|
+
export declare function scoreOf(answer: SystemOneAnswer | undefined, levels: number): number | undefined;
|
|
34
|
+
/** A Choice: what was chosen, how sure (its probability), and its margin over the next. */
|
|
35
|
+
export declare function choiceOf(answer: SystemOneAnswer | undefined): {
|
|
36
|
+
readonly choice: string;
|
|
37
|
+
readonly confidence: number;
|
|
38
|
+
readonly margin: number;
|
|
39
|
+
} | undefined;
|
|
40
|
+
//# sourceMappingURL=system-one.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-one.d.ts","sourceRoot":"","sources":["../../src/tidy/system-one.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,E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,SAAS,CAM3J"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model a dream asks, from what the host lent: `model` when given, else
|
|
3
|
+
* the host's Fast slot, else its `decide` under its name. Nothing when the
|
|
4
|
+
* host said AI is off or lent no System One model: the dream then stands on
|
|
5
|
+
* its judges alone.
|
|
6
|
+
*/
|
|
7
|
+
export function systemOneOf(model, ai) {
|
|
8
|
+
if (model)
|
|
9
|
+
return model;
|
|
10
|
+
if (!ai || ai.off === true)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (ai.fast)
|
|
13
|
+
return { model: ai.fast.model, decide: ai.fast.decide, ...(ai.fast.price ? { price: ai.fast.price } : {}) };
|
|
14
|
+
if (ai.decide)
|
|
15
|
+
return { model: ai.name ?? "model", decide: ai.decide };
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
/** The host's ranker for near records, when it lent one and AI is on. */
|
|
19
|
+
export const nearOf = (ai) => (ai && ai.off !== true ? ai.near : undefined);
|
|
20
|
+
/** The model as a basis names it: "Jev" for any Jev, else its own name. */
|
|
21
|
+
export const modelWord = (model) => (/^jev\b/i.test(model) ? "Jev" : model);
|
|
22
|
+
const round = (value) => Math.round(Math.max(0, Math.min(1, value)) * 100) / 100;
|
|
23
|
+
/** How sure a Noul is that its statement holds: its probability. */
|
|
24
|
+
export function noulOf(answer) {
|
|
25
|
+
return answer?.type === "noul" && Number.isFinite(answer.noul) ? round(answer.noul) : undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A Score as 0 to 1: its expected level over the levels it was asked on,
|
|
29
|
+
* "the same thing" at the top. From its probabilities when it sent them,
|
|
30
|
+
* else from the score itself.
|
|
31
|
+
*/
|
|
32
|
+
export function scoreOf(answer, levels) {
|
|
33
|
+
if (answer?.type !== "score" || levels < 2)
|
|
34
|
+
return undefined;
|
|
35
|
+
const entries = Object.entries(answer.probabilities ?? {}).map(([level, p]) => [Number(level), p]).filter(([level, p]) => Number.isInteger(level) && Number.isFinite(p));
|
|
36
|
+
const total = entries.reduce((sum, [, p]) => sum + p, 0);
|
|
37
|
+
const expected = total > 0 ? entries.reduce((sum, [level, p]) => sum + level * p, 0) / total : answer.score;
|
|
38
|
+
return Number.isFinite(expected) ? round(expected / (levels - 1)) : undefined;
|
|
39
|
+
}
|
|
40
|
+
/** A Choice: what was chosen, how sure (its probability), and its margin over the next. */
|
|
41
|
+
export function choiceOf(answer) {
|
|
42
|
+
if (answer?.type !== "choice")
|
|
43
|
+
return undefined;
|
|
44
|
+
const probabilities = answer.probabilities ?? {};
|
|
45
|
+
const top = probabilities[answer.choice] ?? answer.confidence ?? 0;
|
|
46
|
+
const others = Object.entries(probabilities).filter(([option, p]) => option !== answer.choice && Number.isFinite(p)).map(([, p]) => p);
|
|
47
|
+
return { choice: answer.choice, confidence: round(top), margin: round(top - Math.max(0, ...others)) };
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=system-one.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-one.js","sourceRoot":"","sources":["../../src/tidy/system-one.ts"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAA6B,EAAE,EAAsB;IAC/E,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAC7C,IAAI,EAAE,CAAC,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACzH,IAAI,EAAE,CAAC,MAAM;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MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACvI,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;AACxG,CAAC"}
|
package/dist/tidy.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { archive, categorize, duplicates, links, missingLinks, JUDGES, type Candidate, type Judge, type JudgeContext } from "./tidy/judges.js";
|
|
2
|
+
export { dream, touchedIn, TIDYING_ACTOR, type DreamOptions, type DreamOutcome, type DreamReport } from "./tidy/dream.js";
|
|
3
|
+
export { BANDS, routeOf, type Band, type Route, type Severity } from "./tidy/policy.js";
|
|
4
|
+
export { memoryDreamCache, type DreamAnswers, type DreamBudget, type DreamCache, type DreamUsage } from "./tidy/asking.js";
|
|
5
|
+
export { NONE_FITS, NONE_OF_THESE, QUESTION_SET } from "./tidy/judging.js";
|
|
6
|
+
export { systemOneOf, type DreamModel, type SystemOneAnswer, type SystemOneDecide } from "./tidy/system-one.js";
|
|
7
|
+
export { whileAway, type AwaySince, type WhileAway } from "./tidy/away.js";
|
|
8
|
+
//# sourceMappingURL=tidy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tidy.d.ts","sourceRoot":"","sources":["../src/tidy.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/I,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1H,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3H,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAChH,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/tidy.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* `@graview/tools/tidy` — WHAT THE APP'S OWN ACTOR SUGGESTS, AND RUNNING IT.
|
|
3
|
+
*
|
|
4
|
+
* The framework kept the actor to what people said (`@graview/core/tidying`)
|
|
5
|
+
* but never decided what to suggest. Here code finds what is worth asking
|
|
6
|
+
* about (blocking), a System One model the host lends judges it — the same
|
|
7
|
+
* thing twice, which record a relation means, finished, which option fits
|
|
8
|
+
* — and code routes each answer by how much the change would undo: made
|
|
9
|
+
* where the host lets it, suggested, or let go. The deterministic judges —
|
|
10
|
+
* duplicates by a shared name or key, links a record's own text names,
|
|
11
|
+
* finished records long unchanged — are the floor without a model. A
|
|
12
|
+
* host's schedule, an alarm or `graview dream` calls `dream`; `whileAway`
|
|
13
|
+
* says what it did since a person last looked. Its own entry, and on no
|
|
14
|
+
* page's first load: nothing a page draws needs it until the tray says so.
|
|
15
|
+
*/
|
|
16
|
+
export { archive, categorize, duplicates, links, missingLinks, JUDGES } from "./tidy/judges.js";
|
|
17
|
+
export { dream, touchedIn, TIDYING_ACTOR } from "./tidy/dream.js";
|
|
18
|
+
export { BANDS, routeOf } from "./tidy/policy.js";
|
|
19
|
+
export { memoryDreamCache } from "./tidy/asking.js";
|
|
20
|
+
export { NONE_FITS, NONE_OF_THESE, QUESTION_SET } from "./tidy/judging.js";
|
|
21
|
+
export { systemOneOf } from "./tidy/system-one.js";
|
|
22
|
+
export { whileAway } from "./tidy/away.js";
|
|
23
|
+
//# sourceMappingURL=tidy.js.map
|
package/dist/tidy.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tidy.js","sourceRoot":"","sources":["../src/tidy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAiD,MAAM,kBAAkB,CAAC;AAC/I,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAA0D,MAAM,iBAAiB,CAAC;AAC1H,OAAO,EAAE,KAAK,EAAE,OAAO,EAAwC,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAyE,MAAM,kBAAkB,CAAC;AAC3H,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAA+D,MAAM,sBAAsB,CAAC;AAChH,OAAO,EAAE,SAAS,EAAkC,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graview/tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -52,11 +52,15 @@
|
|
|
52
52
|
"./inline-ai": {
|
|
53
53
|
"types": "./dist/inline-ai.d.ts",
|
|
54
54
|
"default": "./dist/inline-ai.js"
|
|
55
|
+
},
|
|
56
|
+
"./tidy": {
|
|
57
|
+
"types": "./dist/tidy.d.ts",
|
|
58
|
+
"default": "./dist/tidy.js"
|
|
55
59
|
}
|
|
56
60
|
},
|
|
57
61
|
"dependencies": {
|
|
58
|
-
"@graview/core": "0.1.
|
|
59
|
-
"@graview/ship": "0.1.
|
|
62
|
+
"@graview/core": "0.1.50",
|
|
63
|
+
"@graview/ship": "0.1.50"
|
|
60
64
|
},
|
|
61
65
|
"devDependencies": {
|
|
62
66
|
"@modelcontextprotocol/sdk": "^1.32.0",
|