@graview/tools 0.1.18 → 0.1.19

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.
Files changed (63) hide show
  1. package/README.md +47 -0
  2. package/dist/agent/tools.d.ts +37 -0
  3. package/dist/agent/tools.d.ts.map +1 -1
  4. package/dist/agent/tools.js +75 -13
  5. package/dist/agent/tools.js.map +1 -1
  6. package/dist/ai.d.ts +64 -0
  7. package/dist/ai.d.ts.map +1 -0
  8. package/dist/ai.js +11 -0
  9. package/dist/ai.js.map +1 -0
  10. package/dist/capital.d.ts +3 -0
  11. package/dist/capital.d.ts.map +1 -0
  12. package/dist/capital.js +3 -0
  13. package/dist/capital.js.map +1 -0
  14. package/dist/conversation.d.ts +36 -12
  15. package/dist/conversation.d.ts.map +1 -1
  16. package/dist/conversation.js +94 -30
  17. package/dist/conversation.js.map +1 -1
  18. package/dist/dev-ai.d.ts +27 -0
  19. package/dist/dev-ai.d.ts.map +1 -0
  20. package/dist/dev-ai.js +48 -0
  21. package/dist/dev-ai.js.map +1 -0
  22. package/dist/draft.d.ts +194 -0
  23. package/dist/draft.d.ts.map +1 -0
  24. package/dist/draft.js +1083 -0
  25. package/dist/draft.js.map +1 -0
  26. package/dist/frame.d.ts +6 -6
  27. package/dist/frame.d.ts.map +1 -1
  28. package/dist/frame.js +5 -5
  29. package/dist/frame.js.map +1 -1
  30. package/dist/go.d.ts +177 -0
  31. package/dist/go.d.ts.map +1 -0
  32. package/dist/go.js +839 -0
  33. package/dist/go.js.map +1 -0
  34. package/dist/index.d.ts +7 -3
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +4 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/intelligence.d.ts.map +1 -1
  39. package/dist/intelligence.js +2 -2
  40. package/dist/intelligence.js.map +1 -1
  41. package/dist/keep.d.ts +45 -0
  42. package/dist/keep.d.ts.map +1 -0
  43. package/dist/keep.js +86 -0
  44. package/dist/keep.js.map +1 -0
  45. package/dist/local.d.ts +50 -42
  46. package/dist/local.d.ts.map +1 -1
  47. package/dist/local.js +104 -146
  48. package/dist/local.js.map +1 -1
  49. package/dist/providers/schema.d.ts.map +1 -1
  50. package/dist/providers/schema.js +7 -7
  51. package/dist/providers/schema.js.map +1 -1
  52. package/dist/providers/structure.d.ts.map +1 -1
  53. package/dist/providers/structure.js +2 -2
  54. package/dist/providers/structure.js.map +1 -1
  55. package/dist/suggest.d.ts +102 -0
  56. package/dist/suggest.d.ts.map +1 -0
  57. package/dist/suggest.js +234 -0
  58. package/dist/suggest.js.map +1 -0
  59. package/package.json +19 -3
  60. package/dist/rungs.d.ts +0 -73
  61. package/dist/rungs.d.ts.map +0 -1
  62. package/dist/rungs.js +0 -60
  63. package/dist/rungs.js.map +0 -1
@@ -0,0 +1,102 @@
1
+ import { type AnySchema, type Store, type Violation } from "@graview/core";
2
+ import type { Affordance } from "./types.js";
3
+ /**
4
+ * WHAT THE SEAT OFFERS BEFORE ANYBODY ASKS — a few things, in the reader's
5
+ * words, built from the graph.
6
+ *
7
+ * The seat opened on every act the selected record had: nine buttons, nine
8
+ * stars, a filter field and "Show 1 more", in the mutations' own words. A
9
+ * person reading it learned what the declaration could do, not what was
10
+ * worth doing here. Opened with nothing asked, it says one plain line
11
+ * about where the reader is, offers at most three questions the graph can
12
+ * answer about it, and at most three acts — the repairs a broken rule names
13
+ * for this very thing, and the ones the reader pinned. Everything else is
14
+ * one question, the context menu, or Pages' "What can be done" away.
15
+ *
16
+ * Pure: the store it is handed is already the one the reader may see
17
+ * (`store.seenBy(principal)`), so nothing here names what they may not.
18
+ */
19
+ /** At most this many of each: suggestions, and acts offered unprompted. */
20
+ export declare const SEAT_OFFERS = 3;
21
+ /** What the seat is about: a record, a kind, a place, or the whole thing. */
22
+ export interface SeatSubject {
23
+ /** A node id, `kind:<kind>`, `aggregate:<kind>`, or null for the whole thing. */
24
+ readonly id: string | null;
25
+ /** How the subject is said: a record's name, a place's title, a kind's plural. */
26
+ readonly name: string;
27
+ }
28
+ export interface SuggestInput<S extends AnySchema> {
29
+ readonly store: Pick<Store<S>, "schema" | "graph">;
30
+ readonly subject: SeatSubject;
31
+ /** The rules broken right now, as the reader may see them. */
32
+ readonly violations: readonly Violation[];
33
+ /** The place the reader is looking at, when the picture is one. */
34
+ readonly place?: {
35
+ readonly title: string;
36
+ readonly kind?: string;
37
+ } | null;
38
+ /** The app's places the reader may go to; `picture` marks a declared picture rather than a kind's list. */
39
+ readonly places?: readonly {
40
+ readonly title: string;
41
+ readonly kind: string | null;
42
+ readonly picture?: boolean;
43
+ }[];
44
+ /** The day it is (YYYY-MM-DD): what "this week" is read against. */
45
+ readonly today?: string;
46
+ }
47
+ /**
48
+ * Why a suggestion is offered: a problem; what this is or what is here; a
49
+ * picture to go to ("go"); what falls due this week ("due"); a way of
50
+ * drawing what is here ("draw").
51
+ */
52
+ export type SuggestionWhy = "problem" | "about" | "here" | "go" | "due" | "draw";
53
+ export interface Suggestion {
54
+ /** What pressing it asks, in the reader's words. */
55
+ readonly ask: string;
56
+ readonly why: SuggestionWhy;
57
+ }
58
+ /**
59
+ * ONE PLAIN LINE ABOUT WHERE THE READER IS: the problem on what they are
60
+ * looking at first, else what it is — a record and its kind, a place and
61
+ * how much is on it, or the whole thing by its largest kinds.
62
+ */
63
+ export declare function whereLine<S extends AnySchema>({ store, subject, violations, place }: SuggestInput<S>): string;
64
+ /**
65
+ * AT MOST THREE THINGS TO ASK, each one the graph can answer about where
66
+ * the reader is, in this order: what is wrong (only when something is);
67
+ * what falls due this week, else another picture to go to; a way of
68
+ * drawing what is here that a shipped lens can bind ("Show tasks as a
69
+ * board by day"); and, while there is room, what this thing is or what is
70
+ * here. None when none applies — the line stands alone.
71
+ *
72
+ * Each is worded the way the seat reads it without a model: the due-soon
73
+ * ask as `resolveAsk` narrows a kind, the drawing as `templateDraft` reads
74
+ * a board.
75
+ */
76
+ export declare function suggestionsFor<S extends AnySchema>(input: SuggestInput<S>): readonly Suggestion[];
77
+ export interface OfferedAct {
78
+ readonly affordance: Affordance;
79
+ /** The act in the declaration's words, said about the subject. */
80
+ readonly label: string;
81
+ }
82
+ /**
83
+ * THE ACTS OFFERED UNPROMPTED: the repairs a broken rule names for this
84
+ * thing, then the ones the reader pinned — at most three, never one that
85
+ * cannot be taken back first. Everything else is asked for.
86
+ */
87
+ export declare function offeredActs<S extends AnySchema>(affordances: readonly Affordance[], { store, subject }: {
88
+ readonly store: Pick<Store<S>, "schema" | "graph" | "allMutations">;
89
+ readonly subject: SeatSubject;
90
+ }): readonly OfferedAct[];
91
+ /**
92
+ * AN ACT, SAID ABOUT THE THING IT IS OFFERED ON. The act's own sentence
93
+ * where it has one and nothing is left to ask ("Finish “Pay the deposit”");
94
+ * else its title with "it" named ("Give Pay the deposit a new date"); never
95
+ * the mutation's name — a title nobody wrote is spoken, and `graview
96
+ * check` says so (`act-without-title`).
97
+ */
98
+ export declare function sayAct<S extends AnySchema>(affordance: Affordance, { store, subject }: {
99
+ readonly store: Pick<Store<S>, "graph" | "allMutations">;
100
+ readonly subject: SeatSubject;
101
+ }): string;
102
+ //# sourceMappingURL=suggest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../src/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAC5H,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;;;;;;;;;;GAeG;AAEH,2EAA2E;AAC3E,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY,CAAC,CAA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AG,SAAS,UAAU,EAAE,CAoBjG;AA0ED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAC7C,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,cAAc,CAAC,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GACzH,SAAS,UAAU,EAAE,CAMvB;AAKD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,SAAS,EACxC,UAAU,EAAE,UAAU,EACtB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GAC9G,MAAM,CAqBR"}
@@ -0,0 +1,234 @@
1
+ import { pluralOf, counted, labelOf, nounOf, withArticle } from "@graview/core";
2
+ import { capitalize } from "./capital.js";
3
+ /**
4
+ * WHAT THE SEAT OFFERS BEFORE ANYBODY ASKS — a few things, in the reader's
5
+ * words, built from the graph.
6
+ *
7
+ * The seat opened on every act the selected record had: nine buttons, nine
8
+ * stars, a filter field and "Show 1 more", in the mutations' own words. A
9
+ * person reading it learned what the declaration could do, not what was
10
+ * worth doing here. Opened with nothing asked, it says one plain line
11
+ * about where the reader is, offers at most three questions the graph can
12
+ * answer about it, and at most three acts — the repairs a broken rule names
13
+ * for this very thing, and the ones the reader pinned. Everything else is
14
+ * one question, the context menu, or Pages' "What can be done" away.
15
+ *
16
+ * Pure: the store it is handed is already the one the reader may see
17
+ * (`store.seenBy(principal)`), so nothing here names what they may not.
18
+ */
19
+ /** At most this many of each: suggestions, and acts offered unprompted. */
20
+ export const SEAT_OFFERS = 3;
21
+ /** The record the subject names, when it names one. */
22
+ function recordOf(store, subject) {
23
+ return subject.id ? store.graph.getNode(subject.id) : undefined;
24
+ }
25
+ /** The kind a card id names — `kind:task`, `aggregate:task`. */
26
+ function kindOfCard(id) {
27
+ if (!id)
28
+ return undefined;
29
+ const match = /^(?:kind|aggregate):([^:]+)$/.exec(id);
30
+ return match?.[1];
31
+ }
32
+ /** The rule broken on this very record, if one is. */
33
+ function problemOn(violations, id) {
34
+ if (!id)
35
+ return undefined;
36
+ return violations.find((violation) => violation.nodeIds.includes(id) || violation.subjectId === id);
37
+ }
38
+ const sentenceOf = (text) => {
39
+ const said = text.trim();
40
+ if (!said)
41
+ return said;
42
+ const first = said.charAt(0).toUpperCase() + said.slice(1);
43
+ return /[.!?…]$/.test(first) ? first : `${first}.`;
44
+ };
45
+ /**
46
+ * ONE PLAIN LINE ABOUT WHERE THE READER IS: the problem on what they are
47
+ * looking at first, else what it is — a record and its kind, a place and
48
+ * how much is on it, or the whole thing by its largest kinds.
49
+ */
50
+ export function whereLine({ store, subject, violations, place }) {
51
+ const record = recordOf(store, subject);
52
+ const problem = problemOn(violations, record?.id ?? null);
53
+ if (problem)
54
+ return sentenceOf(problem.message);
55
+ if (record) {
56
+ const kind = record.kind;
57
+ return `${labelOf(store.schema.tryDefinition(kind), record)}, ${withArticle(nounOf(store.schema.tryDefinition(kind), kind))}.`;
58
+ }
59
+ const kind = place?.kind ?? kindOfCard(subject.id);
60
+ if (kind) {
61
+ const count = store.graph.nodesOfKind(kind).length;
62
+ const title = place?.title ?? subject.name;
63
+ const plural = pluralOf(store.schema, kind);
64
+ const said = counted(store.schema, kind, count);
65
+ return title.toLowerCase() === plural.toLowerCase() ? `${count === 1 ? "There is" : "There are"} ${said} here.` : `${title}: ${said}.`;
66
+ }
67
+ const kinds = store.schema.kinds
68
+ .map((one) => ({ kind: one, count: store.graph.nodesOfKind(one).length }))
69
+ .filter((one) => one.count > 0)
70
+ .sort((a, b) => b.count - a.count)
71
+ .slice(0, 3);
72
+ if (kinds.length === 0)
73
+ return "Nothing here yet.";
74
+ const said = kinds.map((one) => counted(store.schema, one.kind, one.count));
75
+ // In the words the bar names this place by (`The whole thing`), not a second name for it.
76
+ return `The whole thing: ${said.length === 1 ? said[0] : `${said.slice(0, -1).join(", ")} and ${said[said.length - 1]}`}.`;
77
+ }
78
+ /**
79
+ * AT MOST THREE THINGS TO ASK, each one the graph can answer about where
80
+ * the reader is, in this order: what is wrong (only when something is);
81
+ * what falls due this week, else another picture to go to; a way of
82
+ * drawing what is here that a shipped lens can bind ("Show tasks as a
83
+ * board by day"); and, while there is room, what this thing is or what is
84
+ * here. None when none applies — the line stands alone.
85
+ *
86
+ * Each is worded the way the seat reads it without a model: the due-soon
87
+ * ask as `resolveAsk` narrows a kind, the drawing as `templateDraft` reads
88
+ * a board.
89
+ */
90
+ export function suggestionsFor(input) {
91
+ const { store, subject, violations } = input;
92
+ const record = recordOf(store, subject);
93
+ const out = [];
94
+ if (record && problemOn(violations, record.id))
95
+ out.push({ ask: `What's wrong with ${subject.name}?`, why: "problem" });
96
+ else if (violations.length > 0)
97
+ out.push({ ask: "What needs attention?", why: "problem" });
98
+ const kind = record ? record.kind : (input.place?.kind ?? kindOfCard(subject.id));
99
+ const due = dueThisWeek(input, kind);
100
+ if (due)
101
+ out.push(due);
102
+ else {
103
+ const go = anotherPlace(input, kind);
104
+ if (go)
105
+ out.push(go);
106
+ }
107
+ const draw = aDrawing(input, kind);
108
+ if (draw)
109
+ out.push(draw);
110
+ if (out.length < SEAT_OFFERS) {
111
+ if (record)
112
+ out.push({ ask: `Tell me about ${subject.name}`, why: "about" });
113
+ else
114
+ out.push({ ask: "What is here?", why: "here" });
115
+ }
116
+ return out.slice(0, SEAT_OFFERS);
117
+ }
118
+ /** A kind's declared fields, by name: what a zod object's shape holds. */
119
+ function fieldsOf(store, kind) {
120
+ return (store.schema.tryDefinition(kind)?.fields?.shape ?? {});
121
+ }
122
+ /** The choices of a choice field (a zod enum), or undefined. */
123
+ function choicesOf(field) {
124
+ let inner = field;
125
+ for (let depth = 0; depth < 4 && inner; depth++) {
126
+ const one = inner;
127
+ if (Array.isArray(one.options) && one.options.every((option) => typeof option === "string"))
128
+ return one.options;
129
+ inner = typeof one.unwrap === "function" ? one.unwrap() : one._def?.innerType;
130
+ }
131
+ return undefined;
132
+ }
133
+ const DAY = /^\d{4}-\d{2}-\d{2}/;
134
+ const DATE_NAMES = ["due", "deadline", "date", "when"];
135
+ /** "Tasks due this week", when something of this kind (or, nothing chosen, of any kind) falls due in the next seven days. */
136
+ function dueThisWeek(input, kind) {
137
+ const { store } = input;
138
+ const today = input.today;
139
+ if (!today || !DAY.test(today))
140
+ return undefined;
141
+ const end = new Date(`${today.slice(0, 10)}T00:00:00Z`);
142
+ end.setUTCDate(end.getUTCDate() + 6);
143
+ const last = end.toISOString().slice(0, 10);
144
+ // This kind first; then, when nothing of it falls due, any kind's.
145
+ const kinds = [...new Set([...(kind ? [kind] : []), ...store.schema.kinds])];
146
+ for (const one of kinds) {
147
+ const field = DATE_NAMES.find((name) => name in fieldsOf(store, one));
148
+ if (!field)
149
+ continue;
150
+ const soon = store.graph.nodesOfKind(one).some((node) => {
151
+ const value = node[field];
152
+ const done = node["done"];
153
+ return typeof value === "string" && DAY.test(value) && value.slice(0, 10) >= today.slice(0, 10) && value.slice(0, 10) <= last && done !== true;
154
+ });
155
+ if (!soon)
156
+ continue;
157
+ const plural = pluralOf(store.schema, one);
158
+ return { ask: `${capitalize(plural)} due this week`, why: "due" };
159
+ }
160
+ return undefined;
161
+ }
162
+ /** "Go to The week": a picture of the app's that the reader is not standing in. */
163
+ function anotherPlace(input, kind) {
164
+ const here = input.place?.title;
165
+ // A picture of something else than what the reader is looking at.
166
+ const picture = (input.places ?? []).find((place) => place.kind !== null && place.picture === true && place.title !== here && place.kind !== kind);
167
+ return picture ? { ask: `Go to ${picture.title}`, why: "go" } : undefined;
168
+ }
169
+ /** "Show tasks as a board by day": a kind here with a choice to put its records in columns by. */
170
+ function aDrawing(input, kind) {
171
+ const { store } = input;
172
+ // This kind first; then the kind with the most records that has a choice to draw by.
173
+ const most = [...store.schema.kinds].sort((a, b) => store.graph.nodesOfKind(b).length - store.graph.nodesOfKind(a).length);
174
+ const kinds = [...new Set([...(kind ? [kind] : []), ...most])];
175
+ for (const one of kinds) {
176
+ if (store.graph.nodesOfKind(one).length < 2)
177
+ continue;
178
+ const fields = fieldsOf(store, one);
179
+ const choice = Object.keys(fields).find((name) => (choicesOf(fields[name])?.length ?? 0) >= 2);
180
+ if (!choice)
181
+ continue;
182
+ const plural = pluralOf(store.schema, one).toLowerCase();
183
+ const words = choice.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase();
184
+ return { ask: `Show ${plural} as a board by ${words}`, why: "draw" };
185
+ }
186
+ return undefined;
187
+ }
188
+ /**
189
+ * THE ACTS OFFERED UNPROMPTED: the repairs a broken rule names for this
190
+ * thing, then the ones the reader pinned — at most three, never one that
191
+ * cannot be taken back first. Everything else is asked for.
192
+ */
193
+ export function offeredActs(affordances, { store, subject }) {
194
+ const about = (affordance) => subject.id !== null && (affordance.nodeIds.includes(subject.id) || Object.values(affordance.args).includes(subject.id));
195
+ const repairs = affordances.filter((affordance) => affordance.provider === "invariant" && about(affordance));
196
+ const pinned = affordances.filter((affordance) => affordance.pinned === "user" && !repairs.includes(affordance));
197
+ const chosen = [...repairs, ...pinned].sort((a, b) => Number(a.destructive ?? false) - Number(b.destructive ?? false));
198
+ return chosen.slice(0, SEAT_OFFERS).map((affordance) => ({ affordance, label: sayAct(affordance, { store, subject }) }));
199
+ }
200
+ /** A label that is a mutation's name rather than words: `move-to-list`, `moveToList`. */
201
+ const machineWord = (label) => /^[a-z0-9]+(?:[-_][a-z0-9]+)+$|^[a-z]+[A-Z][A-Za-z0-9]*$/.test(label);
202
+ /**
203
+ * AN ACT, SAID ABOUT THE THING IT IS OFFERED ON. The act's own sentence
204
+ * where it has one and nothing is left to ask ("Finish “Pay the deposit”");
205
+ * else its title with "it" named ("Give Pay the deposit a new date"); never
206
+ * the mutation's name — a title nobody wrote is spoken, and `graview
207
+ * check` says so (`act-without-title`).
208
+ */
209
+ export function sayAct(affordance, { store, subject }) {
210
+ let label = affordance.label;
211
+ const named = machineWord(label) || label === affordance.mutation;
212
+ if (named) {
213
+ const spoken = label.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase();
214
+ label = spoken.charAt(0).toUpperCase() + spoken.slice(1);
215
+ }
216
+ const record = subject.id ? store.graph.getNode(subject.id) : undefined;
217
+ const onSubject = record !== undefined && affordance.nodeIds.length <= 1 && (affordance.nodeIds[0] ?? record.id) === record.id;
218
+ if (onSubject && /\bit\b/.test(label))
219
+ return label.replace(/\bit\b/, subject.name);
220
+ /* A title with no "it" to name, or no title at all: the act's own sentence, where nothing is left to ask. */
221
+ const mutation = store.allMutations().find((one) => one.name === affordance.mutation);
222
+ if (affordance.open.length === 0 && mutation?.describe && (named || onSubject)) {
223
+ try {
224
+ const said = mutation.describe(affordance.args, store.graph);
225
+ if (said.trim())
226
+ return said.trim();
227
+ }
228
+ catch {
229
+ // A sentence that cannot be said for these arguments: the title.
230
+ }
231
+ }
232
+ return label;
233
+ }
234
+ //# sourceMappingURL=suggest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggest.js","sourceRoot":"","sources":["../src/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAA8C,MAAM,eAAe,CAAC;AAE5H,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AAEH,2EA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,CAAC,IAAI,QAAQ,EAAE,QAAQ,IAAI,CAAC,KAAK,IAAI,SAAS,CAAC,EAAE,CAAC;QAC/E,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAa,EAAE,KAAK,CAAC,KAAc,CAAC,CAAC;YAC/E,IAAI,IAAI,CAAC,IAAI,EAAE;gBAAE,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACtC,CAAC;QAAC,MAAM,CAAC;YACP,iEAAiE;QACnE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graview/tools",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -20,11 +20,27 @@
20
20
  "./edit": {
21
21
  "types": "./dist/edit.d.ts",
22
22
  "default": "./dist/edit.js"
23
+ },
24
+ "./suggest": {
25
+ "types": "./dist/suggest.d.ts",
26
+ "default": "./dist/suggest.js"
27
+ },
28
+ "./go": {
29
+ "types": "./dist/go.d.ts",
30
+ "default": "./dist/go.js"
31
+ },
32
+ "./draft": {
33
+ "types": "./dist/draft.d.ts",
34
+ "default": "./dist/draft.js"
35
+ },
36
+ "./keep": {
37
+ "types": "./dist/keep.d.ts",
38
+ "default": "./dist/keep.js"
23
39
  }
24
40
  },
25
41
  "dependencies": {
26
- "@graview/core": "0.1.18",
27
- "@graview/ship": "0.1.18"
42
+ "@graview/core": "0.1.19",
43
+ "@graview/ship": "0.1.19"
28
44
  },
29
45
  "devDependencies": {
30
46
  "@modelcontextprotocol/sdk": "^1.32.0",
package/dist/rungs.d.ts DELETED
@@ -1,73 +0,0 @@
1
- import type { IntelligenceCapability } from "@graview/core";
2
- /**
3
- * THE INTELLIGENCE LADDER, as configuration a person can climb.
4
- *
5
- * Four rungs: the graph answers for itself (keyless, always there); a
6
- * model runs in the person's own browser (free after the download, and
7
- * nothing leaves the machine); a decision provider answers typed questions
8
- * exactly and has no prose; a frontier model answers over the network with
9
- * the person's own key. The three that talk are the same Responder
10
- * contract, and the one that does not says so in its answers — so choosing
11
- * a rung is choosing a config value, and whatever answers, its proposals
12
- * still travel the one validated path.
13
- *
14
- * The config is plain serializable data in the BROWSER's storage, because
15
- * an API key belongs to the person at the keyboard: it must never sit in a
16
- * repo, a bundle, or a declaration that ships.
17
- */
18
- export type IntelligenceSource = "graph" | "local" | "decision" | "remote";
19
- export interface IntelligenceConfig {
20
- readonly source: IntelligenceSource;
21
- readonly local?: {
22
- /** A WebLLM model id. The default is small enough to be honest about. */
23
- readonly model?: string;
24
- };
25
- /**
26
- * THE DECISION RUNG: a provider that answers typed questions exactly
27
- * and has no prose. Reached with the person's own key straight from
28
- * this browser, or through the dev server's decision door — which holds
29
- * the key on its side, so a browser never does. With neither, the
30
- * default is the door at its default path.
31
- */
32
- readonly decision?: {
33
- readonly apiKey?: string;
34
- /** The door's path when the key is on the server side. */
35
- readonly bridge?: string;
36
- readonly model?: string;
37
- };
38
- readonly remote?: {
39
- readonly preset?: "xai" | "custom";
40
- /** For `custom`: any OpenAI-compatible /chat/completions endpoint. */
41
- readonly baseUrl?: string;
42
- readonly apiKey: string;
43
- readonly model?: string;
44
- };
45
- }
46
- export declare const DEFAULT_INTELLIGENCE: IntelligenceConfig;
47
- /**
48
- * FOUR RUNGS, TWO AXES. Each rung says which capabilities it serves; a
49
- * surface asks for a capability, never for a rung; and what the chosen
50
- * rung cannot serve falls DOWN to the graph, which is keyless and always
51
- * there. Pretending the ladder has one axis is how a switch starts lying:
52
- * a decision provider is the best rung for a decision and no rung at all
53
- * for prose.
54
- */
55
- export declare const RUNGS: Readonly<Record<IntelligenceSource, {
56
- readonly label: string;
57
- readonly serves: readonly IntelligenceCapability[];
58
- }>>;
59
- /**
60
- * Which rung answers a capability under this config: the chosen one when
61
- * it serves the capability, the graph otherwise — with `fell` saying so,
62
- * which is what a seat's honesty sentence is made of.
63
- */
64
- export declare function rungFor(config: IntelligenceConfig, capability: IntelligenceCapability): {
65
- readonly rung: IntelligenceSource;
66
- readonly fell: boolean;
67
- };
68
- /** The sentence a seat says on a rung that cannot talk. Part of the answer, not chrome. */
69
- export declare function rungHonesty(config: IntelligenceConfig, capability: IntelligenceCapability): string | undefined;
70
- /** The saved rung, or the keyless default — never a throw. */
71
- export declare function loadIntelligenceConfig(): IntelligenceConfig;
72
- export declare function saveIntelligenceConfig(config: IntelligenceConfig): void;
73
- //# sourceMappingURL=rungs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rungs.d.ts","sourceRoot":"","sources":["../src/rungs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACf,yEAAyE;QACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,0DAA0D;QAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;QACnC,sEAAsE;QACtE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,oBAAoB,EAAE,kBAAwC,CAAC;AAE5E;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,QAAQ,CAC1B,MAAM,CAAC,kBAAkB,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAAE,CAAC,CAM3G,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,kBAAkB,EAC1B,UAAU,EAAE,sBAAsB,GACjC;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAG/D;AAED,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,sBAAsB,GAAG,MAAM,GAAG,SAAS,CAO9G;AAID,8DAA8D;AAC9D,wBAAgB,sBAAsB,IAAI,kBAAkB,CAU3D;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAMvE"}
package/dist/rungs.js DELETED
@@ -1,60 +0,0 @@
1
- export const DEFAULT_INTELLIGENCE = { source: "graph" };
2
- /**
3
- * FOUR RUNGS, TWO AXES. Each rung says which capabilities it serves; a
4
- * surface asks for a capability, never for a rung; and what the chosen
5
- * rung cannot serve falls DOWN to the graph, which is keyless and always
6
- * there. Pretending the ladder has one axis is how a switch starts lying:
7
- * a decision provider is the best rung for a decision and no rung at all
8
- * for prose.
9
- */
10
- export const RUNGS = {
11
- graph: { label: "Graph only", serves: ["decide", "propose"] },
12
- local: { label: "Onboard AI", serves: ["prose", "decide", "propose"] },
13
- decision: { label: "Jev", serves: ["decide"] },
14
- remote: { label: "LLM", serves: ["prose", "decide", "propose"] },
15
- };
16
- /**
17
- * Which rung answers a capability under this config: the chosen one when
18
- * it serves the capability, the graph otherwise — with `fell` saying so,
19
- * which is what a seat's honesty sentence is made of.
20
- */
21
- export function rungFor(config, capability) {
22
- if (RUNGS[config.source].serves.includes(capability))
23
- return { rung: config.source, fell: false };
24
- return { rung: "graph", fell: true };
25
- }
26
- /** The sentence a seat says on a rung that cannot talk. Part of the answer, not chrome. */
27
- export function rungHonesty(config, capability) {
28
- const { fell } = rungFor(config, capability);
29
- if (!fell)
30
- return undefined;
31
- const rung = RUNGS[config.source].label;
32
- return capability === "prose"
33
- ? `(${rung} decides rather than talks — the graph is answering here.)`
34
- : `(${rung} cannot ${capability} — the graph is answering here.)`;
35
- }
36
- const STORED = "graview:intelligence";
37
- /** The saved rung, or the keyless default — never a throw. */
38
- export function loadIntelligenceConfig() {
39
- try {
40
- const raw = globalThis.localStorage?.getItem(STORED);
41
- if (!raw)
42
- return DEFAULT_INTELLIGENCE;
43
- const parsed = JSON.parse(raw);
44
- if (parsed.source in RUNGS)
45
- return parsed;
46
- return DEFAULT_INTELLIGENCE;
47
- }
48
- catch {
49
- return DEFAULT_INTELLIGENCE;
50
- }
51
- }
52
- export function saveIntelligenceConfig(config) {
53
- try {
54
- globalThis.localStorage?.setItem(STORED, JSON.stringify(config));
55
- }
56
- catch {
57
- // A rung that cannot be remembered still applies for this visit.
58
- }
59
- }
60
- //# sourceMappingURL=rungs.js.map
package/dist/rungs.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"rungs.js","sourceRoot":"","sources":["../src/rungs.ts"],"names":[],"mappings":"AAiDA,MAAM,CAAC,MAAM,oBAAoB,GAAuB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAE5E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAEd;IACF,KAAK,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE;IAC7D,KAAK,EAAE,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