-
Notifications
You must be signed in to change notification settings - Fork 10
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
Commands on skill cards #2132
Merged
Merged
Commands on skill cards #2132
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
45951e5
Skills can contain links to commands
IanCal bc512a3
Add sending of command definitions
IanCal 5d68bc2
Add function name to commands in skills, support in aibot
IanCal 8eb5e5b
Add lookup and loading of the commands on the host side
IanCal 94d149a
Remove logging
IanCal e1a463e
Improve comment to explain what we're actually doing
IanCal 1e96eb4
Export default and class name
IanCal 4423aed
Undo erroneous capitalisation
IanCal 69d94e3
No default export, keep original casing
IanCal e0912ca
Fix imports
IanCal 7ab89f8
Fix more named imports
IanCal d97f4c8
Inconsistent casing
IanCal c0e3850
Stronger typing for TS
IanCal 3eb3739
Remove unused import
IanCal 4039f66
Add boxel UI state command to shimmed modules and fix import
IanCal 7efc2d6
Fix casing in import
IanCal e068363
Again, casing issues
IanCal b6d0297
Test running command from skill
IanCal 63d3519
Test for commands on skills
IanCal 56b2c12
Fix hash suffix
IanCal b0f66c3
Update hashing function
IanCal a69a31a
Remove logging
IanCal a65d474
Avoid creating room resources in multiple places
IanCal 43e109e
Improve setting of active llm
IanCal 7d986f9
Load skills as we load events
IanCal 7fb4bf4
Remove unneccessary async
IanCal 4cbc99a
Support processing more out of order, add members and user ids as qui…
IanCal fcfd03c
Iterate specifically
IanCal 1f7fe65
test removing restriction on users for tests
IanCal 8a22952
Bring back limits for room resource loading
IanCal a7ea41d
Remove pauses?
IanCal 54beb97
Merge branch 'main' into return-of-the-skill-commands
IanCal bd907fa
Fix eslint issues
lukemelia a85f478
Lint fixes
lukemelia 7df2e0e
Merge branch 'main' into return-of-the-skill-commands
lukemelia 78860a3
Merge branch 'main' into return-of-the-skill-commands
lukemelia 738afb3
Eliminate a relative reference in seed realm that shouldn't be relative
lukemelia 393fe3e
Merge branch 'main' into return-of-the-skill-commands
lukemelia d01b19a
Better handling of commands exported as default
lukemelia 7544d50
Merge branch 'main' into return-of-the-skill-commands
lukemelia 22ecb4e
Merge branch 'faster-matrix-specs' into return-of-the-skill-commands
lukemelia 5c32d82
Merge branch 'main' into return-of-the-skill-commands
lukemelia 2d3ad9d
Safer checking for toolCall
lukemelia 447be78
Merge branch 'main' into return-of-the-skill-commands
lukemelia b20fb12
Fix an import in generator code
lukemelia 167b145
Merge branch 'main' into return-of-the-skill-commands
lukemelia ba864b2
Merge branch 'main' into return-of-the-skill-commands
lukemelia 7be953a
Merge branch 'reuse-room-resource' into return-of-the-skill-commands
lukemelia 8b99982
Merge branch 'main' into return-of-the-skill-commands
lukemelia bad2fd1
Merge branch 'check-room-members-before-processing-events' into retur…
lukemelia 65b9a47
Merge branch 'main' into return-of-the-skill-commands
lukemelia 5e51d57
Merge branch 'main' into return-of-the-skill-commands
lukemelia d46fd35
Merge branch 'main' into return-of-the-skill-commands
lukemelia 0182bd5
Remove unneeded changes
lukemelia a88f906
AI test fixes
lukemelia 0ffa9f1
Merge branch 'code-ref-modules' into return-of-the-skill-commands
lukemelia 57d4693
Merge branch 'main' into return-of-the-skill-commands
lukemelia 3a8219e
Merge branch 'main' into return-of-the-skill-commands
lukemelia 2c43b0e
Merge branch 'main' into return-of-the-skill-commands
lukemelia af764f2
Merge branch 'main' into return-of-the-skill-commands
lukemelia 519e618
Merge branch 'main' into return-of-the-skill-commands
lukemelia 4309af8
Merge branch 'main' into return-of-the-skill-commands
lukemelia e218961
Merge branch 'main' into return-of-the-skill-commands
lukemelia 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 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 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 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 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 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 |
---|---|---|
|
@@ -27,6 +27,7 @@ import { | |
LooseCardResource, | ||
ResolvedCodeRef, | ||
aiBotUsername, | ||
getClass, | ||
} from '@cardstack/runtime-common'; | ||
|
||
import { | ||
|
@@ -42,6 +43,7 @@ import { | |
APP_BOXEL_CARD_FORMAT, | ||
APP_BOXEL_CARDFRAGMENT_MSGTYPE, | ||
APP_BOXEL_COMMAND_MSGTYPE, | ||
APP_BOXEL_COMMAND_DEFINITIONS_MSGTYPE, | ||
APP_BOXEL_COMMAND_RESULT_EVENT_TYPE, | ||
APP_BOXEL_COMMAND_RESULT_WITH_NO_OUTPUT_MSGTYPE, | ||
APP_BOXEL_COMMAND_RESULT_WITH_OUTPUT_MSGTYPE, | ||
|
@@ -73,10 +75,11 @@ import type { | |
MatrixEvent as DiscreteMatrixEvent, | ||
CommandResultWithNoOutputContent, | ||
CommandResultWithOutputContent, | ||
CommandDefinitionsContent, | ||
} from 'https://cardstack.com/base/matrix-event'; | ||
|
||
import type { Tool } from 'https://cardstack.com/base/matrix-event'; | ||
import { SkillCard } from 'https://cardstack.com/base/skill-card'; | ||
import { CommandField, SkillCard } from 'https://cardstack.com/base/skill-card'; | ||
|
||
import AddSkillsToRoomCommand from '../commands/add-skills-to-room'; | ||
import { importResource } from '../resources/import'; | ||
|
@@ -513,7 +516,8 @@ export default class MatrixService extends Service { | |
| CardMessageContent | ||
| CardFragmentContent | ||
| CommandResultWithNoOutputContent | ||
| CommandResultWithOutputContent, | ||
| CommandResultWithOutputContent | ||
| CommandDefinitionsContent, | ||
) { | ||
let roomData = await this.ensureRoomData(roomId); | ||
return roomData.mutex.dispatch(async () => { | ||
|
@@ -578,11 +582,61 @@ export default class MatrixService extends Service { | |
} | ||
} | ||
|
||
async addCommandDefinitionsToRoomHistory( | ||
commandDefinitions: CommandField[], | ||
roomId: string, | ||
) { | ||
// Create the command defs so getting the json schema | ||
// and send it to the matrix room. | ||
let commandDefinitionSchemas: { | ||
codeRef: ResolvedCodeRef; | ||
tool: Tool; | ||
}[] = []; | ||
const mappings = await basicMappings(this.loaderService.loader); | ||
for (let commandDef of commandDefinitions) { | ||
const Command = await getClass( | ||
commandDef.codeRef, | ||
this.loaderService.loader, | ||
); | ||
const command = new Command(this.commandService.commandContext); | ||
const name = commandDef.functionName; | ||
commandDefinitionSchemas.push({ | ||
codeRef: commandDef.codeRef, | ||
tool: { | ||
type: 'function', | ||
function: { | ||
name, | ||
description: command.description, | ||
parameters: { | ||
type: 'object', | ||
properties: { | ||
description: { | ||
type: 'string', | ||
}, | ||
...(await command.getInputJsonSchema(this.cardAPI, mappings)), | ||
}, | ||
required: ['attributes', 'description'], | ||
}, | ||
}, | ||
}, | ||
}); | ||
} | ||
await this.sendEvent(roomId, 'm.room.message', { | ||
msgtype: APP_BOXEL_COMMAND_DEFINITIONS_MSGTYPE, | ||
body: 'Command Definitions', | ||
data: { | ||
commandDefinitions: commandDefinitionSchemas, | ||
}, | ||
}); | ||
} | ||
|
||
async addSkillCardsToRoomHistory( | ||
skills: SkillCard[], | ||
roomId: string, | ||
opts?: CardAPI.SerializeOpts, | ||
): Promise<string[]> { | ||
const commandDefinitions = skills.flatMap((skill) => skill.commands); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to ensure uniqueness here? |
||
await this.addCommandDefinitionsToRoomHistory(commandDefinitions, roomId); | ||
return this.addCardsToRoom(skills, roomId, this.skillCardHashes, opts); | ||
} | ||
|
||
|
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.
Maybe this type should get a name?