flowstatemcp 2.5.0__py3-none-any.whl
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.
- flowstate/__init__.py +34 -0
- flowstate/__main__.py +7 -0
- flowstate/activity.py +224 -0
- flowstate/agent_guide.py +251 -0
- flowstate/app_keys.py +141 -0
- flowstate/approvals.py +974 -0
- flowstate/approve_page.py +565 -0
- flowstate/ask.py +107 -0
- flowstate/autosession.py +480 -0
- flowstate/backup.py +201 -0
- flowstate/brief.py +420 -0
- flowstate/card_offer.py +208 -0
- flowstate/card_taps.py +165 -0
- flowstate/card_trust.py +127 -0
- flowstate/claims.py +461 -0
- flowstate/cleanup.py +619 -0
- flowstate/cli.py +728 -0
- flowstate/cli_data.py +434 -0
- flowstate/cli_more.py +302 -0
- flowstate/cli_review.py +459 -0
- flowstate/cloudflared_check.py +49 -0
- flowstate/conflict_card_ui.py +286 -0
- flowstate/conflict_cards.py +1193 -0
- flowstate/conflict_reopen.py +320 -0
- flowstate/conflicts.py +420 -0
- flowstate/connections.py +33 -0
- flowstate/database.py +2191 -0
- flowstate/dbconn.py +308 -0
- flowstate/deletes.py +860 -0
- flowstate/embeddings.py +354 -0
- flowstate/erase.py +1047 -0
- flowstate/extras.py +71 -0
- flowstate/git_capture.py +157 -0
- flowstate/guard.py +224 -0
- flowstate/handoffs.py +168 -0
- flowstate/history.py +755 -0
- flowstate/history_page.py +276 -0
- flowstate/http_app.py +204 -0
- flowstate/identity.py +387 -0
- flowstate/install_name.py +140 -0
- flowstate/ledger.py +272 -0
- flowstate/legacy_args.py +65 -0
- flowstate/links.py +609 -0
- flowstate/markdown_io.py +242 -0
- flowstate/meaning.py +398 -0
- flowstate/memory_import.py +92 -0
- flowstate/migrations/001_auto_sessions.sql +16 -0
- flowstate/migrations/002_review_queue.sql +33 -0
- flowstate/migrations/003_links.sql +47 -0
- flowstate/migrations/004_review_mode.sql +24 -0
- flowstate/migrations/005_history.sql +21 -0
- flowstate/migrations/006_activity.sql +26 -0
- flowstate/migrations/007_meaning_index.sql +16 -0
- flowstate/migrations/008_git_capture.sql +12 -0
- flowstate/migrations/009_hard_rules.sql +13 -0
- flowstate/migrations/010_handoffs.sql +14 -0
- flowstate/migrations/011_record_meta.sql +13 -0
- flowstate/migrations/012_accountability.sql +71 -0
- flowstate/migrations/013_todo_claims.sql +36 -0
- flowstate/migrations/014_decision_conflicts.sql +41 -0
- flowstate/migrations/015_session_runs.sql +17 -0
- flowstate/migrations/016_write_receipts.sql +35 -0
- flowstate/migrations/017_run_views.sql +26 -0
- flowstate/migrations/018_run_views_upto.sql +4 -0
- flowstate/migrations/019_approvals.sql +47 -0
- flowstate/migrations/020_source_stamps.sql +10 -0
- flowstate/migrations/021_review_links.sql +11 -0
- flowstate/migrations/022_review_start_tickets.sql +10 -0
- flowstate/migrations/023_conflict_cards.sql +68 -0
- flowstate/migrations/024_rule_confirmations.sql +7 -0
- flowstate/migrations/025_confirmed_hash.sql +7 -0
- flowstate/migrations/__init__.py +149 -0
- flowstate/models.py +307 -0
- flowstate/names.py +157 -0
- flowstate/offsite.py +386 -0
- flowstate/offsite_crypto.py +272 -0
- flowstate/paths.py +265 -0
- flowstate/popup.py +238 -0
- flowstate/priority.py +66 -0
- flowstate/privatefs.py +476 -0
- flowstate/project_history.py +710 -0
- flowstate/provenance.py +696 -0
- flowstate/receipts.py +377 -0
- flowstate/relay/__init__.py +72 -0
- flowstate/relay/acme.py +271 -0
- flowstate/relay/api.py +164 -0
- flowstate/relay/cli.py +344 -0
- flowstate/relay/crypto.py +137 -0
- flowstate/relay/ct.py +118 -0
- flowstate/relay/runner.py +177 -0
- flowstate/relay/store.py +191 -0
- flowstate/relay/tunnel.py +413 -0
- flowstate/release_signers +14 -0
- flowstate/remote_auth.py +1219 -0
- flowstate/review.py +320 -0
- flowstate/review_apply.py +140 -0
- flowstate/review_card_ui.py +241 -0
- flowstate/review_cards.py +564 -0
- flowstate/review_mode.py +274 -0
- flowstate/review_page.py +1361 -0
- flowstate/review_phone.py +465 -0
- flowstate/review_tunnel.py +338 -0
- flowstate/routing.py +392 -0
- flowstate/rules.py +418 -0
- flowstate/safety.py +98 -0
- flowstate/saves.py +83 -0
- flowstate/scheduler.py +160 -0
- flowstate/schema.sql +713 -0
- flowstate/search.py +355 -0
- flowstate/secret_store.py +271 -0
- flowstate/secrets_scan.py +135 -0
- flowstate/selfupdate.py +1020 -0
- flowstate/server.py +1299 -0
- flowstate/session_contents.py +382 -0
- flowstate/session_records.py +629 -0
- flowstate/site_style.py +46 -0
- flowstate/stored.py +158 -0
- flowstate/story.py +442 -0
- flowstate/surface.py +173 -0
- flowstate/tasks.py +231 -0
- flowstate/term.py +40 -0
- flowstate/tool_labels.py +104 -0
- flowstate/tooldefs.py +383 -0
- flowstate/tools/__init__.py +118 -0
- flowstate/tools/core.py +545 -0
- flowstate/tools/files.py +416 -0
- flowstate/tools/git_ops.py +1081 -0
- flowstate/tools/intelligence.py +376 -0
- flowstate/tools/learning.py +282 -0
- flowstate/tools/problems.py +159 -0
- flowstate/tools/sessions.py +266 -0
- flowstate/tools/story.py +48 -0
- flowstate/tools/todos.py +79 -0
- flowstate/tools/utils.py +71 -0
- flowstate/tools/variables.py +345 -0
- flowstate/updates.py +482 -0
- flowstate/urls.py +7 -0
- flowstate/waiting.py +828 -0
- flowstate/who.py +302 -0
- flowstatemcp-2.5.0.dist-info/METADATA +88 -0
- flowstatemcp-2.5.0.dist-info/RECORD +143 -0
- flowstatemcp-2.5.0.dist-info/WHEEL +4 -0
- flowstatemcp-2.5.0.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"""The in-chat review card (MCP Apps, spec 2026-01-26).
|
|
2
|
+
|
|
3
|
+
Its own ui:// document, next to the conflict card's: a review item has two outcomes
|
|
4
|
+
(Approve, Reject with an optional reason), a disagreement has four, and keeping the two
|
|
5
|
+
documents apart leaves the conflict card exactly as it was. Both share one page frame
|
|
6
|
+
(conflict_card_ui.document: styles, dark theme, the ui/initialize handshake, size reports).
|
|
7
|
+
|
|
8
|
+
The host loads it when show_review_card is called (that tool's definition names it) and passes
|
|
9
|
+
the result's structuredContent ({cards: [...], more, note}). Buttons call resolve_review_card
|
|
10
|
+
with tools/call through the host (a session summary's records each have Keep / Remove /
|
|
11
|
+
Bring back too: the same tool, decision keep_record / remove_record / restore_record). A card with decide_here false (an item only the user
|
|
12
|
+
decides on their phone or review page) has no buttons. Nothing is loaded from the network,
|
|
13
|
+
and memory text is written with textContent.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from .conflict_card_ui import MIME, UI_META, document # noqa: F401 - MIME, UI_META re-exported
|
|
17
|
+
|
|
18
|
+
UI_URI = "ui://flowstate/review-card.html"
|
|
19
|
+
|
|
20
|
+
REVIEW_CSS = r""".item{border:1px solid var(--line);border-radius:12px;padding:12px 14px;background:var(--card)}
|
|
21
|
+
.kind{font-size:13px;letter-spacing:.08em;text-transform:uppercase;color:var(--accent);margin:0 0 4px}
|
|
22
|
+
.text{margin:0 0 8px;overflow-wrap:anywhere}
|
|
23
|
+
.details{margin:0 0 8px;color:var(--muted);font-size:14px;overflow-wrap:anywhere;white-space:pre-line}
|
|
24
|
+
.change{margin:0 0 8px;font-size:14px;overflow-wrap:anywhere}
|
|
25
|
+
.warn{margin:0 0 8px;font-weight:600;color:var(--danger,#8a2d22);overflow-wrap:anywhere}
|
|
26
|
+
.who{color:var(--muted);font-size:14px;margin:0}
|
|
27
|
+
.saved{margin:0 0 8px;padding-left:18px}.saved li{margin:6px 0;overflow-wrap:anywhere}
|
|
28
|
+
.saved .ex{color:var(--muted);font-size:14px;margin:2px 0 0}
|
|
29
|
+
.sess{color:var(--muted);font-size:14px;margin:0 0 6px}
|
|
30
|
+
.does{color:var(--muted);font-size:14px;margin:12px 0 0}
|
|
31
|
+
.state{display:inline-block;margin-left:8px;font-size:12px;border:1px solid var(--line);border-radius:999px;padding:0 8px;color:var(--accent)}
|
|
32
|
+
.state.st-removed,.state.st-gone{color:var(--danger,#8a2d22)}.state.st-changed{color:var(--muted)}
|
|
33
|
+
.recrow{display:flex;gap:8px;margin:6px 0 2px}.recrow button{min-height:36px;padding:4px 14px;font-size:14px}
|
|
34
|
+
.locked{margin:12px 0 0}
|
|
35
|
+
.link{overflow-wrap:anywhere;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:14px}
|
|
36
|
+
.why{display:flex;flex-direction:column;gap:6px;margin-top:14px}
|
|
37
|
+
.why label{font-size:14px;color:var(--muted)}
|
|
38
|
+
.why input{font:inherit;padding:10px 12px;border-radius:10px;border:1px solid var(--line);
|
|
39
|
+
background:var(--card);color:var(--ink);min-height:44px;width:100%}"""
|
|
40
|
+
|
|
41
|
+
REVIEW_JS = r""" // ---- drawing
|
|
42
|
+
function localTime(utc) { // the reader's own time; UTC, labelled, if it can't
|
|
43
|
+
var d = utc ? new Date(String(utc).replace(" ", "T") + "Z") : null;
|
|
44
|
+
if (!d || isNaN(d.getTime())) { return utc ? utc + " UTC" : ""; }
|
|
45
|
+
return d.toLocaleString([], {dateStyle: "medium", timeStyle: "short"});
|
|
46
|
+
}
|
|
47
|
+
function endTime(a, b) { // the end alone when the session ends the day it began
|
|
48
|
+
var x = new Date(String(a).replace(" ", "T") + "Z"), y = new Date(String(b).replace(" ", "T") + "Z");
|
|
49
|
+
if (isNaN(x.getTime()) || isNaN(y.getTime()) || x.toDateString() !== y.toDateString()) {
|
|
50
|
+
return localTime(b);
|
|
51
|
+
}
|
|
52
|
+
return y.toLocaleTimeString([], {timeStyle: "short"});
|
|
53
|
+
}
|
|
54
|
+
var ACT = {keep: "Keep", remove: "Remove", restore: "Bring back"};
|
|
55
|
+
function drawSaved(item, c, index) { // what a session saved: each record, as text; with
|
|
56
|
+
// `index` (a waiting card) each record's buttons
|
|
57
|
+
if (c.started_utc) {
|
|
58
|
+
item.appendChild(el("p", "sess", "Session " + localTime(c.started_utc) +
|
|
59
|
+
(c.ended_utc ? " to " + endTime(c.started_utc, c.ended_utc) : "") + (c.app ? ", by " + c.app : "")));
|
|
60
|
+
}
|
|
61
|
+
if (!c.entries || !c.entries.length) {
|
|
62
|
+
if (c.note) { item.appendChild(el("p", "details", c.note)); }
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
item.appendChild(el("p", "sess", "What this session saved (" + c.total + "):"));
|
|
66
|
+
if (c.explain && index !== undefined) { item.appendChild(el("p", "sess", c.explain)); }
|
|
67
|
+
var ul = el("ul", "saved");
|
|
68
|
+
c.entries.forEach(function (e) {
|
|
69
|
+
var li = el("li", "");
|
|
70
|
+
li.appendChild(el("strong", "", e.head || ""));
|
|
71
|
+
if (e.state) { li.appendChild(el("span", "state st-" + e.state, e.state_label || e.state)); }
|
|
72
|
+
if (e.excerpt) { li.appendChild(el("p", "ex", e.excerpt)); }
|
|
73
|
+
if (e.solution) { li.appendChild(el("p", "ex", "Solution: " + e.solution)); }
|
|
74
|
+
if (index !== undefined && e.actions && e.actions.length) { // the record's own buttons
|
|
75
|
+
var row = el("div", "recrow");
|
|
76
|
+
e.actions.forEach(function (a) {
|
|
77
|
+
var b = el("button", "ghost small", ACT[a] || a);
|
|
78
|
+
b.type = "button";
|
|
79
|
+
b.addEventListener("click", function () { chooseRecord(index, e.key, a, item); });
|
|
80
|
+
row.appendChild(b);
|
|
81
|
+
});
|
|
82
|
+
li.appendChild(row);
|
|
83
|
+
}
|
|
84
|
+
ul.appendChild(li);
|
|
85
|
+
});
|
|
86
|
+
item.appendChild(ul);
|
|
87
|
+
if (c.more) { item.appendChild(el("p", "sess", c.more + " more on the review page.")); }
|
|
88
|
+
}
|
|
89
|
+
function drawCard(view, index) {
|
|
90
|
+
var box = el("div", "card");
|
|
91
|
+
box.appendChild(el("h1", "", view.title || "Waiting for your OK"));
|
|
92
|
+
var item = el("div", "item");
|
|
93
|
+
item.appendChild(el("p", "kind", view.kind_label || "Review item"));
|
|
94
|
+
item.appendChild(el("p", "text", view.text || ""));
|
|
95
|
+
if (view.details) { item.appendChild(el("p", "details", view.details)); }
|
|
96
|
+
if (view.would_change) { item.appendChild(el("p", "change", view.would_change)); }
|
|
97
|
+
if (view.warning) { item.appendChild(el("p", "warn", view.warning)); }
|
|
98
|
+
if (view.contents) { drawSaved(item, view.contents, view.resolved || !view.decide_here ? undefined : index); }
|
|
99
|
+
var when = localDate(view.when_utc) || view.when;
|
|
100
|
+
item.appendChild(el("p", "who", "From " + (view.who || "an app") + (when ? ", " + when : "")));
|
|
101
|
+
box.appendChild(item);
|
|
102
|
+
if (view.does) { box.appendChild(el("p", "does", view.does)); }
|
|
103
|
+
if (view.resolved) {
|
|
104
|
+
box.appendChild(el("p", "done", view.detail || "Saved."));
|
|
105
|
+
return box;
|
|
106
|
+
}
|
|
107
|
+
if (!view.decide_here) { // only the user decides it, elsewhere: no buttons here
|
|
108
|
+
box.appendChild(el("p", "locked", view.locked_note || "You decide this one yourself, outside the chat."));
|
|
109
|
+
if (view.link) { box.appendChild(el("p", "link", view.link)); }
|
|
110
|
+
return box;
|
|
111
|
+
}
|
|
112
|
+
var actions = el("div", "actions");
|
|
113
|
+
var yes = el("button", "", view.approve_label || "Approve");
|
|
114
|
+
yes.type = "button";
|
|
115
|
+
yes.addEventListener("click", function () { choose(index, "approve", "", box); });
|
|
116
|
+
var no = el("button", "ghost", view.reject_label || "Reject");
|
|
117
|
+
no.type = "button";
|
|
118
|
+
no.addEventListener("click", function () { askWhy(index, box, actions); });
|
|
119
|
+
actions.appendChild(yes);
|
|
120
|
+
actions.appendChild(no);
|
|
121
|
+
box.appendChild(actions);
|
|
122
|
+
return box;
|
|
123
|
+
}
|
|
124
|
+
function askWhy(index, box, actions) { // the reason is typed in the card, not the chat
|
|
125
|
+
var view = cards[index];
|
|
126
|
+
var form = el("div", "why");
|
|
127
|
+
var id = "why-" + index;
|
|
128
|
+
var label = el("label", "", "Reason (optional)");
|
|
129
|
+
label.setAttribute("for", id);
|
|
130
|
+
var input = document.createElement("input");
|
|
131
|
+
input.id = id;
|
|
132
|
+
input.type = "text";
|
|
133
|
+
input.maxLength = 300;
|
|
134
|
+
input.autocomplete = "off";
|
|
135
|
+
var row = el("div", "actions");
|
|
136
|
+
var go = el("button", "", view.reject_label || "Reject");
|
|
137
|
+
go.type = "button";
|
|
138
|
+
go.addEventListener("click", function () { choose(index, "reject", input.value, box); });
|
|
139
|
+
var back = el("button", "ghost", "Back");
|
|
140
|
+
back.type = "button";
|
|
141
|
+
back.addEventListener("click", function () {
|
|
142
|
+
form.parentNode.replaceChild(actions, form);
|
|
143
|
+
reportSize();
|
|
144
|
+
});
|
|
145
|
+
row.appendChild(go);
|
|
146
|
+
row.appendChild(back);
|
|
147
|
+
form.appendChild(label);
|
|
148
|
+
form.appendChild(input);
|
|
149
|
+
form.appendChild(row);
|
|
150
|
+
actions.parentNode.replaceChild(form, actions);
|
|
151
|
+
input.focus();
|
|
152
|
+
reportSize();
|
|
153
|
+
}
|
|
154
|
+
function render(data) {
|
|
155
|
+
data = data || {};
|
|
156
|
+
cards = data.cards || [];
|
|
157
|
+
var root = document.getElementById("cards");
|
|
158
|
+
while (root.firstChild) { root.removeChild(root.firstChild); }
|
|
159
|
+
if (!cards.length) {
|
|
160
|
+
root.appendChild(el("p", "quiet", data.note || "Nothing is waiting for your OK."));
|
|
161
|
+
}
|
|
162
|
+
cards.forEach(function (view, i) { root.appendChild(drawCard(view, i)); });
|
|
163
|
+
var more = document.getElementById("more");
|
|
164
|
+
var bits = [];
|
|
165
|
+
if (data.more) { bits.push(data.more + " more waiting on the review page."); }
|
|
166
|
+
if (data.also) { bits.push(data.also); }
|
|
167
|
+
more.hidden = !bits.length;
|
|
168
|
+
more.textContent = bits.join(" ");
|
|
169
|
+
reportSize();
|
|
170
|
+
}
|
|
171
|
+
function setButtons(box, on) {
|
|
172
|
+
var controls = box.querySelectorAll("button, input");
|
|
173
|
+
for (var i = 0; i < controls.length; i++) { controls[i].disabled = !on; }
|
|
174
|
+
}
|
|
175
|
+
function showError(box, text, expired) { // an expired card keeps its buttons off
|
|
176
|
+
var old = box.querySelector(".err");
|
|
177
|
+
if (old) { old.parentNode.removeChild(old); }
|
|
178
|
+
box.appendChild(el("p", "err", text || "Not saved."));
|
|
179
|
+
setButtons(box, !expired);
|
|
180
|
+
reportSize();
|
|
181
|
+
}
|
|
182
|
+
function chooseRecord(index, record, action, item) { // Keep / Remove / Bring back: one record
|
|
183
|
+
var view = cards[index];
|
|
184
|
+
if (!view) { return; }
|
|
185
|
+
var box = item.parentNode;
|
|
186
|
+
setButtons(box, false);
|
|
187
|
+
var args = {item_id: view.item_id, decision: action + "_record", record: record,
|
|
188
|
+
project: view.project || "", tap: tapFor(view.item_id)};
|
|
189
|
+
request("tools/call", {name: "resolve_review_card", arguments: args}, function (error, result) {
|
|
190
|
+
takeTaps(result);
|
|
191
|
+
if (error) { showError(box, error.message || "Not saved."); return; }
|
|
192
|
+
var sc = (result && result.structuredContent) || {};
|
|
193
|
+
var fresh = sc.cards && sc.cards[0];
|
|
194
|
+
if (!result || result.isError || !fresh) {
|
|
195
|
+
var no = refusal(result);
|
|
196
|
+
showError(box, no.text, no.expired);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
tapDone(view.item_id, result);
|
|
200
|
+
cards[index] = fresh;
|
|
201
|
+
var drawn = drawCard(fresh, index);
|
|
202
|
+
var said = "";
|
|
203
|
+
try { said = JSON.parse(result.content[0].text).note || ""; } catch (e) { said = ""; }
|
|
204
|
+
if (said) { drawn.appendChild(el("p", "done", said)); }
|
|
205
|
+
box.parentNode.replaceChild(drawn, box);
|
|
206
|
+
reportSize();
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function choose(index, decision, why, box) {
|
|
210
|
+
var view = cards[index];
|
|
211
|
+
if (!view) { return; }
|
|
212
|
+
setButtons(box, false);
|
|
213
|
+
var args = {item_id: view.item_id, decision: decision, project: view.project || "",
|
|
214
|
+
tap: tapFor(view.item_id)};
|
|
215
|
+
why = (why || "").replace(/\s+/g, " ").trim();
|
|
216
|
+
if (decision === "reject" && why) { args.reject_reason = why.slice(0, 300); }
|
|
217
|
+
request("tools/call", {name: "resolve_review_card", arguments: args}, function (error, result) {
|
|
218
|
+
takeTaps(result);
|
|
219
|
+
if (error) { showError(box, error.message || "Not saved."); return; }
|
|
220
|
+
if (!result || result.isError) {
|
|
221
|
+
var no = refusal(result);
|
|
222
|
+
showError(box, no.text, no.expired);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
var sc = result.structuredContent || {};
|
|
226
|
+
var fresh = sc.cards && sc.cards[0];
|
|
227
|
+
if (fresh) {
|
|
228
|
+
tapDone(view.item_id, result);
|
|
229
|
+
cards[index] = fresh;
|
|
230
|
+
box.parentNode.replaceChild(drawCard(fresh, index), box);
|
|
231
|
+
} else { // a refusal with more fields (e.g. phone only)
|
|
232
|
+
var said = result.content && result.content[0] && result.content[0].text, msg = "";
|
|
233
|
+
try { msg = JSON.parse(said).message || ""; } catch (e) { msg = ""; }
|
|
234
|
+
showError(box, msg || "Saved, but the card could not be redrawn.");
|
|
235
|
+
}
|
|
236
|
+
reportSize();
|
|
237
|
+
});
|
|
238
|
+
}"""
|
|
239
|
+
|
|
240
|
+
CARD_HTML = document("Waiting for your OK", "Loading what is waiting…", REVIEW_CSS, REVIEW_JS,
|
|
241
|
+
"flowstate-review-card")
|