@tenex-chat/backend 0.9.3 → 0.9.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.
package/dist/src/index.js CHANGED
@@ -5689,10 +5689,6 @@ class AgentStorage {
5689
5689
  const slugEntry = this.index.bySlug[slug];
5690
5690
  if (!slugEntry)
5691
5691
  return null;
5692
- logger.warn("Using deprecated getAgentBySlug() - consider using getAgentBySlugForProject()", {
5693
- slug,
5694
- pubkey: slugEntry.pubkey.substring(0, 8)
5695
- });
5696
5692
  return this.loadAgent(slugEntry.pubkey);
5697
5693
  }
5698
5694
  async getAgentBySlugForProject(slug, projectDTag) {
@@ -46575,7 +46571,7 @@ async function addAgent(eventId) {
46575
46571
  console.log(chalk15.green(`✓ Installed agent "${stored.name}" (${stored.slug})`));
46576
46572
  console.log(chalk15.gray(` pubkey: ${pubkey}`));
46577
46573
  }
46578
- var OPENCLAW_STATE_DIR_NAMES, OPENCLAW_CONFIG_NAMES, importOpenClawCommand, importCommand, addCommand, agentCommand;
46574
+ var OPENCLAW_STATE_DIR_NAMES, OPENCLAW_CONFIG_NAMES, importOpenClawCommand, importCommand, addCommand, assignCommand, agentCommand;
46579
46575
  var init_agent2 = __esm(() => {
46580
46576
  init_AgentStorage();
46581
46577
  init_agent_installer();
@@ -46593,7 +46589,19 @@ var init_agent2 = __esm(() => {
46593
46589
  addCommand = new Command10("add").description("Install an agent from a Nostr event ID or stdin JSON").argument("[event-id]", "Nostr event ID of the agent definition").action(async (eventId) => {
46594
46590
  await addAgent(eventId);
46595
46591
  });
46596
- agentCommand = new Command10("agent").description("Manage TENEX agents").addCommand(importCommand).addCommand(addCommand);
46592
+ assignCommand = new Command10("assign").description("Assign an agent to a project by slug").argument("<slug>", "Agent slug").argument("<project-dtag>", "Project d-tag").action(async (slug, projectDTag) => {
46593
+ await agentStorage.initialize();
46594
+ const agent = await agentStorage.getAgentBySlug(slug);
46595
+ if (!agent) {
46596
+ console.error(chalk15.red(`Agent '${slug}' not found.`));
46597
+ process.exitCode = 1;
46598
+ return;
46599
+ }
46600
+ const pubkey = new NDKPrivateKeySigner20(agent.nsec).pubkey;
46601
+ await agentStorage.addAgentToProject(pubkey, projectDTag);
46602
+ console.log(chalk15.green(`Assigned '${slug}' to project '${projectDTag}'.`));
46603
+ });
46604
+ agentCommand = new Command10("agent").description("Manage TENEX agents").addCommand(assignCommand).addCommand(importCommand).addCommand(addCommand);
46597
46605
  });
46598
46606
 
46599
46607
  // src/utils/cli-error.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenex-chat/backend",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "description": "TENEX Command Line Interface",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -658,12 +658,8 @@ export class AgentStorage {
658
658
 
659
659
  /**
660
660
  * Get agent by slug (uses index for O(1) lookup).
661
- *
662
- * **DEPRECATED**: Use getAgentBySlugForProject() instead for project-scoped lookups.
663
- * This method returns the LAST agent saved with this slug, which may not be the
664
- * correct agent when multiple agents use the same slug across different projects.
665
- *
666
- * @deprecated Use getAgentBySlugForProject(slug, projectDTag) instead
661
+ * Returns the agent matching this slug regardless of project.
662
+ * Use getAgentBySlugForProject() when you need project-scoped lookups.
667
663
  */
668
664
  async getAgentBySlug(slug: string): Promise<StoredAgent | null> {
669
665
  if (!this.index) await this.loadIndex();
@@ -672,11 +668,6 @@ export class AgentStorage {
672
668
  const slugEntry = this.index.bySlug[slug];
673
669
  if (!slugEntry) return null;
674
670
 
675
- logger.warn("Using deprecated getAgentBySlug() - consider using getAgentBySlugForProject()", {
676
- slug,
677
- pubkey: slugEntry.pubkey.substring(0, 8),
678
- });
679
-
680
671
  return this.loadAgent(slugEntry.pubkey);
681
672
  }
682
673
 
@@ -209,7 +209,27 @@ const addCommand = new Command("add")
209
209
  await addAgent(eventId);
210
210
  });
211
211
 
212
+ const assignCommand = new Command("assign")
213
+ .description("Assign an agent to a project by slug")
214
+ .argument("<slug>", "Agent slug")
215
+ .argument("<project-dtag>", "Project d-tag")
216
+ .action(async (slug: string, projectDTag: string) => {
217
+ await agentStorage.initialize();
218
+
219
+ const agent = await agentStorage.getAgentBySlug(slug);
220
+ if (!agent) {
221
+ console.error(chalk.red(`Agent '${slug}' not found.`));
222
+ process.exitCode = 1;
223
+ return;
224
+ }
225
+
226
+ const pubkey = new NDKPrivateKeySigner(agent.nsec).pubkey;
227
+ await agentStorage.addAgentToProject(pubkey, projectDTag);
228
+ console.log(chalk.green(`Assigned '${slug}' to project '${projectDTag}'.`));
229
+ });
230
+
212
231
  export const agentCommand = new Command("agent")
213
232
  .description("Manage TENEX agents")
233
+ .addCommand(assignCommand)
214
234
  .addCommand(importCommand)
215
235
  .addCommand(addCommand);