Skip to content
Merged
4 changes: 2 additions & 2 deletions packages/ai-bot/tests/prompt-construction-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3224,7 +3224,7 @@ Attached Files (files with newer versions don't show their content):
id: 'http://localhost:4201/admin/custom-embedded/Skill/72d005b5-1a6b-4c6d-995f-2411c5948e74',
attributes: {
instructions:
'Use the tool SwitchSubmodeCommand with "code" to go to codemode and "interact" to go to interact mode.',
'Use the tool SwitchSubmodeTool with "code" to go to codemode and "interact" to go to interact mode.',
commands: [
{
codeRef: {
Expand Down Expand Up @@ -3323,7 +3323,7 @@ Attached Files (files with newer versions don't show their content):
);
assert.ok(
switchSubmodeTool,
'Should have SwitchSubmodeCommand function available',
'Should have SwitchSubmodeTool function available',
);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/base/ai-app-generator.gts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { restartableTask } from 'ember-concurrency';

import AskAiCommand from '@cardstack/boxel-host/commands/ask-ai';
import AskAiTool from '@cardstack/boxel-host/commands/ask-ai';
import { AskAiInput } from './command';
import { tracked } from '@glimmer/tracking';

Expand Down Expand Up @@ -54,7 +54,7 @@ export class AiAppGenerator extends CardDef {
throw new Error('No command context found');
}

let command = new AskAiCommand(commandContext);
let command = new AskAiTool(commandContext);
await command.execute(
new AskAiInput({
prompt: this.args.model.promptValue,
Expand Down
8 changes: 4 additions & 4 deletions packages/base/card-api.gts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ import FilePencilIcon from '@cardstack/boxel-icons/file-pencil';
import WandIcon from '@cardstack/boxel-icons/wand';
import HashIcon from '@cardstack/boxel-icons/hash';
// normalizeEnumOptions used by enum moved to packages/base/enum.gts
import PatchThemeCommand from '@cardstack/boxel-host/commands/patch-theme';
import CopyAndEditCommand from '@cardstack/boxel-host/commands/copy-and-edit';
import PatchThemeTool from '@cardstack/boxel-host/commands/patch-theme';
import CopyAndEditTool from '@cardstack/boxel-host/commands/copy-and-edit';
import { md5 } from 'super-fast-md5';

import {
Expand Down Expand Up @@ -3289,7 +3289,7 @@ export class Theme extends CardDef {
if (!params.commandContext || !this.id) {
return;
}
let cmd = new CopyAndEditCommand(params.commandContext);
let cmd = new CopyAndEditTool(params.commandContext);
await cmd.execute({
card: this,
});
Expand All @@ -3300,7 +3300,7 @@ export class Theme extends CardDef {
{
label: 'Modify Theme via AI',
action: async () => {
let cmd = new PatchThemeCommand(params.commandContext);
let cmd = new PatchThemeTool(params.commandContext);
await cmd.execute({
cardId: this.id as unknown as string,
});
Expand Down
4 changes: 3 additions & 1 deletion packages/base/command.gts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import {
} from './commands/search-card-result';
import { eq, gt } from '@cardstack/boxel-ui/helpers';

export type CommandStatus = 'applied' | 'ready' | 'applying';
export type ToolCallStatus = 'applied' | 'ready' | 'applying';
// Pre-rename spelling; new code imports `ToolCallStatus`.
export type CommandStatus = ToolCallStatus;

export class ApplyMarkdownEditInput extends CardDef {
@field cardId = contains(StringField);
Expand Down
2 changes: 1 addition & 1 deletion packages/base/commands/search-card-result.gts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class SearchCardsResultEmbeddedView extends Component<

class SearchCardsResultIsolatedView extends SearchCardsResultEmbeddedView {
<template>
<section class='command-result' data-test-command-result-isolated>
<section class='command-result' data-test-tool-result-isolated>
<header>
<h3>Search Results</h3>
<p class='result-count'>
Expand Down
4 changes: 2 additions & 2 deletions packages/base/default-templates/missing-template.gts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { on } from '@ember/modifier';
import { action } from '@ember/object';
import { Button } from '@cardstack/boxel-ui/components';
// @ts-ignore can't include this in tuntime-common tsconfig until we
import SwitchSubmodeCommand from '@cardstack/boxel-host/commands/switch-submode';
import SwitchSubmodeTool from '@cardstack/boxel-host/commands/switch-submode';

export default class MissingTemplate extends GlimmerComponent<{
Args: {
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class MissingTemplate extends GlimmerComponent<{
}
let moduleId = moduleFrom(ref);
let commandContext = this.args.context?.commandContext;
await new SwitchSubmodeCommand(commandContext!).execute({
await new SwitchSubmodeTool(commandContext!).execute({
codePath: moduleId,
submode: 'code',
});
Expand Down
24 changes: 12 additions & 12 deletions packages/base/file-menu-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import Eye from '@cardstack/boxel-icons/eye';
import LinkIcon from '@cardstack/boxel-icons/link';
import Trash2Icon from '@cardstack/boxel-icons/trash-2';

import CopyCardAsMarkdownCommand from '@cardstack/boxel-host/commands/copy-card-as-markdown';
import CopyFileToRealmCommand from '@cardstack/boxel-host/commands/copy-file-to-realm';
import OpenInInteractModeCommand from '@cardstack/boxel-host/commands/open-in-interact-mode';
import ShowFileCommand from '@cardstack/boxel-host/commands/show-file';
import SwitchSubmodeCommand from '@cardstack/boxel-host/commands/switch-submode';
import CopyCardAsMarkdownTool from '@cardstack/boxel-host/commands/copy-card-as-markdown';
import CopyFileToRealmTool from '@cardstack/boxel-host/commands/copy-file-to-realm';
import OpenInInteractModeTool from '@cardstack/boxel-host/commands/open-in-interact-mode';
import ShowFileTool from '@cardstack/boxel-host/commands/show-file';
import SwitchSubmodeTool from '@cardstack/boxel-host/commands/switch-submode';

import type { FileDef } from './card-api';
import type { GetMenuItemParams } from './menu-items';
Expand All @@ -40,15 +40,15 @@ export function getDefaultFileMenuItems(
if (params.menuContext === 'interact') {
if (fileDefInstanceId) {
// Mirror the CardDef menu so users get a consistent set of actions on
// file rows. `CopyCardAsMarkdownCommand` is generic — it fetches the
// file rows. `CopyCardAsMarkdownTool` is generic — it fetches the
// URL with `Accept: text/markdown` — so a file URL works the same way
// a card URL does, returning whatever the file row's `markdown`
// column holds (populated by the FileRender pass; null today for
// `.gts`/`.ts` rows pending CS-11171).
menuItems.push({
label: 'Copy as Markdown',
action: () =>
new CopyCardAsMarkdownCommand(params.commandContext).execute({
new CopyCardAsMarkdownTool(params.commandContext).execute({
cardId: fileDefInstanceId,
}),
icon: ClipboardCopy,
Expand All @@ -59,7 +59,7 @@ export function getDefaultFileMenuItems(
menuItems.push({
label: 'Open in Code Mode',
action: async () => {
await new SwitchSubmodeCommand(params.commandContext).execute({
await new SwitchSubmodeTool(params.commandContext).execute({
submode: 'code',
codePath: fileDefInstanceId,
});
Expand Down Expand Up @@ -88,14 +88,14 @@ export function getDefaultFileMenuItems(
menuItems.push({
label: 'Copy to Workspace',
action: async () => {
let { newFileIdentifier } = await new CopyFileToRealmCommand(
let { newFileIdentifier } = await new CopyFileToRealmTool(
params.commandContext,
).execute({
sourceFileIdentifier: fileDefInstance.sourceUrl,
targetRealm: params.menuContextParams.activeRealmURL,
});

await new ShowFileCommand(params.commandContext).execute({
await new ShowFileTool(params.commandContext).execute({
fileIdentifier: newFileIdentifier,
});
},
Expand All @@ -108,7 +108,7 @@ export function getDefaultFileMenuItems(
menuItems.push({
label: 'Open in Interact Mode',
action: () => {
new OpenInInteractModeCommand(params.commandContext).execute({
new OpenInInteractModeTool(params.commandContext).execute({
cardId: fileDefInstanceId,
format: params.format === 'edit' ? 'edit' : 'isolated',
});
Expand All @@ -120,7 +120,7 @@ export function getDefaultFileMenuItems(
menuItems.push({
label: 'Open in Code Mode',
action: async () => {
await new SwitchSubmodeCommand(params.commandContext).execute({
await new SwitchSubmodeTool(params.commandContext).execute({
submode: 'code',
codePath: fileDefInstanceId,
});
Expand Down
36 changes: 23 additions & 13 deletions packages/base/matrix-event.gts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export interface DebugMessageEvent extends BaseMatrixEvent {
}

// Synapse JSON does not support decimals, so we encode all arguments as stringified JSON
export type EncodedCommandRequest = Omit<CommandRequest, 'arguments'> & {
export type EncodedToolRequest = Omit<CommandRequest, 'arguments'> & {
arguments: string;
};

Expand Down Expand Up @@ -250,10 +250,10 @@ export interface CardMessageContent {
[APP_BOXEL_HAS_CONTINUATION_CONTENT_KEY]?: boolean;
[APP_BOXEL_CONTINUATION_OF_CONTENT_KEY]?: string; // event_id of the message we are continuing
[APP_BOXEL_REASONING_CONTENT_KEY]?: string;
[APP_BOXEL_TOOL_REQUESTS_KEY]?: Partial<EncodedCommandRequest>[];
[APP_BOXEL_TOOL_REQUESTS_KEY]?: Partial<EncodedToolRequest>[];
// Replay-only: messages written before the command → tool rename carry
// their requests under this key. Read via `getToolRequests`; never write.
[LEGACY_APP_BOXEL_COMMAND_REQUESTS_KEY]?: Partial<EncodedCommandRequest>[];
[LEGACY_APP_BOXEL_COMMAND_REQUESTS_KEY]?: Partial<EncodedToolRequest>[];
errorMessage?: string;
// ID from the client and can be used by client
// to verify whether the message is already sent or not.
Expand Down Expand Up @@ -295,9 +295,9 @@ export interface LLMModeEvent extends RoomStateEvent {
};
}

export interface CommandResultEvent extends BaseMatrixEvent {
export interface ToolResultEvent extends BaseMatrixEvent {
type: ToolResultEventType;
content: CommandResultWithOutputContent | CommandResultWithNoOutputContent;
content: ToolResultWithOutputContent | ToolResultWithNoOutputContent;
unsigned: {
age: number;
transaction_id: string;
Expand Down Expand Up @@ -331,20 +331,20 @@ export interface CodePatchResultEvent extends BaseMatrixEvent {
};
}

export interface CommandDefinitionSchema {
export interface ToolDefinitionSchema {
codeRef: {
module: string;
name: string;
};
tool: Tool;
}

export type CommandResultStatus = 'applied' | 'failed' | 'invalid';
export type ToolResultStatus = 'applied' | 'failed' | 'invalid';

export interface CommandResultWithOutputContent {
export interface ToolResultWithOutputContent {
'm.relates_to': {
rel_type: ToolResultRelType;
key: CommandResultStatus;
key: ToolResultStatus;
event_id: string;
};
commandRequestId: string;
Expand All @@ -362,10 +362,10 @@ export interface CommandResultWithOutputContent {
msgtype: ToolResultWithOutputMsgtype;
}

export interface CommandResultWithNoOutputContent {
export interface ToolResultWithNoOutputContent {
'm.relates_to': {
rel_type: ToolResultRelType;
key: CommandResultStatus;
key: ToolResultStatus;
event_id: string;
};
msgtype: ToolResultWithNoOutputMsgtype;
Expand Down Expand Up @@ -487,15 +487,15 @@ export interface StopGeneratingEvent extends BaseMatrixEvent {

export type MatrixEventWithBoxelContext =
| CardMessageEvent
| CommandResultEvent
| ToolResultEvent
| CodePatchResultEvent;

export type MatrixEvent =
| ActiveLLMEvent
| BotTriggerEvent
| CardMessageEvent
| CodePatchResultEvent
| CommandResultEvent
| ToolResultEvent
| DebugMessageEvent
| InviteEvent
| JoinEvent
Expand All @@ -510,3 +510,13 @@ export type MatrixEvent =
| RoomPowerLevels
| RoomTopicEvent
| SkillsConfigEvent;

// Pre-rename spellings; new code imports the Tool-named types. These stay
// until the ai-bot / prompt-assembly sweep (and out-of-tree content) stops
// importing them.
export type EncodedCommandRequest = EncodedToolRequest;
export type CommandDefinitionSchema = ToolDefinitionSchema;
export type CommandResultEvent = ToolResultEvent;
export type CommandResultWithOutputContent = ToolResultWithOutputContent;
export type CommandResultWithNoOutputContent = ToolResultWithNoOutputContent;
export type CommandResultStatus = ToolResultStatus;
30 changes: 14 additions & 16 deletions packages/base/menu-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import {
type MenuItemOptions,
} from '@cardstack/boxel-ui/helpers';

import CopyCardAsMarkdownCommand from '@cardstack/boxel-host/commands/copy-card-as-markdown';
import CopyCardAsMarkdownTool from '@cardstack/boxel-host/commands/copy-card-as-markdown';
import CopyCardCommand from '@cardstack/boxel-host/commands/copy-card';
import GenerateExampleCardsCommand from '@cardstack/boxel-host/commands/generate-example-cards';
import OpenCreateListingModalCommand from '@cardstack/boxel-host/commands/open-create-listing-modal';
import OpenInInteractModeCommand from '@cardstack/boxel-host/commands/open-in-interact-mode';
import PopulateWithSampleDataCommand from '@cardstack/boxel-host/commands/populate-with-sample-data';
import ShowCardCommand from '@cardstack/boxel-host/commands/show-card';
import SwitchSubmodeCommand from '@cardstack/boxel-host/commands/switch-submode';
import GenerateExampleCardsTool from '@cardstack/boxel-host/commands/generate-example-cards';
import OpenCreateListingModalTool from '@cardstack/boxel-host/commands/open-create-listing-modal';
import OpenInInteractModeTool from '@cardstack/boxel-host/commands/open-in-interact-mode';
import PopulateWithSampleDataTool from '@cardstack/boxel-host/commands/populate-with-sample-data';
import ShowCardTool from '@cardstack/boxel-host/commands/show-card';
import SwitchSubmodeTool from '@cardstack/boxel-host/commands/switch-submode';
import type {
CommandContext,
Format,
Expand Down Expand Up @@ -92,7 +92,7 @@ export function getDefaultCardMenuItems(
menuItems.push({
label: 'Copy as Markdown',
action: () =>
new CopyCardAsMarkdownCommand(params.commandContext).execute({
new CopyCardAsMarkdownTool(params.commandContext).execute({
cardId,
}),
icon: ClipboardCopy,
Expand Down Expand Up @@ -176,7 +176,7 @@ export function getDefaultCardMenuItems(
targetRealm: params.menuContextParams.activeRealmURL,
});

let showCardCommand = new ShowCardCommand(params.commandContext);
let showCardCommand = new ShowCardTool(params.commandContext);
await showCardCommand.execute({
cardId: newCardId,
});
Expand All @@ -190,7 +190,7 @@ export function getDefaultCardMenuItems(
menuItems.push({
label: 'Open in Interact Mode',
action: () => {
new OpenInInteractModeCommand(params.commandContext).execute({
new OpenInInteractModeTool(params.commandContext).execute({
cardId,
format: params.format === 'edit' ? 'edit' : 'isolated',
});
Expand All @@ -203,7 +203,7 @@ export function getDefaultCardMenuItems(
menuItems.push({
label: 'Open in Code Mode',
action: async () => {
await new SwitchSubmodeCommand(params.commandContext).execute({
await new SwitchSubmodeTool(params.commandContext).execute({
submode: 'code',
codePath: cardId,
});
Expand All @@ -224,9 +224,7 @@ export function getDefaultCardMenuItems(
if (!targetRealm) {
throw new Error('Unable to determine target realm from card');
}
await new OpenCreateListingModalCommand(
params.commandContext,
).execute({
await new OpenCreateListingModalTool(params.commandContext).execute({
codeRef,
openCardIds: [cardId],
targetRealm,
Expand All @@ -250,7 +248,7 @@ function getSampleDataMenuItems(
menuItems.push({
label: `Fill in Sample Data with AI`,
action: async () =>
await new PopulateWithSampleDataCommand(commandContext).execute({
await new PopulateWithSampleDataTool(commandContext).execute({
cardId: card.id,
}),
icon: Wand,
Expand All @@ -262,7 +260,7 @@ function getSampleDataMenuItems(
menuItems.push({
label: `Generate ${GENERATED_EXAMPLE_COUNT} examples with AI`,
action: async () => {
await new GenerateExampleCardsCommand(commandContext).execute({
await new GenerateExampleCardsTool(commandContext).execute({
count: GENERATED_EXAMPLE_COUNT,
codeRef: codeRef as ResolvedCodeRef,
realm: card[realmURL]?.href,
Expand Down
4 changes: 2 additions & 2 deletions packages/base/realm.gts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import World from '@cardstack/boxel-icons/world';
import { action } from '@ember/object';
import { commandData } from './resources/command-data';
import type { GetAllRealmMetasResult } from './command';
import GetAllRealmMetasCommand from '@cardstack/boxel-host/commands/get-all-realm-metas';
import GetAllRealmMetasTool from '@cardstack/boxel-host/commands/get-all-realm-metas';

type RealmMeta = {
realmIdentifier: string;
Expand All @@ -28,7 +28,7 @@ type RealmMeta = {
class EditComponent extends Component<typeof RealmField> {
allRealmsInfoResource = commandData<typeof GetAllRealmMetasResult>(
this,
GetAllRealmMetasCommand,
GetAllRealmMetasTool,
);

get writableRealms(): RealmMeta[] {
Expand Down
Loading
Loading