lyra-ai-agent 0.1.4 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyra-ai-agent",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "lyra CLI: a Sui-native, policy-bound AI finance agent. Real on-chain work gated by deterministic policy, simulation, and approval",
6
6
  "license": "MIT",
@@ -51,8 +51,8 @@
51
51
  "@opentui/core": "^0.1.97",
52
52
  "@opentui/solid": "^0.1.97",
53
53
  "lyra-core": "^0.1.2",
54
- "lyra-gateway": "^0.1.2",
55
- "lyra-plugin-onchain": "^0.1.2",
54
+ "lyra-gateway": "^0.1.6",
55
+ "lyra-plugin-onchain": "^0.1.5",
56
56
  "lyra-plugin-system": "^0.1.2",
57
57
  "lyra-plugin-telegram": "^0.1.2",
58
58
  "picocolors": "^1.1.1",
@@ -1,14 +1,13 @@
1
1
  import { cancel, intro, isCancel, note, outro, password, spinner, text } from '@clack/prompts'
2
2
  import { findAndLoadConfig } from '../config/load'
3
3
  import { writeConfigTs } from '../config/render'
4
+ import { setDotenvVar } from '../util/dotenv'
4
5
  import { fetchBotInfo, looksLikeBotToken, parseAllowedUserIds } from '../util/telegram-secrets'
5
6
 
6
7
  /**
7
- * `lyra telegram setup` — validate a bot token and print the env vars to set.
8
- *
9
- * On Sui the bot token is NOT stored on disk (there is no operator wallet to
10
- * encrypt it with). It lives only in the environment, so this command's job is
11
- * to validate the token + allowlist and hand back the exact `export` lines.
8
+ * `lyra telegram setup` — validate a bot token, enable the plugin, and persist
9
+ * the token to `~/.lyra/.env` (0600) so it's loaded automatically by `lyra` chat
10
+ * AND the `lyra gateway start` daemon no manual `export` needed.
12
11
  */
13
12
  export async function runTelegramSetup(): Promise<void> {
14
13
  intro('lyra telegram setup')
@@ -65,15 +64,20 @@ export async function runTelegramSetup(): Promise<void> {
65
64
  })
66
65
  }
67
66
 
67
+ // Persist to ~/.lyra/.env (0600) so both `lyra` and the gateway daemon load the
68
+ // token automatically — no manual export.
69
+ const envPath = setDotenvVar('TELEGRAM_BOT_TOKEN', String(token))
70
+ setDotenvVar('TELEGRAM_USERNAME', info.username)
71
+ if (chatId) setDotenvVar('TELEGRAM_CHAT_ID', String(chatId))
72
+
68
73
  note(
69
74
  [
70
- 'Set these in your environment (e.g. .env), then run `lyra`:',
75
+ `Saved to ${envPath} (loaded automatically).`,
76
+ chatId ? `Allowed user id: ${chatId}` : 'Open access (no allowlist).',
71
77
  '',
72
- ` export TELEGRAM_BOT_TOKEN=${token}`,
73
- ` export TELEGRAM_USERNAME=${info.username}`,
74
- ...(chatId
75
- ? [` export TELEGRAM_CHAT_ID=${chatId}`]
76
- : [' # TELEGRAM_CHAT_ID unset = open access']),
78
+ 'Run the bot:',
79
+ ' lyra — responds while the chat is open',
80
+ ' lyra gateway start — always-on daemon (responds 24/7)',
77
81
  '',
78
82
  `Then open https://t.me/${info.username} and send any message.`,
79
83
  ].join('\n'),
package/src/index.ts CHANGED
@@ -3,6 +3,9 @@
3
3
  * commands/<name>.
4
4
  */
5
5
 
6
+ // MUST be first: guards Error.captureStackTrace so navi-sdk's transitive
7
+ // follow-redirects import doesn't crash Bun at startup. See the shim for why.
8
+ import './util/capture-shim'
6
9
  import { loadDotenvFile } from './util/dotenv'
7
10
 
8
11
  // Zero-env-var startup: load `~/.lyra/.env` (e.g. the OPENAI_API_KEY that
@@ -160,6 +163,6 @@ main()
160
163
  process.exit(0)
161
164
  })
162
165
  .catch(e => {
163
- console.error('fatal:', (e as Error)?.message ?? e)
166
+ console.error('fatal:', e instanceof Error ? e.message : e)
164
167
  process.exit(1)
165
168
  })
@@ -0,0 +1,21 @@
1
+ // Bun's `Error.captureStackTrace` throws "First argument must be an Error object"
2
+ // for some calls `follow-redirects` makes at module-init time (it builds error
3
+ // subclasses via `new BaseError()` whose constructor calls captureStackTrace).
4
+ // follow-redirects is pulled in by axios → navi-sdk, so importing the on-chain
5
+ // plugin (lending tools) used to crash `lyra` chat on startup.
6
+ //
7
+ // Guard captureStackTrace so such calls are a harmless no-op instead of throwing
8
+ // — the affected error objects simply won't carry a V8-captured stack. This MUST
9
+ // be imported before anything that transitively loads navi-sdk/axios.
10
+ const original = Error.captureStackTrace
11
+ if (typeof original === 'function') {
12
+ Error.captureStackTrace = ((target: object, ctor?: unknown) => {
13
+ try {
14
+ ;(original as (t: object, c?: unknown) => void).call(Error, target, ctor)
15
+ } catch {
16
+ // Bun rejects some non-Error targets here — ignore.
17
+ }
18
+ }) as typeof Error.captureStackTrace
19
+ }
20
+
21
+ export {}