@graview/tools 0.1.0

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 (111) hide show
  1. package/LICENSE +96 -0
  2. package/README.md +47 -0
  3. package/dist/agent/adapters.d.ts +43 -0
  4. package/dist/agent/adapters.d.ts.map +1 -0
  5. package/dist/agent/adapters.js +52 -0
  6. package/dist/agent/adapters.js.map +1 -0
  7. package/dist/agent/tools.d.ts +105 -0
  8. package/dist/agent/tools.d.ts.map +1 -0
  9. package/dist/agent/tools.js +311 -0
  10. package/dist/agent/tools.js.map +1 -0
  11. package/dist/cli.d.ts +37 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +306 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/conversation.d.ts +108 -0
  16. package/dist/conversation.d.ts.map +1 -0
  17. package/dist/conversation.js +698 -0
  18. package/dist/conversation.js.map +1 -0
  19. package/dist/decide.d.ts +43 -0
  20. package/dist/decide.d.ts.map +1 -0
  21. package/dist/decide.js +125 -0
  22. package/dist/decide.js.map +1 -0
  23. package/dist/derive.d.ts +84 -0
  24. package/dist/derive.d.ts.map +1 -0
  25. package/dist/derive.js +302 -0
  26. package/dist/derive.js.map +1 -0
  27. package/dist/edit.d.ts +70 -0
  28. package/dist/edit.d.ts.map +1 -0
  29. package/dist/edit.js +97 -0
  30. package/dist/edit.js.map +1 -0
  31. package/dist/figure.d.ts +53 -0
  32. package/dist/figure.d.ts.map +1 -0
  33. package/dist/figure.js +86 -0
  34. package/dist/figure.js.map +1 -0
  35. package/dist/index.d.ts +44 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +31 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/intelligence.d.ts +132 -0
  40. package/dist/intelligence.d.ts.map +1 -0
  41. package/dist/intelligence.js +463 -0
  42. package/dist/intelligence.js.map +1 -0
  43. package/dist/local.d.ts +192 -0
  44. package/dist/local.d.ts.map +1 -0
  45. package/dist/local.js +365 -0
  46. package/dist/local.js.map +1 -0
  47. package/dist/loop.d.ts +84 -0
  48. package/dist/loop.d.ts.map +1 -0
  49. package/dist/loop.js +173 -0
  50. package/dist/loop.js.map +1 -0
  51. package/dist/mcp-stdio.d.ts +38 -0
  52. package/dist/mcp-stdio.d.ts.map +1 -0
  53. package/dist/mcp-stdio.js +83 -0
  54. package/dist/mcp-stdio.js.map +1 -0
  55. package/dist/pins.d.ts +29 -0
  56. package/dist/pins.d.ts.map +1 -0
  57. package/dist/pins.js +60 -0
  58. package/dist/pins.js.map +1 -0
  59. package/dist/plan.d.ts +150 -0
  60. package/dist/plan.d.ts.map +1 -0
  61. package/dist/plan.js +303 -0
  62. package/dist/plan.js.map +1 -0
  63. package/dist/providers/insight.d.ts +14 -0
  64. package/dist/providers/insight.d.ts.map +1 -0
  65. package/dist/providers/insight.js +81 -0
  66. package/dist/providers/insight.js.map +1 -0
  67. package/dist/providers/invariant.d.ts +14 -0
  68. package/dist/providers/invariant.d.ts.map +1 -0
  69. package/dist/providers/invariant.js +123 -0
  70. package/dist/providers/invariant.js.map +1 -0
  71. package/dist/providers/jev.d.ts +115 -0
  72. package/dist/providers/jev.d.ts.map +1 -0
  73. package/dist/providers/jev.js +148 -0
  74. package/dist/providers/jev.js.map +1 -0
  75. package/dist/providers/lens.d.ts +24 -0
  76. package/dist/providers/lens.d.ts.map +1 -0
  77. package/dist/providers/lens.js +36 -0
  78. package/dist/providers/lens.js.map +1 -0
  79. package/dist/providers/llm.d.ts +25 -0
  80. package/dist/providers/llm.d.ts.map +1 -0
  81. package/dist/providers/llm.js +44 -0
  82. package/dist/providers/llm.js.map +1 -0
  83. package/dist/providers/schema.d.ts +12 -0
  84. package/dist/providers/schema.d.ts.map +1 -0
  85. package/dist/providers/schema.js +508 -0
  86. package/dist/providers/schema.js.map +1 -0
  87. package/dist/providers/structure.d.ts +14 -0
  88. package/dist/providers/structure.d.ts.map +1 -0
  89. package/dist/providers/structure.js +211 -0
  90. package/dist/providers/structure.js.map +1 -0
  91. package/dist/questions.d.ts +162 -0
  92. package/dist/questions.d.ts.map +1 -0
  93. package/dist/questions.js +316 -0
  94. package/dist/questions.js.map +1 -0
  95. package/dist/run.d.ts +202 -0
  96. package/dist/run.d.ts.map +1 -0
  97. package/dist/run.js +453 -0
  98. package/dist/run.js.map +1 -0
  99. package/dist/space.d.ts +50 -0
  100. package/dist/space.d.ts.map +1 -0
  101. package/dist/space.js +55 -0
  102. package/dist/space.js.map +1 -0
  103. package/dist/types.d.ts +122 -0
  104. package/dist/types.d.ts.map +1 -0
  105. package/dist/types.js +2 -0
  106. package/dist/types.js.map +1 -0
  107. package/dist/usage.d.ts +10 -0
  108. package/dist/usage.d.ts.map +1 -0
  109. package/dist/usage.js +59 -0
  110. package/dist/usage.js.map +1 -0
  111. package/package.json +61 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive.js","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiE,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA+D7D;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CAAC,iBAAiB,EAAK,EAAE,iBAAiB,EAAK,EAAE,cAAc,EAAK,EAAE,eAAe,EAAK,CAAC,CAAC;AACrG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAe,EACf,SAA4B,EAC5B,UAA4B,EAAE;IAE9B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC;IACtB,MAAM,SAAS,GAAG,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C,KAAK,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACnE,IAAI,EAAE,UAAU,CAAC,QAAQ;QACzB,IAAI,EAAE,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,SAAS,EAAE;KACpD,CAAC,CAAC,CAAC;IACJ;;;;;;;;;;;OAWG;IACH,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;IAChG,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE;QAC3B,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC;QAC3D,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtD,CAAC,CAAC;AACL,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,iBAAiB,CAC/B,KAAe,EACf,UAAsB,EACtB,YAA+C,EAAE;IAEjD,OAAO,KAAK,CAAC,OAAO,CAAC;QACnB,IAAI,EAAE,UAAU,CAAC,QAAQ;QACzB,IAAI,EAAE,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,SAAS,EAAE;KAC3C,CAAC,CAAC;AACL,CAAC"}
package/dist/edit.d.ts ADDED
@@ -0,0 +1,70 @@
1
+ import { type AnySchema, type ArgShape, type Store } from "@graview/core";
2
+ import type { OpenParameter } from "./types.js";
3
+ /**
4
+ * A field you can change where it is shown, and the mutation that would do it.
5
+ *
6
+ * Reading a node closely is exactly when you most want to change it, and
7
+ * until now the only way was to find a named mutation in the actions strip
8
+ * and answer its arguments in a form. "Change this word" should be available
9
+ * on the word.
10
+ *
11
+ * It still goes through a mutation. That is not a formality: the mutation is
12
+ * what puts the change in the op log with an author and an intent, what makes
13
+ * it undoable, and what the invariants judge. An in-place edit that wrote the
14
+ * graph directly would be the one kind of change nobody could take back.
15
+ */
16
+ export interface EditableField {
17
+ /** The field on the node, as the schema declares it. */
18
+ readonly field: string;
19
+ readonly mutation: string;
20
+ /** The mutation's own title, so the control can say what applying it means. */
21
+ readonly title: string;
22
+ /** What sort of answer the field wants, read off the mutation's input. */
23
+ readonly shape: ArgShape;
24
+ /**
25
+ * Whether the mutation takes the new value as an argument. `rename` does;
26
+ * `finish` sets `done` without asking — a writer by declaration whose
27
+ * whole meaning is in its title. A control for the second kind offers the
28
+ * act, not a text box.
29
+ */
30
+ readonly takesValue: boolean;
31
+ /**
32
+ * Other declared writers of the same field, for a control that must offer
33
+ * a choice of acts: `done` is written by "Mark it done" AND "Put it back".
34
+ */
35
+ readonly alternatives: readonly EditableField[];
36
+ /**
37
+ * Anything else the mutation needs that the edit cannot supply. Present
38
+ * rather than filtered out: a field editable only by answering a second
39
+ * question is still worth offering, and hiding it would be a lie.
40
+ */
41
+ readonly open: readonly OpenParameter[];
42
+ /** The call for a new value. */
43
+ call(value: unknown): {
44
+ name: string;
45
+ args: Record<string, unknown>;
46
+ };
47
+ }
48
+ /**
49
+ * Which of a node's fields can be edited in place, derived from declarations.
50
+ *
51
+ * Two sources, in order of trust. A mutation that DECLARES what it writes
52
+ * (`writes: ["done"]`) is believed, and only about that — which is how
53
+ * `finish` and `reopen` stop being invisible writers of `done`. One that
54
+ * does not is read by name: an input argument named exactly like one of the
55
+ * kind's fields writes that field — `relabelEntity` takes `label`,
56
+ * `rescheduleTrigger` takes `when` — with no app saying anything per field.
57
+ *
58
+ * The derived edit act (`edit-<kind>`, see `deriveEditMutations` in core)
59
+ * arrives here like any other mutation, declaring the fields it covers, so
60
+ * a field you could set at creation is editable where it is shown.
61
+ *
62
+ * The name heuristic's limit is worth being honest about: an argument called
63
+ * `label` that means something other than the subject's own label would be
64
+ * matched wrongly. Nothing here writes anything on its own — the edit runs
65
+ * the mutation, the mutation decides, the invariants judge — so the cost of
66
+ * a wrong guess is an action offered that does not do what its name
67
+ * suggests, not a corrupted graph. Declaring `writes` removes the guess.
68
+ */
69
+ export declare function editableFields<S extends AnySchema>(store: Store<S>, nodeId: string): readonly EditableField[];
70
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,aAAa,EAAE,CAAC;IAChD;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,CAAC;IACxC,gCAAgC;IAChC,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CACvE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,SAAS,EAChD,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,MAAM,EAAE,MAAM,GACb,SAAS,aAAa,EAAE,CAoE1B"}
package/dist/edit.js ADDED
@@ -0,0 +1,97 @@
1
+ import { argShape, fieldsWrittenBy, nodeRefArgs, } from "@graview/core";
2
+ /**
3
+ * Which of a node's fields can be edited in place, derived from declarations.
4
+ *
5
+ * Two sources, in order of trust. A mutation that DECLARES what it writes
6
+ * (`writes: ["done"]`) is believed, and only about that — which is how
7
+ * `finish` and `reopen` stop being invisible writers of `done`. One that
8
+ * does not is read by name: an input argument named exactly like one of the
9
+ * kind's fields writes that field — `relabelEntity` takes `label`,
10
+ * `rescheduleTrigger` takes `when` — with no app saying anything per field.
11
+ *
12
+ * The derived edit act (`edit-<kind>`, see `deriveEditMutations` in core)
13
+ * arrives here like any other mutation, declaring the fields it covers, so
14
+ * a field you could set at creation is editable where it is shown.
15
+ *
16
+ * The name heuristic's limit is worth being honest about: an argument called
17
+ * `label` that means something other than the subject's own label would be
18
+ * matched wrongly. Nothing here writes anything on its own — the edit runs
19
+ * the mutation, the mutation decides, the invariants judge — so the cost of
20
+ * a wrong guess is an action offered that does not do what its name
21
+ * suggests, not a corrupted graph. Declaring `writes` removes the guess.
22
+ */
23
+ export function editableFields(store, nodeId) {
24
+ const node = store.graph.getNode(nodeId);
25
+ if (!node)
26
+ return [];
27
+ const kind = node["kind"];
28
+ const definition = store.schema.tryDefinition(kind);
29
+ if (!definition)
30
+ return [];
31
+ const candidates = new Map();
32
+ for (const mutation of store.allMutations()) {
33
+ const subject = mutation.subject;
34
+ if (!subject)
35
+ continue;
36
+ const accepts = subject.kinds === "*" || subject.kinds.includes(kind);
37
+ if (!accepts)
38
+ continue;
39
+ const shape = mutation.input.shape ?? {};
40
+ for (const name of fieldsWrittenBy(mutation, definition)) {
41
+ const takesValue = name in shape;
42
+ const open = [];
43
+ for (const other of Object.keys(shape)) {
44
+ if (other === subject.arg || other === name)
45
+ continue;
46
+ if (optional(shape[other]))
47
+ continue;
48
+ const ref = nodeRefArgs(mutation.input).find((candidate) => candidate.name === other);
49
+ open.push({
50
+ name: other,
51
+ ...(ref ? { kinds: ref.kinds } : {}),
52
+ ...(ref
53
+ ? {
54
+ candidates: ref.kinds.includes("*")
55
+ ? store.graph.allNodes().map((other2) => other2.id)
56
+ : ref.kinds.flatMap((refKind) => store.graph.nodesOfKind(refKind).map((other2) => other2.id)),
57
+ }
58
+ : {}),
59
+ shape: argShape(mutation.input, other),
60
+ });
61
+ }
62
+ const field = {
63
+ field: name,
64
+ mutation: mutation.name,
65
+ title: mutation.title ?? mutation.name,
66
+ shape: takesValue ? argShape(mutation.input, name) : { type: "unknown" },
67
+ takesValue,
68
+ alternatives: [],
69
+ open,
70
+ call: (value) => ({
71
+ name: mutation.name,
72
+ args: takesValue
73
+ ? { [subject.arg]: nodeId, [name]: value }
74
+ : { [subject.arg]: nodeId },
75
+ }),
76
+ };
77
+ candidates.set(name, [...(candidates.get(name) ?? []), field]);
78
+ }
79
+ }
80
+ /*
81
+ * One control per field. A writer that takes the value is the natural
82
+ * control and comes first; among equals, declaration order holds, so
83
+ * which mutation edits a field is stable rather than registration luck.
84
+ * The rest ride along as alternatives, for a control that offers acts.
85
+ */
86
+ return [...candidates.values()].map((writers) => {
87
+ const ordered = [...writers.filter((w) => w.takesValue), ...writers.filter((w) => !w.takesValue)];
88
+ const [first, ...rest] = ordered;
89
+ return { ...first, alternatives: rest };
90
+ });
91
+ }
92
+ /** Whether an argument may be left out, so it does not count as unanswered. */
93
+ function optional(schema) {
94
+ const type = schema?._def?.type;
95
+ return type === "optional" || type === "default" || type === "nullable";
96
+ }
97
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,WAAW,GAIZ,MAAM,eAAe,CAAC;AA8CvB;;;;;;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ion } from "./intelligence.js";
2
+ /**
3
+ * AN AGENT DRAWS A KIND'S FIGURE — in the house style, or not at all.
4
+ *
5
+ * The declaration is a graph and a brand is a declaration, so the drawing
6
+ * of a kind is a thing an agent can propose like any other change. What it
7
+ * must not be is a free hand: twelve figures drawn without a shared
8
+ * discipline read as twelve clip-art imports rather than as one city, and
9
+ * the isometric city's feel is the entire reason a figure is worth having.
10
+ *
11
+ * So the prompt is the style guide, and the ANSWER IS JUDGED before it is
12
+ * offered: `figureFaults` is the same function `graview check` runs, so a
13
+ * drawing that would fail the build never reaches a person as a proposal.
14
+ * Where a model gives nothing usable, the nearest shipped figure is a
15
+ * better answer than a bad drawing, and saying which is better than both.
16
+ */
17
+ export interface DrawnFigure {
18
+ readonly kind: string;
19
+ /** The SVG, or the name of a shipped figure. */
20
+ readonly figure: string;
21
+ /** Where it came from, so a person keeping it knows what they are keeping. */
22
+ readonly from: "model" | "shipped";
23
+ /** What the model produced and why it was not used, when it was not. */
24
+ readonly refused?: readonly string[];
25
+ }
26
+ export declare const FIGURE_STYLE = "You are drawing one figure for a kind of thing in a software application.\n\nThe house style, and every rule matters:\n- ONE SVG element, with one viewBox of \"0 0 24 24\" and nothing outside it.\n- Line art only: stroke=\"currentColor\", stroke-width=\"1.4\", fill=\"none\",\n stroke-linecap=\"round\", stroke-linejoin=\"round\". Never a literal colour,\n never a fill, never a gradient, never text.\n- Drawn from the same three-quarter isometric angle as an architect's\n blueprint: the thing seen from slightly above and to one side, with the\n edges that would be hidden left out rather than dashed.\n- It is a drawing of the THING, not an emblem for it. A vehicle is a body\n on wheels; a person is a head and shoulders; a plot is ground with an\n edge. Never a badge, a rounded-square icon, a letter, or an abstract mark.\n- It must read at twenty pixels: at most about eight paths, nothing thinner\n than the stroke width, no detail smaller than a fortieth of the box.\n\nAnswer with the SVG and nothing else \u2014 no prose, no code fence.";
27
+ /**
28
+ * Asks a model for a figure and judges what comes back.
29
+ *
30
+ * `nearest` is the honest fallback: a kind called "vehicle" gets the
31
+ * shipped vehicle rather than a drawing that fails the checker, and the
32
+ * result says which happened so a person is never shown a machine's work
33
+ * and told it was a choice.
34
+ */
35
+ export declare function drawFigure(kind: string, description: string | undefined, complete: Completion): Promise<DrawnFigure>;
36
+ /**
37
+ * The SVG out of whatever a model wrapped it in.
38
+ *
39
+ * Models fence code, apologise first and explain afterwards; none of that
40
+ * is a reason to refuse a good drawing, and none of it is something to
41
+ * store in a declaration.
42
+ */
43
+ export declare function onlyTheSvg(answer: string): string | undefined;
44
+ /**
45
+ * The shipped figure whose name is closest to a kind's.
46
+ *
47
+ * By name, and only by name: guessing that a "cleat" is a "box" because
48
+ * both are objects would be the framework having an opinion about a domain
49
+ * it has never met. An exact name, a name the kind contains, or nothing —
50
+ * and "nothing" is the `note`, which is honest about being a placeholder.
51
+ */
52
+ export declare function nearestFigure(kind: string): string;
53
+ //# sourceMappingURL=figure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figure.d.ts","sourceRoot":"","sources":["../src/figure.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,wEAAwE;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,miCAgBuC,CAAC;AAEjE;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,WAAW,CAAC,CA2BtB;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK7D;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKlD"}
package/dist/figure.js ADDED
@@ -0,0 +1,86 @@
1
+ import { figureFaults, FIGURE_NAMES, FIGURES } from "@graview/core";
2
+ export const FIGURE_STYLE = `You are drawing one figure for a kind of thing in a software application.
3
+
4
+ The house style, and every rule matters:
5
+ - ONE SVG element, with one viewBox of "0 0 24 24" and nothing outside it.
6
+ - Line art only: stroke="currentColor", stroke-width="1.4", fill="none",
7
+ stroke-linecap="round", stroke-linejoin="round". Never a literal colour,
8
+ never a fill, never a gradient, never text.
9
+ - Drawn from the same three-quarter isometric angle as an architect's
10
+ blueprint: the thing seen from slightly above and to one side, with the
11
+ edges that would be hidden left out rather than dashed.
12
+ - It is a drawing of the THING, not an emblem for it. A vehicle is a body
13
+ on wheels; a person is a head and shoulders; a plot is ground with an
14
+ edge. Never a badge, a rounded-square icon, a letter, or an abstract mark.
15
+ - It must read at twenty pixels: at most about eight paths, nothing thinner
16
+ than the stroke width, no detail smaller than a fortieth of the box.
17
+
18
+ Answer with the SVG and nothing else — no prose, no code fence.`;
19
+ /**
20
+ * Asks a model for a figure and judges what comes back.
21
+ *
22
+ * `nearest` is the honest fallback: a kind called "vehicle" gets the
23
+ * shipped vehicle rather than a drawing that fails the checker, and the
24
+ * result says which happened so a person is never shown a machine's work
25
+ * and told it was a choice.
26
+ */
27
+ export async function drawFigure(kind, description, complete) {
28
+ const asked = `${FIGURE_STYLE}
29
+
30
+ The kind is called "${kind}".${description ? `\nIt is described as: ${description}` : ""}`;
31
+ let answer = "";
32
+ try {
33
+ answer = await complete(asked);
34
+ }
35
+ catch (error) {
36
+ return {
37
+ kind,
38
+ figure: nearestFigure(kind),
39
+ from: "shipped",
40
+ refused: [error instanceof Error ? error.message : String(error)],
41
+ };
42
+ }
43
+ const svg = onlyTheSvg(answer);
44
+ if (svg) {
45
+ const faults = figureFaults(svg);
46
+ if (faults.length === 0)
47
+ return { kind, figure: svg, from: "model" };
48
+ return { kind, figure: nearestFigure(kind), from: "shipped", refused: faults };
49
+ }
50
+ return {
51
+ kind,
52
+ figure: nearestFigure(kind),
53
+ from: "shipped",
54
+ refused: ["the answer contained no <svg> element."],
55
+ };
56
+ }
57
+ /**
58
+ * The SVG out of whatever a model wrapped it in.
59
+ *
60
+ * Models fence code, apologise first and explain afterwards; none of that
61
+ * is a reason to refuse a good drawing, and none of it is something to
62
+ * store in a declaration.
63
+ */
64
+ export function onlyTheSvg(answer) {
65
+ const at = answer.indexOf("<svg");
66
+ const end = answer.lastIndexOf("</svg>");
67
+ if (at === -1 || end === -1 || end < at)
68
+ return undefined;
69
+ return answer.slice(at, end + "</svg>".length).trim();
70
+ }
71
+ /**
72
+ * The shipped figure whose name is closest to a kind's.
73
+ *
74
+ * By name, and only by name: guessing that a "cleat" is a "box" because
75
+ * both are objects would be the framework having an opinion about a domain
76
+ * it has never met. An exact name, a name the kind contains, or nothing —
77
+ * and "nothing" is the `note`, which is honest about being a placeholder.
78
+ */
79
+ export function nearestFigure(kind) {
80
+ const said = kind.toLowerCase();
81
+ if (FIGURES[said])
82
+ return said;
83
+ const held = FIGURE_NAMES.find((name) => said.includes(name) || name.includes(said));
84
+ return held ?? "note";
85
+ }
86
+ //# sourceMappingURL=figure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figure.js","sourceRoot":"","sources":["../src/figure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA6BpE,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;gEAgBoC,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAY,EACZ,WAA+B,EAC/B,QAAoB;IAEpB,MAAM,KAAK,GAAG,GAAG,YA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zC,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,EAAE;QAAE,OAAO,SAAS,CAAC;IAC1D,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,IAAI,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACrF,OAAO,IAAI,IAAI,MAAM,CAAC;AACxB,CAAC"}
@@ -0,0 +1,44 @@
1
+ export { applyAffordance, defaultProviders, deriveAffordances, previewAffordance, } from "./derive.js";
2
+ export type { WithheldAffordance } from "./types.js";
3
+ export type { DeriveOptions } from "./derive.js";
4
+ export type { Affordance, AffordanceProvider, AffordanceSet, DeriveContext, Observation, OpenParameter, ProviderName, } from "./types.js";
5
+ export { editableFields } from "./edit.js";
6
+ export type { EditableField } from "./edit.js";
7
+ export { invariantProvider } from "./providers/invariant.js";
8
+ export { schemaProvider } from "./providers/schema.js";
9
+ export { structureProvider } from "./providers/structure.js";
10
+ export { lensProvider } from "./providers/lens.js";
11
+ export type { LensAction } from "./providers/lens.js";
12
+ export { deriveWithLlm } from "./providers/llm.js";
13
+ export type { LlmProposal, LlmProvider } from "./providers/llm.js";
14
+ export { createToolRuntime } from "./agent/tools.js";
15
+ export type { ToolDefinition, ToolResult, ToolRuntime, ToolRuntimeOptions, ToolCall, } from "./agent/tools.js";
16
+ export { createInAppAdapter, createMcpAdapter } from "./agent/adapters.js";
17
+ export type { InAppAgent, McpContent, McpTool, McpToolResult } from "./agent/adapters.js";
18
+ export { insightProvider } from "./providers/insight.js";
19
+ export { usageBoost, usageWeights } from "./usage.js";
20
+ export { loadPins, savePins, togglePin, NO_PINS } from "./pins.js";
21
+ export type { PinOverrides } from "./pins.js";
22
+ export { describeProposal, droppedProposals, firstJsonObject, resolveProposal, stillNeeded, intelligenceProvider, llmIntelligence, toCall, templateIntelligence, validateProposals, } from "./intelligence.js";
23
+ export type { Completion, Intelligence, ProposedCall } from "./intelligence.js";
24
+ export { graphResponder, llmResponder } from "./conversation.js";
25
+ export type { ChatContext, ChatReply, Responder } from "./conversation.js";
26
+ export { completionFor, configuredResponder, decideFor, DEFAULT_INTELLIGENCE, describeIntelligence, loadIntelligenceConfig, localCompletion, openAiCompatibleCompletion, RUNGS, rungFor, rungHonesty, saveIntelligenceConfig, xaiCompletion, } from "./local.js";
27
+ export type { IntelligenceConfig, IntelligenceSource, LocalStatus } from "./local.js";
28
+ export { completionDecide, graphDecide } from "./decide.js";
29
+ export type { PartlyDecided } from "./decide.js";
30
+ export { drawFigure, FIGURE_STYLE, nearestFigure, onlyTheSvg } from "./figure.js";
31
+ export type { DrawnFigure } from "./figure.js";
32
+ export { applyPlan, dependentsOf, describePlan, isPlanReference, planFrom, without } from "./plan.js";
33
+ export type { AppliedPlan, Plan, PlanEntry, PlanOptions, PlannedCall, PlanReference } from "./plan.js";
34
+ export { across, inside, within } from "./space.js";
35
+ export type { Ring, SpacePoint } from "./space.js";
36
+ export { allQuestions, nodeState, pairQuestion, questionsForInvariant, questionsForKind, questionsForMutation, scoreToValue, } from "./questions.js";
37
+ export type { ChoiceQuestion, DerivedQuestion, NoulQuestion, OfferedQuestion, Question, QuestionAbout, ScoreQuestion } from "./questions.js";
38
+ export { JEV_ENDPOINT, JEV_INPUT_USD_PER_MILLION, JEV_MODEL, JevError, jevCostUsd, jevDecide, jevKeyFromEnvironment } from "./providers/jev.js";
39
+ export type { Answer, ChoiceAnswer, Decide, Decided, JevFailure, JevOptions, NoulAnswer, ScoreAnswer, Usage } from "./providers/jev.js";
40
+ export { describeRun, landRun, offerOf, readRun, replyFromRun, runFrom, valueOf } from "./run.js";
41
+ export type { Answered, RunDeclaration, RunOptions, RunReading, RunResult, RunStep, StepOutcome } from "./run.js";
42
+ export { replyFromLoop, runLoop } from "./loop.js";
43
+ export type { LoopDeclaration, LoopOptions, LoopResult, LoopTurn, StopWhy, Stopped } from "./loop.js";
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,k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AAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGlH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ // Derived affordances: actions found in the graph, not authored per selection.
2
+ export { applyAffordance, defaultProviders, deriveAffordances, previewAffordance, } from "./derive.js";
3
+ // The providers, individually, so an app can replace or reorder them.
4
+ export { editableFields } from "./edit.js";
5
+ export { invariantProvider } from "./providers/invariant.js";
6
+ export { schemaProvider } from "./providers/schema.js";
7
+ export { structureProvider } from "./providers/structure.js";
8
+ export { lensProvider } from "./providers/lens.js";
9
+ export { deriveWithLlm } from "./providers/llm.js";
10
+ // One tool surface, two transports.
11
+ export { createToolRuntime } from "./agent/tools.js";
12
+ export { createInAppAdapter, createMcpAdapter } from "./agent/adapters.js";
13
+ export { insightProvider } from "./providers/insight.js";
14
+ export { usageBoost, usageWeights } from "./usage.js";
15
+ export { loadPins, savePins, togglePin, NO_PINS } from "./pins.js";
16
+ export { describeProposal, droppedProposals, firstJsonObject, resolveProposal, stillNeeded, intelligenceProvider, llmIntelligence, toCall, templateIntelligence, validateProposals, } from "./intelligence.js";
17
+ export { graphResponder, llmResponder } from "./conversation.js";
18
+ export { completionFor, configuredResponder, decideFor, DEFAULT_INTELLIGENCE, describeIntelligence, loadIntelligenceConfig, localCompletion, openAiCompatibleCompletion, RUNGS, rungFor, rungHonesty, saveIntelligenceConfig, xaiCompletion, } from "./local.js";
19
+ export { completionDecide, graphDecide } from "./decide.js";
20
+ export { drawFigure, FIGURE_STYLE, nearestFigure, onlyTheSvg } from "./figure.js";
21
+ export { applyPlan, dependentsOf, describePlan, isPlanReference, planFrom, without } from "./plan.js";
22
+ export { across, inside, within } from "./space.js";
23
+ // The questions a declaration already types, derived rather than authored.
24
+ export { allQuestions, nodeState, pairQuestion, questionsForInvariant, questionsForKind, questionsForMutation, scoreToValue, } from "./questions.js";
25
+ // The decision provider: one call, many questions, honest about failure.
26
+ export { JEV_ENDPOINT, JEV_INPUT_USD_PER_MILLION, JEV_MODEL, JevError, jevCostUsd, jevDecide, jevKeyFromEnvironment } from "./providers/jev.js";
27
+ // A run: a sequence of typed asks over the graph, declared not scripted.
28
+ export { describeRun, landRun, offerOf, readRun, replyFromRun, runFrom, valueOf } from "./run.js";
29
+ // A loop: act, re-judge, act again, and know when to stop.
30
+ export { replyFromLoop, runLoop } from "./loop.js";
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAarB,sEAAsE;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,oCAAoC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,QAAQ,E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;AAGlG,2DAA2D;AAC3D,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,132 @@
1
+ import { type AnySchema, type MutationCall, type Store } from "@graview/core";
2
+ import type { AffordanceProvider, OpenParameter } from "./types.js";
3
+ /**
4
+ * INTELLIGENCE IS ONE SEAM, whoever supplies it.
5
+ *
6
+ * Three layers of trust share it: the graph's own structural derivations,
7
+ * a model reached through a completion function, and a customer's external
8
+ * agent arriving over the derived tool surface. All three produce the same
9
+ * thing — proposed calls to declared mutations — and everything downstream
10
+ * (preview, permission, the op log, selective undo) treats them exactly
11
+ * like a human's, because they travel the same path. There is no second,
12
+ * privileged way in, and "add AI" is choosing a provider, not an
13
+ * integration.
14
+ */
15
+ export interface ProposedCall {
16
+ readonly mutation: string;
17
+ readonly args: Readonly<Record<string, unknown>>;
18
+ /** Why this provider suggests it, in one sentence. */
19
+ readonly why?: string;
20
+ }
21
+ /**
22
+ * THE FIRST WHOLE JSON OBJECT IN AN ANSWER, or nothing.
23
+ *
24
+ * Models fence code, apologise first, explain afterwards and — often
25
+ * enough to matter — close one brace too many. Taking everything between
26
+ * the first `{` and the last `}` swallowed the extra, `JSON.parse` threw,
27
+ * and the caller fell back to showing the person the raw answer: a chat
28
+ * bubble containing `{"say": "Yes", "proposals": [...]}}`, which is the
29
+ * seat handing over its own plumbing.
30
+ *
31
+ * Scanning for the BALANCED close instead reads the object the model meant
32
+ * and ignores whatever it typed after it. Strings and their escapes are
33
+ * respected, or a brace inside a description ends the object early.
34
+ */
35
+ export declare function firstJsonObject(answer: string): unknown;
36
+ /**
37
+ * A NAME IS NOT AN ID, and a model will hand you a name.
38
+ *
39
+ * Asked to add a field to Meal, a model answers `{"kind": "Meal"}` — the
40
+ * word on the screen rather than the node's id — and the store refuses it
41
+ * for the arguments, in zod's words, under a struck-through line. That is
42
+ * a lookup, not a guess: where EXACTLY ONE node of a kind the argument
43
+ * accepts carries that label, the label means that node. Where two do, or
44
+ * none, the value is left exactly as it came and the form asks.
45
+ */
46
+ export declare function resolveProposal<S extends AnySchema>(store: Store<S>, proposal: ProposedCall): ProposedCall;
47
+ /** A proposal as the store's own call shape, ready for apply/preview. */
48
+ export declare function toCall(proposal: ProposedCall): MutationCall;
49
+ export interface Intelligence<S extends AnySchema = AnySchema> {
50
+ readonly name: string;
51
+ /** What this provider may call. Absent means anything declared. */
52
+ readonly may?: readonly string[];
53
+ propose(store: Store<S>): Promise<readonly ProposedCall[]>;
54
+ }
55
+ /** The whole vendor surface: one prompt in, one string out. */
56
+ export type Completion = (prompt: string) => Promise<string>;
57
+ /**
58
+ * WHAT THE GATE TOOK OUT, AND WHY — so a seat can say so.
59
+ *
60
+ * `validateProposals` drops silently, which is right for a provider filling
61
+ * the inspector and wrong for a conversation: a model that answers "Sure"
62
+ * and names `add_field` on an app whose act is `add-field` left a person
63
+ * looking at a sentence with nothing under it and no way to know why. The
64
+ * seat can only say what it is told.
65
+ */
66
+ export declare function droppedProposals<S extends AnySchema>(store: Store<S>, proposals: readonly ProposedCall[], may?: readonly string[]): readonly {
67
+ readonly proposal: ProposedCall;
68
+ readonly why: "unknown" | "not-allowed";
69
+ }[];
70
+ /** Drops proposals naming unknown or disallowed mutations, with no guessing. */
71
+ export declare function validateProposals<S extends AnySchema>(store: Store<S>, proposals: readonly ProposedCall[], may?: readonly string[]): readonly ProposedCall[];
72
+ /**
73
+ * An LLM as a provider: the model reads a compact statement of the
74
+ * declaration and the current trouble, and answers with calls to declared
75
+ * mutations. Vendor-neutral by construction — the adapter is one async
76
+ * function, so claude/openai/local are one line each in the host.
77
+ */
78
+ export declare function llmIntelligence<S extends AnySchema>(options: {
79
+ readonly name: string;
80
+ readonly complete: Completion;
81
+ readonly may?: readonly string[];
82
+ }): Intelligence<S>;
83
+ /**
84
+ * Starter data FROM THE DECLARATION ALONE — the intelligence an empty app
85
+ * has before any key exists. For each mutation that creates a kind with no
86
+ * members yet, synthesise honest arguments off the derived form: sample
87
+ * text, today's date, a bounded number, the first choice. Anything needing
88
+ * a node that does not exist is left for the next round rather than faked.
89
+ */
90
+ export declare function templateIntelligence<S extends AnySchema>(options?: {
91
+ readonly name?: string;
92
+ readonly today?: string;
93
+ }): Intelligence<S>;
94
+ /**
95
+ * An Intelligence as an affordance provider, for the suggestion surfaces.
96
+ *
97
+ * `deriveAffordances` is synchronous and a model is not, so the wrapper
98
+ * answers from a cache keyed to the log length and refreshes in the
99
+ * background; `notify` tells the host a fresh answer landed (a re-render
100
+ * re-derives). Every suggestion says which provider and why, and applies
101
+ * through the ordinary path — previewable, attributed, undoable.
102
+ */
103
+ export declare function intelligenceProvider<S extends AnySchema>(intelligence: Intelligence<S>, hooks?: {
104
+ readonly notify?: () => void;
105
+ }): AffordanceProvider<S>;
106
+ /** Something readable for logs and seats: the provider's own sentence. */
107
+ export declare function describeProposal<S extends AnySchema>(store: Store<S>, proposal: ProposedCall): string;
108
+ /**
109
+ * WHAT A PROPOSAL HAS NOT SAID YET.
110
+ *
111
+ * A responder proposes from the graph and knows nothing of the policy, so
112
+ * the seat asks the store whether the person may do a thing before offering
113
+ * it. It knows just as little about the ACT'S OWN ARGUMENTS — a model told
114
+ * "add a shift called soup kitchen" will happily answer `add-shift` with no
115
+ * arguments at all, or with the label and none of the day, the place and
116
+ * the hours. Applied, the store refuses, and what reaches the person is the
117
+ * validator talking to itself:
118
+ *
119
+ * Refused: Invalid arguments for mutation "add-shift" label: Invalid
120
+ * input: expected string, received undefined; on: Invalid input: …
121
+ *
122
+ * That is not a refusal, it is a stack trace. The act was never impossible;
123
+ * it was under-specified, and the framework already knows what to do with
124
+ * an under-specified act — it asks. A person pressing "Add a shift" from
125
+ * the menu gets the same questions one at a time, with the graph's own
126
+ * candidates offered for anything that names a node.
127
+ *
128
+ * So: the arguments this proposal still owes, in the shape the ask already
129
+ * takes. Empty means it is ready to apply.
130
+ */
131
+ export declare function stillNeeded<S extends AnySchema>(store: Store<S>, proposal: ProposedCall): readonly OpenParameter[];
132
+ //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