-
Notifications
You must be signed in to change notification settings - Fork 0
fix: discover agents across all accessible drives, not just the default #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { test } from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
| import { | ||
| collectAgentPages, | ||
| dedupeAgentNames, | ||
| orderDrivesPreferredFirst, | ||
| type Drive, | ||
| type Page, | ||
| } from "../../src/api.ts"; | ||
|
|
||
| const page = (id: string, title: string, type: string, children?: Page[]): Page => ({ | ||
| id, | ||
| title, | ||
| type, | ||
| parentId: null, | ||
| children, | ||
| }); | ||
|
|
||
| test("collectAgentPages: finds AI_CHAT pages at any depth, in tree order, titles as names", () => { | ||
| const tree: Page[] = [ | ||
| page("a", "Top Agent", "AI_CHAT"), | ||
| page("f", "Folder", "FOLDER", [ | ||
| page("doc", "Doc", "DOCUMENT"), | ||
| page("b", "Nested Agent", "AI_CHAT", [page("c", "Deep Agent", "AI_CHAT")]), | ||
| ]), | ||
| ]; | ||
| assert.deepEqual(collectAgentPages(tree), [ | ||
| { id: "a", name: "Top Agent" }, | ||
| { id: "b", name: "Nested Agent" }, | ||
| { id: "c", name: "Deep Agent" }, | ||
| ]); | ||
| }); | ||
|
|
||
| test("collectAgentPages: no agents → empty list", () => { | ||
| assert.deepEqual(collectAgentPages([page("d", "Doc", "DOCUMENT")]), []); | ||
| }); | ||
|
|
||
| test("orderDrivesPreferredFirst: preferred drive moves to front, others keep order", () => { | ||
| const drives: Drive[] = [ | ||
| { id: "1", name: "A", slug: "a" }, | ||
| { id: "2", name: "B", slug: "b" }, | ||
| { id: "3", name: "C", slug: "c" }, | ||
| ]; | ||
| assert.deepEqual( | ||
| orderDrivesPreferredFirst(drives, "b").map((d) => d.slug), | ||
| ["b", "a", "c"], | ||
| ); | ||
| // No preference (or unknown slug) → unchanged order, original array untouched. | ||
| assert.deepEqual( | ||
| orderDrivesPreferredFirst(drives).map((d) => d.slug), | ||
| ["a", "b", "c"], | ||
| ); | ||
| assert.deepEqual( | ||
| orderDrivesPreferredFirst(drives, "zzz").map((d) => d.slug), | ||
| ["a", "b", "c"], | ||
| ); | ||
| assert.deepEqual( | ||
| drives.map((d) => d.slug), | ||
| ["a", "b", "c"], | ||
| ); | ||
| }); | ||
|
|
||
| test("dedupeAgentNames: duplicate names get a short id suffix; unique names untouched", () => { | ||
| const agents = [ | ||
| { id: "abcdefgh1234", name: "Curator" }, | ||
| { id: "ijklmnop5678", name: "Curator" }, | ||
| { id: "qrstuvwx9012", name: "Writer" }, | ||
| ]; | ||
| assert.deepEqual(dedupeAgentNames(agents), [ | ||
| { id: "abcdefgh1234", name: "Curator (abcdefgh)" }, | ||
| { id: "ijklmnop5678", name: "Curator (ijklmnop)" }, | ||
| { id: "qrstuvwx9012", name: "Writer" }, | ||
| ]); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an existing agent is already titled like a generated name (for example,
Curator (abcdefgh)alongside two agents namedCurator), or two duplicate-name agents share the same eight-character ID prefix, this produces duplicate pi model IDs. Selecting the later model then still routes throughconfig.models.find(...)to the first matching entry, so requests can be sent to the wrong PageSpace agent; generate suffixes while checking the complete resulting name set rather than only counting the original titles.Useful? React with 👍 / 👎.