@graview/core 0.1.53 → 0.1.55
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/alias-findings.d.ts +40 -0
- package/dist/alias-findings.d.ts.map +1 -0
- package/dist/alias-findings.js +95 -0
- package/dist/alias-findings.js.map +1 -0
- package/dist/app.d.ts +13 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js.map +1 -1
- package/dist/archived-seen.d.ts +51 -15
- package/dist/archived-seen.d.ts.map +1 -1
- package/dist/archived-seen.js +123 -28
- package/dist/archived-seen.js.map +1 -1
- package/dist/capabilities.js +1 -1
- package/dist/capabilities.js.map +1 -1
- package/dist/catalog.d.ts +32 -0
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +17 -1
- package/dist/catalog.js.map +1 -1
- package/dist/check.d.ts +2 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +2 -0
- package/dist/check.js.map +1 -1
- package/dist/cli/check/aliases.d.ts +11 -0
- package/dist/cli/check/aliases.d.ts.map +1 -0
- package/dist/cli/check/aliases.js +17 -0
- package/dist/cli/check/aliases.js.map +1 -0
- package/dist/cli/check/context.d.ts +2 -0
- package/dist/cli/check/context.d.ts.map +1 -1
- package/dist/cli/check/context.js.map +1 -1
- package/dist/cli/check/index.d.ts +2 -0
- package/dist/cli/check/index.d.ts.map +1 -1
- package/dist/cli/check/index.js +2 -0
- package/dist/cli/check/index.js.map +1 -1
- package/dist/cli/check/jobs.d.ts +12 -0
- package/dist/cli/check/jobs.d.ts.map +1 -0
- package/dist/cli/check/jobs.js +25 -0
- package/dist/cli/check/jobs.js.map +1 -0
- package/dist/cli/check.d.ts +13 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +25 -2
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/describe.d.ts.map +1 -1
- package/dist/cli/describe.js +41 -0
- package/dist/cli/describe.js.map +1 -1
- package/dist/cli/document-schema.d.ts.map +1 -1
- package/dist/cli/document-schema.js +7 -0
- package/dist/cli/document-schema.js.map +1 -1
- package/dist/compose.d.ts +99 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/compose.js +245 -0
- package/dist/compose.js.map +1 -0
- package/dist/document/brand-check.d.ts +3 -0
- package/dist/document/brand-check.d.ts.map +1 -1
- package/dist/document/brand-check.js +21 -2
- package/dist/document/brand-check.js.map +1 -1
- package/dist/document/brand.d.ts.map +1 -1
- package/dist/document/brand.js +10 -2
- package/dist/document/brand.js.map +1 -1
- package/dist/document/compile-checked.d.ts.map +1 -1
- package/dist/document/compile-checked.js +13 -7
- package/dist/document/compile-checked.js.map +1 -1
- package/dist/document/compiled.d.ts.map +1 -1
- package/dist/document/compiled.js +6 -0
- package/dist/document/compiled.js.map +1 -1
- package/dist/document/design-findings.d.ts +32 -0
- package/dist/document/design-findings.d.ts.map +1 -0
- package/dist/document/design-findings.js +593 -0
- package/dist/document/design-findings.js.map +1 -0
- package/dist/document/diff.js +1 -1
- package/dist/document/diff.js.map +1 -1
- package/dist/document/edit.d.ts +1 -1
- package/dist/document/edit.d.ts.map +1 -1
- package/dist/document/edit.js +255 -4
- package/dist/document/edit.js.map +1 -1
- package/dist/document/findings.d.ts +8 -2
- package/dist/document/findings.d.ts.map +1 -1
- package/dist/document/findings.js +4 -3
- package/dist/document/findings.js.map +1 -1
- package/dist/document/graview-template.d.ts +3 -3
- package/dist/document/purpose-spec.d.ts +37 -0
- package/dist/document/purpose-spec.d.ts.map +1 -0
- package/dist/document/purpose-spec.js +41 -0
- package/dist/document/purpose-spec.js.map +1 -0
- package/dist/document/schema.d.ts +32 -11
- package/dist/document/schema.d.ts.map +1 -1
- package/dist/document/schema.js +30 -0
- package/dist/document/schema.js.map +1 -1
- package/dist/document/to-document.d.ts.map +1 -1
- package/dist/document/to-document.js +5 -1
- package/dist/document/to-document.js.map +1 -1
- package/dist/document.schema.json +142 -2
- package/dist/friction-record.d.ts +52 -0
- package/dist/friction-record.d.ts.map +1 -0
- package/dist/friction-record.js +36 -0
- package/dist/friction-record.js.map +1 -0
- package/dist/friction.d.ts +209 -0
- package/dist/friction.d.ts.map +1 -0
- package/dist/friction.js +302 -0
- package/dist/friction.js.map +1 -0
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +20 -0
- package/dist/graph/graph.js.map +1 -1
- package/dist/history.d.ts +32 -0
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/job-findings.d.ts +39 -0
- package/dist/job-findings.d.ts.map +1 -0
- package/dist/job-findings.js +171 -0
- package/dist/job-findings.js.map +1 -0
- package/dist/job-shape.d.ts +57 -0
- package/dist/job-shape.d.ts.map +1 -0
- package/dist/job-shape.js +5 -0
- package/dist/job-shape.js.map +1 -0
- package/dist/jobs.d.ts +62 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +112 -0
- package/dist/jobs.js.map +1 -0
- package/dist/learn.d.ts +151 -0
- package/dist/learn.d.ts.map +1 -0
- package/dist/learn.js +520 -0
- package/dist/learn.js.map +1 -0
- package/dist/past.d.ts +37 -2
- package/dist/past.d.ts.map +1 -1
- package/dist/past.js +73 -13
- package/dist/past.js.map +1 -1
- package/dist/schema/types.d.ts +9 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +2 -0
- package/dist/search.js.map +1 -1
- package/dist/seat.d.ts +3 -2
- package/dist/seat.d.ts.map +1 -1
- package/dist/seat.js +3 -2
- package/dist/seat.js.map +1 -1
- package/dist/subscriptions.d.ts +5 -0
- package/dist/subscriptions.d.ts.map +1 -1
- package/dist/subscriptions.js +46 -1
- package/dist/subscriptions.js.map +1 -1
- package/dist/theme/accent.d.ts +8 -6
- package/dist/theme/accent.d.ts.map +1 -1
- package/dist/theme/accent.js +29 -23
- package/dist/theme/accent.js.map +1 -1
- package/dist/theme/ground-check.d.ts +27 -0
- package/dist/theme/ground-check.d.ts.map +1 -0
- package/dist/theme/ground-check.js +81 -0
- package/dist/theme/ground-check.js.map +1 -0
- package/dist/theme/ground.d.ts +42 -0
- package/dist/theme/ground.d.ts.map +1 -0
- package/dist/theme/ground.js +101 -0
- package/dist/theme/ground.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +20 -2
package/dist/jobs.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { shapesFor } from "./document/computed-values.js";
|
|
2
|
+
import { evaluateExpr, ExprEvalError, NodeSet } from "./document/expr/evaluate.js";
|
|
3
|
+
import { ExprSyntaxError, parseExpr } from "./document/expr/parse.js";
|
|
4
|
+
import { gridSortOf, sortForGrid } from "./grid-sort.js";
|
|
5
|
+
import { jobIsFor } from "./job-shape.js";
|
|
6
|
+
import { labelOf, pluralOf } from "./schema/define-node.js";
|
|
7
|
+
export { jobIsFor, MOST_JOBS } from "./job-shape.js";
|
|
8
|
+
/**
|
|
9
|
+
* THE APP'S JOBS, RESOLVED, in the order declared. A job over a kind the app
|
|
10
|
+
* does not have is left out: the checker says so (`job-kind`), and nothing
|
|
11
|
+
* could answer it.
|
|
12
|
+
*/
|
|
13
|
+
export function jobsOf(app) {
|
|
14
|
+
const kinds = new Set(app.schema.kinds);
|
|
15
|
+
// A document compiled without the checker reads its purpose loosely: what is not a job is no job.
|
|
16
|
+
const declared = Array.isArray(app.purpose?.jobs) ? app.purpose.jobs : [];
|
|
17
|
+
return declared.flatMap((job) => {
|
|
18
|
+
if (typeof job !== "object" || job === null || typeof job.name !== "string" || typeof job.ask !== "string" || !kinds.has(job.kind))
|
|
19
|
+
return [];
|
|
20
|
+
const sort = gridSortOf(job.sort);
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
name: job.name,
|
|
24
|
+
ask: job.ask,
|
|
25
|
+
kind: job.kind,
|
|
26
|
+
plural: pluralOf(app.schema, job.kind),
|
|
27
|
+
...(job.where !== undefined ? { where: job.where } : {}),
|
|
28
|
+
...(sort ? { sort } : {}),
|
|
29
|
+
...(job.act !== undefined ? { act: job.act } : {}),
|
|
30
|
+
...(job.roles && job.roles.length > 0 ? { roles: [...job.roles] } : {}),
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** The jobs a seat holding these roles comes to do: the ones naming one of its roles, and the ones naming none. */
|
|
36
|
+
export function jobsFor(jobs, principal) {
|
|
37
|
+
return jobs.filter((job) => jobIsFor(job, principal.roles));
|
|
38
|
+
}
|
|
39
|
+
const PARSED = new Map();
|
|
40
|
+
/** An expression parsed once; one that does not parse is null (the checker said why). */
|
|
41
|
+
function parsed(source) {
|
|
42
|
+
if (!PARSED.has(source)) {
|
|
43
|
+
try {
|
|
44
|
+
PARSED.set(source, parseExpr(source));
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (!(e instanceof ExprSyntaxError))
|
|
48
|
+
throw e;
|
|
49
|
+
PARSED.set(source, null);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return PARSED.get(source);
|
|
53
|
+
}
|
|
54
|
+
/** Whether a value the language gives counts as yes. */
|
|
55
|
+
const holds = (value) => (value instanceof NodeSet ? value.nodes.length > 0 : Array.isArray(value) ? value.length > 0 : Boolean(value));
|
|
56
|
+
/** A value to order by: a record as its name, a set as how many. */
|
|
57
|
+
const orderable = (schema, value) => value instanceof NodeSet ? value.nodes.length : value !== null && typeof value === "object" && !Array.isArray(value) ? labelOf(schema.tryDefinition(value.kind), value) : value;
|
|
58
|
+
/**
|
|
59
|
+
* A JOB ANSWERED AS THIS SEAT SEES IT: the live records of its kind the seat
|
|
60
|
+
* may see, those its `where` holds for (each read under the language's
|
|
61
|
+
* budget; one it cannot be read for is not counted), in its order — by a
|
|
62
|
+
* field, a computed field or `label`, the ones with none last — and their
|
|
63
|
+
* ids. A kind kept from the seat answers nothing; so does a `where` that
|
|
64
|
+
* does not parse.
|
|
65
|
+
*/
|
|
66
|
+
export function answerJob(given, job, principal) {
|
|
67
|
+
const store = given;
|
|
68
|
+
if (store.kindsKeptFrom(principal).has(job.kind) || !store.schema.tryDefinition(job.kind))
|
|
69
|
+
return { count: 0, ids: [] };
|
|
70
|
+
const seen = store.seenBy(principal);
|
|
71
|
+
const graph = seen.graph;
|
|
72
|
+
const schema = seen.schema;
|
|
73
|
+
const kinds = shapesFor(schema);
|
|
74
|
+
const today = seen.today?.();
|
|
75
|
+
const read = (expr, node) => evaluateExpr(expr, { graph, subject: node, kinds, ...(today ? { today } : {}) });
|
|
76
|
+
const where = job.where === undefined ? undefined : parsed(job.where);
|
|
77
|
+
if (where === null)
|
|
78
|
+
return { count: 0, ids: [] };
|
|
79
|
+
const records = graph.nodesOfKind(job.kind).filter((node) => {
|
|
80
|
+
if (!where)
|
|
81
|
+
return true;
|
|
82
|
+
try {
|
|
83
|
+
return holds(read(where, node));
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
if (!(e instanceof ExprEvalError))
|
|
87
|
+
throw e;
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const sort = gridSortOf(job.sort);
|
|
92
|
+
const key = sort && sort.by !== "label" ? parsed(sort.by) : undefined;
|
|
93
|
+
const ordered = !sort
|
|
94
|
+
? records
|
|
95
|
+
: sortForGrid(records, sort, (node) => {
|
|
96
|
+
if (sort.by === "label")
|
|
97
|
+
return labelOf(schema.tryDefinition(node.kind), node);
|
|
98
|
+
if (!key)
|
|
99
|
+
return undefined;
|
|
100
|
+
try {
|
|
101
|
+
return orderable(schema, read(key, node));
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
if (!(e instanceof ExprEvalError))
|
|
105
|
+
throw e;
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
const ids = ordered.map((node) => node.id);
|
|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ED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@graview/core/learn` — APPS IMPROVE FROM USE (Roadmap f-learned-suggestions).
|
|
3
|
+
*
|
|
4
|
+
* The app's own actor ("Graview, tidying") suggests changes to records and
|
|
5
|
+
* a person accepts or declines each (`@graview/core/tidying`). This is the
|
|
6
|
+
* same actor suggesting changes to the APP — the declaration — from
|
|
7
|
+
* evidence of use: the words people searched with and found nothing
|
|
8
|
+
* (`@graview/core/friction`), the values a text field keeps repeating and
|
|
9
|
+
* the dates written into one (the records), the same two acts taken one
|
|
10
|
+
* after the other on one record (the op log), a place nobody opens (counts
|
|
11
|
+
* a host passes), and an agent's tool calls that went wrong.
|
|
12
|
+
*
|
|
13
|
+
* Each is offered only when at least `minPeople` distinct people show it —
|
|
14
|
+
* never one person's habit — and each is a suggestion, never a change:
|
|
15
|
+
* `learnFromUse` reads and writes nothing, `acceptAppSuggestion` applies a
|
|
16
|
+
* suggestion's edits through `editDocument` as one change with its lineage
|
|
17
|
+
* (`{ basis, suggestion }`), and `declineAppSuggestion` is a decision a host
|
|
18
|
+
* keeps (`LearnedStore`; `graview serve` keeps `learned.json` beside the
|
|
19
|
+
* store) and hands back as `declined`, so the same suggestion — by its
|
|
20
|
+
* `key`, stable across runs — is never offered again.
|
|
21
|
+
*
|
|
22
|
+
* Its own entry: a page draws nothing with it, and it reaches the editor.
|
|
23
|
+
*/
|
|
24
|
+
import { type DocumentEdit, type EditOptions, type Fill } from "./document/edit.js";
|
|
25
|
+
import type { Finding } from "./document/findings.js";
|
|
26
|
+
import type { GraviewDocument } from "./document/schema.js";
|
|
27
|
+
import type { FrictionEvent } from "./friction.js";
|
|
28
|
+
import { type Lineage } from "./ops/lineage.js";
|
|
29
|
+
import type { Author, Operation } from "./ops/types.js";
|
|
30
|
+
/** One change to the app the actor suggests: its edits, what it would do and why, and how many people showed it. */
|
|
31
|
+
export interface AppSuggestion {
|
|
32
|
+
/** Who it is, the same on every run: a decline holds by it. At most 120 characters. */
|
|
33
|
+
readonly key: string;
|
|
34
|
+
/** The edits that make it, as `editDocument` takes them. */
|
|
35
|
+
readonly edits: readonly DocumentEdit[];
|
|
36
|
+
/** What it would change, in a sentence. */
|
|
37
|
+
readonly said: string;
|
|
38
|
+
/** What it is based on, in a sentence: the lineage's `basis` once accepted. */
|
|
39
|
+
readonly why: string;
|
|
40
|
+
/** How many distinct people showed it, and how many times. */
|
|
41
|
+
readonly evidence: {
|
|
42
|
+
readonly people: number;
|
|
43
|
+
readonly times: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** A record, as the graph holds it. */
|
|
47
|
+
export type LearnedRecord = {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly kind: string;
|
|
50
|
+
} & Readonly<Record<string, unknown>>;
|
|
51
|
+
/** A person's answer to a suggestion, kept where the host keeps the app's other state. */
|
|
52
|
+
export interface LearnedDecision {
|
|
53
|
+
readonly key: string;
|
|
54
|
+
readonly answer: "accepted" | "declined";
|
|
55
|
+
readonly at: string;
|
|
56
|
+
readonly by?: Author;
|
|
57
|
+
/** What the suggestion would have changed, as it was said. */
|
|
58
|
+
readonly said?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface LearnInput {
|
|
61
|
+
/** The app, as a document (`documentOf(app) ?? toDocument(app).document`). */
|
|
62
|
+
readonly document: GraviewDocument;
|
|
63
|
+
/** What people could not do, as the host keeps it (`friction.json` beside a served store). */
|
|
64
|
+
readonly friction?: readonly FrictionEvent[];
|
|
65
|
+
/** The store's op log: who wrote what, and the acts people take one after another. */
|
|
66
|
+
readonly log?: readonly Operation[];
|
|
67
|
+
/** The graph's records: the values a field keeps. Who wrote each is read from `log`. */
|
|
68
|
+
readonly records?: readonly LearnedRecord[];
|
|
69
|
+
/** What was answered before — decisions, or their keys alone — never offered again. */
|
|
70
|
+
readonly declined?: readonly (string | {
|
|
71
|
+
readonly key: string;
|
|
72
|
+
})[];
|
|
73
|
+
/**
|
|
74
|
+
* HOW MANY PEOPLE OPENED EACH PLACE, by its slug (`placeSlug(title)`), over
|
|
75
|
+
* a window the host chose. The framework does not see a place open; a host
|
|
76
|
+
* with analytics passes the counts. A declared place at 0 while another
|
|
77
|
+
* was opened by `minPeople` or more is suggested hidden.
|
|
78
|
+
*/
|
|
79
|
+
readonly opens?: Readonly<Record<string, number>>;
|
|
80
|
+
/** The fewest distinct people a suggestion rests on: 3 unsaid, never fewer than 2. */
|
|
81
|
+
readonly minPeople?: number;
|
|
82
|
+
}
|
|
83
|
+
/** What the actor learned: the suggestions, and what it saw and could not suggest, with why. */
|
|
84
|
+
export interface Learned {
|
|
85
|
+
readonly suggestions: readonly AppSuggestion[];
|
|
86
|
+
readonly skipped: readonly {
|
|
87
|
+
readonly key: string;
|
|
88
|
+
readonly why: string;
|
|
89
|
+
}[];
|
|
90
|
+
}
|
|
91
|
+
/** The judge's name on what it suggests and what an accepted suggestion changes (`lineage.actor`). */
|
|
92
|
+
export declare const LEARNING_ACTOR = "learns from use";
|
|
93
|
+
/** The suggestions, with what the actor saw and could not suggest, and why. */
|
|
94
|
+
export declare function learningFrom(input: LearnInput): Learned;
|
|
95
|
+
/**
|
|
96
|
+
* WHAT THE APP'S OWN ACTOR SUGGESTS CHANGING IN THE APP, from evidence of
|
|
97
|
+
* use. Reads and writes nothing; a person accepts each
|
|
98
|
+
* (`acceptAppSuggestion`) or declines it (`declineAppSuggestion`).
|
|
99
|
+
*/
|
|
100
|
+
export declare function learnFromUse(input: LearnInput): AppSuggestion[];
|
|
101
|
+
export interface AnswerOptions {
|
|
102
|
+
/** Who answered. */
|
|
103
|
+
readonly by?: Author;
|
|
104
|
+
/** When, as an ISO time; now unsaid. */
|
|
105
|
+
readonly at?: string;
|
|
106
|
+
}
|
|
107
|
+
export type AcceptedSuggestion = {
|
|
108
|
+
readonly ok: true;
|
|
109
|
+
readonly document: GraviewDocument;
|
|
110
|
+
/** What the edits did, in the editor's words. */
|
|
111
|
+
readonly said: readonly string[];
|
|
112
|
+
/** Values for records already there, for the migration (`editDocument`'s). */
|
|
113
|
+
readonly fills: readonly Fill[];
|
|
114
|
+
/** What the change is based on: the suggestion's why, and its key. */
|
|
115
|
+
readonly lineage: Lineage;
|
|
116
|
+
/** The answer, for the host to keep beside its other decisions. */
|
|
117
|
+
readonly decision: LearnedDecision;
|
|
118
|
+
} | {
|
|
119
|
+
readonly ok: false;
|
|
120
|
+
readonly findings: readonly Finding[];
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* ACCEPT A SUGGESTION: its edits applied to the document through
|
|
124
|
+
* `editDocument`, as one change, carrying its lineage — `{ basis: why,
|
|
125
|
+
* suggestion: key }` — and the decision the host keeps. The caller compiles,
|
|
126
|
+
* checks and keeps the document as it keeps any other change; an edit that
|
|
127
|
+
* no longer applies is refused with the editor's findings.
|
|
128
|
+
*/
|
|
129
|
+
export declare function acceptAppSuggestion(document: GraviewDocument, suggestion: AppSuggestion, options?: AnswerOptions & EditOptions): AcceptedSuggestion;
|
|
130
|
+
/** DECLINE A SUGGESTION: the decision a host keeps and hands back as `declined`, so it is never offered again. Changes nothing. */
|
|
131
|
+
export declare function declineAppSuggestion(suggestion: AppSuggestion | string, options?: AnswerOptions): LearnedDecision;
|
|
132
|
+
/**
|
|
133
|
+
* WHERE A HOST KEEPS WHAT PEOPLE ANSWERED: append and read back.
|
|
134
|
+
* `memoryLearned` here; `fileLearned` (`learned.json` beside the store,
|
|
135
|
+
* where `graview serve` keeps the friction log) in `@graview/ship`; a host's
|
|
136
|
+
* own anywhere — Graview Cloud beside an app's document versions.
|
|
137
|
+
*/
|
|
138
|
+
export interface LearnedStore {
|
|
139
|
+
add(decision: LearnedDecision): void | Promise<void>;
|
|
140
|
+
list(): readonly LearnedDecision[] | Promise<readonly LearnedDecision[]>;
|
|
141
|
+
}
|
|
142
|
+
/** A store that answers at once. */
|
|
143
|
+
export interface HeldLearned extends LearnedStore {
|
|
144
|
+
add(decision: LearnedDecision): void;
|
|
145
|
+
list(): readonly LearnedDecision[];
|
|
146
|
+
}
|
|
147
|
+
/** The decisions kept, one per key: the latest answer stands. */
|
|
148
|
+
export declare function keptDecisions(decisions: readonly LearnedDecision[]): readonly LearnedDecision[];
|
|
149
|
+
/** Answers kept in memory for as long as the process runs. */
|
|
150
|
+
export declare function memoryLearned(): HeldLearned;
|
|
151
|
+
//# sourceMappingURL=learn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learn.d.ts","sourceRoot":"","sources":["../src/learn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAgB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAClG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMxD,oHAAoH;AACpH,MAAM,WAAW,aAAa;IAC5B,uFAAuF;IACvF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACxE;AAED,uCAAuC;AACvC,MAAM,MA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