arc402-cli 0.7.5 → 0.9.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/INK6-UX-SPEC.md +446 -0
- package/MIGRATION-SPEC.md +108 -0
- package/dist/abis.js +14 -17
- package/dist/abis.js.map +1 -1
- package/dist/bundler.d.ts +1 -1
- package/dist/bundler.d.ts.map +1 -1
- package/dist/bundler.js +27 -61
- package/dist/bundler.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -9
- package/dist/client.js.map +1 -1
- package/dist/coinbase-smart-wallet.js +1 -4
- package/dist/coinbase-smart-wallet.js.map +1 -1
- package/dist/commands/accept.js +25 -28
- package/dist/commands/accept.js.map +1 -1
- package/dist/commands/agent-handshake.js +15 -18
- package/dist/commands/agent-handshake.js.map +1 -1
- package/dist/commands/agent.js +98 -104
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/agreements.js +62 -98
- package/dist/commands/agreements.js.map +1 -1
- package/dist/commands/arbitrator.js +45 -81
- package/dist/commands/arbitrator.js.map +1 -1
- package/dist/commands/arena-handshake.js +27 -30
- package/dist/commands/arena-handshake.js.map +1 -1
- package/dist/commands/arena.js +12 -18
- package/dist/commands/arena.js.map +1 -1
- package/dist/commands/backup.js +30 -36
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/cancel.js +15 -18
- package/dist/commands/cancel.js.map +1 -1
- package/dist/commands/channel.js +45 -81
- package/dist/commands/channel.js.map +1 -1
- package/dist/commands/coldstart.js +31 -34
- package/dist/commands/coldstart.js.map +1 -1
- package/dist/commands/config.js +23 -29
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/contract-interaction.js +12 -15
- package/dist/commands/contract-interaction.js.map +1 -1
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +98 -135
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/deliver.js +37 -76
- package/dist/commands/deliver.js.map +1 -1
- package/dist/commands/discover.js +24 -27
- package/dist/commands/discover.js.map +1 -1
- package/dist/commands/dispute.js +104 -110
- package/dist/commands/dispute.js.map +1 -1
- package/dist/commands/doctor.js +16 -55
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/endpoint.js +56 -95
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/feed.js +11 -18
- package/dist/commands/feed.js.map +1 -1
- package/dist/commands/hire.js +37 -40
- package/dist/commands/hire.js.map +1 -1
- package/dist/commands/migrate.js +30 -33
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/negotiate.d.ts.map +1 -1
- package/dist/commands/negotiate.js +34 -36
- package/dist/commands/negotiate.js.map +1 -1
- package/dist/commands/openshell.js +68 -104
- package/dist/commands/openshell.js.map +1 -1
- package/dist/commands/owner.js +17 -20
- package/dist/commands/owner.js.map +1 -1
- package/dist/commands/policy.js +41 -43
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/relay.d.ts.map +1 -1
- package/dist/commands/relay.js +18 -51
- package/dist/commands/relay.js.map +1 -1
- package/dist/commands/remediate.js +20 -23
- package/dist/commands/remediate.js.map +1 -1
- package/dist/commands/reputation.js +25 -27
- package/dist/commands/reputation.js.map +1 -1
- package/dist/commands/setup.js +65 -104
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/trust.js +17 -20
- package/dist/commands/trust.js.map +1 -1
- package/dist/commands/verify.js +18 -21
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/wallet.js +619 -625
- package/dist/commands/wallet.js.map +1 -1
- package/dist/commands/watch.js +33 -36
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/watchtower.js +37 -73
- package/dist/commands/watchtower.js.map +1 -1
- package/dist/commands/workroom.d.ts.map +1 -1
- package/dist/commands/workroom.js +138 -171
- package/dist/commands/workroom.js.map +1 -1
- package/dist/config.js +21 -65
- package/dist/config.js.map +1 -1
- package/dist/daemon/config.d.ts.map +1 -1
- package/dist/daemon/config.js +16 -53
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/hire-listener.d.ts +3 -3
- package/dist/daemon/hire-listener.d.ts.map +1 -1
- package/dist/daemon/hire-listener.js +13 -47
- package/dist/daemon/hire-listener.js.map +1 -1
- package/dist/daemon/index.d.ts +1 -1
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +50 -88
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/job-lifecycle.d.ts +1 -1
- package/dist/daemon/job-lifecycle.d.ts.map +1 -1
- package/dist/daemon/job-lifecycle.js +11 -51
- package/dist/daemon/job-lifecycle.js.map +1 -1
- package/dist/daemon/notify.d.ts +1 -1
- package/dist/daemon/notify.d.ts.map +1 -1
- package/dist/daemon/notify.js +19 -53
- package/dist/daemon/notify.js.map +1 -1
- package/dist/daemon/token-metering.js +8 -47
- package/dist/daemon/token-metering.js.map +1 -1
- package/dist/daemon/userops.d.ts +2 -2
- package/dist/daemon/userops.d.ts.map +1 -1
- package/dist/daemon/userops.js +23 -27
- package/dist/daemon/userops.js.map +1 -1
- package/dist/daemon/wallet-monitor.d.ts +1 -1
- package/dist/daemon/wallet-monitor.d.ts.map +1 -1
- package/dist/daemon/wallet-monitor.js +8 -12
- package/dist/daemon/wallet-monitor.js.map +1 -1
- package/dist/drain-v4.js +26 -64
- package/dist/drain-v4.js.map +1 -1
- package/dist/endpoint-config.js +20 -63
- package/dist/endpoint-config.js.map +1 -1
- package/dist/endpoint-notify.js +9 -48
- package/dist/endpoint-notify.js.map +1 -1
- package/dist/index.js +16 -50
- package/dist/index.js.map +1 -1
- package/dist/openshell-runtime.d.ts.map +1 -1
- package/dist/openshell-runtime.js +38 -82
- package/dist/openshell-runtime.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +77 -83
- package/dist/program.js.map +1 -1
- package/dist/repl.js +25 -31
- package/dist/repl.js.map +1 -1
- package/dist/signing.js +3 -6
- package/dist/signing.js.map +1 -1
- package/dist/telegram-notify.js +3 -40
- package/dist/telegram-notify.js.map +1 -1
- package/dist/tui/App.d.ts +1 -9
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +87 -65
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/Footer.js +4 -7
- package/dist/tui/Footer.js.map +1 -1
- package/dist/tui/Header.d.ts +1 -2
- package/dist/tui/Header.d.ts.map +1 -1
- package/dist/tui/Header.js +9 -14
- package/dist/tui/Header.js.map +1 -1
- package/dist/tui/InputLine.d.ts +1 -2
- package/dist/tui/InputLine.d.ts.map +1 -1
- package/dist/tui/InputLine.js +92 -46
- package/dist/tui/InputLine.js.map +1 -1
- package/dist/tui/Viewport.d.ts +5 -4
- package/dist/tui/Viewport.d.ts.map +1 -1
- package/dist/tui/Viewport.js +20 -13
- package/dist/tui/Viewport.js.map +1 -1
- package/dist/tui/WalletConnectPairing.d.ts +23 -0
- package/dist/tui/WalletConnectPairing.d.ts.map +1 -0
- package/dist/tui/WalletConnectPairing.js +75 -0
- package/dist/tui/WalletConnectPairing.js.map +1 -0
- package/dist/tui/components/Button.d.ts +7 -0
- package/dist/tui/components/Button.d.ts.map +1 -0
- package/dist/tui/components/Button.js +18 -0
- package/dist/tui/components/Button.js.map +1 -0
- package/dist/tui/components/CeremonyView.d.ts +13 -0
- package/dist/tui/components/CeremonyView.d.ts.map +1 -0
- package/dist/tui/components/CeremonyView.js +7 -0
- package/dist/tui/components/CeremonyView.js.map +1 -0
- package/dist/tui/components/CompletionDropdown.d.ts +7 -0
- package/dist/tui/components/CompletionDropdown.d.ts.map +1 -0
- package/dist/tui/components/CompletionDropdown.js +20 -0
- package/dist/tui/components/CompletionDropdown.js.map +1 -0
- package/dist/tui/components/ConfirmPrompt.d.ts +9 -0
- package/dist/tui/components/ConfirmPrompt.d.ts.map +1 -0
- package/dist/tui/components/ConfirmPrompt.js +7 -0
- package/dist/tui/components/ConfirmPrompt.js.map +1 -0
- package/dist/tui/components/InteractiveTable.d.ts +14 -0
- package/dist/tui/components/InteractiveTable.d.ts.map +1 -0
- package/dist/tui/components/InteractiveTable.js +58 -0
- package/dist/tui/components/InteractiveTable.js.map +1 -0
- package/dist/tui/components/StepSpinner.d.ts +11 -0
- package/dist/tui/components/StepSpinner.d.ts.map +1 -0
- package/dist/tui/components/StepSpinner.js +29 -0
- package/dist/tui/components/StepSpinner.js.map +1 -0
- package/dist/tui/components/Toast.d.ts +18 -0
- package/dist/tui/components/Toast.d.ts.map +1 -0
- package/dist/tui/components/Toast.js +25 -0
- package/dist/tui/components/Toast.js.map +1 -0
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +28 -21
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/useChat.js +13 -19
- package/dist/tui/useChat.js.map +1 -1
- package/dist/tui/useCommand.d.ts +2 -7
- package/dist/tui/useCommand.d.ts.map +1 -1
- package/dist/tui/useCommand.js +77 -165
- package/dist/tui/useCommand.js.map +1 -1
- package/dist/tui/useNotifications.d.ts +9 -0
- package/dist/tui/useNotifications.d.ts.map +1 -0
- package/dist/tui/useNotifications.js +14 -0
- package/dist/tui/useNotifications.js.map +1 -0
- package/dist/tui/useScroll.js +9 -12
- package/dist/tui/useScroll.js.map +1 -1
- package/dist/ui/banner.d.ts +12 -0
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +35 -19
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/colors.js +13 -19
- package/dist/ui/colors.js.map +1 -1
- package/dist/ui/format.js +6 -14
- package/dist/ui/format.js.map +1 -1
- package/dist/ui/spinner.js +6 -12
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/tree.js +3 -6
- package/dist/ui/tree.js.map +1 -1
- package/dist/utils/format.js +27 -41
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/hash.js +4 -42
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/time.js +2 -6
- package/dist/utils/time.js.map +1 -1
- package/dist/wallet-router.d.ts +1 -1
- package/dist/wallet-router.d.ts.map +1 -1
- package/dist/wallet-router.js +12 -19
- package/dist/wallet-router.js.map +1 -1
- package/dist/walletconnect-session.d.ts +1 -1
- package/dist/walletconnect-session.d.ts.map +1 -1
- package/dist/walletconnect-session.js +6 -11
- package/dist/walletconnect-session.js.map +1 -1
- package/dist/walletconnect.d.ts +6 -1
- package/dist/walletconnect.d.ts.map +1 -1
- package/dist/walletconnect.js +32 -35
- package/dist/walletconnect.js.map +1 -1
- package/package.json +7 -6
- package/src/bundler.ts +1 -1
- package/src/client.ts +1 -1
- package/src/commands/accept.ts +7 -7
- package/src/commands/agent-handshake.ts +4 -4
- package/src/commands/agent.ts +9 -9
- package/src/commands/agreements.ts +8 -8
- package/src/commands/arbitrator.ts +5 -5
- package/src/commands/arena-handshake.ts +6 -6
- package/src/commands/arena.ts +2 -2
- package/src/commands/backup.ts +1 -1
- package/src/commands/cancel.ts +6 -6
- package/src/commands/channel.ts +6 -6
- package/src/commands/coldstart.ts +5 -5
- package/src/commands/config.ts +2 -2
- package/src/commands/contract-interaction.ts +2 -2
- package/src/commands/daemon.ts +14 -11
- package/src/commands/deliver.ts +9 -9
- package/src/commands/discover.ts +5 -5
- package/src/commands/dispute.ts +7 -7
- package/src/commands/doctor.ts +2 -2
- package/src/commands/endpoint.ts +6 -6
- package/src/commands/feed.ts +1 -1
- package/src/commands/hire.ts +10 -10
- package/src/commands/migrate.ts +7 -7
- package/src/commands/negotiate.ts +6 -5
- package/src/commands/openshell.ts +4 -4
- package/src/commands/owner.ts +5 -5
- package/src/commands/policy.ts +5 -5
- package/src/commands/relay.ts +5 -1
- package/src/commands/remediate.ts +5 -5
- package/src/commands/reputation.ts +6 -6
- package/src/commands/setup.ts +1 -1
- package/src/commands/trust.ts +6 -6
- package/src/commands/verify.ts +6 -6
- package/src/commands/wallet.ts +15 -15
- package/src/commands/watch.ts +3 -3
- package/src/commands/watchtower.ts +6 -6
- package/src/commands/workroom.ts +14 -10
- package/src/daemon/config.ts +2 -1
- package/src/daemon/hire-listener.ts +3 -3
- package/src/daemon/index.ts +10 -9
- package/src/daemon/job-lifecycle.ts +1 -1
- package/src/daemon/notify.ts +4 -4
- package/src/daemon/userops.ts +4 -4
- package/src/daemon/wallet-monitor.ts +2 -2
- package/src/endpoint-notify.ts +1 -1
- package/src/index.ts +8 -7
- package/src/openshell-runtime.ts +5 -1
- package/src/program.ts +36 -36
- package/src/repl.ts +3 -3
- package/src/tui/App.tsx +75 -52
- package/src/tui/Header.tsx +26 -12
- package/src/tui/InputLine.tsx +108 -33
- package/src/tui/Viewport.tsx +22 -18
- package/src/tui/WalletConnectPairing.tsx +131 -0
- package/src/tui/components/Button.tsx +38 -0
- package/src/tui/components/CeremonyView.tsx +39 -0
- package/src/tui/components/CompletionDropdown.tsx +59 -0
- package/src/tui/components/ConfirmPrompt.tsx +36 -0
- package/src/tui/components/InteractiveTable.tsx +112 -0
- package/src/tui/components/StepSpinner.tsx +84 -0
- package/src/tui/components/Toast.tsx +59 -0
- package/src/tui/index.tsx +27 -9
- package/src/tui/useChat.ts +1 -1
- package/src/tui/useCommand.ts +86 -183
- package/src/tui/useNotifications.ts +28 -0
- package/src/ui/banner.ts +29 -2
- package/src/ui/tree.ts +1 -1
- package/src/wallet-router.ts +2 -2
- package/src/walletconnect-session.ts +1 -1
- package/src/walletconnect.ts +20 -5
- package/tsconfig.json +16 -7
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Box, Text, useInput } from "ink";
|
|
4
|
+
const MAX_VISIBLE_ROWS = 15;
|
|
5
|
+
export function InteractiveTable({ columns, rows, onSelect, selectedIndex: controlledIdx, }) {
|
|
6
|
+
const [internalIdx, setInternalIdx] = useState(0);
|
|
7
|
+
const selectedIndex = controlledIdx ?? internalIdx;
|
|
8
|
+
useInput((_input, key) => {
|
|
9
|
+
if (key.upArrow) {
|
|
10
|
+
setInternalIdx((i) => Math.max(0, i - 1));
|
|
11
|
+
}
|
|
12
|
+
if (key.downArrow) {
|
|
13
|
+
setInternalIdx((i) => Math.min(rows.length - 1, i + 1));
|
|
14
|
+
}
|
|
15
|
+
if (key.return && onSelect && rows[selectedIndex]) {
|
|
16
|
+
onSelect(rows[selectedIndex], selectedIndex);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
// Compute column widths
|
|
20
|
+
const colWidths = columns.map((col) => {
|
|
21
|
+
if (col.width)
|
|
22
|
+
return col.width;
|
|
23
|
+
let max = col.header.length;
|
|
24
|
+
for (const row of rows) {
|
|
25
|
+
const val = row[col.key] ?? "";
|
|
26
|
+
if (val.length > max)
|
|
27
|
+
max = val.length;
|
|
28
|
+
}
|
|
29
|
+
return Math.min(max + 2, 30);
|
|
30
|
+
});
|
|
31
|
+
const pad = (text, width, align = "left") => {
|
|
32
|
+
const truncated = text.length > width ? text.slice(0, width - 1) + "…" : text;
|
|
33
|
+
if (align === "right")
|
|
34
|
+
return truncated.padStart(width);
|
|
35
|
+
return truncated.padEnd(width);
|
|
36
|
+
};
|
|
37
|
+
// Window visible rows
|
|
38
|
+
let startRow = 0;
|
|
39
|
+
if (rows.length > MAX_VISIBLE_ROWS) {
|
|
40
|
+
startRow = Math.max(0, selectedIndex - Math.floor(MAX_VISIBLE_ROWS / 2));
|
|
41
|
+
startRow = Math.min(startRow, rows.length - MAX_VISIBLE_ROWS);
|
|
42
|
+
}
|
|
43
|
+
const visibleRows = rows.slice(startRow, startRow + MAX_VISIBLE_ROWS);
|
|
44
|
+
// Header
|
|
45
|
+
const headerLine = columns
|
|
46
|
+
.map((col, i) => pad(col.header, colWidths[i], col.align))
|
|
47
|
+
.join(" ");
|
|
48
|
+
const separatorLine = "─".repeat(headerLine.length);
|
|
49
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { children: _jsxs(Text, { bold: true, color: "white", children: [" ", headerLine] }) }), _jsx(Box, { children: _jsxs(Text, { dimColor: true, children: [" ", separatorLine] }) }), visibleRows.map((row, vi) => {
|
|
50
|
+
const actualIdx = startRow + vi;
|
|
51
|
+
const isSelected = actualIdx === selectedIndex;
|
|
52
|
+
const line = columns
|
|
53
|
+
.map((col, i) => pad(row[col.key] ?? "", colWidths[i], col.align))
|
|
54
|
+
.join(" ");
|
|
55
|
+
return (_jsx(Box, { children: _jsxs(Text, { color: isSelected ? "cyan" : "white", bold: isSelected, children: [isSelected ? "▸" : " ", " ", line] }) }, actualIdx));
|
|
56
|
+
}), rows.length > MAX_VISIBLE_ROWS && (_jsx(Box, { children: _jsxs(Text, { dimColor: true, children: [" ", "(", rows.length, " rows \u00B7 \u2191\u2193 navigate \u00B7 Enter select)"] }) })), rows.length <= MAX_VISIBLE_ROWS && rows.length > 0 && (_jsx(Box, { children: _jsx(Text, { dimColor: true, children: " (\u2191\u2193 navigate \u00B7 Enter select)" }) }))] }));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=InteractiveTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractiveTable.js","sourceRoot":"","sources":["../../../src/tui/components/InteractiveTable.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAgB1C,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,MAAM,UAAU,gBAAgB,CAAC,EAC/B,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,aAAa,EAAE,aAAa,GACN;IACtB,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,aAAa,IAAI,WAAW,CAAC;IAEnD,QAAQ,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACvB,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,cAAc,CAAC,CAAC,CAAC,EAAE,EAA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EAAE,EAAE,EAAE,EAAE;gBAC3B,MAAM,SAAS,GAAG,QAAQ,GAAG,EAAE,CAAC;gBAChC,MAAM,UAAU,GAAG,SAAS,KAAK,aAAa,CAAC;gBAC/C,MAAM,IAAI,GAAG,OAAO;qBACjB,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;qBACjE,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,CACL,KAAC,GAAG,cACF,MAAC,IAAI,IAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,aACzD,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAG,IAAI,IACzB,IAHC,SAAS,CAIb,CACP,CAAC;YACJ,CAAC,CAAC,EACD,IAAI,CAAC,MAAM,GAAG,gBAAgB,IAAI,CACjC,KAAC,GAAG,cACF,MAAC,IAAI,IAAC,QAAQ,mBACX,GAAG,OACF,IAAI,CAAC,MAAM,+DACR,GACH,CACP,EACA,IAAI,CAAC,MAAM,IAAI,gBAAgB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CACrD,KAAC,GAAG,cACF,KAAC,IAAI,IAAC,QAAQ,mEAAqC,GAC/C,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type StepStatus = "pending" | "running" | "done" | "error";
|
|
2
|
+
export interface StepSpinnerProps {
|
|
3
|
+
step: number;
|
|
4
|
+
total: number;
|
|
5
|
+
label: string;
|
|
6
|
+
status: StepStatus;
|
|
7
|
+
detail?: string;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function StepSpinner({ step, total, label, status, detail, error, }: StepSpinnerProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=StepSpinner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepSpinner.d.ts","sourceRoot":"","sources":["../../../src/tui/components/StepSpinner.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,GACN,EAAE,gBAAgB,2CA2DlB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { Box, Text } from "ink";
|
|
4
|
+
const SPINNER_FRAMES = ["◈", "◇", "◆", "◇"];
|
|
5
|
+
const SPINNER_INTERVAL = 120;
|
|
6
|
+
export function StepSpinner({ step, total, label, status, detail, error, }) {
|
|
7
|
+
const [frame, setFrame] = useState(0);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (status !== "running")
|
|
10
|
+
return;
|
|
11
|
+
const timer = setInterval(() => {
|
|
12
|
+
setFrame((f) => (f + 1) % SPINNER_FRAMES.length);
|
|
13
|
+
}, SPINNER_INTERVAL);
|
|
14
|
+
return () => clearInterval(timer);
|
|
15
|
+
}, [status]);
|
|
16
|
+
const prefix = `Step ${step}/${total}`;
|
|
17
|
+
if (status === "pending") {
|
|
18
|
+
return (_jsx(Box, { children: _jsxs(Text, { dimColor: true, children: [" ", prefix, " \u2014 ", label] }) }));
|
|
19
|
+
}
|
|
20
|
+
if (status === "running") {
|
|
21
|
+
return (_jsx(Box, { flexDirection: "column", children: _jsx(Box, { children: _jsxs(Text, { color: "cyan", children: [" ", SPINNER_FRAMES[frame], " ", prefix, " \u2014 ", label, "..."] }) }) }));
|
|
22
|
+
}
|
|
23
|
+
if (status === "done") {
|
|
24
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { children: _jsxs(Text, { color: "green", children: [" \u2713 ", prefix, " \u2014 ", label] }) }), detail && (_jsx(Box, { children: _jsxs(Text, { dimColor: true, children: [" \u2514 ", detail] }) }))] }));
|
|
25
|
+
}
|
|
26
|
+
// error
|
|
27
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { children: _jsxs(Text, { color: "red", children: [" \u2717 ", prefix, " \u2014 ", label] }) }), error && (_jsx(Box, { children: _jsxs(Text, { color: "red", children: [" \u2514 ", error] }) }))] }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=StepSpinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepSpinner.js","sourceRoot":"","sources":["../../../src/tui/components/StepSpinner.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAC5C,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAa7B,MAAM,UAAU,WAAW,CAAC,EAC1B,IAAI,EACJ,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,GACY;IACjB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IA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AAQ,aACzB,KAAC,GAAG,cACF,MAAC,IAAI,IAAC,KAAK,EAAC,KAAK,yBAAK,MAAM,cAAK,KAAK,IAAQ,GAC1C,EACL,KAAK,IAAI,CACR,KAAC,GAAG,cACF,MAAC,IAAI,IAAC,KAAK,EAAC,KAAK,2BAAO,KAAK,IAAQ,GACjC,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ToastVariant = "info" | "success" | "warning" | "error";
|
|
2
|
+
export interface ToastData {
|
|
3
|
+
id: string;
|
|
4
|
+
message: string;
|
|
5
|
+
variant: ToastVariant;
|
|
6
|
+
duration?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ToastProps {
|
|
9
|
+
toast: ToastData;
|
|
10
|
+
onDismiss: (id: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function Toast({ toast, onDismiss }: ToastProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export interface ToastContainerProps {
|
|
14
|
+
toasts: ToastData[];
|
|
15
|
+
onDismiss: (id: string) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function ToastContainer({ toasts, onDismiss }: ToastContainerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../src/tui/components/Toast.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AASD,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,UAAU,2CAiBrD;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,mBAAmB,kDAUxE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { Box, Text } from "ink";
|
|
4
|
+
const VARIANT_CONFIG = {
|
|
5
|
+
info: { icon: "◈", color: "cyan" },
|
|
6
|
+
success: { icon: "✓", color: "green" },
|
|
7
|
+
warning: { icon: "⚠", color: "yellow" },
|
|
8
|
+
error: { icon: "✗", color: "red" },
|
|
9
|
+
};
|
|
10
|
+
export function Toast({ toast, onDismiss }) {
|
|
11
|
+
const { icon, color } = VARIANT_CONFIG[toast.variant];
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const timer = setTimeout(() => {
|
|
14
|
+
onDismiss(toast.id);
|
|
15
|
+
}, toast.duration ?? 5000);
|
|
16
|
+
return () => clearTimeout(timer);
|
|
17
|
+
}, [toast.id, toast.duration, onDismiss]);
|
|
18
|
+
return (_jsx(Box, { children: _jsxs(Text, { color: color, children: [icon, " ", toast.message] }) }));
|
|
19
|
+
}
|
|
20
|
+
export function ToastContainer({ toasts, onDismiss }) {
|
|
21
|
+
if (toasts.length === 0)
|
|
22
|
+
return null;
|
|
23
|
+
return (_jsx(Box, { flexDirection: "column", children: toasts.map((toast) => (_jsx(Toast, { toast: toast, onDismiss: onDismiss }, toast.id))) }));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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M,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAErC,OAAO,CACL,KAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,YACxB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,KAAC,KAAK,IAAgB,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,IAA5C,KAAK,CAAC,EAAE,CAAwC,CAC7D,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
|
package/dist/tui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tui/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tui/index.tsx"],"names":[],"mappings":"AA8CA,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CA2C/C"}
|
package/dist/tui/index.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const os_1 = __importDefault(require("os"));
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
|
-
const pkg = require("../../package.json");
|
|
15
|
-
const CONFIG_PATH = path_1.default.join(os_1.default.homedir(), ".arc402", "config.json");
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from "ink";
|
|
3
|
+
import { App } from "./App.js";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import os from "node:os";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
const pkg = createRequire(import.meta.url)("../../package.json");
|
|
9
|
+
const CONFIG_PATH = path.join(os.homedir(), ".arc402", "config.json");
|
|
16
10
|
async function loadConfig() {
|
|
17
|
-
if (!
|
|
11
|
+
if (!fs.existsSync(CONFIG_PATH))
|
|
18
12
|
return {};
|
|
19
13
|
try {
|
|
20
|
-
return JSON.parse(
|
|
14
|
+
return JSON.parse(fs.readFileSync(CONFIG_PATH, "utf-8"));
|
|
21
15
|
}
|
|
22
16
|
catch {
|
|
23
17
|
return {};
|
|
@@ -25,8 +19,7 @@ async function loadConfig() {
|
|
|
25
19
|
}
|
|
26
20
|
async function getBalance(rpcUrl, address) {
|
|
27
21
|
try {
|
|
28
|
-
|
|
29
|
-
const ethersLib = require("ethers");
|
|
22
|
+
const ethersLib = await import("ethers");
|
|
30
23
|
const provider = new ethersLib.ethers.JsonRpcProvider(rpcUrl);
|
|
31
24
|
const bal = await Promise.race([
|
|
32
25
|
provider.getBalance(address),
|
|
@@ -38,7 +31,7 @@ async function getBalance(rpcUrl, address) {
|
|
|
38
31
|
return undefined;
|
|
39
32
|
}
|
|
40
33
|
}
|
|
41
|
-
async function launchTUI() {
|
|
34
|
+
export async function launchTUI() {
|
|
42
35
|
const config = await loadConfig();
|
|
43
36
|
let walletDisplay;
|
|
44
37
|
if (config.walletContractAddress) {
|
|
@@ -49,7 +42,21 @@ async function launchTUI() {
|
|
|
49
42
|
if (config.rpcUrl && config.walletContractAddress) {
|
|
50
43
|
balance = await getBalance(config.rpcUrl, config.walletContractAddress);
|
|
51
44
|
}
|
|
52
|
-
|
|
45
|
+
// Enter alternate screen buffer (full-screen mode)
|
|
46
|
+
process.stdout.write("\x1b[?1049h");
|
|
47
|
+
// Hide cursor initially — Ink manages it
|
|
48
|
+
process.stdout.write("\x1b[?25l");
|
|
49
|
+
const restore = () => {
|
|
50
|
+
process.stdout.write("\x1b[?25h"); // show cursor
|
|
51
|
+
process.stdout.write("\x1b[?1049l"); // leave alternate buffer
|
|
52
|
+
};
|
|
53
|
+
// Ensure restore on unexpected exit
|
|
54
|
+
process.on("exit", restore);
|
|
55
|
+
process.on("SIGINT", restore);
|
|
56
|
+
process.on("SIGTERM", restore);
|
|
57
|
+
const { waitUntilExit } = render(_jsx(App, { version: pkg.version, network: config.network, wallet: walletDisplay, balance: balance }), { exitOnCtrlC: true });
|
|
53
58
|
await waitUntilExit();
|
|
59
|
+
// Clean restore
|
|
60
|
+
restore();
|
|
54
61
|
}
|
|
55
62
|
//# sourceMappingURL=index.js.map
|
package/dist/tui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tui/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tui/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAwB,CAAC;AAExF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AAQtE,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,CAAC;IAC3C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAW,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,KAAK,U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AC;IAED,mDAAmD;IACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACpC,yCAAyC;IACzC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAElC,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc;QACjD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,yBAAyB;IAChE,CAAC,CAAC;IAEF,oCAAoC;IACpC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE/B,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAC9B,KAAC,GAAG,IACF,OAAO,EAAE,GAAG,CAAC,OAAO,EACpB,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,OAAO,GAChB,EACF,EAAE,WAAW,EAAE,IAAI,EAAE,CACtB,CAAC;IAEF,MAAM,aAAa,EAAE,CAAC;IAEtB,gBAAgB;IAChB,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/tui/useChat.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useChat = useChat;
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const colors_1 = require("../ui/colors");
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { c } from "../ui/colors.js";
|
|
10
4
|
/**
|
|
11
5
|
* Sends messages to the OpenClaw gateway and streams responses
|
|
12
6
|
* line-by-line into the viewport buffer via onLine callback.
|
|
13
7
|
*/
|
|
14
|
-
function useChat() {
|
|
15
|
-
const [isSending, setIsSending] =
|
|
16
|
-
const send =
|
|
8
|
+
export function useChat() {
|
|
9
|
+
const [isSending, setIsSending] = useState(false);
|
|
10
|
+
const send = useCallback(async (message, onLine) => {
|
|
17
11
|
setIsSending(true);
|
|
18
12
|
const trimmed = message.trim().slice(0, 10000);
|
|
19
13
|
// Show thinking placeholder
|
|
20
|
-
onLine(
|
|
14
|
+
onLine(chalk.dim(" ◈ ") + chalk.dim("thinking..."));
|
|
21
15
|
let res;
|
|
22
16
|
try {
|
|
23
17
|
res = await fetch("http://localhost:19000/api/agent", {
|
|
@@ -35,19 +29,19 @@ function useChat() {
|
|
|
35
29
|
msg.includes("UND_ERR_SOCKET");
|
|
36
30
|
if (isDown) {
|
|
37
31
|
onLine(" " +
|
|
38
|
-
|
|
32
|
+
chalk.yellow("⚠") +
|
|
39
33
|
" " +
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
chalk.dim("OpenClaw gateway not running. Start with: ") +
|
|
35
|
+
chalk.white("openclaw gateway start"));
|
|
42
36
|
}
|
|
43
37
|
else {
|
|
44
|
-
onLine(` ${
|
|
38
|
+
onLine(` ${c.failure} ${chalk.red(msg)}`);
|
|
45
39
|
}
|
|
46
40
|
setIsSending(false);
|
|
47
41
|
return;
|
|
48
42
|
}
|
|
49
43
|
if (!res.body) {
|
|
50
|
-
onLine(
|
|
44
|
+
onLine(chalk.dim(" ◈ ") + chalk.white("(empty response)"));
|
|
51
45
|
setIsSending(false);
|
|
52
46
|
return;
|
|
53
47
|
}
|
|
@@ -66,7 +60,7 @@ function useChat() {
|
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
if (line.trim()) {
|
|
69
|
-
onLine(
|
|
63
|
+
onLine(chalk.dim(" ◈ ") + chalk.white(line));
|
|
70
64
|
}
|
|
71
65
|
};
|
|
72
66
|
const reader = res.body.getReader();
|
package/dist/tui/useChat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChat.js","sourceRoot":"","sources":["../../src/tui/useChat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useChat.js","sourceRoot":"","sources":["../../src/tui/useChat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAOpC;;;GAGG;AACH,MAAM,UAAU,OAAO;IACrB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,MAAM,IAAI,GAAG,WAAW,CACtB,KAAK,EAAE,OAAe,EAAE,MAA8B,EAAiB,EAAE;QACvE,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAE/C,4BAA4B;QAC5B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;QAEpD,IAAI,GAAa,CAAC;QAClB,IAAI,CAAC;YACH,GAAG,GAAG,MAAM,KAAK,CAAC,kCAAkC,EAAE;gBACpD,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;gBACjE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;aACnC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAY,EA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AC"}
|
package/dist/tui/useCommand.d.ts
CHANGED
|
@@ -4,13 +4,8 @@ interface UseCommandResult {
|
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* Dispatches parsed commands to the commander program.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* process.stdout.write and routes output to the viewport.
|
|
10
|
-
*
|
|
11
|
-
* INTERACTIVE commands (WalletConnect, prompts): spawns a child process
|
|
12
|
-
* running `arc402 <command>` with inherited stdin so that QR codes render
|
|
13
|
-
* and prompts accept input. Output is captured line-by-line into the viewport.
|
|
7
|
+
* Captures stdout/stderr by monkey-patching process.stdout.write
|
|
8
|
+
* and routes all output to the viewport buffer via onLine callback.
|
|
14
9
|
*/
|
|
15
10
|
export declare function useCommand(): UseCommandResult;
|
|
16
11
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCommand.d.ts","sourceRoot":"","sources":["../../src/tui/useCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCommand.d.ts","sourceRoot":"","sources":["../../src/tui/useCommand.ts"],"names":[],"mappings":"AAKA,UAAU,gBAAgB;IACxB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,gBAAgB,CA+F7C"}
|
package/dist/tui/useCommand.js
CHANGED
|
@@ -1,178 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useCommand = useCommand;
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const program_1 = require("../program");
|
|
9
|
-
const child_process_1 = require("child_process");
|
|
10
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const colors_1 = require("../ui/colors");
|
|
12
|
-
/**
|
|
13
|
-
* Commands that use interactive prompts or WalletConnect QR flows.
|
|
14
|
-
* These MUST run in a child process so they can own stdin/stdout directly,
|
|
15
|
-
* because Ink holds stdin in raw mode for its own input handling.
|
|
16
|
-
*/
|
|
17
|
-
const INTERACTIVE_COMMANDS = new Set([
|
|
18
|
-
"wallet deploy",
|
|
19
|
-
"wallet set-guardian",
|
|
20
|
-
"wallet unfreeze",
|
|
21
|
-
"wallet authorize-machine-key",
|
|
22
|
-
"wallet revoke-machine-key",
|
|
23
|
-
"wallet set-passkey",
|
|
24
|
-
"wallet set-interceptor",
|
|
25
|
-
"wallet set-velocity-limit",
|
|
26
|
-
"wallet upgrade-registry",
|
|
27
|
-
"wallet execute-registry-upgrade",
|
|
28
|
-
"wallet cancel-registry-upgrade",
|
|
29
|
-
"wallet register-policy",
|
|
30
|
-
"wallet whitelist-contract",
|
|
31
|
-
"wallet governance setup",
|
|
32
|
-
"wallet policy set-limit",
|
|
33
|
-
"wallet policy set-daily-limit",
|
|
34
|
-
"wallet policy set",
|
|
35
|
-
"wallet import",
|
|
36
|
-
"config init",
|
|
37
|
-
]);
|
|
38
|
-
function isInteractiveCommand(input) {
|
|
39
|
-
const normalized = input.trim();
|
|
40
|
-
for (const cmd of INTERACTIVE_COMMANDS) {
|
|
41
|
-
if (normalized === cmd || normalized.startsWith(cmd + " "))
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
import { createProgram } from "../program.js";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { c } from "../ui/colors.js";
|
|
46
5
|
/**
|
|
47
6
|
* Dispatches parsed commands to the commander program.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* process.stdout.write and routes output to the viewport.
|
|
51
|
-
*
|
|
52
|
-
* INTERACTIVE commands (WalletConnect, prompts): spawns a child process
|
|
53
|
-
* running `arc402 <command>` with inherited stdin so that QR codes render
|
|
54
|
-
* and prompts accept input. Output is captured line-by-line into the viewport.
|
|
7
|
+
* Captures stdout/stderr by monkey-patching process.stdout.write
|
|
8
|
+
* and routes all output to the viewport buffer via onLine callback.
|
|
55
9
|
*/
|
|
56
|
-
function useCommand() {
|
|
57
|
-
const [isRunning, setIsRunning] =
|
|
58
|
-
const execute =
|
|
10
|
+
export function useCommand() {
|
|
11
|
+
const [isRunning, setIsRunning] = useState(false);
|
|
12
|
+
const execute = useCallback(async (input, onLine) => {
|
|
59
13
|
setIsRunning(true);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
14
|
+
// Capture stdout/stderr
|
|
15
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
16
|
+
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
17
|
+
let captureBuffer = "";
|
|
18
|
+
const flushBuffer = () => {
|
|
19
|
+
if (!captureBuffer)
|
|
20
|
+
return;
|
|
21
|
+
const lines = captureBuffer.split("\n");
|
|
22
|
+
captureBuffer = lines.pop() ?? "";
|
|
23
|
+
for (const line of lines) {
|
|
24
|
+
onLine(line);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const capturedWrite = (chunk, encodingOrCb, cb) => {
|
|
28
|
+
const str = typeof chunk === "string"
|
|
29
|
+
? chunk
|
|
30
|
+
: Buffer.from(chunk).toString("utf8");
|
|
31
|
+
captureBuffer += str;
|
|
32
|
+
flushBuffer();
|
|
33
|
+
// call callback if provided
|
|
34
|
+
const callback = typeof encodingOrCb === "function" ? encodingOrCb : cb;
|
|
35
|
+
if (callback)
|
|
36
|
+
callback();
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
// Monkey-patch (cast through unknown to bypass strict overload checking)
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
process.stdout.write = capturedWrite;
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
process.stderr.write = capturedWrite;
|
|
44
|
+
try {
|
|
45
|
+
const tokens = parseTokens(input);
|
|
46
|
+
const prog = createProgram();
|
|
47
|
+
prog.exitOverride();
|
|
48
|
+
prog.configureOutput({
|
|
49
|
+
writeOut: (str) => process.stdout.write(str),
|
|
50
|
+
writeErr: (str) => process.stderr.write(str),
|
|
51
|
+
});
|
|
52
|
+
await prog.parseAsync(["node", "arc402", ...tokens]);
|
|
65
53
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// Use stdio: 'inherit' so the child owns stdin/stdout/stderr directly.
|
|
81
|
-
// This means its output goes straight to the terminal (not captured in viewport)
|
|
82
|
-
// but that's correct — the child needs raw terminal access for QR codes, prompts, etc.
|
|
83
|
-
const child = (0, child_process_1.spawn)(process.execPath, [process.argv[1], ...tokens], {
|
|
84
|
-
stdio: "inherit",
|
|
85
|
-
env: { ...process.env, ARC402_NO_TUI: "1" }, // prevent child from launching its own TUI
|
|
86
|
-
cwd: process.cwd(),
|
|
87
|
-
});
|
|
88
|
-
child.on("close", (code) => {
|
|
89
|
-
onLine("");
|
|
90
|
-
if (code === 0) {
|
|
91
|
-
onLine(` ${colors_1.c.success} ${chalk_1.default.dim("Command completed")}`);
|
|
54
|
+
catch (err) {
|
|
55
|
+
const e = err;
|
|
56
|
+
if (e.code === "commander.helpDisplayed" ||
|
|
57
|
+
e.code === "commander.version" ||
|
|
58
|
+
e.code === "commander.executeSubCommandAsync") {
|
|
59
|
+
// already written or normal exit — no-op
|
|
60
|
+
}
|
|
61
|
+
else if (e.code === "commander.unknownCommand") {
|
|
62
|
+
const tokens = parseTokens(input);
|
|
63
|
+
onLine(` ${c.failure} ${chalk.red(`Unknown command: ${chalk.white(tokens[0])}`)} `);
|
|
64
|
+
onLine(chalk.dim(" Type 'help' for available commands"));
|
|
65
|
+
}
|
|
66
|
+
else if (e.code?.startsWith("commander.")) {
|
|
67
|
+
onLine(` ${c.failure} ${chalk.red(e.message ?? String(err))}`);
|
|
92
68
|
}
|
|
93
69
|
else {
|
|
94
|
-
onLine(` ${
|
|
70
|
+
onLine(` ${c.failure} ${chalk.red(e.message ?? String(err))}`);
|
|
95
71
|
}
|
|
96
|
-
resolve();
|
|
97
|
-
});
|
|
98
|
-
child.on("error", (err) => {
|
|
99
|
-
onLine(` ${colors_1.c.failure} ${chalk_1.default.red(`Failed to spawn: ${err.message}`)}`);
|
|
100
|
-
resolve();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Run a non-interactive command in-process with captured output.
|
|
106
|
-
*/
|
|
107
|
-
async function executeInProcess(input, onLine) {
|
|
108
|
-
// Capture stdout/stderr
|
|
109
|
-
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
110
|
-
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
111
|
-
let captureBuffer = "";
|
|
112
|
-
const flushBuffer = () => {
|
|
113
|
-
if (!captureBuffer)
|
|
114
|
-
return;
|
|
115
|
-
const lines = captureBuffer.split("\n");
|
|
116
|
-
captureBuffer = lines.pop() ?? "";
|
|
117
|
-
for (const line of lines) {
|
|
118
|
-
onLine(line);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
const capturedWrite = (chunk, encodingOrCb, cb) => {
|
|
122
|
-
const str = typeof chunk === "string"
|
|
123
|
-
? chunk
|
|
124
|
-
: Buffer.from(chunk).toString("utf8");
|
|
125
|
-
captureBuffer += str;
|
|
126
|
-
flushBuffer();
|
|
127
|
-
const callback = typeof encodingOrCb === "function" ? encodingOrCb : cb;
|
|
128
|
-
if (callback)
|
|
129
|
-
callback();
|
|
130
|
-
return true;
|
|
131
|
-
};
|
|
132
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
-
process.stdout.write = capturedWrite;
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
-
process.stderr.write = capturedWrite;
|
|
136
|
-
try {
|
|
137
|
-
const tokens = parseTokens(input);
|
|
138
|
-
const prog = (0, program_1.createProgram)();
|
|
139
|
-
prog.exitOverride();
|
|
140
|
-
prog.configureOutput({
|
|
141
|
-
writeOut: (str) => process.stdout.write(str),
|
|
142
|
-
writeErr: (str) => process.stderr.write(str),
|
|
143
|
-
});
|
|
144
|
-
await prog.parseAsync(["node", "arc402", ...tokens]);
|
|
145
|
-
}
|
|
146
|
-
catch (err) {
|
|
147
|
-
const e = err;
|
|
148
|
-
if (e.code === "commander.helpDisplayed" ||
|
|
149
|
-
e.code === "commander.version" ||
|
|
150
|
-
e.code === "commander.executeSubCommandAsync") {
|
|
151
|
-
// already written or normal exit — no-op
|
|
152
|
-
}
|
|
153
|
-
else if (e.code === "commander.unknownCommand") {
|
|
154
|
-
const tokens = parseTokens(input);
|
|
155
|
-
onLine(` ${colors_1.c.failure} ${chalk_1.default.red(`Unknown command: ${chalk_1.default.white(tokens[0])}`)} `);
|
|
156
|
-
onLine(chalk_1.default.dim(" Type 'help' for available commands"));
|
|
157
|
-
}
|
|
158
|
-
else if (e.code?.startsWith("commander.")) {
|
|
159
|
-
onLine(` ${colors_1.c.failure} ${chalk_1.default.red(e.message ?? String(err))}`);
|
|
160
72
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
73
|
+
finally {
|
|
74
|
+
// Flush remaining buffer
|
|
75
|
+
if (captureBuffer.trim()) {
|
|
76
|
+
onLine(captureBuffer);
|
|
77
|
+
captureBuffer = "";
|
|
78
|
+
}
|
|
79
|
+
// Restore original write functions
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
process.stdout.write = originalStdoutWrite;
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
+
process.stderr.write = originalStderrWrite;
|
|
84
|
+
setIsRunning(false);
|
|
170
85
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
|
-
process.stderr.write = originalStderrWrite;
|
|
175
|
-
}
|
|
86
|
+
}, []);
|
|
87
|
+
return { execute, isRunning };
|
|
176
88
|
}
|
|
177
89
|
// Shell-style tokenizer
|
|
178
90
|
function parseTokens(input) {
|