@odysx/codemind 0.0.0-stage → 0.1.1
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 +293 -2
- package/dist/commands/agents.d.ts +2 -0
- package/dist/commands/agents.js +91 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +35 -0
- package/dist/commands/chat.d.ts +2 -0
- package/dist/commands/chat.js +180 -0
- package/dist/commands/keys.d.ts +2 -0
- package/dist/commands/keys.js +81 -0
- package/dist/commands/local.d.ts +2 -0
- package/dist/commands/local.js +325 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.js +73 -0
- package/dist/commands/prompts.d.ts +2 -0
- package/dist/commands/prompts.js +59 -0
- package/dist/commands/skills.d.ts +2 -0
- package/dist/commands/skills.js +41 -0
- package/dist/core/auth/index.d.ts +10 -0
- package/dist/core/auth/index.js +82 -0
- package/dist/core/config/index.d.ts +47 -0
- package/dist/core/config/index.js +118 -0
- package/dist/core/history.d.ts +14 -0
- package/dist/core/history.js +80 -0
- package/dist/core/markdown-renderer.d.ts +47 -0
- package/dist/core/markdown-renderer.js +385 -0
- package/dist/core/permissions/index.d.ts +31 -0
- package/dist/core/permissions/index.js +64 -0
- package/dist/core/provider/external.d.ts +28 -0
- package/dist/core/provider/external.js +248 -0
- package/dist/core/provider/index.d.ts +138 -0
- package/dist/core/provider/index.js +510 -0
- package/dist/core/registry/index.d.ts +25 -0
- package/dist/core/registry/index.js +216 -0
- package/dist/core/schema/types.d.ts +93 -0
- package/dist/core/schema/types.js +12 -0
- package/dist/core/terminal.d.ts +40 -0
- package/dist/core/terminal.js +134 -0
- package/dist/core/workspace/index.d.ts +35 -0
- package/dist/core/workspace/index.js +194 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +393 -0
- package/dist/ui/app.d.ts +3 -0
- package/dist/ui/app.js +554 -0
- package/dist/ui/commands/cases/catalog.d.ts +11 -0
- package/dist/ui/commands/cases/catalog.js +62 -0
- package/dist/ui/commands/cases/misc.d.ts +35 -0
- package/dist/ui/commands/cases/misc.js +245 -0
- package/dist/ui/commands/cases/tasks.d.ts +13 -0
- package/dist/ui/commands/cases/tasks.js +91 -0
- package/dist/ui/commands/runCommand.d.ts +22 -0
- package/dist/ui/commands/runCommand.js +136 -0
- package/dist/ui/components/AgentPicker.d.ts +11 -0
- package/dist/ui/components/AgentPicker.js +7 -0
- package/dist/ui/components/AuthPicker.d.ts +14 -0
- package/dist/ui/components/AuthPicker.js +7 -0
- package/dist/ui/components/Banner.d.ts +8 -0
- package/dist/ui/components/Banner.js +24 -0
- package/dist/ui/components/CommandMenu.d.ts +17 -0
- package/dist/ui/components/CommandMenu.js +21 -0
- package/dist/ui/components/ErrorBoundary.d.ts +24 -0
- package/dist/ui/components/ErrorBoundary.js +51 -0
- package/dist/ui/components/InputBar.d.ts +28 -0
- package/dist/ui/components/InputBar.js +108 -0
- package/dist/ui/components/KeysPanel.d.ts +12 -0
- package/dist/ui/components/KeysPanel.js +25 -0
- package/dist/ui/components/MessageView.d.ts +29 -0
- package/dist/ui/components/MessageView.js +107 -0
- package/dist/ui/components/PermissionPrompt.d.ts +10 -0
- package/dist/ui/components/PermissionPrompt.js +4 -0
- package/dist/ui/components/Pickers.d.ts +43 -0
- package/dist/ui/components/Pickers.js +33 -0
- package/dist/ui/components/SearchOverlay.d.ts +21 -0
- package/dist/ui/components/SearchOverlay.js +14 -0
- package/dist/ui/components/SessionPicker.d.ts +12 -0
- package/dist/ui/components/SessionPicker.js +8 -0
- package/dist/ui/components/WorkingIndicator.d.ts +10 -0
- package/dist/ui/components/WorkingIndicator.js +23 -0
- package/dist/ui/controls/ApiKeyEntry.d.ts +8 -0
- package/dist/ui/controls/ApiKeyEntry.js +5 -0
- package/dist/ui/controls/MultiSelect.d.ts +18 -0
- package/dist/ui/controls/MultiSelect.js +9 -0
- package/dist/ui/hooks/useAgentPicker.d.ts +14 -0
- package/dist/ui/hooks/useAgentPicker.js +53 -0
- package/dist/ui/hooks/useAuthFlow.d.ts +14 -0
- package/dist/ui/hooks/useAuthFlow.js +31 -0
- package/dist/ui/hooks/useKeysFlow.d.ts +17 -0
- package/dist/ui/hooks/useKeysFlow.js +130 -0
- package/dist/ui/hooks/useSessionPicker.d.ts +29 -0
- package/dist/ui/hooks/useSessionPicker.js +58 -0
- package/dist/ui/hooks/useTerminalSize.d.ts +6 -0
- package/dist/ui/hooks/useTerminalSize.js +29 -0
- package/dist/ui/input/keyRouter.d.ts +125 -0
- package/dist/ui/input/keyRouter.js +574 -0
- package/dist/ui/layouts/ScreenLayout.d.ts +98 -0
- package/dist/ui/layouts/ScreenLayout.js +56 -0
- package/dist/ui/shared/types.d.ts +143 -0
- package/dist/ui/shared/types.js +38 -0
- package/dist/ui/theme.d.ts +29 -0
- package/dist/ui/theme.js +54 -0
- package/dist/ui/utils/markdown.d.ts +74 -0
- package/dist/ui/utils/markdown.js +187 -0
- package/dist/ui/utils/mentions.d.ts +12 -0
- package/dist/ui/utils/mentions.js +28 -0
- package/dist/ui/utils/terminal-text.d.ts +33 -0
- package/dist/ui/utils/terminal-text.js +123 -0
- package/dist/ui/utils/text.d.ts +72 -0
- package/dist/ui/utils/text.js +171 -0
- package/package.json +50 -6
package/dist/ui/app.js
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Interactive Ink UI — Claude Code style REPL.
|
|
5
|
+
*
|
|
6
|
+
* app.tsx is the orchestrator only: it owns the state hooks, builds the
|
|
7
|
+
* CommandCtx / KeyRouterDeps bundles, and renders ScreenLayout. The actual
|
|
8
|
+
* behavior lives in:
|
|
9
|
+
* hooks/ — per-flow state + API actions (keys, agent, sessions, auth)
|
|
10
|
+
* commands/ — slash-command dispatch (runCommand + cases/)
|
|
11
|
+
* input/ — global keyboard router (keyRouter.ts)
|
|
12
|
+
* layouts/ — screen composition (ScreenLayout.tsx)
|
|
13
|
+
* controls/ — interactive overlay widgets (MultiSelect, ApiKeyEntry)
|
|
14
|
+
* utils/ — pure helpers (@file mention expansion)
|
|
15
|
+
*/
|
|
16
|
+
import { useState, useEffect, useCallback, useMemo, useRef } from "react";
|
|
17
|
+
import { render, useApp, useInput } from "ink";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import { sep, join, dirname } from "node:path";
|
|
20
|
+
import { existsSync } from "node:fs";
|
|
21
|
+
import { randomUUID } from "node:crypto";
|
|
22
|
+
import { getConfig } from "../core/config/index.js";
|
|
23
|
+
import { getWorkspaceRoot, isFolderTrusted, trustFolder as rememberFolder } from "../core/workspace/index.js";
|
|
24
|
+
import { getPermissionMode } from "../core/permissions/index.js";
|
|
25
|
+
import { streamChat, apiCall } from "../core/provider/index.js";
|
|
26
|
+
import { getActiveProvider, streamExternalChat } from "../core/provider/external.js";
|
|
27
|
+
import { SLASH_COMMANDS } from "./shared/types.js";
|
|
28
|
+
import { ScreenLayout } from "./layouts/ScreenLayout.js";
|
|
29
|
+
import { useKeysFlow } from "./hooks/useKeysFlow.js";
|
|
30
|
+
import { useAgentPicker } from "./hooks/useAgentPicker.js";
|
|
31
|
+
import { useSessionPicker } from "./hooks/useSessionPicker.js";
|
|
32
|
+
import { useAuthFlow } from "./hooks/useAuthFlow.js";
|
|
33
|
+
import { runCommand } from "./commands/runCommand.js";
|
|
34
|
+
import { handleKey } from "./input/keyRouter.js";
|
|
35
|
+
import { expandMentions } from "./utils/mentions.js";
|
|
36
|
+
import { wordAt, toChars, clampCursor, fuzzyRank } from "./utils/text.js";
|
|
37
|
+
import { useTerminalSize } from "./hooks/useTerminalSize.js";
|
|
38
|
+
import { ErrorBoundary } from "./components/ErrorBoundary.js";
|
|
39
|
+
import { enterAltScreen, exitWith, restoreScreen } from "../core/terminal.js";
|
|
40
|
+
import { loadHistory, appendHistory } from "../core/history.js";
|
|
41
|
+
/**
|
|
42
|
+
* Where unhandled rejections go. Writing to stderr while Ink owns the screen
|
|
43
|
+
* desyncs its frame tracker, so the app registers a sink that turns them into
|
|
44
|
+
* ordinary transcript warnings instead.
|
|
45
|
+
*/
|
|
46
|
+
let rejectionSink = null;
|
|
47
|
+
const App = () => {
|
|
48
|
+
const app = useApp();
|
|
49
|
+
const config = getConfig();
|
|
50
|
+
// Re-render on window resize so the footer/menu re-layout immediately
|
|
51
|
+
// instead of waiting for the next keystroke.
|
|
52
|
+
const terminal = useTerminalSize();
|
|
53
|
+
/* ── Flow hooks ─────────────────────────────────────── */
|
|
54
|
+
/** Append a system line to the transcript (shared by every flow). */
|
|
55
|
+
const addMessage = useCallback((text) => {
|
|
56
|
+
setMessages((prev) => [...prev, { role: "system", text }]);
|
|
57
|
+
}, []);
|
|
58
|
+
const keysFlow = useKeysFlow(addMessage);
|
|
59
|
+
const agentPickFlow = useAgentPicker(addMessage);
|
|
60
|
+
const authFlow = useAuthFlow(addMessage);
|
|
61
|
+
// Route stray rejections into the transcript (see rejectionSink above).
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
rejectionSink = addMessage;
|
|
64
|
+
return () => { rejectionSink = null; };
|
|
65
|
+
}, [addMessage]);
|
|
66
|
+
// Session id lives in a ref so command cases can read it without re-render
|
|
67
|
+
// dependency loops; resumeSession swaps it when loading past history.
|
|
68
|
+
const sessionIdRef = useRef("");
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
sessionIdRef.current = randomUUID();
|
|
71
|
+
}, []);
|
|
72
|
+
const [messages, setMessages] = useState([]);
|
|
73
|
+
// <Static> writes each message once and never removes it. A transcript wipe
|
|
74
|
+
// (/clear, /compact, session resume) therefore needs a batch key that maps
|
|
75
|
+
// to a *fresh* Static; otherwise the old lines stay on screen.
|
|
76
|
+
const [transcriptKey, setTranscriptKey] = useState(0);
|
|
77
|
+
const resetTranscript = useCallback(() => {
|
|
78
|
+
setMessages([]);
|
|
79
|
+
setTranscriptKey((k) => k + 1);
|
|
80
|
+
}, []);
|
|
81
|
+
const loadHistoryMessages = useCallback((msgs) => {
|
|
82
|
+
// Resuming swaps the whole transcript, so the static region must remount
|
|
83
|
+
// or the previous session's lines would remain on screen.
|
|
84
|
+
setTranscriptKey((k) => k + 1);
|
|
85
|
+
setMessages(msgs.map((m) => ({
|
|
86
|
+
role: m.role === "assistant" ? "assistant" : "user",
|
|
87
|
+
text: m.content,
|
|
88
|
+
})));
|
|
89
|
+
}, []);
|
|
90
|
+
const sessionPickFlow = useSessionPicker(addMessage, sessionIdRef, setMessages, loadHistoryMessages);
|
|
91
|
+
const [agentId, setAgentId] = useState(config.model ?? "master");
|
|
92
|
+
const permissionMode = getPermissionMode();
|
|
93
|
+
// Trust gate: check before the REPL is usable. If the folder is new, the
|
|
94
|
+
// overlay owns all input until the user accepts or declines; the trust store
|
|
95
|
+
// persists the answer so familiar folders start straight into the prompt.
|
|
96
|
+
const trustFolderPath = getWorkspaceRoot();
|
|
97
|
+
const [trust, setTrust] = useState(() => ({
|
|
98
|
+
pending: !isFolderTrusted(),
|
|
99
|
+
index: 0,
|
|
100
|
+
}));
|
|
101
|
+
// Launch folder for the footer. Collapse to ~/… relative to the monorepo
|
|
102
|
+
// root (walk up to the .git dir) — the project lives outside the OS home, so
|
|
103
|
+
// the OS-home rule alone would print the full C:\… absolute path. Display
|
|
104
|
+
// uses forward slashes even on Windows (Claude Code style).
|
|
105
|
+
const cwd = (() => {
|
|
106
|
+
const norm = (p) => p.split(sep).join("/");
|
|
107
|
+
const root = norm(getWorkspaceRoot());
|
|
108
|
+
const home = norm(homedir());
|
|
109
|
+
if (root === home || root.startsWith(home + "/")) {
|
|
110
|
+
return "~" + root.slice(home.length);
|
|
111
|
+
}
|
|
112
|
+
// Walk up from the workspace root to the nearest .git — that's our ~ anchor.
|
|
113
|
+
let anchor = root;
|
|
114
|
+
while (anchor && anchor !== dirname(anchor)) {
|
|
115
|
+
if (existsSync(join(anchor, ".git")))
|
|
116
|
+
break;
|
|
117
|
+
anchor = dirname(anchor);
|
|
118
|
+
}
|
|
119
|
+
return root === anchor || root.startsWith(anchor + "/")
|
|
120
|
+
? "~" + root.slice(anchor.length)
|
|
121
|
+
: root;
|
|
122
|
+
})();
|
|
123
|
+
// Pending risky local op awaiting y/N approval
|
|
124
|
+
const [pendingOp, setPendingOp] = useState(null);
|
|
125
|
+
const [input, setInputRaw] = useState("");
|
|
126
|
+
const [cursor, setCursor] = useState(0);
|
|
127
|
+
// Keep the caret inside the value on every edit path. This is an effect, not
|
|
128
|
+
// a side effect inside the updater: React may replay an updater (StrictMode,
|
|
129
|
+
// concurrent rendering), and a state write in there can run with a stale
|
|
130
|
+
// value and leave the caret drifting.
|
|
131
|
+
const setInput = useCallback((action) => {
|
|
132
|
+
setInputRaw(action);
|
|
133
|
+
}, []);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
setCursor((c) => clampCursor(c, input));
|
|
136
|
+
}, [input]);
|
|
137
|
+
const [streaming, setStreaming] = useState(false);
|
|
138
|
+
const [elapsed, setElapsed] = useState(0);
|
|
139
|
+
const [menuIndex, setMenuIndex] = useState(0);
|
|
140
|
+
// Input history recall (↑/↓ when the slash menu is closed)
|
|
141
|
+
// Prompt history survives restarts (~/.odysx/history.json).
|
|
142
|
+
const [history, setHistory] = useState(() => loadHistory());
|
|
143
|
+
// Stable handle so the memoized submit / command path can append without
|
|
144
|
+
// taking a dependency on the history array (which would thrash the memos).
|
|
145
|
+
const appendHistoryRef = useRef(appendHistory);
|
|
146
|
+
const [historyIndex, setHistoryIndex] = useState(-1); // -1 = not browsing
|
|
147
|
+
const historyDraftRef = useRef(""); // what was typed before ↑ was pressed
|
|
148
|
+
// Ctrl+/ and Ctrl+R overlays. Ranked rows are computed here so keyRouter
|
|
149
|
+
// addresses exactly what ScreenLayout paints.
|
|
150
|
+
const [search, setSearch] = useState({ mode: null, query: "", index: 0 });
|
|
151
|
+
const commandRows = useMemo(() => fuzzyRank(SLASH_COMMANDS.map((c) => ({
|
|
152
|
+
key: `/${c.name}`, label: `/${c.name}${c.args ? ` ${c.args}` : ""}`, detail: c.description,
|
|
153
|
+
})), search.query, (r) => `${r.label} ${r.detail ?? ""}`), [search.query]);
|
|
154
|
+
const historyRows = useMemo(() => fuzzyRank(history.map((h, i) => ({ key: `h${i}`, label: h })), search.query, (r) => r.label), [history, search.query]);
|
|
155
|
+
// Live abort handle for the in-flight stream + one queued prompt.
|
|
156
|
+
const abortRef = useRef(null);
|
|
157
|
+
const queuedSubmitRef = useRef(null);
|
|
158
|
+
// Per-session token accounting, filled from stream/chat responses.
|
|
159
|
+
const usageRef = useRef({ requests: 0, promptTokens: 0, completionTokens: 0 });
|
|
160
|
+
// Fresh transcript for memoized callbacks (sendTurn must see every turn).
|
|
161
|
+
const messagesRef = useRef([]);
|
|
162
|
+
useEffect(() => { messagesRef.current = messages; }, [messages]);
|
|
163
|
+
const authed = Boolean(config.apiKey || config.token);
|
|
164
|
+
// A bring-your-own external provider supplies its own key, so platform auth
|
|
165
|
+
// is not required to chat when one is active.
|
|
166
|
+
const externalActive = Boolean(getActiveProvider());
|
|
167
|
+
const agentName = agentPickFlow.agentNames.current.get(agentId) ?? agentId;
|
|
168
|
+
// Elapsed-seconds ticker while streaming
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (!streaming)
|
|
171
|
+
return;
|
|
172
|
+
setElapsed(0);
|
|
173
|
+
const iv = setInterval(() => setElapsed((s) => s + 1), 1000);
|
|
174
|
+
return () => clearInterval(iv);
|
|
175
|
+
}, [streaming]);
|
|
176
|
+
// Resolve the current agent's display name shortly after startup.
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
if (!authed)
|
|
179
|
+
return;
|
|
180
|
+
let alive = true;
|
|
181
|
+
import("../core/provider/index.js").then(async ({ apiCall }) => {
|
|
182
|
+
const res = await apiCall("/api/v1/agents");
|
|
183
|
+
if (!alive || !res.ok)
|
|
184
|
+
return;
|
|
185
|
+
for (const a of res.data ?? []) {
|
|
186
|
+
const id = (a.id ?? a.agent_id ?? "");
|
|
187
|
+
if (id && a.name)
|
|
188
|
+
agentPickFlow.agentNames.current.set(id, a.name);
|
|
189
|
+
}
|
|
190
|
+
}).catch(() => { });
|
|
191
|
+
return () => { alive = false; };
|
|
192
|
+
}, [authed, agentPickFlow.agentNames]);
|
|
193
|
+
/* ── Local `odysx local ...` dispatch (non-gated ops + approvals) ── */
|
|
194
|
+
const runLocal = useCallback(async (cliArgs) => {
|
|
195
|
+
try {
|
|
196
|
+
// Import registers the command, then fetch it from the registry.
|
|
197
|
+
await import("../commands/local.js");
|
|
198
|
+
const { getAllCommands } = await import("../core/registry/index.js");
|
|
199
|
+
const entry = getAllCommands().get("local");
|
|
200
|
+
if (!entry)
|
|
201
|
+
throw new Error("local command not registered");
|
|
202
|
+
const result = await entry.handler({}, { args: cliArgs });
|
|
203
|
+
// Keep the command output even on failure — see the same logic in
|
|
204
|
+
// runCommand.ts; a failed `local exec` still made sense to read.
|
|
205
|
+
const output = typeof result.data === "string"
|
|
206
|
+
? result.data
|
|
207
|
+
: result.data === undefined
|
|
208
|
+
? ""
|
|
209
|
+
: JSON.stringify(result.data);
|
|
210
|
+
const body = [
|
|
211
|
+
result.error ? `✗ ${result.error}` : result.message,
|
|
212
|
+
output.trim(),
|
|
213
|
+
].filter(Boolean).join("\n");
|
|
214
|
+
addMessage((body || "(no output)").slice(0, 1500));
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
addMessage(`✗ ${err instanceof Error ? err.message : String(err)}`);
|
|
218
|
+
}
|
|
219
|
+
}, [addMessage]);
|
|
220
|
+
/* ── Slash-menu state: opens whenever the word under the *caret* starts
|
|
221
|
+
* with "/" — not just at line start, so "/cmd" works mid-prompt too.
|
|
222
|
+
* Bare "/" lists ALL commands; typing letters after it filters them.
|
|
223
|
+
* A command only dispatches when it is the first token; text before it
|
|
224
|
+
* means the user is writing prose, so Enter sends instead. ── */
|
|
225
|
+
const { word: menuWordRaw, start: menuWordStart } = wordAt(input, cursor);
|
|
226
|
+
const menuWord = menuWordRaw.startsWith("/") ? menuWordRaw.slice(1) : null;
|
|
227
|
+
// menuWordStart is a code-point index; slice the code-point array, not the
|
|
228
|
+
// string (an emoji before the command is two UTF-16 units and would make
|
|
229
|
+
// the prefix look non-empty, so the menu never opened after "😀 /h").
|
|
230
|
+
const menuOpen = menuWord !== null && toChars(input).slice(0, menuWordStart).join("").trim() === "";
|
|
231
|
+
const filteredCommands = menuOpen
|
|
232
|
+
? SLASH_COMMANDS.filter((c) => c.name.startsWith(menuWord.toLowerCase()))
|
|
233
|
+
: [];
|
|
234
|
+
const clampedMenuIndex = Math.min(menuIndex, Math.max(0, filteredCommands.length - 1));
|
|
235
|
+
/* ── Command context shared by all slash handlers ──── */
|
|
236
|
+
const requestExit = useCallback(() => {
|
|
237
|
+
// Stop an in-flight stream first: exiting with the HTTP body reader open
|
|
238
|
+
// leaves the server waiting on a socket nobody owns.
|
|
239
|
+
abortRef.current?.abort();
|
|
240
|
+
abortRef.current = null;
|
|
241
|
+
app.exit();
|
|
242
|
+
exitWith(0);
|
|
243
|
+
}, [app]);
|
|
244
|
+
const acceptTrust = useCallback(() => {
|
|
245
|
+
try {
|
|
246
|
+
rememberFolder();
|
|
247
|
+
setTrust((t) => ({ ...t, pending: false }));
|
|
248
|
+
addMessage(`✓ Trusted workspace — ${permissionMode} mode. Manage with /trust and /mode.`);
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
// A failed write must NOT unlock the UI: the trust store failing closed
|
|
252
|
+
// is what keeps an untrusted folder from being used by default.
|
|
253
|
+
addMessage(`✗ Could not save folder trust: ${err instanceof Error ? err.message : String(err)}`);
|
|
254
|
+
requestExit();
|
|
255
|
+
}
|
|
256
|
+
}, [addMessage, permissionMode, requestExit]);
|
|
257
|
+
const openAgentPicker = useCallback(() => void agentPickFlow.openAgentPicker(agentId), [agentPickFlow, agentId]);
|
|
258
|
+
const cmdCtx = {
|
|
259
|
+
addMessage,
|
|
260
|
+
setMessages,
|
|
261
|
+
sessionId: () => sessionIdRef.current,
|
|
262
|
+
agentId,
|
|
263
|
+
config: { apiKey: config.apiKey ?? undefined, token: config.token ?? undefined, apiUrl: config.apiUrl },
|
|
264
|
+
openAgentPicker,
|
|
265
|
+
setAgentId,
|
|
266
|
+
resumeSession: (sid) => void sessionPickFlow.resumeSession(sid),
|
|
267
|
+
openSessionPicker: () => void sessionPickFlow.openSessionPicker(),
|
|
268
|
+
openKeysPanel: keysFlow.openKeysPanel,
|
|
269
|
+
setPendingOp,
|
|
270
|
+
resetTranscript,
|
|
271
|
+
newSession: () => {
|
|
272
|
+
abortRef.current?.abort();
|
|
273
|
+
abortRef.current = null;
|
|
274
|
+
sessionIdRef.current = randomUUID();
|
|
275
|
+
usageRef.current = { requests: 0, promptTokens: 0, completionTokens: 0 };
|
|
276
|
+
resetTranscript();
|
|
277
|
+
addMessage(`✓ New session ${sessionIdRef.current.slice(0, 8)} — server conversation reset.`);
|
|
278
|
+
},
|
|
279
|
+
usageRef,
|
|
280
|
+
abortStream: () => abortRef.current?.abort(),
|
|
281
|
+
requestExit,
|
|
282
|
+
setAuthMode: authFlow.setAuthMode,
|
|
283
|
+
setAuthIndex: authFlow.setAuthIndex,
|
|
284
|
+
};
|
|
285
|
+
const runCommandFromShell = useCallback((raw) => runCommand(raw, cmdCtx, messages),
|
|
286
|
+
// cmdCtx is rebuilt each render by design — messages must stay fresh.
|
|
287
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
288
|
+
[cmdCtx, messages]);
|
|
289
|
+
/* ── Chat turn: stream the reply with fallback + usage accounting ── */
|
|
290
|
+
const sendTurn = useCallback(async (text) => {
|
|
291
|
+
const controller = new AbortController();
|
|
292
|
+
abortRef.current = controller;
|
|
293
|
+
// Tokens can arrive dozens of times per second. Re-rendering Ink on each
|
|
294
|
+
// one is the main source of stream flicker, so buffer them and commit at
|
|
295
|
+
// ~30fps. The final flush in `finally` guarantees no text is lost.
|
|
296
|
+
let pending = "";
|
|
297
|
+
let timer = null;
|
|
298
|
+
const commit = () => {
|
|
299
|
+
if (!pending)
|
|
300
|
+
return;
|
|
301
|
+
const chunk = pending;
|
|
302
|
+
pending = "";
|
|
303
|
+
setMessages((prev) => {
|
|
304
|
+
const next = [...prev];
|
|
305
|
+
const last = next[next.length - 1];
|
|
306
|
+
if (last && last.role === "assistant") {
|
|
307
|
+
next[next.length - 1] = { ...last, text: last.text + chunk };
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
next.push({ role: "assistant", text: chunk, agentName });
|
|
311
|
+
}
|
|
312
|
+
return next;
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
const appendAssistant = (token) => {
|
|
316
|
+
if (!token)
|
|
317
|
+
return;
|
|
318
|
+
pending += token;
|
|
319
|
+
if (timer)
|
|
320
|
+
return;
|
|
321
|
+
timer = setTimeout(() => {
|
|
322
|
+
timer = null;
|
|
323
|
+
commit();
|
|
324
|
+
}, 33);
|
|
325
|
+
};
|
|
326
|
+
const flushAssistant = () => {
|
|
327
|
+
if (timer) {
|
|
328
|
+
clearTimeout(timer);
|
|
329
|
+
timer = null;
|
|
330
|
+
}
|
|
331
|
+
commit();
|
|
332
|
+
};
|
|
333
|
+
try {
|
|
334
|
+
usageRef.current.requests += 1;
|
|
335
|
+
// External provider active (config.provider set) → talk to it directly,
|
|
336
|
+
// bypassing the OdysX backend entirely (bring-your-own key).
|
|
337
|
+
const external = getActiveProvider();
|
|
338
|
+
if (external) {
|
|
339
|
+
// Read the transcript through a ref: sendTurn is memoized, so closing
|
|
340
|
+
// over `messages` would freeze the provider history at mount time
|
|
341
|
+
// (turn 2 onward would forget the conversation).
|
|
342
|
+
const history = messagesRef.current
|
|
343
|
+
.filter((m) => m.role === "user" || m.role === "assistant")
|
|
344
|
+
.map((m) => ({ role: m.role, content: m.text }));
|
|
345
|
+
await streamExternalChat([...history, { role: "user", content: text }], {
|
|
346
|
+
system: `You are ${agentName}, the user's coding agent in the OdysX Codemind CLI. ` +
|
|
347
|
+
`Be concise and precise.`,
|
|
348
|
+
onToken: appendAssistant,
|
|
349
|
+
signal: controller.signal,
|
|
350
|
+
});
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
await streamChat("/api/v1/llm/chat/stream", { agent_id: agentId, message: text, session_id: sessionIdRef.current }, appendAssistant, undefined, controller.signal, (u) => {
|
|
354
|
+
usageRef.current.promptTokens += u.promptTokens;
|
|
355
|
+
usageRef.current.completionTokens += u.completionTokens;
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
catch (streamErr) {
|
|
359
|
+
const streamText = streamErr instanceof Error ? streamErr.message : String(streamErr);
|
|
360
|
+
// User pressed esc — the abort already stopped the stream; say so cleanly.
|
|
361
|
+
const aborted = (streamErr instanceof Error && streamErr.name === "AbortError") || controller.signal.aborted;
|
|
362
|
+
if (aborted) {
|
|
363
|
+
flushAssistant(); // keep whatever arrived before the interrupt
|
|
364
|
+
addMessage("✋ interrupted");
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
// The master agent doesn't support SSE — fall back to blocking /llm/chat.
|
|
368
|
+
if (/HTTP 400/.test(streamText) && /Streaming is not supported/i.test(streamText)) {
|
|
369
|
+
try {
|
|
370
|
+
const res = await apiCall("/api/v1/llm/chat", {
|
|
371
|
+
method: "POST",
|
|
372
|
+
body: { agent_id: agentId, message: text, session_id: sessionIdRef.current },
|
|
373
|
+
signal: controller.signal,
|
|
374
|
+
});
|
|
375
|
+
if (!res.ok)
|
|
376
|
+
throw new Error(res.error ?? `HTTP ${res.status}`);
|
|
377
|
+
usageRef.current.promptTokens += res.data?.usage?.prompt_tokens ?? 0;
|
|
378
|
+
usageRef.current.completionTokens += res.data?.usage?.completion_tokens ?? 0;
|
|
379
|
+
appendAssistant(res.data?.answer ?? "(empty reply)");
|
|
380
|
+
}
|
|
381
|
+
catch (chatErr) {
|
|
382
|
+
addMessage(`Error: ${chatErr instanceof Error ? chatErr.message : String(chatErr)}`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
addMessage(`Error: ${streamText}`);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
finally {
|
|
390
|
+
// Commit any buffered tokens before the turn is marked finished.
|
|
391
|
+
flushAssistant();
|
|
392
|
+
abortRef.current = null;
|
|
393
|
+
setStreaming(false);
|
|
394
|
+
// Drain the queue: a prompt typed while this turn was running.
|
|
395
|
+
const queued = queuedSubmitRef.current;
|
|
396
|
+
if (queued) {
|
|
397
|
+
queuedSubmitRef.current = null;
|
|
398
|
+
void submitRef.current?.(queued);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}, [agentId, agentName, addMessage]);
|
|
402
|
+
/* Entry point for every submitted line — slash commands or chat. */
|
|
403
|
+
const submit = useCallback(async (override) => {
|
|
404
|
+
const msg = (override ?? input).trim();
|
|
405
|
+
setInput("");
|
|
406
|
+
setCursor(0);
|
|
407
|
+
if (!msg)
|
|
408
|
+
return;
|
|
409
|
+
// A live (interactive) submit is blocked while a turn is streaming — but a
|
|
410
|
+
// queued drain always arrives via `override`, so it must bypass this guard.
|
|
411
|
+
// Without the override check the drained message hit the stale `streaming`
|
|
412
|
+
// closure in sendTurn's finally and was silently dropped.
|
|
413
|
+
if (!override && streaming)
|
|
414
|
+
return;
|
|
415
|
+
if (msg.startsWith("/")) {
|
|
416
|
+
setHistory((h) => appendHistoryRef.current(h, msg));
|
|
417
|
+
setHistoryIndex(-1);
|
|
418
|
+
const keysSub = msg.slice(1).split(" ");
|
|
419
|
+
if (keysSub[0].toLowerCase() === "keys" && (keysSub[1] ?? "").toLowerCase() === "new") {
|
|
420
|
+
const name = keysSub.slice(2).join(" ").trim();
|
|
421
|
+
keysFlow.setKeys((k) => ({ ...k, mode: "create-name", draftName: name, createdKey: null }));
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
runCommandFromShell(msg);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (!authed && !externalActive) {
|
|
428
|
+
addMessage("Not signed in — press Enter or type /signin to open the sign-in menu.");
|
|
429
|
+
// Land the user on the sign-in picker instead of a dead end: they can
|
|
430
|
+
// choose an existing key, manage keys, or cancel.
|
|
431
|
+
authFlow.setAuthIndex(0);
|
|
432
|
+
authFlow.setAuthMode("picker");
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
// @file mentions — inline each referenced file as context before sending.
|
|
436
|
+
// Resolution is confined to the workspace, same as every local op, so a
|
|
437
|
+
// prompt can't exfiltrate files the CLI wouldn't let it read directly.
|
|
438
|
+
let effective = msg;
|
|
439
|
+
if (msg.includes("@")) {
|
|
440
|
+
const { readFileSync, existsSync } = await import("node:fs");
|
|
441
|
+
const { confinePath } = await import("../core/workspace/index.js");
|
|
442
|
+
const { effective: expanded, unreadable } = expandMentions(msg, (p) => {
|
|
443
|
+
const decision = confinePath(p);
|
|
444
|
+
if (!decision.ok || !decision.resolved)
|
|
445
|
+
throw new Error("outside workspace");
|
|
446
|
+
return readFileSync(decision.resolved, "utf-8");
|
|
447
|
+
}, (p) => existsSync(p) && confinePath(p).ok);
|
|
448
|
+
for (const m of unreadable)
|
|
449
|
+
addMessage(`⚠ could not read @${m} — outside workspace or missing; sending without it`);
|
|
450
|
+
effective = expanded;
|
|
451
|
+
}
|
|
452
|
+
setHistory((h) => appendHistoryRef.current(h, msg));
|
|
453
|
+
setHistoryIndex(-1);
|
|
454
|
+
setMessages((prev) => [...prev, { role: "user", text: msg }]);
|
|
455
|
+
setStreaming(true);
|
|
456
|
+
await sendTurn(effective);
|
|
457
|
+
}, [input, streaming, authed, runCommandFromShell, sendTurn, authFlow, keysFlow, addMessage]);
|
|
458
|
+
// sendTurn's finally-block drains the queue through submit without a cycle.
|
|
459
|
+
const submitRef = useRef(null);
|
|
460
|
+
submitRef.current = submit;
|
|
461
|
+
/* ── Keyboard handling — delegated to input/keyRouter.ts ── */
|
|
462
|
+
useInput((chunk, key) => {
|
|
463
|
+
handleKey(chunk, key, {
|
|
464
|
+
trust,
|
|
465
|
+
setTrust,
|
|
466
|
+
search,
|
|
467
|
+
setSearch,
|
|
468
|
+
commandRows,
|
|
469
|
+
historyRows,
|
|
470
|
+
trustFolder: acceptTrust,
|
|
471
|
+
pendingOp,
|
|
472
|
+
keys: keysFlow.keys,
|
|
473
|
+
sessionPick: sessionPickFlow.sessionPick,
|
|
474
|
+
agentPick: agentPickFlow.agentPick,
|
|
475
|
+
authMode: authFlow.authMode,
|
|
476
|
+
authIndex: authFlow.authIndex,
|
|
477
|
+
authBusy: authFlow.authBusy,
|
|
478
|
+
apiKeyDraft: authFlow.apiKeyDraft,
|
|
479
|
+
streaming,
|
|
480
|
+
input,
|
|
481
|
+
cursor,
|
|
482
|
+
history,
|
|
483
|
+
historyIndex,
|
|
484
|
+
menuOpen,
|
|
485
|
+
filteredCommands,
|
|
486
|
+
clampedMenuIndex,
|
|
487
|
+
menuWordLength: menuWord?.length ?? 0,
|
|
488
|
+
setMessages,
|
|
489
|
+
setPendingOp,
|
|
490
|
+
setKeys: keysFlow.setKeys,
|
|
491
|
+
openKeysPanel: keysFlow.openKeysPanel,
|
|
492
|
+
createKey: keysFlow.createKey,
|
|
493
|
+
revokeSelected: keysFlow.revokeSelected,
|
|
494
|
+
showUsage: keysFlow.showUsage,
|
|
495
|
+
selectKey: (row) => void keysFlow.selectKey(row),
|
|
496
|
+
resumeSession: sessionPickFlow.resumeSession,
|
|
497
|
+
setSessionPick: sessionPickFlow.setSessionPick,
|
|
498
|
+
setAgentId,
|
|
499
|
+
setAgentPick: agentPickFlow.setAgentPick,
|
|
500
|
+
setAuthMode: authFlow.setAuthMode,
|
|
501
|
+
setAuthIndex: authFlow.setAuthIndex,
|
|
502
|
+
setApiKeyDraft: authFlow.setApiKeyDraft,
|
|
503
|
+
submitApiKey: authFlow.submitApiKey,
|
|
504
|
+
runLocal,
|
|
505
|
+
submit,
|
|
506
|
+
setMenuIndex,
|
|
507
|
+
setInput,
|
|
508
|
+
setCursor,
|
|
509
|
+
setHistory,
|
|
510
|
+
setHistoryIndex,
|
|
511
|
+
historyDraftRef,
|
|
512
|
+
abortRef,
|
|
513
|
+
queuedSubmitRef,
|
|
514
|
+
runCommand: runCommandFromShell,
|
|
515
|
+
requestExit,
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
/* ── Render ─────────────────────────────────────────── */
|
|
519
|
+
return (_jsx(ScreenLayout, { messages: messages, streaming: streaming, elapsed: elapsed, trust: { ...trust, folder: trustFolderPath, mode: permissionMode }, permissionMode: permissionMode, search: search, commandRows: commandRows, historyRows: historyRows, agentPick: agentPickFlow.agentPick, authMode: authFlow.authMode, authIndex: authFlow.authIndex, authBusy: authFlow.authBusy, apiKeyDraft: authFlow.apiKeyDraft, sessionPick: sessionPickFlow.sessionPick, pendingOp: pendingOp, keys: keysFlow.keys, menuOpen: menuOpen, filteredCommands: filteredCommands, clampedMenuIndex: clampedMenuIndex, input: input, cursor: cursor, agentName: agentName, model: config.model ?? "", authed: authed, provider: getActiveProvider()?.name, cwd: cwd, rows: terminal.rows }, transcriptKey));
|
|
520
|
+
};
|
|
521
|
+
/* -----------------------------------------------------
|
|
522
|
+
* Render entry point
|
|
523
|
+
* ----------------------------------------------------- */
|
|
524
|
+
export const runApp = () => {
|
|
525
|
+
// Run the REPL in the terminal's alternate screen buffer: everything we
|
|
526
|
+
// render is hidden on exit and the tab continues exactly where the user
|
|
527
|
+
// left off — scrollback, prompts, prior commands all intact. This must be
|
|
528
|
+
// written BEFORE render(): raw stdout writes anywhere inside Ink's render
|
|
529
|
+
// lifecycle desync its frame tracker (the /clear freeze bug), but a write
|
|
530
|
+
// before Ink starts is safe. Signal handlers re-raise so Ctrl+C/kill
|
|
531
|
+
// actually terminates instead of leaving a live process on a restored screen.
|
|
532
|
+
enterAltScreen();
|
|
533
|
+
// A render-time throw must never strand the user on a half-painted alt
|
|
534
|
+
// screen with no way back: the boundary catches component crashes, and the
|
|
535
|
+
// process-level hook covers everything outside React (key handlers,
|
|
536
|
+
// promises) — restore first, then report.
|
|
537
|
+
process.on("uncaughtException", (err) => {
|
|
538
|
+
restoreScreen();
|
|
539
|
+
process.stderr.write(`\n${err.stack ?? err.message}\n`);
|
|
540
|
+
process.exit(1);
|
|
541
|
+
});
|
|
542
|
+
process.on("unhandledRejection", (reason) => {
|
|
543
|
+
// A stray rejection during a stream must be visible, not silent — but a
|
|
544
|
+
// raw stderr write would corrupt Ink's frame, so go through the transcript
|
|
545
|
+
// when the app is mounted and fall back to stderr only if it is not.
|
|
546
|
+
const text = `⚠ ${reason instanceof Error ? reason.message : String(reason)}`;
|
|
547
|
+
if (rejectionSink)
|
|
548
|
+
rejectionSink(text);
|
|
549
|
+
else
|
|
550
|
+
process.stderr.write(`\n${text}\n`);
|
|
551
|
+
});
|
|
552
|
+
render(_jsx(ErrorBoundary, { children: _jsx(App, {}) }), { exitOnCtrlC: false });
|
|
553
|
+
};
|
|
554
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog listing commands: /mcp, /prompts, /skills.
|
|
3
|
+
*/
|
|
4
|
+
import type { CommandCtx } from "../../shared/types.js";
|
|
5
|
+
/** /mcp — list registered MCP servers. */
|
|
6
|
+
export declare const runMcp: (ctx: CommandCtx) => Promise<void>;
|
|
7
|
+
/** /prompts [slug] — list templates or render one template's body. */
|
|
8
|
+
export declare const runPrompts: (arg: string, ctx: CommandCtx) => Promise<void>;
|
|
9
|
+
/** /skills — list installed skills. */
|
|
10
|
+
export declare const runSkills: (ctx: CommandCtx) => Promise<void>;
|
|
11
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** /mcp — list registered MCP servers. */
|
|
2
|
+
export const runMcp = async (ctx) => {
|
|
3
|
+
const { apiCall } = await import("../../../core/provider/index.js");
|
|
4
|
+
const res = await apiCall("/api/v1/mcp-servers");
|
|
5
|
+
if (!res.ok) {
|
|
6
|
+
ctx.addMessage(`✗ ${res.error}`);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (!res.data.length) {
|
|
10
|
+
ctx.addMessage("No MCP servers registered. Register one: odysx mcp register");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
ctx.addMessage(`MCP servers (${res.data.length}):\n` +
|
|
14
|
+
res.data.map((s) => ` ${(s.name || s.id || "?").padEnd(24)} ${s.status ?? ""}`).join("\n"));
|
|
15
|
+
};
|
|
16
|
+
/** /prompts [slug] — list templates or render one template's body. */
|
|
17
|
+
export const runPrompts = async (arg, ctx) => {
|
|
18
|
+
const { apiCall } = await import("../../../core/provider/index.js");
|
|
19
|
+
if (arg.trim()) {
|
|
20
|
+
// Resolve one template by id or slug and show its rendered body.
|
|
21
|
+
let res = await apiCall(`/api/v1/prompt-templates/${encodeURIComponent(arg.trim())}`);
|
|
22
|
+
if (!res.ok) {
|
|
23
|
+
res = await apiCall(`/api/v1/prompt-templates/slug/${encodeURIComponent(arg.trim())}`);
|
|
24
|
+
}
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
ctx.addMessage(`✗ ${res.error}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
ctx.addMessage(`${res.data.name ?? arg}\n\n${(res.data.content ?? res.data.template ?? "").slice(0, 600)}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const res = await apiCall("/api/v1/prompt-templates");
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
ctx.addMessage(`✗ ${res.error}`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!res.data.length) {
|
|
38
|
+
ctx.addMessage("No prompt templates found.");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
ctx.addMessage(`Prompt templates (${res.data.length}) — view with /prompts <slug>:\n` +
|
|
42
|
+
res.data.slice(0, 15).map((p) => ` ${(p.slug || p.id || "?").padEnd(24)} ${p.name ?? ""}`).join("\n"));
|
|
43
|
+
};
|
|
44
|
+
/** /skills — list installed skills. */
|
|
45
|
+
export const runSkills = async (ctx) => {
|
|
46
|
+
const { apiCall } = await import("../../../core/provider/index.js");
|
|
47
|
+
const res = await apiCall("/api/v1/skills");
|
|
48
|
+
if (!res.ok) {
|
|
49
|
+
ctx.addMessage(`✗ ${res.error}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!res.data.length) {
|
|
53
|
+
ctx.addMessage("No skills installed. Browse: odysx skills marketplace");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
ctx.addMessage(`Skills (${res.data.length}):\n` +
|
|
57
|
+
res.data
|
|
58
|
+
.slice(0, 15)
|
|
59
|
+
.map((s) => ` ${(s.name || s.id || "?").padEnd(24)} ${s.description?.slice(0, 48) ?? ""}`)
|
|
60
|
+
.join("\n"));
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Misc slash-command bodies: help/status/model/sessions/usage/export/local/quit.
|
|
3
|
+
*/
|
|
4
|
+
import type { CommandCtx } from "../../shared/types.js";
|
|
5
|
+
/** /help — the command table. */
|
|
6
|
+
export declare const runHelp: (ctx: CommandCtx) => void;
|
|
7
|
+
/** /status — session info block. */
|
|
8
|
+
export declare const runStatus: (ctx: CommandCtx) => Promise<void>;
|
|
9
|
+
/** /mode — show or switch the permission posture for workspace operations. */
|
|
10
|
+
export declare const runMode: (arg: string, ctx: CommandCtx) => Promise<void>;
|
|
11
|
+
/** /trust — list trusted folders, or forget one. */
|
|
12
|
+
export declare const runTrust: (arg: string, ctx: CommandCtx) => Promise<void>;
|
|
13
|
+
/** /model <id> — persist a model override. */
|
|
14
|
+
export declare const runModel: (arg: string, ctx: CommandCtx) => Promise<void>;
|
|
15
|
+
/** /provider — list configured external providers or switch the active one. */
|
|
16
|
+
export declare const runProvider: (arg: string, ctx: CommandCtx) => Promise<void>;
|
|
17
|
+
/** /usage — per-session token totals. */
|
|
18
|
+
export declare const runUsage: (ctx: CommandCtx) => void;
|
|
19
|
+
/** /export — dump transcript JSON next to cwd, through the permission gate. */
|
|
20
|
+
export declare const runExport: (messages: Array<{
|
|
21
|
+
role: string;
|
|
22
|
+
text: string;
|
|
23
|
+
agentName?: string;
|
|
24
|
+
}>, ctx: CommandCtx) => Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* /local <read|write|exec|...> — mutating ops are put to the permission mode
|
|
27
|
+
* before anything is shown or run.
|
|
28
|
+
*
|
|
29
|
+
* Returns true when the caller must NOT run the command itself: either the
|
|
30
|
+
* prompt is now on screen, or the mode already answered (refused, or printed
|
|
31
|
+
* the command in guide mode). Read-only subcommands and `allow` decisions
|
|
32
|
+
* return false so the handler runs normally.
|
|
33
|
+
*/
|
|
34
|
+
export declare const runLocalGate: (arg: string, ctx: CommandCtx) => Promise<boolean>;
|
|
35
|
+
//# sourceMappingURL=misc.d.ts.map
|