Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(ai): remove rewrite tool (#1067)
Eric Hayes5a50b25958e6
diff --git a/js/app/packages/block-md/signal/rewriteSignal.ts b/js/app/packages/block-md/signal/rewriteSignal.tsindex 631cb10133..22c5ffd50c 100644--- a/js/app/packages/block-md/signal/rewriteSignal.ts+++ b/js/app/packages/block-md/signal/rewriteSignal.ts@@ -1,10 +1,14 @@import { createBlockSignal } from '@core/block';-import type { NamedTool } from '@service-cognition/generated/tools/tool';-export type MarkdownRewriteOutput = NamedTool<- 'MarkdownRewrite',- 'response'->['data'];+export interface Diff {+ operation: string;+ node_key: string;+ markdown_text: string;+}++export type MarkdownRewriteOutput = {+ diffs: Diff[];+};export const rewriteSignal = createBlockSignal<boolean>(false);export const isRewritingSignal = createBlockSignal<boolean>(false);@@ -18,6 +22,4 @@ export const nodesAndTextSignal = createBlockSignal<NodeWithText[] | undefined>(undefined);-export const revisionsSignal = createBlockSignal<- MarkdownRewriteOutput['diffs'] | undefined->(undefined);+export const revisionsSignal = createBlockSignal<Diff[] | undefined>(undefined);diff --git a/js/app/packages/core/component/AI/component/tool/MarkdownRewrite.tsx b/js/app/packages/core/component/AI/component/tool/MarkdownRewrite.tsxindex 42b58e7731..11a768f02f 100644--- a/js/app/packages/core/component/AI/component/tool/MarkdownRewrite.tsx+++ b/js/app/packages/core/component/AI/component/tool/MarkdownRewrite.tsx@@ -1,46 +1,49 @@-import { useGlobalBlockOrchestrator } from '@app/component/GlobalAppState';-import { useSplitLayout } from '@app/component/split-layout/layout';-import Pencil from '@phosphor-icons/core/regular/pencil.svg';-import { BaseTool } from './BaseTool';-import { createToolRenderer } from './ToolRenderer';+// MarkdownRewrite tool has been flagged off - this file is kept for reference+// but the tool is no longer registered in the toolset.-const toolTargetMap: Record<string, string> = {};+// import { useGlobalBlockOrchestrator } from '@app/component/GlobalAppState';+// import { useSplitLayout } from '@app/component/split-layout/layout';+// import Pencil from '@phosphor-icons/core/regular/pencil.svg';+// import { BaseTool } from './BaseTool';+// import { createToolRenderer } from './ToolRenderer';-export const rewriteHandler = createToolRenderer({- name: 'MarkdownRewrite',- handleCall: async (ctx) => {- // cringe- toolTargetMap[ctx.tool.id] = ctx.tool.data.markdown_file_id;- },+// const toolTargetMap: Record<string, string> = {};- handleResponse: async (ctx) => {- const orchestrator = useGlobalBlockOrchestrator();- const targetId = toolTargetMap[ctx.tool.id];- delete toolTargetMap[ctx.tool.id];- const { insertSplit } = useSplitLayout();- insertSplit({ type: 'md', id: targetId });- const handle = await orchestrator.getBlockHandle(targetId, 'md');- if (!handle) {- return;- }- handle.setIsRewriting();- handle.setPatches({ patches: ctx.tool.data.diffs });- },+// export const rewriteHandler = createToolRenderer({+// name: 'MarkdownRewrite',+// handleCall: async (ctx) => {+// // cringe+// toolTargetMap[ctx.tool.id] = ctx.tool.data.markdown_file_id;+// },- renderCall: (ctx) => (- <BaseTool- icon={Pencil}- text="Rewriting"- renderContext={ctx.renderContext}- type="call"- />- ),- renderResponse: (ctx) => (- <BaseTool- icon={Pencil}- text="Rewrite Complete"- renderContext={ctx.renderContext}- type="response"- />- ),-});+// handleResponse: async (ctx) => {+// const orchestrator = useGlobalBlockOrchestrator();+// const targetId = toolTargetMap[ctx.tool.id];+// delete toolTargetMap[ctx.tool.id];+// const { insertSplit } = useSplitLayout();+// insertSplit({ type: 'md', id: targetId });+// const handle = await orchestrator.getBlockHandle(targetId, 'md');+// if (!handle) {+// return;+// }+// handle.setIsRewriting();+// handle.setPatches({ patches: ctx.tool.data.diffs });+// },++// renderCall: (ctx) => (+// <BaseTool+// icon={Pencil}+// text="Rewriting"+// renderContext={ctx.renderContext}+// type="call"+// />+// ),+// renderResponse: (ctx) => (+// <BaseTool+// icon={Pencil}+// text="Rewrite Complete"+// renderContext={ctx.renderContext}+// type="response"+// />+// ),+// });diff --git a/js/app/packages/core/component/AI/component/tool/handler.tsx b/js/app/packages/core/component/AI/component/tool/handler.tsxindex ee6b5555ee..3916163ec0 100644--- a/js/app/packages/core/component/AI/component/tool/handler.tsx+++ b/js/app/packages/core/component/AI/component/tool/handler.tsx@@ -14,7 +14,6 @@ import { bashCodeExecutionHandler } from './BashCodeExecution';import { listChannelsHandler } from './ListChannels';import { listDocumentsHandler } from './ListDocuments';import { listEmailsHandler } from './ListEmails';-import { rewriteHandler } from './MarkdownRewrite';import { readHandler } from './Read';import { contentSearchHandler, nameSearchHandler } from './Search';import { textEditorCodeExecutionHandler } from './TextEditorCodeExecution';@@ -32,7 +31,6 @@ const toolHandlers: ToolHandlerMap<RenderContext> = {ListChannels: listChannelsHandler,ListDocuments: listDocumentsHandler,ListEmails: listEmailsHandler,- MarkdownRewrite: rewriteHandler,NameSearch: nameSearchHandler,Read: readHandler,text_editor_code_execution: textEditorCodeExecutionHandler,diff --git a/js/app/packages/core/component/LexicalMarkdown/plugins/diff/diffPlugin.ts b/js/app/packages/core/component/LexicalMarkdown/plugins/diff/diffPlugin.tsindex ad26043960..d34f146794 100644--- a/js/app/packages/core/component/LexicalMarkdown/plugins/diff/diffPlugin.ts+++ b/js/app/packages/core/component/LexicalMarkdown/plugins/diff/diffPlugin.ts@@ -9,7 +9,6 @@ import {$getNodeById,$isDiffNode,} from '@lexical-core';-import type { NamedTool } from '@service-cognition/generated/tools/tool';import { useUserId } from '@core/context/user';import type { LexicalEditor } from 'lexical';import {@@ -20,7 +19,11 @@ import {import { createEffect } from 'solid-js';import { mapRegisterDelete } from '../shared/utils';-type Diff = NamedTool<'MarkdownRewrite', 'response'>['data']['diffs'][number];+interface Diff {+ operation: string;+ node_key: string;+ markdown_text: string;+}export type DiffPluginArgs = {revisionsSignal: ReturnType<typeof createBlockSignal<Diff[] | undefined>>;diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.tsindex 003d217816..85cdad3d13 100644--- a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts+++ b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts@@ -445,24 +445,6 @@ export const ApiPaginatedThreadCursor = z.object({next_cursor: z.union([z.string(), z.null()]).optional(),});-export const MarkdownRewrite = z- .object({ instructions: z.string(), markdown_file_id: z.string() })- .strict();--export const AIDiffResponse = z- .object({- diffs: z.array(- z- .object({- markdown_text: z.string(),- node_key: z.string(),- operation: z.string(),- })- .strict()- ),- })- .strict();-export const NameSearch = z.object({entityTypes: zdiff --git a/js/app/packages/service-clients/service-cognition/generated/tools/tool.ts b/js/app/packages/service-clients/service-cognition/generated/tools/tool.tsindex 22e50cd6b1..26d66b1c6f 100644--- a/js/app/packages/service-clients/service-cognition/generated/tools/tool.ts+++ b/js/app/packages/service-clients/service-cognition/generated/tools/tool.ts@@ -29,10 +29,6 @@ type ToolParserMap = {call: types.ListEmails;response: types.ApiPaginatedThreadCursor;};- MarkdownRewrite: {- call: types.MarkdownRewrite;- response: types.AIDiffResponse;- };NameSearch: { call: types.NameSearch; response: types.SearchToolResponse };Read: { call: types.Read; response: types.ReadResponse };text_editor_code_execution: {@@ -67,10 +63,6 @@ const toolParserMap = {call: schemas.ListEmails,response: schemas.ApiPaginatedThreadCursor,},- MarkdownRewrite: {- call: schemas.MarkdownRewrite,- response: schemas.AIDiffResponse,- },NameSearch: {call: schemas.NameSearch,response: schemas.SearchToolResponse,@@ -119,10 +111,6 @@ type ToolDataMap = {call: types.ListEmails;response: types.ApiPaginatedThreadCursor;};- MarkdownRewrite: {- call: types.MarkdownRewrite;- response: types.AIDiffResponse;- };NameSearch: { call: types.NameSearch; response: types.SearchToolResponse };Read: { call: types.Read; response: types.ReadResponse };text_editor_code_execution: {diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts b/js/app/packages/service-clients/service-cognition/generated/tools/types.tsindex 77aa527acc..c9f6173d26 100644--- a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts+++ b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts@@ -833,43 +833,6 @@ export interface ApiPaginatedThreadCursor {next_cursor?: string | null;}-/* eslint-disable */-/**- * This file was automatically generated by json-schema-to-typescript.- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,- * and run json-schema-to-typescript to regenerate this file.- */--/**- * Instruct an agent to edit a markdown file identified by an id.- * This tool should be used when the user include a markdown file in context and requests a revision or edit to that file- */-export interface MarkdownRewrite {- /**- * Instructions for the revision agent to follow to edit the markdown. These instructions will be provided by the user.- */- instructions: string;- /**- * The markdown file id to target for editing. This file id will be in your context and labeled as a markdown (md) document- */- markdown_file_id: string;-}--/* eslint-disable */-/**- * This file was automatically generated by json-schema-to-typescript.- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,- * and run json-schema-to-typescript to regenerate this file.- */--export interface AIDiffResponse {- diffs: {- markdown_text: string;- node_key: string;- operation: string;- }[];-}-/* eslint-disable *//*** This file was automatically generated by json-schema-to-typescript.diff --git a/rust/cloud-storage/ai_tools/src/lib.rs b/rust/cloud-storage/ai_tools/src/lib.rsindex 9c49174552..7b887d7692 100644--- a/rust/cloud-storage/ai_tools/src/lib.rs+++ b/rust/cloud-storage/ai_tools/src/lib.rs@@ -4,7 +4,8 @@ pub mod code_execution;pub mod list;pub mod prompts;pub mod read;-pub mod rewrite;+#[allow(dead_code)]+mod rewrite;pub mod search;mod tool_context;pub mod web_fetch;@@ -41,9 +42,7 @@ pub fn all_tools() -> ToolSetWithPrompt {.add_toolset(list_toolset()).expect("failed to add list toolset").add_tool::<read::Read, Arc<ToolScribe>>()- .expect("read tool")- .add_tool::<rewrite::MarkdownRewrite, Arc<ToolScribe>>()- .expect("markdown revision tool");+ .expect("read tool");let prompt = prompts::TOOLS_PROMPT;ToolSetWithPrompt { toolset, prompt }}diff --git a/rust/cloud-storage/ai_tools/src/rewrite/mod.rs b/rust/cloud-storage/ai_tools/src/rewrite/mod.rsindex 17c45f45ff..e7d42b6c48 100644--- a/rust/cloud-storage/ai_tools/src/rewrite/mod.rs+++ b/rust/cloud-storage/ai_tools/src/rewrite/mod.rs@@ -1,3 +1,5 @@+#![allow(unused)]+pub mod tool;pub mod types;