@ai-matrx/records-ui 0.116.118 → 0.116.119
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/CHANGELOG.md +5 -1
- package/dist/{chunk-ATJH5PBT.js → chunk-ZFNJTEIB.js} +12 -12
- package/dist/decision-gate.cjs +319 -0
- package/dist/decision-gate.cjs.map +1 -0
- package/dist/decision-gate.d.cts +76 -0
- package/dist/decision-gate.d.ts +76 -0
- package/dist/decision-gate.js +298 -0
- package/dist/decision-gate.js.map +1 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.js +131 -131
- package/dist/pickers.js +3 -3
- package/package.json +12 -2
- /package/dist/{chunk-ATJH5PBT.js.map → chunk-ZFNJTEIB.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.116.
|
|
3
|
+
## 0.116.119
|
|
4
4
|
|
|
5
5
|
UNVERIFIED: this release has no Unreleased entry and the package-input comparison could not be made (the caller supplied no source comparison). Whether package inputs changed is unknown; consumer action is unknown.
|
|
6
6
|
Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui`.
|
|
7
7
|
|
|
8
|
+
## 0.116.118
|
|
9
|
+
|
|
10
|
+
- The Board options button keeps its full height when a tall board is constrained by its frame, preventing the button from shrinking and shifting column headings. No API change. Consumer action: none.
|
|
11
|
+
|
|
8
12
|
## 0.116.117
|
|
9
13
|
### lane app-frame
|
|
10
14
|
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
formatForField,
|
|
4
|
-
isYearField,
|
|
5
|
-
isYearValue,
|
|
6
|
-
shownAsOf,
|
|
7
|
-
useEmbeddedLook
|
|
8
|
-
} from "./chunk-OY553AFP.js";
|
|
9
|
-
import {
|
|
10
|
-
HtmlSampleFrame,
|
|
11
|
-
HtmlSampleTokensProvider
|
|
12
|
-
} from "./chunk-4CI2HLX3.js";
|
|
13
2
|
import {
|
|
14
3
|
ABSENCE_WORD_LABEL,
|
|
15
4
|
CONTEXT_POLICY_LABEL,
|
|
@@ -72,6 +61,13 @@ import {
|
|
|
72
61
|
kindValueWords,
|
|
73
62
|
shapeOfValue
|
|
74
63
|
} from "./chunk-YHPVSUK6.js";
|
|
64
|
+
import {
|
|
65
|
+
formatForField,
|
|
66
|
+
isYearField,
|
|
67
|
+
isYearValue,
|
|
68
|
+
shownAsOf,
|
|
69
|
+
useEmbeddedLook
|
|
70
|
+
} from "./chunk-OY553AFP.js";
|
|
75
71
|
import {
|
|
76
72
|
carriesTimeOfDay,
|
|
77
73
|
choiceChipLookOf,
|
|
@@ -105,6 +101,10 @@ import {
|
|
|
105
101
|
isRelationFieldType,
|
|
106
102
|
isSystemFieldKind
|
|
107
103
|
} from "./chunk-WCQSJPLS.js";
|
|
104
|
+
import {
|
|
105
|
+
HtmlSampleFrame,
|
|
106
|
+
HtmlSampleTokensProvider
|
|
107
|
+
} from "./chunk-4CI2HLX3.js";
|
|
108
108
|
import {
|
|
109
109
|
__reExport
|
|
110
110
|
} from "./chunk-HKYEHBQT.js";
|
|
@@ -14340,4 +14340,4 @@ export {
|
|
|
14340
14340
|
RecordNameText,
|
|
14341
14341
|
HeldChangeDecision
|
|
14342
14342
|
};
|
|
14343
|
-
//# sourceMappingURL=chunk-
|
|
14343
|
+
//# sourceMappingURL=chunk-ZFNJTEIB.js.map
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/decisionGateEntry.ts
|
|
22
|
+
var decisionGateEntry_exports = {};
|
|
23
|
+
__export(decisionGateEntry_exports, {
|
|
24
|
+
DecisionGate: () => DecisionGate,
|
|
25
|
+
VALUE_VERDICTS: () => VALUE_VERDICTS,
|
|
26
|
+
decisionAnswerComplete: () => decisionAnswerComplete,
|
|
27
|
+
decisionAnswersConfirmingRest: () => decisionAnswersConfirmingRest,
|
|
28
|
+
decisionBlockers: () => decisionBlockers,
|
|
29
|
+
decisionResumeValue: () => decisionResumeValue,
|
|
30
|
+
decisionResumeWithSettled: () => decisionResumeWithSettled,
|
|
31
|
+
decisionValueText: () => decisionValueText,
|
|
32
|
+
parseDecisionSpec: () => parseDecisionSpec
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(decisionGateEntry_exports);
|
|
35
|
+
|
|
36
|
+
// src/DecisionGate.tsx
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_icons = require("@ai-matrx/design-system/icons");
|
|
39
|
+
var import_controls = require("@ai-matrx/design-system/controls");
|
|
40
|
+
var import_writing_field = require("@ai-matrx/design-system/writing-field");
|
|
41
|
+
var import_cn = require("@ai-matrx/design-system/cn");
|
|
42
|
+
|
|
43
|
+
// src/decision-gate.ts
|
|
44
|
+
function isRecord(value) {
|
|
45
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
|
+
}
|
|
47
|
+
function str(value) {
|
|
48
|
+
return typeof value === "string" ? value : "";
|
|
49
|
+
}
|
|
50
|
+
var CHOICES = /* @__PURE__ */ new Set(["confirm", "not_true", "edit", "pick_one", "pick_many", "custom"]);
|
|
51
|
+
var VALUE_VERDICTS = /* @__PURE__ */ new Set(["edit", "pick_one", "pick_many", "custom"]);
|
|
52
|
+
function parseDecisionSpec(raw) {
|
|
53
|
+
if (!isRecord(raw) || !Array.isArray(raw.items)) return null;
|
|
54
|
+
const items = [];
|
|
55
|
+
for (const entry of raw.items) {
|
|
56
|
+
if (!isRecord(entry)) continue;
|
|
57
|
+
const key = str(entry.key).trim();
|
|
58
|
+
if (!key) continue;
|
|
59
|
+
const choices = (Array.isArray(entry.choices) ? entry.choices : ["confirm", "not_true", "edit"]).filter((c) => typeof c === "string" && CHOICES.has(c));
|
|
60
|
+
items.push({
|
|
61
|
+
key,
|
|
62
|
+
label: str(entry.label).trim() || key,
|
|
63
|
+
value: entry.value ?? null,
|
|
64
|
+
source: str(entry.source).trim() || null,
|
|
65
|
+
confidence: typeof entry.confidence === "number" ? entry.confidence : null,
|
|
66
|
+
choices: choices.length > 0 ? choices : ["confirm"],
|
|
67
|
+
options: (Array.isArray(entry.options) ? entry.options : []).filter(isRecord).map((o) => ({ value: o.value ?? null, label: str(o.label) || String(o.value ?? "") })),
|
|
68
|
+
required: entry.required === true
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (items.length === 0) return null;
|
|
72
|
+
return {
|
|
73
|
+
items,
|
|
74
|
+
minAnswers: typeof raw.min_answers === "number" ? raw.min_answers : 0,
|
|
75
|
+
submitLabel: str(raw.submit_label).trim() || "Confirm",
|
|
76
|
+
seatNotice: isRecord(raw.seat) ? str(raw.seat.notice).trim() || null : null,
|
|
77
|
+
seatFilled: !isRecord(raw.seat) || raw.seat.filled !== false
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function decisionAnswerComplete(answer) {
|
|
81
|
+
if (!answer) return false;
|
|
82
|
+
if (!VALUE_VERDICTS.has(answer.verdict)) return true;
|
|
83
|
+
const v = answer.value;
|
|
84
|
+
if (Array.isArray(v)) return v.length > 0;
|
|
85
|
+
if (typeof v === "string") return v.trim().length > 0;
|
|
86
|
+
return v !== void 0 && v !== null;
|
|
87
|
+
}
|
|
88
|
+
function decisionBlockers(spec, answers) {
|
|
89
|
+
const done = spec.items.filter((i) => decisionAnswerComplete(answers[i.key]));
|
|
90
|
+
return {
|
|
91
|
+
missingRequired: spec.items.filter((i) => i.required && !decisionAnswerComplete(answers[i.key])).map((i) => i.label),
|
|
92
|
+
needMore: Math.max(0, spec.minAnswers - done.length)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function decisionResumeValue(spec, answers) {
|
|
96
|
+
const out = {};
|
|
97
|
+
for (const item of spec.items) {
|
|
98
|
+
const a = answers[item.key];
|
|
99
|
+
if (!decisionAnswerComplete(a) || !a) continue;
|
|
100
|
+
out[item.key] = VALUE_VERDICTS.has(a.verdict) ? { verdict: a.verdict, value: a.value } : { verdict: a.verdict };
|
|
101
|
+
}
|
|
102
|
+
return { answer: { answers: out } };
|
|
103
|
+
}
|
|
104
|
+
function decisionResumeWithSettled(spec, answers, settledKeys) {
|
|
105
|
+
const settled = new Set(settledKeys);
|
|
106
|
+
const open = { ...spec, items: spec.items.filter((i) => !settled.has(i.key)) };
|
|
107
|
+
const body = decisionResumeValue(open, answers);
|
|
108
|
+
const out = body.answer.answers;
|
|
109
|
+
for (const item of spec.items) {
|
|
110
|
+
if (!settled.has(item.key) || !item.choices.includes("confirm")) continue;
|
|
111
|
+
if (item.required || Object.keys(out).length < spec.minAnswers) out[item.key] = { verdict: "confirm" };
|
|
112
|
+
}
|
|
113
|
+
return body;
|
|
114
|
+
}
|
|
115
|
+
function decisionValueText(value) {
|
|
116
|
+
if (value === null || value === void 0 || value === "") return "";
|
|
117
|
+
if (Array.isArray(value)) return value.map((v) => decisionValueText(v)).filter(Boolean).join(", ");
|
|
118
|
+
if (isRecord(value)) return str(value.name) || str(value.label) || JSON.stringify(value);
|
|
119
|
+
return String(value);
|
|
120
|
+
}
|
|
121
|
+
function decisionAnswersConfirmingRest(spec, answers, skipKeys = []) {
|
|
122
|
+
const skip = new Set(skipKeys);
|
|
123
|
+
const out = { ...answers };
|
|
124
|
+
for (const item of spec.items) {
|
|
125
|
+
if (skip.has(item.key) || out[item.key] || !item.choices.includes("confirm")) continue;
|
|
126
|
+
out[item.key] = { verdict: "confirm" };
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/DecisionGate.tsx
|
|
132
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
133
|
+
var CHOICE_LABEL = {
|
|
134
|
+
confirm: "Yes",
|
|
135
|
+
not_true: "Not true",
|
|
136
|
+
edit: "Edit",
|
|
137
|
+
pick_one: "Pick",
|
|
138
|
+
pick_many: "Pick",
|
|
139
|
+
custom: "Other"
|
|
140
|
+
};
|
|
141
|
+
function confidenceText(confidence) {
|
|
142
|
+
if (confidence === null) return null;
|
|
143
|
+
return `${Math.round(confidence * 100)}% sure`;
|
|
144
|
+
}
|
|
145
|
+
function draftFor(item) {
|
|
146
|
+
return decisionValueText(item.value);
|
|
147
|
+
}
|
|
148
|
+
function typedValue(item, text) {
|
|
149
|
+
if (Array.isArray(item.value)) {
|
|
150
|
+
return text.split(",").map((part) => part.trim()).filter(Boolean);
|
|
151
|
+
}
|
|
152
|
+
return text;
|
|
153
|
+
}
|
|
154
|
+
function DecisionGate({
|
|
155
|
+
spec,
|
|
156
|
+
sending,
|
|
157
|
+
onSubmit,
|
|
158
|
+
settled
|
|
159
|
+
}) {
|
|
160
|
+
const [answers, setAnswers] = (0, import_react.useState)({});
|
|
161
|
+
const [drafts, setDrafts] = (0, import_react.useState)({});
|
|
162
|
+
const settledKeys = spec.items.filter((i) => settled?.[i.key]).map((i) => i.key);
|
|
163
|
+
const openSpec = {
|
|
164
|
+
...spec,
|
|
165
|
+
items: spec.items.filter((i) => !settledKeys.includes(i.key)),
|
|
166
|
+
minAnswers: Math.max(0, spec.minAnswers - settledKeys.length)
|
|
167
|
+
};
|
|
168
|
+
const sendAnswers = decisionAnswersConfirmingRest(openSpec, answers);
|
|
169
|
+
const confirmingRest = openSpec.items.filter((i) => !answers[i.key] && sendAnswers[i.key]).length;
|
|
170
|
+
const blockers = decisionBlockers(openSpec, sendAnswers);
|
|
171
|
+
const ready = blockers.missingRequired.length === 0 && blockers.needMore === 0;
|
|
172
|
+
const choose = (item, verdict) => {
|
|
173
|
+
setAnswers((prev) => {
|
|
174
|
+
const next = { ...prev };
|
|
175
|
+
if (verdict === "edit" || verdict === "custom") {
|
|
176
|
+
const text = drafts[item.key] ?? (verdict === "edit" ? draftFor(item) : "");
|
|
177
|
+
next[item.key] = { verdict, value: typedValue(item, text) };
|
|
178
|
+
} else if (verdict === "pick_one" || verdict === "pick_many") {
|
|
179
|
+
next[item.key] = { verdict, value: verdict === "pick_many" ? [] : void 0 };
|
|
180
|
+
} else {
|
|
181
|
+
next[item.key] = { verdict };
|
|
182
|
+
}
|
|
183
|
+
return next;
|
|
184
|
+
});
|
|
185
|
+
if (verdict === "edit") {
|
|
186
|
+
setDrafts((prev) => item.key in prev ? prev : { ...prev, [item.key]: draftFor(item) });
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const type = (item, text) => {
|
|
190
|
+
setDrafts((prev) => ({ ...prev, [item.key]: text }));
|
|
191
|
+
setAnswers((prev) => {
|
|
192
|
+
const current = prev[item.key];
|
|
193
|
+
if (!current || !VALUE_VERDICTS.has(current.verdict)) return prev;
|
|
194
|
+
return { ...prev, [item.key]: { verdict: current.verdict, value: typedValue(item, text) } };
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
const pick = (item, value) => {
|
|
198
|
+
setAnswers((prev) => {
|
|
199
|
+
const current = prev[item.key];
|
|
200
|
+
if (current?.verdict === "pick_many") {
|
|
201
|
+
const list = Array.isArray(current.value) ? current.value : [];
|
|
202
|
+
const has = list.some((v) => JSON.stringify(v) === JSON.stringify(value));
|
|
203
|
+
return {
|
|
204
|
+
...prev,
|
|
205
|
+
[item.key]: {
|
|
206
|
+
verdict: "pick_many",
|
|
207
|
+
value: has ? list.filter((v) => JSON.stringify(v) !== JSON.stringify(value)) : [...list, value]
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return { ...prev, [item.key]: { verdict: "pick_one", value } };
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
const submit = () => {
|
|
215
|
+
if (!ready || sending) return;
|
|
216
|
+
onSubmit(decisionResumeWithSettled(spec, sendAnswers, settledKeys));
|
|
217
|
+
};
|
|
218
|
+
const onKeyDown = (event) => {
|
|
219
|
+
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
|
|
220
|
+
event.preventDefault();
|
|
221
|
+
submit();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const status = blockers.missingRequired.length > 0 ? `Needed: ${blockers.missingRequired.join(", ")}` : blockers.needMore > 0 ? `Answer ${blockers.needMore} more` : confirmingRest > 0 && confirmingRest < openSpec.items.length ? `${confirmingRest} unanswered ${confirmingRest === 1 ? "suggestion is" : "suggestions are"} confirmed as written` : null;
|
|
225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-decision-gate": true, onKeyDown, className: "mt-2", children: [
|
|
226
|
+
spec.seatNotice ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
227
|
+
"div",
|
|
228
|
+
{
|
|
229
|
+
"data-decision-seat": true,
|
|
230
|
+
className: (0, import_cn.cn)("mb-1.5 type-meta", spec.seatFilled ? "text-muted-foreground" : "text-destructive"),
|
|
231
|
+
children: spec.seatNotice
|
|
232
|
+
}
|
|
233
|
+
) : null,
|
|
234
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "divide-y divide-border overflow-hidden rounded-lg border border-border bg-card", children: spec.items.map((item) => {
|
|
235
|
+
const settledAs = settled?.[item.key];
|
|
236
|
+
if (settledAs) {
|
|
237
|
+
const settledText = decisionValueText(item.value);
|
|
238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { "data-decision-item": item.key, "data-decision-settled": true, className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-[11px] text-muted-foreground", children: item.label }),
|
|
241
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "whitespace-pre-wrap break-words text-sm text-foreground", children: settledText })
|
|
242
|
+
] }),
|
|
243
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground", children: [
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CheckIcon, { className: "size-3.5" }),
|
|
245
|
+
settledAs
|
|
246
|
+
] })
|
|
247
|
+
] }) }, item.key);
|
|
248
|
+
}
|
|
249
|
+
const answer = answers[item.key];
|
|
250
|
+
const verdict = answer?.verdict ?? null;
|
|
251
|
+
const pickVerdict = item.choices.find((c) => c === "pick_one" || c === "pick_many");
|
|
252
|
+
const shown = decisionValueText(item.value);
|
|
253
|
+
const meta = [item.source, confidenceText(item.confidence)].filter(Boolean).join(" \xB7 ");
|
|
254
|
+
const segments = item.choices.filter((c, _i, all) => !(c === "pick_many" && all.includes("pick_one"))).map((c) => ({ value: c, label: CHOICE_LABEL[c] }));
|
|
255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { "data-decision-item": item.key, className: "px-3 py-2", children: [
|
|
256
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3", children: [
|
|
257
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
258
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-start gap-1 text-xs text-muted-foreground", children: [
|
|
259
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: item.label }),
|
|
260
|
+
item.required ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-label": "required", children: "*" }) : null
|
|
261
|
+
] }),
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
263
|
+
"div",
|
|
264
|
+
{
|
|
265
|
+
className: (0, import_cn.cn)(
|
|
266
|
+
"whitespace-pre-wrap break-words text-sm",
|
|
267
|
+
shown ? "text-foreground" : "text-muted-foreground",
|
|
268
|
+
verdict === "not_true" && "line-through decoration-muted-foreground"
|
|
269
|
+
),
|
|
270
|
+
children: shown || "Nothing yet"
|
|
271
|
+
}
|
|
272
|
+
),
|
|
273
|
+
meta ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "line-clamp-2 text-[11px] text-muted-foreground", title: meta, children: meta }) : null
|
|
274
|
+
] }),
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
276
|
+
import_controls.SegmentedControl,
|
|
277
|
+
{
|
|
278
|
+
"aria-label": `${item.label}: your answer`,
|
|
279
|
+
value: verdict === "pick_many" && pickVerdict === "pick_one" ? "pick_one" : verdict,
|
|
280
|
+
onValueChange: (v) => choose(item, v === "pick_one" && pickVerdict ? pickVerdict : v),
|
|
281
|
+
data: segments,
|
|
282
|
+
className: "shrink-0 self-start sm:self-center"
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
] }),
|
|
286
|
+
verdict === "edit" || verdict === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
287
|
+
import_writing_field.ProInput,
|
|
288
|
+
{
|
|
289
|
+
className: "mt-1.5",
|
|
290
|
+
autoFocus: true,
|
|
291
|
+
"aria-label": `${item.label}: the right value`,
|
|
292
|
+
placeholder: Array.isArray(item.value) ? "Separate with commas" : item.label,
|
|
293
|
+
value: drafts[item.key] ?? "",
|
|
294
|
+
onChange: (event) => type(item, event.target.value)
|
|
295
|
+
}
|
|
296
|
+
) : null,
|
|
297
|
+
(verdict === "pick_one" || verdict === "pick_many") && item.options.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: item.options.map((option) => {
|
|
298
|
+
const on = Array.isArray(answer?.value) ? answer.value.some((v) => JSON.stringify(v) === JSON.stringify(option.value)) : JSON.stringify(answer?.value) === JSON.stringify(option.value);
|
|
299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.Chip, { label: option.label, pressed: on, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => pick(item, option.value) }) }, option.label);
|
|
300
|
+
}) }) : null
|
|
301
|
+
] }, item.key);
|
|
302
|
+
}) }),
|
|
303
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mt-2 flex items-center justify-end gap-2", children: [
|
|
304
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "min-w-0 flex-1 truncate text-[11px] text-muted-foreground", "aria-live": "polite", children: status ?? "" }),
|
|
305
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
306
|
+
import_controls.Button,
|
|
307
|
+
{
|
|
308
|
+
variant: "success",
|
|
309
|
+
disabled: !ready || sending,
|
|
310
|
+
icon: sending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.Loader2Icon, { className: "animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CheckIcon, {}),
|
|
311
|
+
onClick: submit,
|
|
312
|
+
"data-decision-submit": true,
|
|
313
|
+
children: spec.submitLabel
|
|
314
|
+
}
|
|
315
|
+
)
|
|
316
|
+
] })
|
|
317
|
+
] });
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=decision-gate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/decisionGateEntry.ts","../src/DecisionGate.tsx","../src/decision-gate.ts"],"sourcesContent":["// The human gate alone (records-ui light entry): a run's question renders it without loading the screens.\nexport { DecisionGate } from \"./DecisionGate\";\nexport {\n VALUE_VERDICTS,\n decisionAnswerComplete,\n decisionAnswersConfirmingRest,\n decisionBlockers,\n decisionResumeValue,\n decisionResumeWithSettled,\n decisionValueText,\n parseDecisionSpec,\n} from \"./decision-gate\";\nexport type { DecisionAnswer, DecisionChoice, DecisionItemView, DecisionSpecView } from \"./decision-gate\";\n","\"use client\";\n\n/**\n * THE HUMAN GATE — renders any `decision` spec (matrx_graph/decision_spec.py).\n *\n * One row per item: the question, what we believe (in full — never cut off), where it came\n * from, how sure we are, and the quick choices the item allows. The one button confirms\n * every untouched suggestion that can be confirmed, so \"Confirm all\" means what it says;\n * it stays off only while an item that cannot be confirmed is unanswered. The engine\n * re-validates anyway. Cmd/Ctrl+Enter submits. Rows stack on a phone.\n * Pure half: `decision-gate.ts`. Contract: common-docs/systems/workflows/human-gates/FEATURE.md.\n */\n\nimport { useState, type KeyboardEvent } from \"react\";\nimport { CheckIcon as Check, Loader2Icon as Loader2 } from \"@ai-matrx/design-system/icons\";\nimport { Button, Chip, SegmentedControl } from \"@ai-matrx/design-system/controls\";\nimport { ProInput } from \"@ai-matrx/design-system/writing-field\";\nimport { cn } from \"@ai-matrx/design-system/cn\";\nimport {\n VALUE_VERDICTS,\n decisionAnswersConfirmingRest,\n decisionBlockers,\n decisionResumeWithSettled,\n decisionValueText,\n type DecisionAnswer,\n type DecisionChoice,\n type DecisionItemView,\n type DecisionSpecView,\n} from \"./decision-gate\";\n\nconst CHOICE_LABEL: Record<DecisionChoice, string> = {\n confirm: \"Yes\",\n not_true: \"Not true\",\n edit: \"Edit\",\n pick_one: \"Pick\",\n pick_many: \"Pick\",\n custom: \"Other\",\n};\n\nfunction confidenceText(confidence: number | null): string | null {\n if (confidence === null) return null;\n return `${Math.round(confidence * 100)}% sure`;\n}\n\nfunction draftFor(item: DecisionItemView): string {\n return decisionValueText(item.value);\n}\n\n/** Text typed for a list-valued item becomes a list again (comma-separated). */\nfunction typedValue(item: DecisionItemView, text: string): unknown {\n if (Array.isArray(item.value)) {\n return text\n .split(\",\")\n .map((part) => part.trim())\n .filter(Boolean);\n }\n return text;\n}\n\nexport function DecisionGate({\n spec,\n sending,\n onSubmit,\n settled,\n}: {\n spec: DecisionSpecView;\n sending: boolean;\n onSubmit: (resumeValue: Record<string, unknown>) => void;\n /** Items the host knows the person already decided elsewhere ({key: why}): shown settled, never asked. */\n settled?: Record<string, string>;\n}) {\n const [answers, setAnswers] = useState<Record<string, DecisionAnswer>>({});\n const [drafts, setDrafts] = useState<Record<string, string>>({});\n const settledKeys = spec.items.filter((i) => settled?.[i.key]).map((i) => i.key);\n // A settled item counts as answered: the engine gets its \"confirm\" only when it needs one (decisionResumeWithSettled).\n const openSpec = {\n ...spec,\n items: spec.items.filter((i) => !settledKeys.includes(i.key)),\n minAnswers: Math.max(0, spec.minAnswers - settledKeys.length),\n };\n // The button confirms every untouched suggestion that can be confirmed.\n const sendAnswers = decisionAnswersConfirmingRest(openSpec, answers);\n const confirmingRest = openSpec.items.filter((i) => !answers[i.key] && sendAnswers[i.key]).length;\n const blockers = decisionBlockers(openSpec, sendAnswers);\n const ready = blockers.missingRequired.length === 0 && blockers.needMore === 0;\n\n const choose = (item: DecisionItemView, verdict: DecisionChoice) => {\n setAnswers((prev) => {\n const next = { ...prev };\n if (verdict === \"edit\" || verdict === \"custom\") {\n const text = drafts[item.key] ?? (verdict === \"edit\" ? draftFor(item) : \"\");\n next[item.key] = { verdict, value: typedValue(item, text) };\n } else if (verdict === \"pick_one\" || verdict === \"pick_many\") {\n next[item.key] = { verdict, value: verdict === \"pick_many\" ? [] : undefined };\n } else {\n next[item.key] = { verdict };\n }\n return next;\n });\n if (verdict === \"edit\") {\n setDrafts((prev) => (item.key in prev ? prev : { ...prev, [item.key]: draftFor(item) }));\n }\n };\n\n const type = (item: DecisionItemView, text: string) => {\n setDrafts((prev) => ({ ...prev, [item.key]: text }));\n setAnswers((prev) => {\n const current = prev[item.key];\n if (!current || !VALUE_VERDICTS.has(current.verdict)) return prev;\n return { ...prev, [item.key]: { verdict: current.verdict, value: typedValue(item, text) } };\n });\n };\n\n const pick = (item: DecisionItemView, value: unknown) => {\n setAnswers((prev) => {\n const current = prev[item.key];\n if (current?.verdict === \"pick_many\") {\n const list = Array.isArray(current.value) ? current.value : [];\n const has = list.some((v) => JSON.stringify(v) === JSON.stringify(value));\n return {\n ...prev,\n [item.key]: {\n verdict: \"pick_many\",\n value: has ? list.filter((v) => JSON.stringify(v) !== JSON.stringify(value)) : [...list, value],\n },\n };\n }\n return { ...prev, [item.key]: { verdict: \"pick_one\", value } };\n });\n };\n\n const submit = () => {\n if (!ready || sending) return;\n onSubmit(decisionResumeWithSettled(spec, sendAnswers, settledKeys));\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\" && (event.metaKey || event.ctrlKey)) {\n event.preventDefault();\n submit();\n }\n };\n\n const status = blockers.missingRequired.length > 0\n ? `Needed: ${blockers.missingRequired.join(\", \")}`\n : blockers.needMore > 0\n ? `Answer ${blockers.needMore} more`\n : confirmingRest > 0 && confirmingRest < openSpec.items.length\n ? `${confirmingRest} unanswered ${confirmingRest === 1 ? \"suggestion is\" : \"suggestions are\"} confirmed as written`\n : null;\n\n return (\n <div data-decision-gate onKeyDown={onKeyDown} className=\"mt-2\">\n {spec.seatNotice ? (\n <div\n data-decision-seat\n className={cn(\"mb-1.5 type-meta\", spec.seatFilled ? \"text-muted-foreground\" : \"text-destructive\")}\n >\n {spec.seatNotice}\n </div>\n ) : null}\n <ul className=\"divide-y divide-border overflow-hidden rounded-lg border border-border bg-card\">\n {spec.items.map((item) => {\n const settledAs = settled?.[item.key];\n if (settledAs) {\n const settledText = decisionValueText(item.value);\n return (\n <li key={item.key} data-decision-item={item.key} data-decision-settled className=\"px-3 py-2\">\n <div className=\"flex items-center gap-3\">\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[11px] text-muted-foreground\">{item.label}</div>\n <div className=\"whitespace-pre-wrap break-words text-sm text-foreground\">\n {settledText}\n </div>\n </div>\n <span className=\"inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground\">\n <Check className=\"size-3.5\" />\n {settledAs}\n </span>\n </div>\n </li>\n );\n }\n const answer = answers[item.key];\n const verdict = answer?.verdict ?? null;\n const pickVerdict = item.choices.find((c) => c === \"pick_one\" || c === \"pick_many\");\n const shown = decisionValueText(item.value);\n const meta = [item.source, confidenceText(item.confidence)].filter(Boolean).join(\" · \");\n const segments = item.choices\n .filter((c, _i, all) => !(c === \"pick_many\" && all.includes(\"pick_one\")))\n .map((c) => ({ value: c, label: CHOICE_LABEL[c] }));\n return (\n <li key={item.key} data-decision-item={item.key} className=\"px-3 py-2\">\n <div className=\"flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3\">\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-start gap-1 text-xs text-muted-foreground\">\n <span>{item.label}</span>\n {item.required ? <span aria-label=\"required\">*</span> : null}\n </div>\n <div\n className={cn(\n \"whitespace-pre-wrap break-words text-sm\",\n shown ? \"text-foreground\" : \"text-muted-foreground\",\n verdict === \"not_true\" && \"line-through decoration-muted-foreground\",\n )}\n >\n {shown || \"Nothing yet\"}\n </div>\n {meta ? <div className=\"line-clamp-2 text-[11px] text-muted-foreground\" title={meta}>{meta}</div> : null}\n </div>\n <SegmentedControl<DecisionChoice>\n aria-label={`${item.label}: your answer`}\n value={verdict === \"pick_many\" && pickVerdict === \"pick_one\" ? \"pick_one\" : verdict}\n onValueChange={(v) => choose(item, v === \"pick_one\" && pickVerdict ? pickVerdict : v)}\n data={segments}\n className=\"shrink-0 self-start sm:self-center\"\n />\n </div>\n {verdict === \"edit\" || verdict === \"custom\" ? (\n <ProInput\n className=\"mt-1.5\"\n autoFocus\n aria-label={`${item.label}: the right value`}\n placeholder={Array.isArray(item.value) ? \"Separate with commas\" : item.label}\n value={drafts[item.key] ?? \"\"}\n onChange={(event) => type(item, event.target.value)}\n />\n ) : null}\n {(verdict === \"pick_one\" || verdict === \"pick_many\") && item.options.length > 0 ? (\n <div className=\"mt-1.5 flex flex-wrap gap-1.5\">\n {item.options.map((option) => {\n const on = Array.isArray(answer?.value)\n ? answer.value.some((v) => JSON.stringify(v) === JSON.stringify(option.value))\n : JSON.stringify(answer?.value) === JSON.stringify(option.value);\n return (\n <Chip key={option.label} label={option.label} pressed={on} asChild>\n <button type=\"button\" onClick={() => pick(item, option.value)} />\n </Chip>\n );\n })}\n </div>\n ) : null}\n </li>\n );\n })}\n </ul>\n <div className=\"mt-2 flex items-center justify-end gap-2\">\n <span className=\"min-w-0 flex-1 truncate text-[11px] text-muted-foreground\" aria-live=\"polite\">\n {status ?? \"\"}\n </span>\n <Button\n variant=\"success\"\n disabled={!ready || sending}\n icon={sending ? <Loader2 className=\"animate-spin\" /> : <Check />}\n onClick={submit}\n data-decision-submit\n >\n {spec.submitLabel}\n </Button>\n </div>\n </div>\n );\n}\n","/**\n * THE HUMAN GATE — the pure half (preset `decision`, matrx_graph/decision_spec.py).\n *\n * Reads a `decision` spec off a run's question, says what still blocks it, and builds the\n * resume body the engine validates. No React, no network. The component is `DecisionGate`;\n * hosts: matrx-frontend's run pages and record panels, and workflow-studio's question form.\n * Contract: common-docs/systems/workflows/human-gates/FEATURE.md.\n */\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction str(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nexport type DecisionChoice = \"confirm\" | \"not_true\" | \"edit\" | \"pick_one\" | \"pick_many\" | \"custom\";\nconst CHOICES: ReadonlySet<string> = new Set([\"confirm\", \"not_true\", \"edit\", \"pick_one\", \"pick_many\", \"custom\"]);\n/** Verdicts that carry a value the person typed or picked. */\nexport const VALUE_VERDICTS: ReadonlySet<DecisionChoice> = new Set([\"edit\", \"pick_one\", \"pick_many\", \"custom\"]);\n\nexport interface DecisionItemView {\n key: string;\n label: string;\n value: unknown;\n source: string | null;\n /** 0..1, or null when nobody measured it. */\n confidence: number | null;\n choices: DecisionChoice[];\n options: { value: unknown; label: string }[];\n required: boolean;\n}\n\nexport interface DecisionSpecView {\n items: DecisionItemView[];\n minAnswers: number;\n submitLabel: string;\n /** A gate addressed to an org-chart seat: the engine's words for who it asks\n * (\"Waiting on Arman (Brand owner)\" / \"No one holds Brand owner\"). */\n seatNotice: string | null;\n /** False when nobody held the seat as the gate opened. */\n seatFilled: boolean;\n}\n\n/** One person's answer to one item — the wire shape the engine validates. */\nexport interface DecisionAnswer {\n verdict: DecisionChoice;\n value?: unknown;\n}\n\nexport function parseDecisionSpec(raw: unknown): DecisionSpecView | null {\n if (!isRecord(raw) || !Array.isArray(raw.items)) return null;\n const items: DecisionItemView[] = [];\n for (const entry of raw.items) {\n if (!isRecord(entry)) continue;\n const key = str(entry.key).trim();\n if (!key) continue;\n const choices = (Array.isArray(entry.choices) ? entry.choices : [\"confirm\", \"not_true\", \"edit\"])\n .filter((c): c is DecisionChoice => typeof c === \"string\" && CHOICES.has(c));\n items.push({\n key,\n label: str(entry.label).trim() || key,\n value: entry.value ?? null,\n source: str(entry.source).trim() || null,\n confidence: typeof entry.confidence === \"number\" ? entry.confidence : null,\n choices: choices.length > 0 ? choices : [\"confirm\"],\n options: (Array.isArray(entry.options) ? entry.options : [])\n .filter(isRecord)\n .map((o) => ({ value: o.value ?? null, label: str(o.label) || String(o.value ?? \"\") })),\n required: entry.required === true,\n });\n }\n if (items.length === 0) return null;\n return {\n items,\n minAnswers: typeof raw.min_answers === \"number\" ? raw.min_answers : 0,\n submitLabel: str(raw.submit_label).trim() || \"Confirm\",\n seatNotice: isRecord(raw.seat) ? str(raw.seat.notice).trim() || null : null,\n seatFilled: !isRecord(raw.seat) || raw.seat.filled !== false,\n };\n}\n\n/** True when the answer is complete enough for the engine to accept it. */\nexport function decisionAnswerComplete(answer: DecisionAnswer | undefined): boolean {\n if (!answer) return false;\n if (!VALUE_VERDICTS.has(answer.verdict)) return true;\n const v = answer.value;\n if (Array.isArray(v)) return v.length > 0;\n if (typeof v === \"string\") return v.trim().length > 0;\n return v !== undefined && v !== null;\n}\n\n/** What still blocks the gate: unanswered required items and the minimum. Empty = ready. */\nexport function decisionBlockers(\n spec: DecisionSpecView,\n answers: Record<string, DecisionAnswer>,\n): { missingRequired: string[]; needMore: number } {\n const done = spec.items.filter((i) => decisionAnswerComplete(answers[i.key]));\n return {\n missingRequired: spec.items\n .filter((i) => i.required && !decisionAnswerComplete(answers[i.key]))\n .map((i) => i.label),\n needMore: Math.max(0, spec.minAnswers - done.length),\n };\n}\n\n/** The resume body — only complete answers travel; the engine re-validates all of it. */\nexport function decisionResumeValue(\n spec: DecisionSpecView,\n answers: Record<string, DecisionAnswer>,\n): Record<string, unknown> {\n const out: Record<string, DecisionAnswer> = {};\n for (const item of spec.items) {\n const a = answers[item.key];\n if (!decisionAnswerComplete(a) || !a) continue;\n out[item.key] = VALUE_VERDICTS.has(a.verdict) ? { verdict: a.verdict, value: a.value } : { verdict: a.verdict };\n }\n return { answer: { answers: out } };\n}\n\n/**\n * The resume body when some items are already settled by the host (the person decided them elsewhere): a settled\n * item travels only when the engine needs it — a required one, or to reach the gate's minimum — and then as the\n * plain \"confirm\" its value already stands for. Nothing settled is written again otherwise.\n */\nexport function decisionResumeWithSettled(\n spec: DecisionSpecView,\n answers: Record<string, DecisionAnswer>,\n settledKeys: readonly string[],\n): Record<string, unknown> {\n const settled = new Set(settledKeys);\n const open = { ...spec, items: spec.items.filter((i) => !settled.has(i.key)) };\n const body = decisionResumeValue(open, answers) as { answer: { answers: Record<string, DecisionAnswer> } };\n const out = body.answer.answers;\n for (const item of spec.items) {\n if (!settled.has(item.key) || !item.choices.includes(\"confirm\")) continue;\n if (item.required || Object.keys(out).length < spec.minAnswers) out[item.key] = { verdict: \"confirm\" };\n }\n return body;\n}\n\n/** A believed value as one line of text. */\nexport function decisionValueText(value: unknown): string {\n if (value === null || value === undefined || value === \"\") return \"\";\n if (Array.isArray(value)) return value.map((v) => decisionValueText(v)).filter(Boolean).join(\", \");\n if (isRecord(value)) return str(value.name) || str(value.label) || JSON.stringify(value);\n return String(value);\n}\n\n/**\n * The answers \"Confirm all\" sends: everything the person answered, plus a plain confirm for\n * every untouched item that offers one — so the one button means what it says.\n */\nexport function decisionAnswersConfirmingRest(\n spec: DecisionSpecView,\n answers: Record<string, DecisionAnswer>,\n skipKeys: readonly string[] = [],\n): Record<string, DecisionAnswer> {\n const skip = new Set(skipKeys);\n const out = { ...answers };\n for (const item of spec.items) {\n if (skip.has(item.key) || out[item.key] || !item.choices.includes(\"confirm\")) continue;\n out[item.key] = { verdict: \"confirm\" };\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaA,mBAA6C;AAC7C,mBAA2D;AAC3D,sBAA+C;AAC/C,2BAAyB;AACzB,gBAAmB;;;ACRnB,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,IAAI,OAAwB;AACnC,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;AAGA,IAAM,UAA+B,oBAAI,IAAI,CAAC,WAAW,YAAY,QAAQ,YAAY,aAAa,QAAQ,CAAC;AAExG,IAAM,iBAA8C,oBAAI,IAAI,CAAC,QAAQ,YAAY,aAAa,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,6DAA4D,aAAU,UACnF,oBAAU,IACb;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,UAAU,CAAC,SAAS;AAAA,UACpB,MAAM,UAAU,4CAAC,aAAAC,aAAA,EAAQ,WAAU,gBAAe,IAAK,4CAAC,aAAAD,WAAA,EAAM;AAAA,UAC9D,SAAS;AAAA,UACT,wBAAoB;AAAA,UAEnB,eAAK;AAAA;AAAA,MACR;AAAA,OACF;AAAA,KACF;AAEJ;","names":["Check","Loader2"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* THE HUMAN GATE — the pure half (preset `decision`, matrx_graph/decision_spec.py).
|
|
5
|
+
*
|
|
6
|
+
* Reads a `decision` spec off a run's question, says what still blocks it, and builds the
|
|
7
|
+
* resume body the engine validates. No React, no network. The component is `DecisionGate`;
|
|
8
|
+
* hosts: matrx-frontend's run pages and record panels, and workflow-studio's question form.
|
|
9
|
+
* Contract: common-docs/systems/workflows/human-gates/FEATURE.md.
|
|
10
|
+
*/
|
|
11
|
+
type DecisionChoice = "confirm" | "not_true" | "edit" | "pick_one" | "pick_many" | "custom";
|
|
12
|
+
/** Verdicts that carry a value the person typed or picked. */
|
|
13
|
+
declare const VALUE_VERDICTS: ReadonlySet<DecisionChoice>;
|
|
14
|
+
interface DecisionItemView {
|
|
15
|
+
key: string;
|
|
16
|
+
label: string;
|
|
17
|
+
value: unknown;
|
|
18
|
+
source: string | null;
|
|
19
|
+
/** 0..1, or null when nobody measured it. */
|
|
20
|
+
confidence: number | null;
|
|
21
|
+
choices: DecisionChoice[];
|
|
22
|
+
options: {
|
|
23
|
+
value: unknown;
|
|
24
|
+
label: string;
|
|
25
|
+
}[];
|
|
26
|
+
required: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface DecisionSpecView {
|
|
29
|
+
items: DecisionItemView[];
|
|
30
|
+
minAnswers: number;
|
|
31
|
+
submitLabel: string;
|
|
32
|
+
/** A gate addressed to an org-chart seat: the engine's words for who it asks
|
|
33
|
+
* ("Waiting on Arman (Brand owner)" / "No one holds Brand owner"). */
|
|
34
|
+
seatNotice: string | null;
|
|
35
|
+
/** False when nobody held the seat as the gate opened. */
|
|
36
|
+
seatFilled: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** One person's answer to one item — the wire shape the engine validates. */
|
|
39
|
+
interface DecisionAnswer {
|
|
40
|
+
verdict: DecisionChoice;
|
|
41
|
+
value?: unknown;
|
|
42
|
+
}
|
|
43
|
+
declare function parseDecisionSpec(raw: unknown): DecisionSpecView | null;
|
|
44
|
+
/** True when the answer is complete enough for the engine to accept it. */
|
|
45
|
+
declare function decisionAnswerComplete(answer: DecisionAnswer | undefined): boolean;
|
|
46
|
+
/** What still blocks the gate: unanswered required items and the minimum. Empty = ready. */
|
|
47
|
+
declare function decisionBlockers(spec: DecisionSpecView, answers: Record<string, DecisionAnswer>): {
|
|
48
|
+
missingRequired: string[];
|
|
49
|
+
needMore: number;
|
|
50
|
+
};
|
|
51
|
+
/** The resume body — only complete answers travel; the engine re-validates all of it. */
|
|
52
|
+
declare function decisionResumeValue(spec: DecisionSpecView, answers: Record<string, DecisionAnswer>): Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* The resume body when some items are already settled by the host (the person decided them elsewhere): a settled
|
|
55
|
+
* item travels only when the engine needs it — a required one, or to reach the gate's minimum — and then as the
|
|
56
|
+
* plain "confirm" its value already stands for. Nothing settled is written again otherwise.
|
|
57
|
+
*/
|
|
58
|
+
declare function decisionResumeWithSettled(spec: DecisionSpecView, answers: Record<string, DecisionAnswer>, settledKeys: readonly string[]): Record<string, unknown>;
|
|
59
|
+
/** A believed value as one line of text. */
|
|
60
|
+
declare function decisionValueText(value: unknown): string;
|
|
61
|
+
/**
|
|
62
|
+
* The answers "Confirm all" sends: everything the person answered, plus a plain confirm for
|
|
63
|
+
* every untouched item that offers one — so the one button means what it says.
|
|
64
|
+
*/
|
|
65
|
+
declare function decisionAnswersConfirmingRest(spec: DecisionSpecView, answers: Record<string, DecisionAnswer>, skipKeys?: readonly string[]): Record<string, DecisionAnswer>;
|
|
66
|
+
|
|
67
|
+
declare function DecisionGate({ spec, sending, onSubmit, settled, }: {
|
|
68
|
+
spec: DecisionSpecView;
|
|
69
|
+
sending: boolean;
|
|
70
|
+
onSubmit: (resumeValue: Record<string, unknown>) => void;
|
|
71
|
+
/** Items the host knows the person already decided elsewhere ({key: why}): shown settled, never asked. */
|
|
72
|
+
settled?: Record<string, string>;
|
|
73
|
+
}): react.JSX.Element;
|
|
74
|
+
|
|
75
|
+
export { DecisionGate, VALUE_VERDICTS, decisionAnswerComplete, decisionAnswersConfirmingRest, decisionBlockers, decisionResumeValue, decisionResumeWithSettled, decisionValueText, parseDecisionSpec };
|
|
76
|
+
export type { DecisionAnswer, DecisionChoice, DecisionItemView, DecisionSpecView };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* THE HUMAN GATE — the pure half (preset `decision`, matrx_graph/decision_spec.py).
|
|
5
|
+
*
|
|
6
|
+
* Reads a `decision` spec off a run's question, says what still blocks it, and builds the
|
|
7
|
+
* resume body the engine validates. No React, no network. The component is `DecisionGate`;
|
|
8
|
+
* hosts: matrx-frontend's run pages and record panels, and workflow-studio's question form.
|
|
9
|
+
* Contract: common-docs/systems/workflows/human-gates/FEATURE.md.
|
|
10
|
+
*/
|
|
11
|
+
type DecisionChoice = "confirm" | "not_true" | "edit" | "pick_one" | "pick_many" | "custom";
|
|
12
|
+
/** Verdicts that carry a value the person typed or picked. */
|
|
13
|
+
declare const VALUE_VERDICTS: ReadonlySet<DecisionChoice>;
|
|
14
|
+
interface DecisionItemView {
|
|
15
|
+
key: string;
|
|
16
|
+
label: string;
|
|
17
|
+
value: unknown;
|
|
18
|
+
source: string | null;
|
|
19
|
+
/** 0..1, or null when nobody measured it. */
|
|
20
|
+
confidence: number | null;
|
|
21
|
+
choices: DecisionChoice[];
|
|
22
|
+
options: {
|
|
23
|
+
value: unknown;
|
|
24
|
+
label: string;
|
|
25
|
+
}[];
|
|
26
|
+
required: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface DecisionSpecView {
|
|
29
|
+
items: DecisionItemView[];
|
|
30
|
+
minAnswers: number;
|
|
31
|
+
submitLabel: string;
|
|
32
|
+
/** A gate addressed to an org-chart seat: the engine's words for who it asks
|
|
33
|
+
* ("Waiting on Arman (Brand owner)" / "No one holds Brand owner"). */
|
|
34
|
+
seatNotice: string | null;
|
|
35
|
+
/** False when nobody held the seat as the gate opened. */
|
|
36
|
+
seatFilled: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** One person's answer to one item — the wire shape the engine validates. */
|
|
39
|
+
interface DecisionAnswer {
|
|
40
|
+
verdict: DecisionChoice;
|
|
41
|
+
value?: unknown;
|
|
42
|
+
}
|
|
43
|
+
declare function parseDecisionSpec(raw: unknown): DecisionSpecView | null;
|
|
44
|
+
/** True when the answer is complete enough for the engine to accept it. */
|
|
45
|
+
declare function decisionAnswerComplete(answer: DecisionAnswer | undefined): boolean;
|
|
46
|
+
/** What still blocks the gate: unanswered required items and the minimum. Empty = ready. */
|
|
47
|
+
declare function decisionBlockers(spec: DecisionSpecView, answers: Record<string, DecisionAnswer>): {
|
|
48
|
+
missingRequired: string[];
|
|
49
|
+
needMore: number;
|
|
50
|
+
};
|
|
51
|
+
/** The resume body — only complete answers travel; the engine re-validates all of it. */
|
|
52
|
+
declare function decisionResumeValue(spec: DecisionSpecView, answers: Record<string, DecisionAnswer>): Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* The resume body when some items are already settled by the host (the person decided them elsewhere): a settled
|
|
55
|
+
* item travels only when the engine needs it — a required one, or to reach the gate's minimum — and then as the
|
|
56
|
+
* plain "confirm" its value already stands for. Nothing settled is written again otherwise.
|
|
57
|
+
*/
|
|
58
|
+
declare function decisionResumeWithSettled(spec: DecisionSpecView, answers: Record<string, DecisionAnswer>, settledKeys: readonly string[]): Record<string, unknown>;
|
|
59
|
+
/** A believed value as one line of text. */
|
|
60
|
+
declare function decisionValueText(value: unknown): string;
|
|
61
|
+
/**
|
|
62
|
+
* The answers "Confirm all" sends: everything the person answered, plus a plain confirm for
|
|
63
|
+
* every untouched item that offers one — so the one button means what it says.
|
|
64
|
+
*/
|
|
65
|
+
declare function decisionAnswersConfirmingRest(spec: DecisionSpecView, answers: Record<string, DecisionAnswer>, skipKeys?: readonly string[]): Record<string, DecisionAnswer>;
|
|
66
|
+
|
|
67
|
+
declare function DecisionGate({ spec, sending, onSubmit, settled, }: {
|
|
68
|
+
spec: DecisionSpecView;
|
|
69
|
+
sending: boolean;
|
|
70
|
+
onSubmit: (resumeValue: Record<string, unknown>) => void;
|
|
71
|
+
/** Items the host knows the person already decided elsewhere ({key: why}): shown settled, never asked. */
|
|
72
|
+
settled?: Record<string, string>;
|
|
73
|
+
}): react.JSX.Element;
|
|
74
|
+
|
|
75
|
+
export { DecisionGate, VALUE_VERDICTS, decisionAnswerComplete, decisionAnswersConfirmingRest, decisionBlockers, decisionResumeValue, decisionResumeWithSettled, decisionValueText, parseDecisionSpec };
|
|
76
|
+
export type { DecisionAnswer, DecisionChoice, DecisionItemView, DecisionSpecView };
|