@hasna/assistants 1.1.3 → 1.1.4

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 +20 -0
  2. package/dist/lib.js +176 -0
  3. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -162160,6 +162160,15 @@ class AssistantLoop {
162160
162160
  registerConnectorsListTool(this.toolRegistry, {
162161
162161
  getConnectorBridge: () => this.connectorBridge
162162
162162
  });
162163
+ registerConnectorsSearchTool(this.toolRegistry, {
162164
+ getConnectorBridge: () => this.connectorBridge,
162165
+ onConnectorSelected: (connectorName) => {
162166
+ this.connectorBridge.registerConnector(this.toolRegistry, connectorName);
162167
+ }
162168
+ });
162169
+ registerConnectorExecuteTool(this.toolRegistry, {
162170
+ getConnectorBridge: () => this.connectorBridge
162171
+ });
162163
162172
  registerConnectorAutoRefreshTool(this.toolRegistry);
162164
162173
  registerConfigTools(this.toolRegistry, {
162165
162174
  cwd: this.cwd
@@ -162563,6 +162572,17 @@ class AssistantLoop {
162563
162572
  hook_event_name: "Stop",
162564
162573
  cwd: this.cwd
162565
162574
  });
162575
+ try {
162576
+ await nativeHookRegistry.execute("Stop", {
162577
+ session_id: this.sessionId,
162578
+ hook_event_name: "Stop",
162579
+ cwd: this.cwd
162580
+ }, {
162581
+ sessionId: this.sessionId,
162582
+ cwd: this.cwd,
162583
+ messages: this.context.getMessages()
162584
+ });
162585
+ } catch {}
162566
162586
  const shouldSkipVerification = this.shouldStop || streamError !== null;
162567
162587
  if (shouldSkipVerification) {
162568
162588
  this.scopeContextManager.clear();
package/dist/lib.js CHANGED
@@ -113513,6 +113513,162 @@ Use job_status or job_result to check progress.`;
113513
113513
  }
113514
113514
  }
113515
113515
  }
113516
+ var connectorExecuteTool = {
113517
+ name: "connector_execute",
113518
+ description: "Execute a command on any discovered connector. Use connectors_list or connectors_search first to discover available connectors and their commands.",
113519
+ parameters: {
113520
+ type: "object",
113521
+ properties: {
113522
+ connector: {
113523
+ type: "string",
113524
+ description: 'Name of the connector to use (e.g., "notion", "gmail", "googledrive")'
113525
+ },
113526
+ command: {
113527
+ type: "string",
113528
+ description: "The command to run on the connector"
113529
+ },
113530
+ args: {
113531
+ type: "array",
113532
+ description: "Arguments to pass to the command",
113533
+ items: { type: "string", description: "Argument value" }
113534
+ },
113535
+ options: {
113536
+ type: "object",
113537
+ description: "Options to pass to the command (key-value pairs)"
113538
+ }
113539
+ },
113540
+ required: ["connector", "command"]
113541
+ }
113542
+ };
113543
+ function createConnectorExecuteExecutor(context) {
113544
+ return async (input) => {
113545
+ const bridge = context.getConnectorBridge();
113546
+ if (!bridge) {
113547
+ return JSON.stringify({
113548
+ error: "Connector system not available",
113549
+ suggestion: "Ensure connectors are configured and discovered"
113550
+ });
113551
+ }
113552
+ const connectorName = input.connector;
113553
+ if (!connectorName) {
113554
+ return JSON.stringify({
113555
+ error: "Missing required parameter: connector",
113556
+ suggestion: "Use connectors_list to find available connectors"
113557
+ });
113558
+ }
113559
+ const connector = bridge.getConnector(connectorName);
113560
+ if (!connector) {
113561
+ const available = bridge.getConnectors().map((c) => c.name);
113562
+ return JSON.stringify({
113563
+ error: `Connector '${connectorName}' not found`,
113564
+ available: available.slice(0, 10),
113565
+ totalAvailable: available.length,
113566
+ suggestion: "Use connectors_list to see all available connectors"
113567
+ });
113568
+ }
113569
+ const executor = bridge["createExecutor"](connector);
113570
+ return executor({
113571
+ command: input.command,
113572
+ args: input.args,
113573
+ options: input.options,
113574
+ cwd: input.cwd
113575
+ });
113576
+ };
113577
+ }
113578
+ function registerConnectorExecuteTool(registry, context) {
113579
+ const executor = createConnectorExecuteExecutor(context);
113580
+ registry.register(connectorExecuteTool, executor);
113581
+ }
113582
+ var connectorsSearchTool = {
113583
+ name: "connectors_search",
113584
+ description: "Search for connectors by name, description, or command. Use this to find the right connector for a task when many are available.",
113585
+ parameters: {
113586
+ type: "object",
113587
+ properties: {
113588
+ query: {
113589
+ type: "string",
113590
+ description: "Search query to match against connector names, descriptions, and commands"
113591
+ },
113592
+ limit: {
113593
+ type: "number",
113594
+ description: "Maximum number of results to return (default: 5, max: 20)"
113595
+ }
113596
+ },
113597
+ required: ["query"]
113598
+ }
113599
+ };
113600
+ function createConnectorsSearchExecutor(context) {
113601
+ return async (input) => {
113602
+ const bridge = context.getConnectorBridge();
113603
+ if (!bridge) {
113604
+ return JSON.stringify({
113605
+ error: "Connector discovery not available",
113606
+ results: []
113607
+ });
113608
+ }
113609
+ const query = (input.query || "").toLowerCase();
113610
+ const limit = Math.min(Math.max(1, Number(input.limit) || 5), 20);
113611
+ if (!query) {
113612
+ return JSON.stringify({
113613
+ error: "Search query is required",
113614
+ suggestion: 'Provide a query like "email", "storage", or "calendar"'
113615
+ });
113616
+ }
113617
+ const connectors = bridge.getConnectors();
113618
+ const results = [];
113619
+ for (const connector of connectors) {
113620
+ let score = 0;
113621
+ const matchedCommands = [];
113622
+ if (connector.name.toLowerCase().includes(query)) {
113623
+ score += 10;
113624
+ if (connector.name.toLowerCase() === query) {
113625
+ score += 5;
113626
+ }
113627
+ }
113628
+ if (connector.description.toLowerCase().includes(query)) {
113629
+ score += 5;
113630
+ }
113631
+ for (const cmd of connector.commands) {
113632
+ if (cmd.name.toLowerCase().includes(query)) {
113633
+ score += 2;
113634
+ matchedCommands.push(cmd.name);
113635
+ }
113636
+ if (cmd.description.toLowerCase().includes(query)) {
113637
+ score += 1;
113638
+ if (!matchedCommands.includes(cmd.name)) {
113639
+ matchedCommands.push(cmd.name);
113640
+ }
113641
+ }
113642
+ }
113643
+ if (score > 0) {
113644
+ results.push({
113645
+ name: connector.name,
113646
+ description: connector.description,
113647
+ matchedCommands: matchedCommands.slice(0, 5),
113648
+ score
113649
+ });
113650
+ }
113651
+ }
113652
+ results.sort((a, b) => b.score - a.score);
113653
+ const topResults = results.slice(0, limit);
113654
+ if (context.onConnectorSelected && topResults.length > 0) {
113655
+ for (const result of topResults) {
113656
+ context.onConnectorSelected(result.name);
113657
+ }
113658
+ }
113659
+ return JSON.stringify({
113660
+ query,
113661
+ count: topResults.length,
113662
+ totalMatches: results.length,
113663
+ results: topResults.map(({ score, ...rest }) => rest),
113664
+ suggestion: topResults.length > 0 ? `Use connector_execute with connector="${topResults[0].name}" to run commands` : "Try a different search query or use connectors_list to see all available connectors"
113665
+ }, null, 2);
113666
+ };
113667
+ }
113668
+ function registerConnectorsSearchTool(registry, context) {
113669
+ const executor = createConnectorsSearchExecutor(context);
113670
+ registry.register(connectorsSearchTool, executor);
113671
+ }
113516
113672
  var connectorsListTool = {
113517
113673
  name: "connectors_list",
113518
113674
  description: "List all discovered connectors and their available commands. Use this to discover what connectors are available and what operations they support.",
@@ -155185,6 +155341,15 @@ class AssistantLoop {
155185
155341
  registerConnectorsListTool(this.toolRegistry, {
155186
155342
  getConnectorBridge: () => this.connectorBridge
155187
155343
  });
155344
+ registerConnectorsSearchTool(this.toolRegistry, {
155345
+ getConnectorBridge: () => this.connectorBridge,
155346
+ onConnectorSelected: (connectorName) => {
155347
+ this.connectorBridge.registerConnector(this.toolRegistry, connectorName);
155348
+ }
155349
+ });
155350
+ registerConnectorExecuteTool(this.toolRegistry, {
155351
+ getConnectorBridge: () => this.connectorBridge
155352
+ });
155188
155353
  registerConnectorAutoRefreshTool(this.toolRegistry);
155189
155354
  registerConfigTools(this.toolRegistry, {
155190
155355
  cwd: this.cwd
@@ -155588,6 +155753,17 @@ class AssistantLoop {
155588
155753
  hook_event_name: "Stop",
155589
155754
  cwd: this.cwd
155590
155755
  });
155756
+ try {
155757
+ await nativeHookRegistry.execute("Stop", {
155758
+ session_id: this.sessionId,
155759
+ hook_event_name: "Stop",
155760
+ cwd: this.cwd
155761
+ }, {
155762
+ sessionId: this.sessionId,
155763
+ cwd: this.cwd,
155764
+ messages: this.context.getMessages()
155765
+ });
155766
+ } catch {}
155591
155767
  const shouldSkipVerification = this.shouldStop || streamError !== null;
155592
155768
  if (shouldSkipVerification) {
155593
155769
  this.scopeContextManager.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/assistants",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "AI assistant that runs in your terminal - powered by Claude",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -53,7 +53,7 @@
53
53
  "prepublishOnly": "pnpm run clean && pnpm run build"
54
54
  },
55
55
  "dependencies": {
56
- "@hasna/assistants": "^1.1.2",
56
+ "@hasna/assistants": "1.1.3",
57
57
  "chalk": "^5.3.0",
58
58
  "ink": "^6.0.0",
59
59
  "ink-scroll-view": "^0.3.5",