agent-message 0.1.1 → 0.1.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Agent Message
2
2
 
3
+ ```bash
4
+ npx skills add https://github.com/siisee11/agent-message --skill agent-message-cli
5
+ ```
6
+
7
+ Install the skill above, then ask your coding agent (e.g. Claude Code) to "set up agent-message" — it will handle installation and configuration for you.
8
+
3
9
  ```bash
4
10
  npm install -g agent-message
5
11
  ```
@@ -22,10 +28,10 @@ agent-message stop
22
28
  ```
23
29
 
24
30
  Default ports:
25
- - API: `127.0.0.1:8080`
26
- - Web: `127.0.0.1:8788`
31
+ - API: `127.0.0.1:45180`
32
+ - Web: `127.0.0.1:45788`
27
33
 
28
- After `agent-message start`, open `http://127.0.0.1:8788` in your browser.
34
+ After `agent-message start`, open `http://127.0.0.1:45788` in your browser.
29
35
  The bundled CLI continues to work from the same command:
30
36
 
31
37
  ```bash
@@ -9,9 +9,9 @@ import process from 'node:process'
9
9
  import { fileURLToPath } from 'node:url'
10
10
 
11
11
  const DEFAULT_API_HOST = '127.0.0.1'
12
- const DEFAULT_API_PORT = 8080
12
+ const DEFAULT_API_PORT = 45180
13
13
  const DEFAULT_WEB_HOST = '127.0.0.1'
14
- const DEFAULT_WEB_PORT = 8788
14
+ const DEFAULT_WEB_PORT = 45788
15
15
  const STARTUP_ATTEMPTS = 40
16
16
  const STARTUP_DELAY_MS = 500
17
17
  const PROCESS_STOP_DELAY_MS = 1000
@@ -170,6 +170,7 @@ function runtimePaths(runtimeDir) {
170
170
  gatewayLog: join(runtimeDir, 'logs', 'gateway.log'),
171
171
  serverPidfile: join(runtimeDir, 'server.pid'),
172
172
  gatewayPidfile: join(runtimeDir, 'gateway.pid'),
173
+ stackMetadataPath: join(runtimeDir, 'stack.json'),
173
174
  sqlitePath: join(runtimeDir, 'agent_message.sqlite'),
174
175
  }
175
176
  }
@@ -216,6 +217,7 @@ async function startStack(options) {
216
217
  writeFileSync(paths.gatewayPidfile, `${gatewayChild.pid}\n`)
217
218
 
218
219
  await waitForHttp(`http://${options.webHost}:${options.webPort}`, 'web gateway')
220
+ writeStackMetadata(paths.stackMetadataPath, options)
219
221
  } catch (error) {
220
222
  await stopStack(options, { quiet: true })
221
223
  throw error
@@ -231,6 +233,7 @@ async function stopStack(options, { quiet }) {
231
233
  const paths = runtimePaths(options.runtimeDir)
232
234
  const stoppedServer = await killFromPidfile(paths.serverPidfile)
233
235
  const stoppedGateway = await killFromPidfile(paths.gatewayPidfile)
236
+ rmSync(paths.stackMetadataPath, { force: true })
234
237
 
235
238
  if (!quiet) {
236
239
  if (stoppedServer || stoppedGateway) {
@@ -259,7 +262,8 @@ async function printStatus(options) {
259
262
 
260
263
  function delegateToBundledCli(args) {
261
264
  const cliBinary = resolveBinaryPath('agent-message-cli')
262
- const result = spawnSync(cliBinary, args, {
265
+ const delegatedArgs = buildDelegatedCliArgs(args)
266
+ const result = spawnSync(cliBinary, delegatedArgs, {
263
267
  stdio: 'inherit',
264
268
  env: process.env,
265
269
  })
@@ -276,6 +280,59 @@ function delegateToBundledCli(args) {
276
280
  process.exit(result.status ?? 1)
277
281
  }
278
282
 
283
+ function buildDelegatedCliArgs(args) {
284
+ if (shouldSkipLocalServerOverride(args) || hasExplicitServerURL(args)) {
285
+ return args
286
+ }
287
+
288
+ const localServerURL = readLocalServerURL()
289
+ if (!localServerURL) {
290
+ return args
291
+ }
292
+
293
+ return ['--server-url', localServerURL, ...args]
294
+ }
295
+
296
+ function shouldSkipLocalServerOverride(args) {
297
+ const [command] = args
298
+ return command === undefined || command === 'config' || command === 'profile'
299
+ }
300
+
301
+ function hasExplicitServerURL(args) {
302
+ return args.some((arg) => arg === '--server-url' || arg.startsWith('--server-url='))
303
+ }
304
+
305
+ function readLocalServerURL() {
306
+ const paths = runtimePaths(join(os.homedir(), '.agent-message'))
307
+ const serverPid = readPidfile(paths.serverPidfile)
308
+ if (serverPid === null || !isPidAlive(serverPid)) {
309
+ return null
310
+ }
311
+
312
+ try {
313
+ const raw = readFileSync(paths.stackMetadataPath, 'utf8')
314
+ const metadata = JSON.parse(raw)
315
+ const apiHost = typeof metadata.apiHost === 'string' ? metadata.apiHost.trim() : ''
316
+ const apiPort = metadata.apiPort
317
+ if (!apiHost || !Number.isInteger(apiPort) || apiPort <= 0 || apiPort > 65535) {
318
+ return null
319
+ }
320
+ return `http://${apiHost}:${apiPort}`
321
+ } catch {
322
+ return null
323
+ }
324
+ }
325
+
326
+ function writeStackMetadata(path, options) {
327
+ const metadata = {
328
+ apiHost: options.apiHost,
329
+ apiPort: options.apiPort,
330
+ webHost: options.webHost,
331
+ webPort: options.webPort,
332
+ }
333
+ writeFileSync(path, `${JSON.stringify(metadata, null, 2)}\n`)
334
+ }
335
+
279
336
  function spawnDetached(command, args, env, logFile) {
280
337
  const stdoutFd = openSync(logFile, 'a')
281
338
  const stderrFd = openSync(logFile, 'a')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-message",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Agent Message CLI and local stack launcher for macOS",
5
5
  "type": "module",
6
6
  "bin": {