0101-agents 0.1.6 → 0.1.8
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 +12 -0
- package/bin/cli.js +63 -13
- package/package.json +1 -1
package/README.md
ADDED
package/bin/cli.js
CHANGED
|
@@ -336,15 +336,25 @@ async function cmdStart(args) {
|
|
|
336
336
|
die(`${agent} is not installed. Try: 0101-agents install ${agent}`)
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
// Best-effort update
|
|
340
|
-
//
|
|
339
|
+
// Best-effort update nag. Needs a saved key (the releases API is gated);
|
|
340
|
+
// no key, offline, or any non-200 (revoked, lapsed, agent not on the
|
|
341
|
+
// server) → skip silently. Launching NEVER depends on this — deliberately
|
|
342
|
+
// not fetchManifest(), whose die() on HTTP errors would kill the launch.
|
|
341
343
|
try {
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
)
|
|
344
|
+
const key = readConfig().license_key
|
|
345
|
+
if (key) {
|
|
346
|
+
const res = await fetch(`${apiBase()}/api/releases/${encodeURIComponent(agent)}`, {
|
|
347
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
348
|
+
})
|
|
349
|
+
if (res.ok) {
|
|
350
|
+
const manifest = await res.json()
|
|
351
|
+
const current = installedVersion(agent)
|
|
352
|
+
if (current && manifest.latest !== current) {
|
|
353
|
+
console.log(
|
|
354
|
+
dim(`⚠ ${agent} ${manifest.latest} available (run: 0101-agents update ${agent})`),
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
348
358
|
}
|
|
349
359
|
} catch {
|
|
350
360
|
// ignore
|
|
@@ -353,9 +363,46 @@ async function cmdStart(args) {
|
|
|
353
363
|
// Artifacts can declare how `start` launches via manifest.start. The runner
|
|
354
364
|
// sets "npm start"; agents leave it unset and fall through to launching
|
|
355
365
|
// Claude Code below.
|
|
366
|
+
//
|
|
367
|
+
// For the runner specifically we accept an optional `[slug] [cli]` so
|
|
368
|
+
// power users can run multiple bots in parallel terminals without touching
|
|
369
|
+
// .env. The runner derives STATE_DIR from AGENT_DIR, so per-agent state is
|
|
370
|
+
// automatic — we only need to override AGENT_DIR here.
|
|
371
|
+
//
|
|
372
|
+
// start runner → npm start (Telegram, AGENT_DIR from .env)
|
|
373
|
+
// start runner cli → npm start -- --cli (CLI, AGENT_DIR from .env)
|
|
374
|
+
// start runner marketer → npm start (Telegram, AGENT_DIR=~/0101/marketer)
|
|
375
|
+
// start runner marketer cli → npm start -- --cli (CLI, AGENT_DIR=~/0101/marketer)
|
|
376
|
+
// start runner --cli → same as `start runner cli` (long-form flag)
|
|
377
|
+
// start runner -- --cli → same (explicit separator)
|
|
356
378
|
const startCmd = readManifest(agent).start
|
|
357
379
|
if (startCmd) {
|
|
358
|
-
|
|
380
|
+
let extra = args.slice(1)
|
|
381
|
+
if (extra[0] === '--') extra = extra.slice(1)
|
|
382
|
+
|
|
383
|
+
// Optional [slug] [mode] positionals — `cli` is a reserved mode keyword
|
|
384
|
+
// (no real agent will ever be named "cli"). Anything else that doesn't
|
|
385
|
+
// start with `-` is treated as a slug. Verified installed before we spawn.
|
|
386
|
+
let slug = null
|
|
387
|
+
if (extra[0] && extra[0] !== 'cli' && !extra[0].startsWith('-')) {
|
|
388
|
+
slug = extra.shift()
|
|
389
|
+
if (!existsSync(agentInstallDir(slug))) {
|
|
390
|
+
die(`${slug} is not installed. Try: 0101-agents install ${slug}`)
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
extra = extra.map(a => (a === 'cli' ? '--cli' : a))
|
|
394
|
+
|
|
395
|
+
// Override AGENT_DIR per invocation when a slug is given. The runner's
|
|
396
|
+
// config.ts derives STATE_DIR from basename(AGENT_DIR), so the per-agent
|
|
397
|
+
// state/lockfile/incoming dirs follow automatically.
|
|
398
|
+
const childEnv = { ...process.env }
|
|
399
|
+
if (slug) {
|
|
400
|
+
childEnv.AGENT_DIR = agentInstallDir(slug)
|
|
401
|
+
info(`runner: agent=${slug}`)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const full = extra.length > 0 ? `${startCmd} -- ${extra.join(' ')}` : startCmd
|
|
405
|
+
const child = spawn(full, { cwd: dir, stdio: 'inherit', shell: true, env: childEnv })
|
|
359
406
|
child.on('error', (e) => die(`Failed to start: ${e.message}`))
|
|
360
407
|
child.on('exit', (code) => process.exit(code ?? 0))
|
|
361
408
|
return
|
|
@@ -410,10 +457,13 @@ Commands:
|
|
|
410
457
|
${bold('help')} Show this message
|
|
411
458
|
|
|
412
459
|
Examples:
|
|
413
|
-
0101-agents start marketer
|
|
414
|
-
0101-agents start marketer --tg
|
|
415
|
-
0101-agents start marketer --resume
|
|
416
|
-
0101-agents start
|
|
460
|
+
0101-agents start marketer Open in Claude Code
|
|
461
|
+
0101-agents start marketer --tg Run as a Telegram channel bot via Claude Code
|
|
462
|
+
0101-agents start marketer --resume Resume the last Claude Code session
|
|
463
|
+
0101-agents start runner Telegram bot via 0101-runner (uses .env)
|
|
464
|
+
0101-agents start runner cli Chat with the agent in this terminal
|
|
465
|
+
0101-agents start runner marketer Run a Telegram bot for marketer (multi-bot)
|
|
466
|
+
0101-agents start runner marketer cli Terminal chat for marketer
|
|
417
467
|
|
|
418
468
|
Install dir: ${INSTALL_ROOT}
|
|
419
469
|
Config: ${CONFIG_PATH}`)
|