lyra-ai-agent 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/lyra +11 -0
- package/package.json +65 -0
- package/src/commands/_agents.ts +14 -0
- package/src/commands/chat-telegram.ts +398 -0
- package/src/commands/chat.tsx +1220 -0
- package/src/commands/demo.ts +177 -0
- package/src/commands/gateway-logs.ts +49 -0
- package/src/commands/gateway-run.ts +42 -0
- package/src/commands/gateway-start.ts +89 -0
- package/src/commands/gateway-status.ts +73 -0
- package/src/commands/gateway-stop.ts +133 -0
- package/src/commands/gateway.ts +101 -0
- package/src/commands/init/model-picker.ts +17 -0
- package/src/commands/init.ts +153 -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.test.ts +88 -0
- package/src/commands/pairing.ts +81 -0
- package/src/commands/status.ts +84 -0
- package/src/commands/telegram-remove.ts +45 -0
- package/src/commands/telegram-setup.ts +84 -0
- package/src/commands/telegram-status.ts +48 -0
- package/src/commands/telegram.test.ts +50 -0
- package/src/commands/telegram.ts +44 -0
- package/src/commands/whoami.ts +62 -0
- package/src/config/load.ts +35 -0
- package/src/config/render.test.ts +96 -0
- package/src/config/render.ts +99 -0
- package/src/index.ts +147 -0
- package/src/ui/app.tsx +719 -0
- package/src/ui/approval-summary.test.ts +132 -0
- package/src/ui/approval-summary.ts +28 -0
- package/src/ui/markdown-parse.ts +219 -0
- package/src/ui/markdown.test.ts +146 -0
- package/src/ui/markdown.tsx +37 -0
- package/src/ui/state.test.ts +74 -0
- package/src/ui/state.ts +176 -0
- package/src/util/bootstrap-mode.test.ts +40 -0
- package/src/util/bootstrap-mode.ts +25 -0
- package/src/util/bootstrap-progress-box.test.ts +190 -0
- package/src/util/bootstrap-progress-box.ts +378 -0
- package/src/util/cli-version.ts +28 -0
- package/src/util/format.test.ts +16 -0
- package/src/util/format.ts +11 -0
- package/src/util/gateway-spawn.test.ts +86 -0
- package/src/util/gateway-spawn.ts +125 -0
- package/src/util/gateway-version.test.ts +113 -0
- package/src/util/gateway-version.ts +154 -0
- package/src/util/github-releases.test.ts +116 -0
- package/src/util/github-releases.ts +79 -0
- package/src/util/ref-resolver.test.ts +77 -0
- package/src/util/ref-resolver.ts +55 -0
- package/src/util/silence-console.test.ts +53 -0
- package/src/util/silence-console.ts +40 -0
- package/src/util/sui-runtime.ts +74 -0
- package/src/util/telegram-secrets.test.ts +104 -0
- package/src/util/telegram-secrets.ts +99 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
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. `lyra --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 'whoami': {
|
|
33
|
+
const { runWhoami } = await import('./commands/whoami')
|
|
34
|
+
const ownerIdx = argv.indexOf('--owner')
|
|
35
|
+
const owner = ownerIdx >= 0 ? argv[ownerIdx + 1] : undefined
|
|
36
|
+
await runWhoami({ owner })
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
case 'demo': {
|
|
40
|
+
const { runDemo } = await import('./commands/demo')
|
|
41
|
+
await runDemo({ yes: argv.includes('--yes') || argv.includes('-y') })
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
case 'logs': {
|
|
45
|
+
const { runLogs } = await import('./commands/logs')
|
|
46
|
+
const tailIdx = argv.indexOf('--tail')
|
|
47
|
+
const tail = tailIdx >= 0 ? Number(argv[tailIdx + 1]) : undefined
|
|
48
|
+
const agentIdx = argv.indexOf('--agent')
|
|
49
|
+
const agent = agentIdx >= 0 ? argv[agentIdx + 1] : undefined
|
|
50
|
+
await runLogs({ agent, tail })
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
case 'model': {
|
|
54
|
+
const { runModel } = await import('./commands/model')
|
|
55
|
+
await runModel()
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
case 'telegram': {
|
|
59
|
+
const { parseTelegramArgs, runTelegram } = await import('./commands/telegram')
|
|
60
|
+
const parsed = parseTelegramArgs(argv.slice(1))
|
|
61
|
+
if ('error' in parsed) {
|
|
62
|
+
console.error(`lyra telegram: ${parsed.error}`)
|
|
63
|
+
process.exit(1)
|
|
64
|
+
}
|
|
65
|
+
await runTelegram(parsed)
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
case 'pairing': {
|
|
69
|
+
const { parsePairingArgs, runPairing } = await import('./commands/pairing')
|
|
70
|
+
const parsed = parsePairingArgs(argv.slice(1))
|
|
71
|
+
if ('error' in parsed) {
|
|
72
|
+
console.error(`lyra pairing: ${parsed.error}`)
|
|
73
|
+
process.exit(1)
|
|
74
|
+
}
|
|
75
|
+
await runPairing(parsed)
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
case 'gateway': {
|
|
79
|
+
const { parseGatewayArgs, runGateway } = await import('./commands/gateway')
|
|
80
|
+
const parsed = parseGatewayArgs(argv.slice(1))
|
|
81
|
+
if ('error' in parsed) {
|
|
82
|
+
console.error(`lyra gateway: ${parsed.error}`)
|
|
83
|
+
process.exit(1)
|
|
84
|
+
}
|
|
85
|
+
await runGateway(parsed)
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
case '-h':
|
|
89
|
+
case '--help':
|
|
90
|
+
case 'help': {
|
|
91
|
+
printHelp()
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
case '-v':
|
|
95
|
+
case '--version':
|
|
96
|
+
case 'version': {
|
|
97
|
+
const { resolveCliVersion } = await import('./util/cli-version')
|
|
98
|
+
const v = await resolveCliVersion()
|
|
99
|
+
console.log(v)
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
default: {
|
|
103
|
+
console.log(`Unknown command: ${sub}`)
|
|
104
|
+
printHelp()
|
|
105
|
+
process.exit(1)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function printHelp(): void {
|
|
111
|
+
console.log(
|
|
112
|
+
[
|
|
113
|
+
'lyra: a Sui-native, policy-bound AI finance agent',
|
|
114
|
+
'',
|
|
115
|
+
'Commands:',
|
|
116
|
+
' lyra init bootstrap the agent config (uses LYRA_AGENT_KEY)',
|
|
117
|
+
' lyra [--yolo] interactive chat with your agent (default; --yolo skips approvals)',
|
|
118
|
+
' lyra status show agent address + network + SUI balance + policy',
|
|
119
|
+
' lyra whoami [--owner 0x…] resolve the agent wallet an owner controls (same on web/CLI/TG)',
|
|
120
|
+
' lyra demo [--yes] run the guarded pipeline (policy → blocked over-cap → send → walrus)',
|
|
121
|
+
' lyra logs tail the activity log (flags: --tail N, --agent <id>)',
|
|
122
|
+
' lyra model re-pick the brain model',
|
|
123
|
+
' lyra telegram <sub> configure phone-DM gateway (subs: setup | status | remove)',
|
|
124
|
+
' lyra pairing <sub> manage DM pairing approvals (subs: list | approve | revoke | clear-pending)',
|
|
125
|
+
' usage: lyra pairing approve telegram <code>',
|
|
126
|
+
' lyra gateway <sub> always-on agent gateway daemon (subs: run | start | stop | restart | status | logs)',
|
|
127
|
+
' run = foreground, start = bg, stop = SIGTERM via lock',
|
|
128
|
+
' lyra version print CLI version (aliases: --version, -v)',
|
|
129
|
+
' lyra help show this message (aliases: --help, -h)',
|
|
130
|
+
'',
|
|
131
|
+
'Env: LYRA_AGENT_KEY (suiprivkey1…), LYRA_NETWORK, LYRA_PACKAGE_ID,',
|
|
132
|
+
' LYRA_LLM_BASE_URL, LYRA_LLM_MODEL, OPENAI_API_KEY, LYRA_POLICY_*',
|
|
133
|
+
'',
|
|
134
|
+
].join('\n'),
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
main()
|
|
139
|
+
.then(() => {
|
|
140
|
+
// Force-exit on success; `chat` returns only when the user actually quits,
|
|
141
|
+
// so this also gives chat a clean exit.
|
|
142
|
+
process.exit(0)
|
|
143
|
+
})
|
|
144
|
+
.catch(e => {
|
|
145
|
+
console.error('fatal:', (e as Error).message)
|
|
146
|
+
process.exit(1)
|
|
147
|
+
})
|