@hasna/assistants 1.1.18 → 1.1.20

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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": "c7275051-b842-43ce-9bce-20c17467f8c0",
3
+ "createdAt": "2026-02-08T12:09:53.325Z",
4
+ "type": "feedback",
5
+ "title": "good This is great",
6
+ "description": "good This is great",
7
+ "source": "command",
8
+ "metadata": {
9
+ "cwd": "/Users/hasna/Workspace/hasna/opensource/opensourcedev/opensource-assistants"
10
+ }
11
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "0f585da2-b4e5-4967-8283-633ff8cefabb",
3
3
  "createdAt": 1770548570379,
4
- "updatedAt": 1770548660353,
4
+ "updatedAt": 1770561255111,
5
5
  "createdBy": "assistant",
6
6
  "sessionId": "033405ed-b730-47b9-9d6d-ed2e77ff8e65",
7
7
  "actionType": "command",
@@ -13,10 +13,9 @@
13
13
  "unit": "minutes",
14
14
  "interval": 1
15
15
  },
16
- "nextRunAt": 1770548720353,
17
- "lastRunAt": 1770548660353,
16
+ "nextRunAt": 1770561315111,
17
+ "lastRunAt": 1770561255111,
18
18
  "lastResult": {
19
- "ok": true,
20
- "summary": "**@hasna_assistant_bot** is online and healthy."
19
+ "ok": true
21
20
  }
22
21
  }
package/dist/index.js CHANGED
@@ -67321,6 +67321,12 @@ class SwarmCoordinator {
67321
67321
  }
67322
67322
  const config = { ...this.config, ...input.config };
67323
67323
  this.config = config;
67324
+ if (!Number.isFinite(config.maxConcurrent) || config.maxConcurrent < 1) {
67325
+ this.streamText(`
67326
+ \u26A0\uFE0F Invalid swarm config: maxConcurrent=${config.maxConcurrent}. Using 1.
67327
+ `);
67328
+ this.config.maxConcurrent = 1;
67329
+ }
67324
67330
  this.validateToolLists(config);
67325
67331
  const swarmId = generateId();
67326
67332
  this.state = {
@@ -68288,7 +68294,12 @@ class TaskGraphScheduler {
68288
68294
  stopped = false;
68289
68295
  constructor(graph, options = {}) {
68290
68296
  this.graph = graph;
68291
- this.options = { ...DEFAULT_SCHEDULER_OPTIONS, ...options };
68297
+ const merged = { ...DEFAULT_SCHEDULER_OPTIONS, ...options };
68298
+ const maxConcurrent = Number.isFinite(merged.maxConcurrent) ? merged.maxConcurrent : DEFAULT_SCHEDULER_OPTIONS.maxConcurrent;
68299
+ this.options = {
68300
+ ...merged,
68301
+ maxConcurrent: Math.max(1, maxConcurrent)
68302
+ };
68292
68303
  }
68293
68304
  async execute(executor2) {
68294
68305
  const results = new Map;
@@ -74536,7 +74547,7 @@ Configure the external source with the URL and secret above.
74536
74547
  handled: false,
74537
74548
  prompt: `[Channel Message] ${activePerson.name} posted in #${channel}: "${message}"
74538
74549
 
74539
- Respond in #${channel} using channel_send. Be helpful and conversational.`
74550
+ You are in a group channel with other assistants and people. Respond in #${channel} using channel_send. Be helpful and conversational. You may reference or build on what other assistants have said.`
74540
74551
  };
74541
74552
  }
74542
74553
  return { handled: true };
@@ -79391,7 +79402,7 @@ ${repoUrl}/issues/new
79391
79402
  context.setProjectContext(projectContext);
79392
79403
  }
79393
79404
  }
79394
- var VERSION = "1.1.18";
79405
+ var VERSION = "1.1.20";
79395
79406
  var init_builtin = __esm(async () => {
79396
79407
  init_src2();
79397
79408
  init_store();
@@ -172814,11 +172825,12 @@ class ChannelStore {
172814
172825
  sendMessage(channelId, senderId, senderName, content) {
172815
172826
  const id = generateMessageId2();
172816
172827
  const now2 = new Date().toISOString();
172817
- const stmt = this.db.prepare(`INSERT INTO channel_messages (id, channel_id, sender_id, sender_name, content, created_at)
172818
- VALUES (?, ?, ?, ?, ?, ?)`);
172819
- stmt.run(id, channelId, senderId, senderName, content, now2);
172820
- this.db.prepare("UPDATE channels SET updated_at = ? WHERE id = ?").run(now2, channelId);
172821
- this.db.prepare("UPDATE channel_members SET last_read_at = ? WHERE channel_id = ? AND assistant_id = ?").run(now2, channelId, senderId);
172828
+ this.db.transaction(() => {
172829
+ this.db.prepare(`INSERT INTO channel_messages (id, channel_id, sender_id, sender_name, content, created_at)
172830
+ VALUES (?, ?, ?, ?, ?, ?)`).run(id, channelId, senderId, senderName, content, now2);
172831
+ this.db.prepare("UPDATE channels SET updated_at = ? WHERE id = ?").run(now2, channelId);
172832
+ this.db.prepare("UPDATE channel_members SET last_read_at = ? WHERE channel_id = ? AND assistant_id = ?").run(now2, channelId, senderId);
172833
+ });
172822
172834
  return id;
172823
172835
  }
172824
172836
  getMessages(channelId, options) {
@@ -172965,6 +172977,9 @@ class ChannelsManager {
172965
172977
  this.config = options.config;
172966
172978
  this.store = new ChannelStore;
172967
172979
  }
172980
+ getStore() {
172981
+ return this.store;
172982
+ }
172968
172983
  createChannel(name2, description) {
172969
172984
  return this.store.createChannel(name2, description || null, this.assistantId, this.assistantName);
172970
172985
  }
@@ -173598,45 +173613,95 @@ var init_client4 = __esm(async () => {
173598
173613
  class ChannelAgentPool {
173599
173614
  agents = new Map;
173600
173615
  cwd;
173601
- constructor(cwd) {
173616
+ getChannelsManager;
173617
+ responding = false;
173618
+ maxRounds = 2;
173619
+ constructor(cwd, getChannelsManager) {
173602
173620
  this.cwd = cwd;
173621
+ this.getChannelsManager = getChannelsManager;
173603
173622
  }
173604
173623
  async triggerResponses(channelName, personName, message, channelMembers, excludeAssistantId) {
173605
- const assistantMembers = channelMembers.filter((m5) => m5.memberType === "assistant");
173606
- if (assistantMembers.length === 0)
173607
- return;
173608
- let targetMembers = assistantMembers;
173609
- const mentions = parseMentions(message);
173610
- if (mentions.length > 0) {
173611
- const knownNames = assistantMembers.map((m5) => ({
173612
- id: m5.assistantId,
173613
- name: m5.assistantName
173614
- }));
173615
- const resolved = mentions.map((m5) => resolveNameToKnown(m5, knownNames)).filter(Boolean);
173616
- if (resolved.length > 0) {
173617
- const resolvedIds = new Set(resolved.map((r6) => r6.id));
173618
- targetMembers = assistantMembers.filter((m5) => resolvedIds.has(m5.assistantId));
173619
- } else {
173624
+ if (this.responding)
173625
+ return;
173626
+ this.responding = true;
173627
+ try {
173628
+ const assistantMembers = channelMembers.filter((m5) => m5.memberType === "assistant");
173629
+ if (assistantMembers.length === 0)
173620
173630
  return;
173631
+ let targetMembers = assistantMembers;
173632
+ const mentions = parseMentions(message);
173633
+ if (mentions.length > 0) {
173634
+ const knownNames = assistantMembers.map((m5) => ({
173635
+ id: m5.assistantId,
173636
+ name: m5.assistantName
173637
+ }));
173638
+ const resolved = mentions.map((m5) => resolveNameToKnown(m5, knownNames)).filter(Boolean);
173639
+ if (resolved.length > 0) {
173640
+ const resolvedIds = new Set(resolved.map((r6) => r6.id));
173641
+ targetMembers = assistantMembers.filter((m5) => resolvedIds.has(m5.assistantId));
173642
+ } else {
173643
+ return;
173644
+ }
173621
173645
  }
173646
+ if (excludeAssistantId) {
173647
+ targetMembers = targetMembers.filter((m5) => m5.assistantId !== excludeAssistantId);
173648
+ }
173649
+ if (targetMembers.length === 0)
173650
+ return;
173651
+ const prompt = `[Channel Message] ${personName} posted in #${channelName}: "${message}"
173652
+
173653
+ You are in a group channel with other assistants and people. Respond in #${channelName} using channel_send. Be helpful and conversational. You may reference or build on what other assistants have said.`;
173654
+ await this.executeRound(channelName, targetMembers, prompt, excludeAssistantId);
173655
+ for (let round = 2;round <= this.maxRounds; round++) {
173656
+ await new Promise((r6) => setTimeout(r6, 1000));
173657
+ const followUpMembers = this.getAgentsWithUnread(channelName, targetMembers, excludeAssistantId);
173658
+ if (followUpMembers.length === 0)
173659
+ break;
173660
+ const followUpPrompt = `[Channel Update] New messages appeared in #${channelName}. Read them with channel_read and respond if you have something valuable to add. If the conversation is complete or you have nothing meaningful to contribute, simply say nothing (do not use channel_send).`;
173661
+ await this.executeRound(channelName, followUpMembers, followUpPrompt, excludeAssistantId);
173662
+ }
173663
+ } finally {
173664
+ this.responding = false;
173622
173665
  }
173623
- if (excludeAssistantId) {
173624
- targetMembers = targetMembers.filter((m5) => m5.assistantId !== excludeAssistantId);
173625
- }
173626
- if (targetMembers.length === 0)
173666
+ }
173667
+ async executeRound(channelName, members, prompt, excludeAssistantId) {
173668
+ let roundMembers = excludeAssistantId ? members.filter((m5) => m5.assistantId !== excludeAssistantId) : members;
173669
+ if (roundMembers.length === 0)
173627
173670
  return;
173628
- const prompt = `[Channel Message] ${personName} posted in #${channelName}: "${message}"
173629
-
173630
- Respond in #${channelName} using channel_send. Be helpful and conversational.`;
173631
- const sends = targetMembers.map(async (member) => {
173671
+ const shuffled = this.shuffleArray([...roundMembers]);
173672
+ for (let i5 = 0;i5 < shuffled.length; i5++) {
173673
+ const member = shuffled[i5];
173632
173674
  try {
173633
173675
  const client = await this.getOrCreateClient(member.assistantId);
173634
173676
  await client.send(prompt);
173635
173677
  } catch (error3) {
173636
- console.error(`ChannelAgentPool: Failed to trigger response for ${member.assistantName}:`, error3);
173678
+ console.error(`ChannelAgentPool: Failed for ${member.assistantName}:`, error3);
173637
173679
  }
173680
+ if (i5 < shuffled.length - 1) {
173681
+ await new Promise((r6) => setTimeout(r6, 500 + Math.floor(Math.random() * 1500)));
173682
+ }
173683
+ }
173684
+ }
173685
+ getAgentsWithUnread(channelName, members, excludeId) {
173686
+ const manager = this.getChannelsManager?.();
173687
+ if (!manager)
173688
+ return [];
173689
+ const channel = manager.getChannel(channelName);
173690
+ if (!channel)
173691
+ return [];
173692
+ return members.filter((m5) => {
173693
+ if (m5.assistantId === excludeId)
173694
+ return false;
173695
+ const unread = manager.getStore().getUnreadMessages(channel.id, m5.assistantId);
173696
+ return unread.length > 0;
173638
173697
  });
173639
- await Promise.allSettled(sends);
173698
+ }
173699
+ shuffleArray(array) {
173700
+ for (let i5 = array.length - 1;i5 > 0; i5--) {
173701
+ const j7 = Math.floor(Math.random() * (i5 + 1));
173702
+ [array[i5], array[j7]] = [array[j7], array[i5]];
173703
+ }
173704
+ return array;
173640
173705
  }
173641
173706
  async getOrCreateClient(assistantId) {
173642
173707
  const existing = this.agents.get(assistantId);
@@ -182923,7 +182988,7 @@ class AssistantLoop {
182923
182988
  const assistantName = assistant?.name || "assistant";
182924
182989
  this.channelsManager = createChannelsManager(assistantId, assistantName, this.config.channels);
182925
182990
  registerChannelTools(this.toolRegistry, () => this.channelsManager);
182926
- this.channelAgentPool = new ChannelAgentPool(this.cwd);
182991
+ this.channelAgentPool = new ChannelAgentPool(this.cwd, () => this.channelsManager);
182927
182992
  }
182928
182993
  try {
182929
182994
  this.peopleManager = await createPeopleManager();
@@ -233855,7 +233920,7 @@ When done, report the result.`);
233855
233920
  if (isActiveMember && activeAssistantTargeted) {
233856
233921
  const prompt = `[Channel Message] ${personName} posted in #${channelName}: "${message}"
233857
233922
 
233858
- Respond in #${channelName} using channel_send. Be helpful and conversational.`;
233923
+ You are in a group channel with other assistants and people. Respond in #${channelName} using channel_send. Be helpful and conversational. You may reference or build on what other assistants have said.`;
233859
233924
  activeSession?.client.send(prompt);
233860
233925
  }
233861
233926
  }
@@ -234649,7 +234714,7 @@ Interactive Mode:
234649
234714
  // packages/terminal/src/index.tsx
234650
234715
  var jsx_dev_runtime44 = __toESM(require_jsx_dev_runtime(), 1);
234651
234716
  setRuntime(bunRuntime);
234652
- var VERSION4 = "1.1.18";
234717
+ var VERSION4 = "1.1.20";
234653
234718
  var SYNC_START = "\x1B[?2026h";
234654
234719
  var SYNC_END = "\x1B[?2026l";
234655
234720
  function enableSynchronizedOutput() {
@@ -234789,4 +234854,4 @@ export {
234789
234854
  main
234790
234855
  };
234791
234856
 
234792
- //# debugId=C8555F61FD8AD49264756E2164756E21
234857
+ //# debugId=AE2EE7F952FD5F6C64756E2164756E21