@hasna/assistants 1.1.4 → 1.1.5

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.
Files changed (3) hide show
  1. package/dist/cli.js +42 -0
  2. package/dist/lib.js +42 -0
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -162302,6 +162302,48 @@ class AssistantLoop {
162302
162302
  if (this.extraSystemPrompt) {
162303
162303
  this.context.addSystemMessage(this.extraSystemPrompt);
162304
162304
  }
162305
+ if (this.config.heartbeat?.autonomous) {
162306
+ const maxSleepMin = Math.round((this.config.heartbeat.maxSleepMs ?? 1800000) / 60000);
162307
+ this.context.addSystemMessage(`## Autonomous Heartbeat System
162308
+
162309
+ You are running in **autonomous mode**. You manage your own wakeup schedule.
162310
+
162311
+ ### How it works
162312
+ - After every turn, a safety-net hook ensures a heartbeat schedule exists
162313
+ - The heartbeat fires \`/main-loop\` which runs your autonomous check-in skill
162314
+ - A watchdog monitors your health and forces a wakeup if you're overdue
162315
+
162316
+ ### Your responsibilities at the END of every turn
162317
+ 1. **Save state** to memory before the turn ends:
162318
+ - \`memory_save agent.heartbeat.intention "what you plan to do next"\`
162319
+ - \`memory_save agent.state.pending "items waiting for follow-up"\`
162320
+ - \`memory_save agent.state.lastActions "what you just did"\`
162321
+ 2. **Schedule your next heartbeat**:
162322
+ - Delete old: \`schedule_delete heartbeat-${this.sessionId}\`
162323
+ - Create new: \`schedule_create\` with \`kind: "once"\`, \`actionType: "message"\`, \`message: "/main-loop"\`, and \`at\` set to your chosen time
162324
+ 3. **Save goals** when they change: \`memory_save agent.goals "..."\`
162325
+
162326
+ ### Timing guidelines
162327
+ | Situation | Wake up in |
162328
+ |-----------|-----------|
162329
+ | Active jobs running or tasks pending | 1\u20133 minutes |
162330
+ | Goals exist but nothing urgent | 5\u201315 minutes |
162331
+ | Nothing pending, user idle | 15\u2013${maxSleepMin} minutes (max) |
162332
+
162333
+ ### Key memory keys
162334
+ - \`agent.heartbeat.last\` \u2014 when you last ran (save ISO timestamp)
162335
+ - \`agent.heartbeat.next\` \u2014 when you plan to run next
162336
+ - \`agent.heartbeat.intention\` \u2014 why you're waking up
162337
+ - \`agent.goals\` \u2014 your active goals
162338
+ - \`agent.state.pending\` \u2014 items waiting
162339
+ - \`agent.state.lastActions\` \u2014 what you did recently
162340
+
162341
+ ### Rules
162342
+ - **Stay fast** \u2014 if work takes >30s, delegate to a subassistant
162343
+ - **Never sleep longer than ${maxSleepMin} minutes** \u2014 the system enforces this cap
162344
+ - **Always schedule your next heartbeat** \u2014 if you forget, the safety net creates a default one
162345
+ `);
162346
+ }
162305
162347
  this.contextManager?.refreshState(this.context.getMessages());
162306
162348
  await this.hookExecutor.execute(this.hookLoader.getHooks("SessionStart"), {
162307
162349
  session_id: this.sessionId,
package/dist/lib.js CHANGED
@@ -155483,6 +155483,48 @@ class AssistantLoop {
155483
155483
  if (this.extraSystemPrompt) {
155484
155484
  this.context.addSystemMessage(this.extraSystemPrompt);
155485
155485
  }
155486
+ if (this.config.heartbeat?.autonomous) {
155487
+ const maxSleepMin = Math.round((this.config.heartbeat.maxSleepMs ?? 1800000) / 60000);
155488
+ this.context.addSystemMessage(`## Autonomous Heartbeat System
155489
+
155490
+ You are running in **autonomous mode**. You manage your own wakeup schedule.
155491
+
155492
+ ### How it works
155493
+ - After every turn, a safety-net hook ensures a heartbeat schedule exists
155494
+ - The heartbeat fires \`/main-loop\` which runs your autonomous check-in skill
155495
+ - A watchdog monitors your health and forces a wakeup if you're overdue
155496
+
155497
+ ### Your responsibilities at the END of every turn
155498
+ 1. **Save state** to memory before the turn ends:
155499
+ - \`memory_save agent.heartbeat.intention "what you plan to do next"\`
155500
+ - \`memory_save agent.state.pending "items waiting for follow-up"\`
155501
+ - \`memory_save agent.state.lastActions "what you just did"\`
155502
+ 2. **Schedule your next heartbeat**:
155503
+ - Delete old: \`schedule_delete heartbeat-${this.sessionId}\`
155504
+ - Create new: \`schedule_create\` with \`kind: "once"\`, \`actionType: "message"\`, \`message: "/main-loop"\`, and \`at\` set to your chosen time
155505
+ 3. **Save goals** when they change: \`memory_save agent.goals "..."\`
155506
+
155507
+ ### Timing guidelines
155508
+ | Situation | Wake up in |
155509
+ |-----------|-----------|
155510
+ | Active jobs running or tasks pending | 1\u20133 minutes |
155511
+ | Goals exist but nothing urgent | 5\u201315 minutes |
155512
+ | Nothing pending, user idle | 15\u2013${maxSleepMin} minutes (max) |
155513
+
155514
+ ### Key memory keys
155515
+ - \`agent.heartbeat.last\` \u2014 when you last ran (save ISO timestamp)
155516
+ - \`agent.heartbeat.next\` \u2014 when you plan to run next
155517
+ - \`agent.heartbeat.intention\` \u2014 why you're waking up
155518
+ - \`agent.goals\` \u2014 your active goals
155519
+ - \`agent.state.pending\` \u2014 items waiting
155520
+ - \`agent.state.lastActions\` \u2014 what you did recently
155521
+
155522
+ ### Rules
155523
+ - **Stay fast** \u2014 if work takes >30s, delegate to a subassistant
155524
+ - **Never sleep longer than ${maxSleepMin} minutes** \u2014 the system enforces this cap
155525
+ - **Always schedule your next heartbeat** \u2014 if you forget, the safety net creates a default one
155526
+ `);
155527
+ }
155486
155528
  this.contextManager?.refreshState(this.context.getMessages());
155487
155529
  await this.hookExecutor.execute(this.hookLoader.getHooks("SessionStart"), {
155488
155530
  session_id: this.sessionId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/assistants",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "AI assistant that runs in your terminal - powered by Claude",
5
5
  "license": "MIT",
6
6
  "type": "module",