@hasna/assistants 1.1.88 → 1.1.90

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/dist/index.js CHANGED
@@ -112152,7 +112152,7 @@ ${defs.length} agent(s) total. Use /agents show <name> for details.
112152
112152
  };
112153
112153
  }
112154
112154
  }
112155
- var VERSION2 = "1.1.88";
112155
+ var VERSION2 = "1.1.90";
112156
112156
  var init_builtin = __esm(async () => {
112157
112157
  init_src2();
112158
112158
  init_context3();
@@ -198158,7 +198158,8 @@ class EmbeddedClient {
198158
198158
  messages: this.messages,
198159
198159
  startedAt: this.startedAt,
198160
198160
  updatedAt: new Date().toISOString(),
198161
- cwd: this.cwd
198161
+ cwd: this.cwd,
198162
+ pendingQueue: this.messageQueue.length > 0 ? [...this.messageQueue] : undefined
198162
198163
  });
198163
198164
  }
198164
198165
  onChunk(callback) {
@@ -198413,6 +198414,9 @@ class EmbeddedClient {
198413
198414
  this.messageQueue = [];
198414
198415
  this.logger.info("Message queue cleared");
198415
198416
  }
198417
+ getPendingQueue() {
198418
+ return [...this.messageQueue];
198419
+ }
198416
198420
  mergeMessages(contextMessages) {
198417
198421
  if (contextMessages.length === 0)
198418
198422
  return;
@@ -210712,22 +210716,36 @@ ${hookResult.additionalContext}` : hookResult.additionalContext
210712
210716
  const maxTurns = Math.min(config2.maxTurns ?? this.config.maxTurns, MAX_ALLOWED_TURNS);
210713
210717
  const minTurns = Math.min(config2.minTurns ?? this.config.minTurns, maxTurns);
210714
210718
  const workUntilDone = config2.workUntilDone ?? false;
210715
- const runner = await this.context.createSubassistantLoop({
210716
- task: config2.task,
210717
- tools,
210718
- context: config2.context,
210719
- maxTurns,
210720
- minTurns,
210721
- workUntilDone,
210722
- cwd: config2.cwd,
210723
- sessionId: `subassistant-${subassistantId}`,
210724
- depth: config2.depth + 1
210725
- });
210726
- this.activeRunners.set(subassistantId, runner);
210727
210719
  const timeoutMs = config2.timeoutMs ?? this.config.defaultTimeoutMs;
210720
+ let runner = null;
210721
+ const timeoutPromise = this.createTimeout(timeoutMs, () => runner, subassistantId);
210722
+ let subagentLLMClient;
210723
+ const llmConfig = this.context.getLLMConfig?.();
210724
+ if (llmConfig) {
210725
+ try {
210726
+ subagentLLMClient = await createLLMClient(llmConfig);
210727
+ } catch {}
210728
+ }
210729
+ const runPromise = (async () => {
210730
+ const r5 = await this.context.createSubassistantLoop({
210731
+ task: config2.task,
210732
+ tools,
210733
+ context: config2.context,
210734
+ maxTurns,
210735
+ minTurns,
210736
+ workUntilDone,
210737
+ cwd: config2.cwd,
210738
+ sessionId: `subassistant-${subassistantId}`,
210739
+ depth: config2.depth + 1,
210740
+ llmClient: subagentLLMClient
210741
+ });
210742
+ runner = r5;
210743
+ this.activeRunners.set(subassistantId, r5);
210744
+ return r5.run();
210745
+ })();
210728
210746
  const result = await Promise.race([
210729
- runner.run(),
210730
- this.createTimeout(timeoutMs, runner, subassistantId)
210747
+ runPromise,
210748
+ timeoutPromise
210731
210749
  ]);
210732
210750
  if (result.success) {
210733
210751
  info.status = "completed";
@@ -210795,7 +210813,9 @@ ${hookResult.additionalContext}` : hookResult.additionalContext
210795
210813
  startedAt: Date.now()
210796
210814
  };
210797
210815
  this.asyncJobs.set(jobId, job);
210798
- this.runAsyncJob(job).catch(() => {});
210816
+ setTimeout(() => {
210817
+ this.runAsyncJob(job).catch(() => {});
210818
+ }, 0);
210799
210819
  return jobId;
210800
210820
  }
210801
210821
  getJobStatus(jobId) {
@@ -210950,12 +210970,15 @@ ${hookResult.additionalContext}` : hookResult.additionalContext
210950
210970
  });
210951
210971
  } catch {}
210952
210972
  }
210953
- createTimeout(ms, runner, subassistantId) {
210973
+ createTimeout(ms, runnerOrGetter, subassistantId) {
210954
210974
  return new Promise((resolve14) => {
210955
210975
  const timerId = setTimeout(() => {
210956
210976
  this.activeTimeouts.delete(subassistantId);
210957
210977
  this.activeRunners.delete(subassistantId);
210958
- runner.stop();
210978
+ const runner = typeof runnerOrGetter === "function" ? runnerOrGetter() : runnerOrGetter;
210979
+ if (runner) {
210980
+ runner.stop();
210981
+ }
210959
210982
  resolve14({
210960
210983
  success: false,
210961
210984
  error: `Subassistant timed out after ${Math.round(ms / 1000)} seconds`,
@@ -210981,6 +211004,7 @@ ${hookResult.additionalContext}` : hookResult.additionalContext
210981
211004
  var DEFAULT_MAX_DEPTH = 3, DEFAULT_MAX_CONCURRENT = 5, DEFAULT_MAX_TURNS = 25, DEFAULT_MIN_TURNS = 3, MAX_ALLOWED_TURNS = 50, DEFAULT_TIMEOUT_MS3 = 120000, DEFAULT_SUBASSISTANT_TOOLS, FORBIDDEN_SUBASSISTANT_TOOLS;
210982
211005
  var init_subagent_manager = __esm(async () => {
210983
211006
  init_src2();
211007
+ init_client3();
210984
211008
  await init_audit_log();
210985
211009
  DEFAULT_SUBASSISTANT_TOOLS = [
210986
211010
  "read",
@@ -217779,6 +217803,7 @@ Current state: ${voiceState.enabled ? "enabled" : "disabled"}, STT: ${voiceState
217779
217803
  getTools: () => this.toolRegistry.getTools(),
217780
217804
  getParentAllowedTools: () => this.getEffectiveAllowedTools(),
217781
217805
  getLLMClient: () => this.llmClient,
217806
+ getLLMConfig: () => this.config?.llm ?? null,
217782
217807
  fireHook: async (input) => {
217783
217808
  const hooks = this.hookLoader.getHooks(input.hook_event_name);
217784
217809
  return this.hookExecutor.execute(hooks, input);
@@ -293741,6 +293766,30 @@ function App2({ cwd: cwd3, version: version4, permissionMode: initialPermissionM
293741
293766
  seedSessionState(session.id, sessionData.messages);
293742
293767
  }
293743
293768
  await switchToSession(session.id);
293769
+ const pending = sessionData.pendingQueue;
293770
+ let messagesToRequeue = [];
293771
+ if (pending && pending.length > 0) {
293772
+ messagesToRequeue = pending.map((content3) => ({ id: generateId(), content: content3 }));
293773
+ } else {
293774
+ const msgs = sessionData.messages;
293775
+ for (let i6 = msgs.length - 1;i6 >= 0; i6--) {
293776
+ if (msgs[i6].role === "user" && msgs[i6].content) {
293777
+ messagesToRequeue.unshift({ id: msgs[i6].id, content: msgs[i6].content });
293778
+ } else {
293779
+ break;
293780
+ }
293781
+ }
293782
+ }
293783
+ if (messagesToRequeue.length > 0) {
293784
+ const restoredQueue = messagesToRequeue.map(({ id, content: content3 }) => ({
293785
+ id,
293786
+ sessionId: session.id,
293787
+ content: content3,
293788
+ queuedAt: Date.now(),
293789
+ mode: "queued"
293790
+ }));
293791
+ setMessageQueue((prev) => [...prev, ...restoredQueue]);
293792
+ }
293744
293793
  }, [cwd3, registry3, beginAskUser, beginInterview, seedSessionState, switchToSession, workspaceBaseDir]);
293745
293794
  const switchWorkspace = import_react86.useCallback(async (workspaceId) => {
293746
293795
  if (workspaceId === activeWorkspaceId) {
@@ -297828,7 +297877,7 @@ process.on("unhandledRejection", (reason) => {
297828
297877
  cleanup();
297829
297878
  process.exit(1);
297830
297879
  });
297831
- var VERSION4 = "1.1.88";
297880
+ var VERSION4 = "1.1.90";
297832
297881
  var SYNC_START = "\x1B[?2026h";
297833
297882
  var SYNC_END = "\x1B[?2026l";
297834
297883
  function enableSynchronizedOutput() {
@@ -298002,4 +298051,4 @@ export {
298002
298051
  main
298003
298052
  };
298004
298053
 
298005
- //# debugId=745FA86C9D5A475264756E2164756E21
298054
+ //# debugId=EE26EDB19ADBEA5764756E2164756E21