nebula-treasury 0.1.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 +39 -0
- package/bin/nebula +11 -0
- package/package.json +65 -0
- package/src/commands/_agents.ts +14 -0
- package/src/commands/_unlock.ts +66 -0
- package/src/commands/chat-telegram.ts +398 -0
- package/src/commands/chat.tsx +1293 -0
- package/src/commands/drain.ts +90 -0
- package/src/commands/gateway-logs.ts +49 -0
- package/src/commands/gateway-run.ts +42 -0
- package/src/commands/gateway-start.ts +216 -0
- package/src/commands/gateway-status.ts +90 -0
- package/src/commands/gateway-stop.ts +133 -0
- package/src/commands/gateway.ts +101 -0
- package/src/commands/identity.ts +178 -0
- package/src/commands/init/cost.ts +40 -0
- package/src/commands/init/funding-gate.ts +64 -0
- package/src/commands/init/model-picker.ts +25 -0
- package/src/commands/init/operator-picker.ts +233 -0
- package/src/commands/init/telegram-step.ts +245 -0
- package/src/commands/init/wizard-state.ts +94 -0
- package/src/commands/init.ts +439 -0
- package/src/commands/logs.ts +37 -0
- package/src/commands/model.ts +48 -0
- package/src/commands/pairing-approve.ts +65 -0
- package/src/commands/pairing-clear.ts +39 -0
- package/src/commands/pairing-list.ts +55 -0
- package/src/commands/pairing-revoke.ts +49 -0
- package/src/commands/pairing.ts +81 -0
- package/src/commands/status.ts +44 -0
- package/src/commands/telegram-remove.ts +62 -0
- package/src/commands/telegram-setup.ts +64 -0
- package/src/commands/telegram-status.ts +87 -0
- package/src/commands/telegram.ts +44 -0
- package/src/config/load.ts +35 -0
- package/src/config/render.ts +99 -0
- package/src/index.ts +153 -0
- package/src/ui/app.tsx +673 -0
- package/src/ui/approval-summary.ts +32 -0
- package/src/ui/markdown-parse.ts +219 -0
- package/src/ui/markdown.tsx +37 -0
- package/src/ui/state.ts +181 -0
- package/src/util/bootstrap-mode.ts +25 -0
- package/src/util/bootstrap-progress-box.ts +378 -0
- package/src/util/cli-version.ts +28 -0
- package/src/util/format.ts +11 -0
- package/src/util/gateway-spawn.ts +125 -0
- package/src/util/gateway-version.ts +154 -0
- package/src/util/github-releases.ts +79 -0
- package/src/util/profile-key.ts +25 -0
- package/src/util/ref-resolver.ts +55 -0
- package/src/util/silence-console.ts +40 -0
- package/src/util/telegram-secrets.ts +218 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI argv dispatch. No subcommand → chat REPL, otherwise route to
|
|
3
|
+
* commands/<name>.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const argv = process.argv.slice(2)
|
|
7
|
+
// First arg starting with `--` means the user invoked the default subcommand
|
|
8
|
+
// (chat) with flags, e.g. `nebula --yolo`. Treat it as if `chat` were implicit.
|
|
9
|
+
// Exception: `--help` and `--version` are top-level commands, not chat flags.
|
|
10
|
+
const first = argv[0]
|
|
11
|
+
const isTopLevelFlag = first === '--help' || first === '--version'
|
|
12
|
+
const sub = first?.startsWith('--') && !isTopLevelFlag ? 'chat' : first
|
|
13
|
+
|
|
14
|
+
async function main(): Promise<void> {
|
|
15
|
+
switch (sub) {
|
|
16
|
+
case undefined:
|
|
17
|
+
case 'chat': {
|
|
18
|
+
const { runChat } = await import('./commands/chat')
|
|
19
|
+
await runChat({ yolo: argv.includes('--yolo') })
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
case 'init': {
|
|
23
|
+
const { runInit } = await import('./commands/init')
|
|
24
|
+
await runInit()
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
case 'status': {
|
|
28
|
+
const { runStatus } = await import('./commands/status')
|
|
29
|
+
await runStatus()
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
case 'logs': {
|
|
33
|
+
const { runLogs } = await import('./commands/logs')
|
|
34
|
+
const tailIdx = argv.indexOf('--tail')
|
|
35
|
+
const tail = tailIdx >= 0 ? Number(argv[tailIdx + 1]) : undefined
|
|
36
|
+
const agentIdx = argv.indexOf('--agent')
|
|
37
|
+
const agent = agentIdx >= 0 ? argv[agentIdx + 1] : undefined
|
|
38
|
+
await runLogs({ agent, tail })
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
case 'model': {
|
|
42
|
+
const { runModel } = await import('./commands/model')
|
|
43
|
+
await runModel()
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
case 'drain': {
|
|
47
|
+
const toIdx = argv.indexOf('--to')
|
|
48
|
+
const to = toIdx >= 0 ? argv[toIdx + 1] : undefined
|
|
49
|
+
const yes = argv.includes('--yes') || argv.includes('-y')
|
|
50
|
+
const { runDrain } = await import('./commands/drain')
|
|
51
|
+
await runDrain({ to, yes })
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
case 'identity': {
|
|
55
|
+
const { parseIdentityArgs, runIdentity } = await import('./commands/identity')
|
|
56
|
+
const parsed = parseIdentityArgs(argv.slice(1))
|
|
57
|
+
if ('error' in parsed) {
|
|
58
|
+
console.error(`nebula identity: ${parsed.error}`)
|
|
59
|
+
process.exit(1)
|
|
60
|
+
}
|
|
61
|
+
await runIdentity(parsed)
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
case 'telegram': {
|
|
65
|
+
const { parseTelegramArgs, runTelegram } = await import('./commands/telegram')
|
|
66
|
+
const parsed = parseTelegramArgs(argv.slice(1))
|
|
67
|
+
if ('error' in parsed) {
|
|
68
|
+
console.error(`nebula telegram: ${parsed.error}`)
|
|
69
|
+
process.exit(1)
|
|
70
|
+
}
|
|
71
|
+
await runTelegram(parsed)
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
case 'pairing': {
|
|
75
|
+
const { parsePairingArgs, runPairing } = await import('./commands/pairing')
|
|
76
|
+
const parsed = parsePairingArgs(argv.slice(1))
|
|
77
|
+
if ('error' in parsed) {
|
|
78
|
+
console.error(`nebula pairing: ${parsed.error}`)
|
|
79
|
+
process.exit(1)
|
|
80
|
+
}
|
|
81
|
+
await runPairing(parsed)
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
case 'gateway': {
|
|
85
|
+
const { parseGatewayArgs, runGateway } = await import('./commands/gateway')
|
|
86
|
+
const parsed = parseGatewayArgs(argv.slice(1))
|
|
87
|
+
if ('error' in parsed) {
|
|
88
|
+
console.error(`nebula gateway: ${parsed.error}`)
|
|
89
|
+
process.exit(1)
|
|
90
|
+
}
|
|
91
|
+
await runGateway(parsed)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
case '-h':
|
|
95
|
+
case '--help':
|
|
96
|
+
case 'help': {
|
|
97
|
+
printHelp()
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
case '-v':
|
|
101
|
+
case '--version':
|
|
102
|
+
case 'version': {
|
|
103
|
+
const { resolveCliVersion } = await import('./util/cli-version')
|
|
104
|
+
const v = await resolveCliVersion()
|
|
105
|
+
console.log(v)
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
default: {
|
|
109
|
+
console.log(`Unknown command: ${sub}`)
|
|
110
|
+
printHelp()
|
|
111
|
+
process.exit(1)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function printHelp(): void {
|
|
117
|
+
console.log(
|
|
118
|
+
[
|
|
119
|
+
'nebula: a Mantle-native, policy-aware AI treasury assistant',
|
|
120
|
+
'',
|
|
121
|
+
'Commands:',
|
|
122
|
+
' nebula init bootstrap a new agent identity + local keystore',
|
|
123
|
+
' nebula [--yolo] interactive chat with your agent (default; --yolo skips approvals)',
|
|
124
|
+
' nebula status show agent + wallet + config state',
|
|
125
|
+
' nebula logs tail the activity log (flags: --tail N, --agent <id>)',
|
|
126
|
+
' nebula drain --to <addr> sweep agent EOA balance to address (default: operator)',
|
|
127
|
+
' nebula model re-pick the brain model',
|
|
128
|
+
' nebula identity <sub> ERC-8004 agent identity (subs: card | register | show)',
|
|
129
|
+
' nebula telegram <sub> configure phone-DM gateway (subs: setup | status | remove)',
|
|
130
|
+
' nebula pairing <sub> manage DM pairing approvals (subs: list | approve | revoke | clear-pending)',
|
|
131
|
+
' usage: nebula pairing approve telegram <code>',
|
|
132
|
+
' nebula gateway <sub> always-on agent gateway daemon (subs: run | start | stop | restart | status | logs)',
|
|
133
|
+
' run = foreground, start = bg + Touch ID, stop = SIGTERM via lock',
|
|
134
|
+
' nebula version print CLI version (aliases: --version, -v)',
|
|
135
|
+
' nebula help show this message (aliases: --help, -h)',
|
|
136
|
+
'',
|
|
137
|
+
].join('\n'),
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
main()
|
|
142
|
+
.then(() => {
|
|
143
|
+
// Force-exit on success because some SDKs (e.g. the WalletConnect relay)
|
|
144
|
+
// leak open handles (websockets, heartbeat timers) we have no hooks to
|
|
145
|
+
// drain. Without this, one-shot commands like `nebula init` would hang at
|
|
146
|
+
// the prompt indefinitely after their work completed. `chat` returns only
|
|
147
|
+
// when the user actually quits, so this also gives chat a clean exit.
|
|
148
|
+
process.exit(0)
|
|
149
|
+
})
|
|
150
|
+
.catch(e => {
|
|
151
|
+
console.error('fatal:', (e as Error).message)
|
|
152
|
+
process.exit(1)
|
|
153
|
+
})
|