@x-tech-laboratories/x-app 0.117.0 → 0.119.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.
- package/README.md +21 -8
- package/dist/agent/claude_stream.d.ts +22 -0
- package/dist/agent/claude_stream.js +85 -0
- package/dist/agent/git.d.ts +37 -0
- package/dist/agent/git.js +121 -0
- package/dist/agent/github.d.ts +81 -0
- package/dist/agent/github.js +185 -0
- package/dist/agent/programs.d.ts +17 -0
- package/dist/agent/programs.js +62 -0
- package/dist/agent/worktree_files.d.ts +20 -0
- package/dist/agent/worktree_files.js +69 -0
- package/dist/agent_transcript.d.ts +83 -0
- package/dist/agent_transcript.js +267 -0
- package/dist/app/daemon.js +2 -2
- package/dist/app/define.d.ts +7 -2
- package/dist/app/define.js +13 -0
- package/dist/app/desktop.js +2 -2
- package/dist/app/protocol.d.ts +3 -1
- package/dist/app/protocol.js +1 -0
- package/dist/app/server.d.ts +1 -0
- package/dist/app/server.js +13 -2
- package/dist/app/web/android.js +8 -1
- package/dist/app/web/hosts.d.ts +1 -1
- package/dist/app/web/hosts.js +5 -4
- package/dist/connection_protocol.d.ts +1 -0
- package/dist/connection_protocol.js +11 -0
- package/dist/daemon_router.d.ts +2 -2
- package/dist/daemon_router.js +3 -2
- package/dist/diff_rows.d.ts +78 -0
- package/dist/diff_rows.js +158 -0
- package/dist/frontmatter.d.ts +10 -0
- package/dist/frontmatter.js +57 -0
- package/dist/frontmatter_folder.d.ts +24 -0
- package/dist/frontmatter_folder.js +54 -0
- package/dist/history.js +14 -1
- package/dist/server/config.d.ts +2 -0
- package/dist/server/config.js +15 -1
- package/dist/server/events.d.ts +2 -0
- package/dist/server/events.js +3 -1
- package/dist/server/github_webhook.d.ts +30 -0
- package/dist/server/github_webhook.js +146 -0
- package/dist/sync_engine.d.ts +5 -0
- package/dist/sync_engine.js +63 -9
- package/dist/sync_protocol.d.ts +4 -0
- package/dist/sync_protocol.js +11 -0
- package/dist/test_helpers.d.ts +7 -0
- package/dist/test_helpers.js +44 -0
- package/dist/web/react/accounts.js +2 -1
- package/dist/web/react/controls.d.ts +3 -2
- package/dist/web/react/controls.js +6 -4
- package/dist/web/react/copy_button.d.ts +11 -0
- package/dist/web/react/copy_button.js +44 -0
- package/dist/web/react/dialog.js +2 -2
- package/dist/web/react/diff.d.ts +26 -0
- package/dist/web/react/diff.js +79 -0
- package/dist/web/react/file_tree.d.ts +26 -0
- package/dist/web/react/file_tree.js +46 -0
- package/dist/web/react/local_mcp_settings.js +2 -1
- package/dist/web/react/transcript.d.ts +24 -0
- package/dist/web/react/transcript.js +100 -0
- package/dist/web/tree.d.ts +3 -1
- package/dist/web/tree.js +38 -10
- package/package.json +5 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type PermissionDecision, type TranscriptEntry, type UserRole } from "../../agent_transcript.ts";
|
|
2
|
+
export type AnswerPermission = (id: string, decision: PermissionDecision, message: string) => void;
|
|
3
|
+
interface PermissionWords {
|
|
4
|
+
decisions: Record<PermissionDecision, string>;
|
|
5
|
+
allow_for_session: (rule: string) => string;
|
|
6
|
+
}
|
|
7
|
+
interface TranscriptViewProps {
|
|
8
|
+
entries: TranscriptEntry[];
|
|
9
|
+
live: boolean;
|
|
10
|
+
dropped?: number;
|
|
11
|
+
empty_text?: string;
|
|
12
|
+
user_labels?: Partial<Record<UserRole, string>>;
|
|
13
|
+
on_permission?: AnswerPermission;
|
|
14
|
+
allow_for_session?: boolean;
|
|
15
|
+
permission_words?: Partial<PermissionWords>;
|
|
16
|
+
}
|
|
17
|
+
export declare function TranscriptView({ entries, live, dropped, empty_text, user_labels, on_permission, allow_for_session, permission_words }: TranscriptViewProps): import("react").JSX.Element;
|
|
18
|
+
interface TranscriptMessageBoxProps {
|
|
19
|
+
on_send: (text: string) => Promise<boolean> | boolean;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function TranscriptMessageBox({ on_send, placeholder, label }: TranscriptMessageBoxProps): import("react").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// An agent session's transcript from `agent_transcript` as steps: thinking folded to one line, its text as Markdown,
|
|
3
|
+
// each tool call as a row naming the tool and what it works on that opens to its whole input and result, an edit as a
|
|
4
|
+
// small diff, the user's own messages in place, marked while the agent has not read them yet, and each tool call
|
|
5
|
+
// waiting for approval with Allow, Allow for the session and Deny. It follows the newest step until the reader scrolls
|
|
6
|
+
// up, with a button back to the latest. `TranscriptMessageBox` writes to the agent while its session is open.
|
|
7
|
+
// ── Imports ──────────────────────────────────────────────────────────────────
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { edit_of, permission_rule, rule_words, tool_summary } from "../../agent_transcript.js";
|
|
10
|
+
import { cx } from "../dom.js";
|
|
11
|
+
import { Badge } from "./badges.js";
|
|
12
|
+
import { EditDiff } from "./diff.js";
|
|
13
|
+
import { use_follow_tail } from "./following.js";
|
|
14
|
+
import { Markdown } from "./markdown.js";
|
|
15
|
+
// ── Steps ────────────────────────────────────────────────────────────────────
|
|
16
|
+
const default_user_labels = { input: "Input", message: "You" };
|
|
17
|
+
function last_line(text) {
|
|
18
|
+
return text.trim().split("\n").at(-1)?.trim() ?? "";
|
|
19
|
+
}
|
|
20
|
+
function Thinking({ entry }) {
|
|
21
|
+
return (_jsxs("details", { className: "transcript-step transcript-thinking", children: [_jsxs("summary", { children: [_jsx("span", { className: cx("status-dot", "tone-info", entry.streaming && "busy"), "aria-hidden": "true" }), " ", _jsx("span", { className: "muted", children: entry.streaming ? "Thinking…" : "Thought" }), " ", _jsx("span", { className: "transcript-line muted small", children: last_line(entry.text) })] }), _jsx("p", { className: "transcript-text muted", children: entry.text || "The model kept its thinking to itself." })] }));
|
|
22
|
+
}
|
|
23
|
+
function ToolInput({ name, input, input_text }) {
|
|
24
|
+
if (input_text !== undefined)
|
|
25
|
+
return _jsx("pre", { className: "transcript-code", children: input_text });
|
|
26
|
+
const edits = edit_of(name, input);
|
|
27
|
+
if (edits)
|
|
28
|
+
return _jsx(_Fragment, { children: edits.map((edit, index) => _jsx(EditDiff, { ...edit }, index)) });
|
|
29
|
+
if (typeof input.command === "string")
|
|
30
|
+
return _jsx("pre", { className: "transcript-code", children: input.command });
|
|
31
|
+
return _jsx("pre", { className: "transcript-code", children: JSON.stringify(input, null, 2) });
|
|
32
|
+
}
|
|
33
|
+
const default_permission_words = {
|
|
34
|
+
decisions: { allowed: "Allowed", allowed_for_session: "Allowed for this session", denied: "Denied" },
|
|
35
|
+
allow_for_session: (rule) => `Allow ${rule} for This Session`,
|
|
36
|
+
};
|
|
37
|
+
function Permission({ entry, on_answer, allow_for_session, words }) {
|
|
38
|
+
const [reason, set_reason] = useState("");
|
|
39
|
+
const waiting = !entry.decision;
|
|
40
|
+
const tone = waiting ? "warn" : entry.decision === "denied" ? "bad" : "good";
|
|
41
|
+
return (_jsxs("div", { className: cx("transcript-step transcript-permission", `tone-edge-${tone}`), role: waiting ? "group" : undefined, "aria-label": waiting ? `${entry.tool} waits for approval` : undefined, children: [_jsxs("div", { className: "transcript-head", children: [_jsx(Badge, { tone: tone, children: waiting ? "Waiting for approval" : words.decisions[entry.decision] }), _jsx("strong", { children: entry.tool }), !waiting && _jsx("code", { className: "transcript-line", children: tool_summary(entry.input) })] }), entry.reason && _jsx("p", { className: "small muted", children: entry.reason }), waiting && _jsx(ToolInput, { name: entry.tool, input: entry.input }), entry.message && _jsxs("p", { className: "small", children: ["Reason given: ", entry.message] }), waiting && on_answer && (_jsxs("div", { className: "transcript-answer", children: [_jsx("input", { type: "text", "aria-label": `Why ${entry.tool} is refused`, placeholder: "Why not, for the agent (optional)", value: reason, onChange: (event) => set_reason(event.currentTarget.value) }), _jsxs("span", { className: "transcript-head", children: [_jsx("button", { type: "button", className: "accent solid", onClick: () => on_answer(entry.id, "allowed", ""), children: "Allow" }), allow_for_session && (_jsx("button", { type: "button", onClick: () => on_answer(entry.id, "allowed_for_session", ""), children: words.allow_for_session(rule_words(permission_rule(entry.tool, entry.input))) })), _jsx("button", { type: "button", className: "danger", onClick: () => on_answer(entry.id, "denied", reason), children: "Deny" })] })] }))] }));
|
|
42
|
+
}
|
|
43
|
+
function Tool({ entry, live }) {
|
|
44
|
+
const running = entry.result === undefined && live;
|
|
45
|
+
return (_jsxs("details", { className: cx("transcript-step transcript-tool", entry.is_error && "failed tone-edge-bad"), children: [_jsxs("summary", { children: [_jsx(Badge, { tone: entry.is_error ? "bad" : "none", children: entry.name }), running && _jsx("span", { className: "status-dot tone-info busy", role: "status", "aria-label": "Running" }), _jsx("code", { className: "transcript-line", children: tool_summary(entry.input) || (entry.input_text ? "…" : "") }), entry.is_error && _jsx("span", { className: "tone-bad small", children: "failed" })] }), _jsx(ToolInput, { name: entry.name, input: entry.input, input_text: entry.input_text }), entry.result !== undefined && _jsx("pre", { className: cx("transcript-code", entry.is_error && "failed"), children: entry.result || "No output." })] }));
|
|
46
|
+
}
|
|
47
|
+
function UserMessage({ entry, labels }) {
|
|
48
|
+
const label = labels[entry.role] ?? entry.role;
|
|
49
|
+
if (entry.role === "input") {
|
|
50
|
+
return (_jsxs("details", { className: "transcript-step", children: [_jsx("summary", { className: "muted", children: label }), _jsx(Markdown, { text: entry.text })] }));
|
|
51
|
+
}
|
|
52
|
+
return (_jsxs("div", { className: "transcript-step transcript-user", children: [_jsxs("div", { className: "small muted", children: [label, " ", entry.pending && _jsx(Badge, { tone: "warn", children: "Not read yet" })] }), _jsx("p", { className: "transcript-text", children: entry.text })] }));
|
|
53
|
+
}
|
|
54
|
+
function Step({ entry, live, labels, on_permission, allow_for_session, words }) {
|
|
55
|
+
if (entry.kind === "thinking")
|
|
56
|
+
return _jsx(Thinking, { entry: entry });
|
|
57
|
+
if (entry.kind === "text")
|
|
58
|
+
return _jsx(Markdown, { text: entry.text, class_name: "transcript-step" });
|
|
59
|
+
if (entry.kind === "tool")
|
|
60
|
+
return _jsx(Tool, { entry: entry, live: live });
|
|
61
|
+
if (entry.kind === "user")
|
|
62
|
+
return _jsx(UserMessage, { entry: entry, labels: labels });
|
|
63
|
+
if (entry.kind === "permission")
|
|
64
|
+
return _jsx(Permission, { entry: entry, on_answer: live ? on_permission : undefined, allow_for_session: allow_for_session, words: words });
|
|
65
|
+
return _jsx("p", { className: cx("transcript-step transcript-notice small", `tone-${entry.tone}`), children: entry.text });
|
|
66
|
+
}
|
|
67
|
+
export function TranscriptView({ entries, live, dropped = 0, empty_text = "Nothing yet.", user_labels, on_permission, allow_for_session = true, permission_words }) {
|
|
68
|
+
const last = entries.at(-1);
|
|
69
|
+
const size = `${entries.length} ${last && "text" in last ? last.text.length : 0} ${last?.kind === "tool" ? `${last.input_text?.length ?? 0} ${last.result?.length ?? 0}` : ""}`;
|
|
70
|
+
const follow = use_follow_tail(size, live);
|
|
71
|
+
const labels = { ...default_user_labels, ...user_labels };
|
|
72
|
+
const words = { ...default_permission_words, ...permission_words };
|
|
73
|
+
return (_jsxs("div", { className: "transcript-frame", children: [_jsxs("div", { ref: follow.ref, className: "transcript", role: "log", "aria-label": "Transcript", "aria-live": live ? "polite" : "off", onScroll: follow.on_scroll, children: [dropped > 0 && _jsxs("p", { className: "muted small", children: [dropped, " earlier steps were left out to keep the transcript within its size."] }), entries.length === 0 ? _jsx("p", { className: "muted", children: empty_text }) : entries.map((entry, index) => _jsx(Step, { entry: entry, live: live, labels: labels, on_permission: on_permission, allow_for_session: allow_for_session, words: words }, index))] }), live && !follow.following && (_jsx("button", { type: "button", className: "transcript-jump", onClick: follow.jump, children: "Jump to Latest" }))] }));
|
|
74
|
+
}
|
|
75
|
+
// A box to write to the agent, sent by its button or Ctrl+Enter.
|
|
76
|
+
export function TranscriptMessageBox({ on_send, placeholder = "Steer the agent; it reads this after its current step", label = "Message to the agent" }) {
|
|
77
|
+
const [text, set_text] = useState("");
|
|
78
|
+
const [sending, set_sending] = useState(false);
|
|
79
|
+
async function send() {
|
|
80
|
+
if (!text.trim() || sending)
|
|
81
|
+
return;
|
|
82
|
+
set_sending(true);
|
|
83
|
+
try {
|
|
84
|
+
if (await on_send(text))
|
|
85
|
+
set_text("");
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
set_sending(false);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return (_jsxs("form", { className: "transcript-message", onSubmit: (event) => {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
void send();
|
|
94
|
+
}, children: [_jsx("textarea", { "aria-label": label, rows: 2, placeholder: placeholder, value: text, onChange: (event) => set_text(event.currentTarget.value), onKeyDown: (event) => {
|
|
95
|
+
if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
void send();
|
|
98
|
+
}
|
|
99
|
+
} }), _jsx("button", { type: "submit", className: "accent solid", disabled: !text.trim() || sending, children: "Send" })] }));
|
|
100
|
+
}
|
package/dist/web/tree.d.ts
CHANGED
|
@@ -16,11 +16,13 @@ export interface TreeMove {
|
|
|
16
16
|
export interface DropOptions {
|
|
17
17
|
by_list_order?: boolean;
|
|
18
18
|
}
|
|
19
|
+
export declare function item_by_id<Item extends TreeItem>(items: readonly Item[], id: string | null): Item | undefined;
|
|
20
|
+
export declare function with_ancestors<Item extends TreeItem>(item: Item, items: readonly Item[]): Item[];
|
|
19
21
|
export declare function by_position<Item extends {
|
|
20
22
|
position: number;
|
|
21
23
|
}>(first: Item, second: Item): number;
|
|
22
24
|
export declare function children_of<Item extends TreeItem>(parent_id: string | null, items: Item[]): Item[];
|
|
23
|
-
export declare function subtree_ids(item_id: string, items: TreeItem[]): Set<string>;
|
|
25
|
+
export declare function subtree_ids(item_id: string, items: readonly TreeItem[]): Set<string>;
|
|
24
26
|
export declare function nest<Item extends TreeItem>(shown: Item[], all?: Item[]): TreeNode<Item>[];
|
|
25
27
|
export declare function in_tree_order<Item extends TreeItem>(items: Item[], reversed?: boolean): Item[];
|
|
26
28
|
export declare function path_names<Item extends TreeItem>(item: Item, items: Item[], name_of: (item: Item) => string): string[];
|
package/dist/web/tree.js
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
// Trees of rows that name their parent and their place among siblings, and where a dragged or keyed row lands.
|
|
2
|
+
// Made once per list and reused while it keeps its length; a list whose items are edited in place must be copied first.
|
|
3
|
+
const indexes = new WeakMap();
|
|
4
|
+
function index_of(items) {
|
|
5
|
+
const kept = indexes.get(items);
|
|
6
|
+
if (kept && kept.length === items.length)
|
|
7
|
+
return kept;
|
|
8
|
+
const index = { length: items.length, by_id: new Map(), child_ids: new Map() };
|
|
9
|
+
for (const item of items) {
|
|
10
|
+
index.by_id.set(item.id, item);
|
|
11
|
+
const siblings = index.child_ids.get(item.parent_id);
|
|
12
|
+
if (siblings)
|
|
13
|
+
siblings.push(item.id);
|
|
14
|
+
else
|
|
15
|
+
index.child_ids.set(item.parent_id, [item.id]);
|
|
16
|
+
}
|
|
17
|
+
indexes.set(items, index);
|
|
18
|
+
return index;
|
|
19
|
+
}
|
|
20
|
+
// The item with the id, found without walking the list each time.
|
|
21
|
+
export function item_by_id(items, id) {
|
|
22
|
+
return id === null ? undefined : index_of(items).by_id.get(id);
|
|
23
|
+
}
|
|
24
|
+
// The item and every item above it, nearest first; stops at a missing parent or a loop.
|
|
25
|
+
export function with_ancestors(item, items) {
|
|
26
|
+
const chain = [item];
|
|
27
|
+
const seen = new Set([item.id]);
|
|
28
|
+
let parent = item_by_id(items, item.parent_id);
|
|
29
|
+
while (parent && !seen.has(parent.id)) {
|
|
30
|
+
chain.push(parent);
|
|
31
|
+
seen.add(parent.id);
|
|
32
|
+
parent = item_by_id(items, parent.parent_id);
|
|
33
|
+
}
|
|
34
|
+
return chain;
|
|
35
|
+
}
|
|
2
36
|
// ── Shape ────────────────────────────────────────────────────────────────────
|
|
3
37
|
export function by_position(first, second) {
|
|
4
38
|
return first.position - second.position;
|
|
@@ -8,10 +42,11 @@ export function children_of(parent_id, items) {
|
|
|
8
42
|
}
|
|
9
43
|
// The item itself plus everything below it, at any depth.
|
|
10
44
|
export function subtree_ids(item_id, items) {
|
|
45
|
+
const { child_ids } = index_of(items);
|
|
11
46
|
const ids = new Set([item_id]);
|
|
12
47
|
for (const id of ids) {
|
|
13
|
-
for (const
|
|
14
|
-
ids.add(
|
|
48
|
+
for (const child_id of child_ids.get(id) ?? [])
|
|
49
|
+
ids.add(child_id);
|
|
15
50
|
}
|
|
16
51
|
return ids;
|
|
17
52
|
}
|
|
@@ -46,14 +81,7 @@ export function in_tree_order(items, reversed = false) {
|
|
|
46
81
|
}
|
|
47
82
|
// The names from the top of the tree down to the item, such as ["Work", "Clients"]; stops at a missing parent or a loop.
|
|
48
83
|
export function path_names(item, items, name_of) {
|
|
49
|
-
|
|
50
|
-
const path = [item];
|
|
51
|
-
let parent = item.parent_id === null ? undefined : item_by_id.get(item.parent_id);
|
|
52
|
-
while (parent && !path.includes(parent)) {
|
|
53
|
-
path.unshift(parent);
|
|
54
|
-
parent = parent.parent_id === null ? undefined : item_by_id.get(parent.parent_id);
|
|
55
|
-
}
|
|
56
|
-
return path.map(name_of);
|
|
84
|
+
return with_ancestors(item, items).reverse().map(name_of);
|
|
57
85
|
}
|
|
58
86
|
// ── Dropping ─────────────────────────────────────────────────────────────────
|
|
59
87
|
// The top and bottom quarters of a row drop beside it and the middle drops into it, or halves when nothing drops inside.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-tech-laboratories/x-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.119.0",
|
|
4
4
|
"description": "Code the X-apps share: agents and their long runs, passwords and sign-in, the Fastify server pieces, durations, and the web page's helpers and widgets",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@fastify/formbody": "^9.0.1",
|
|
49
49
|
"@fastify/rate-limit": "^11.2.2",
|
|
50
50
|
"@fastify/session": "^11.1.6",
|
|
51
|
-
"@fastify/static": "^
|
|
51
|
+
"@fastify/static": "^11.0.0",
|
|
52
52
|
"@fastify/websocket": "^11.3.5",
|
|
53
53
|
"@mdx-js/rollup": "^3.1.1",
|
|
54
54
|
"@modelcontextprotocol/client": "^2.4.0",
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
"@fastify/formbody": "^9.0.1",
|
|
193
193
|
"@fastify/rate-limit": "^11.2.2",
|
|
194
194
|
"@fastify/session": "^11.1.6",
|
|
195
|
-
"@fastify/static": "^
|
|
195
|
+
"@fastify/static": "^11.0.0",
|
|
196
196
|
"@fastify/websocket": "^11.3.5",
|
|
197
197
|
"@mdx-js/rollup": "^3.1.1",
|
|
198
198
|
"@modelcontextprotocol/client": "^2.4.0",
|
|
@@ -246,6 +246,7 @@
|
|
|
246
246
|
"@tiptap/starter-kit": "^3.33.0",
|
|
247
247
|
"bonjour-service": "^1.4.4",
|
|
248
248
|
"dayjs": "^1.11.23",
|
|
249
|
+
"diff": "^9.0.0",
|
|
249
250
|
"dompurify": "^3.4.17",
|
|
250
251
|
"drizzle-orm": "1.0.0-rc.6",
|
|
251
252
|
"emojibase": "^18.0.0",
|
|
@@ -257,6 +258,7 @@
|
|
|
257
258
|
"hookable": "^6.1.2",
|
|
258
259
|
"lucide-react": "^1.67.0",
|
|
259
260
|
"marked": "^18.1.3",
|
|
261
|
+
"parse-diff": "^0.12.0",
|
|
260
262
|
"parse-duration": "^2.1.11",
|
|
261
263
|
"pretty-bytes": "^7.2.0",
|
|
262
264
|
"react-error-boundary": "^6.1.6",
|