Skip to content

Commit

Permalink
feat: add caller type to tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Neet-Nestor committed Oct 22, 2024
1 parent 528c6cb commit eabd24a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
16 changes: 10 additions & 6 deletions src/action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Scope } from "./scope";
import { CallerType, Scope, ToolType } from "./enum";
import { State } from "./state";
import { Tool } from "./tool";

Expand Down Expand Up @@ -127,8 +127,9 @@ export const actions: Record<string, Tool> = {
},
},
},
type: "action",
scopes: [Scope.Overleaf],
type: ToolType.Action,
scope: [Scope.Overleaf],
caller: CallerType.ContentScript,
implementation: replaceSelectedText,
},
appendTextToDocument: {
Expand All @@ -150,8 +151,9 @@ export const actions: Record<string, Tool> = {
},
},
},
type: "action",
scopes: [Scope.Overleaf],
type: ToolType.Action,
scope: [Scope.Overleaf],
caller: CallerType.ContentScript,
implementation: appendTextToDocument,
},
createCalendarEvent: {
Expand All @@ -178,7 +180,9 @@ export const actions: Record<string, Tool> = {
},
},
},
type: "action",
type: ToolType.Action,
scope: [Scope.Overleaf],
caller: CallerType.Any,
implementation: createCalendarEvent,
},
};
17 changes: 17 additions & 0 deletions src/enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Which domain should a tool be availale */
export enum Scope {
Any = "Any",
Overleaf = "Overleaf",
GoogleDoc = "Google Doc",
}

export enum ToolType {
Action = "action",
Retriever = "retriever",
}

/* Who should call this function */
export enum CallerType {
Any = "any",
ContentScript = "content script",
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export { retrievers } from "./retriever";
export { actions } from "./action";
export { tool, toolName, ToolName } from "./tool";
export { State } from "./state";
export { Scope } from "./scope";
export { Scope, ToolType, CallerType } from "./enum";
export * as retriever from "./retriever";
export * as action from "./action";
10 changes: 7 additions & 3 deletions src/retriever.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Scope } from "./scope";
import { CallerType, Scope, ToolType } from "./enum";
import { State } from "./state";
import { Tool } from "./tool";

Expand Down Expand Up @@ -64,7 +64,9 @@ export const retrievers: Record<string, Tool> = {
parameters: { type: "object", properties: {}, required: [] },
},
},
type: "retriever",
type: ToolType.Retriever,
scope: Scope.Any,
caller: CallerType.Any,
implementation: getSelectedText,
},
getCalendarEvents: {
Expand All @@ -85,7 +87,9 @@ export const retrievers: Record<string, Tool> = {
},
},
},
type: "retriever",
type: ToolType.Retriever,
scope: Scope.Any,
caller: CallerType.Any,
implementation: getCalendarEvents,
},
};
5 changes: 0 additions & 5 deletions src/scope.ts

This file was deleted.

7 changes: 4 additions & 3 deletions src/tool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { actions } from "./action";
import { retrievers } from "./retriever";
import { Scope } from "./scope";
import { CallerType, Scope, ToolType } from "./enum";
import { State } from "./state";

export const tool: Record<string, Tool> = {
Expand Down Expand Up @@ -29,7 +29,8 @@ export interface Tool {
};
};
};
type: "retriever" | "action";
scopes?: Scope[];
type: ToolType;
scope: Scope.Any | Scope[];
caller: CallerType;
implementation: (state: State, parameters: any) => void;
}

0 comments on commit eabd24a

Please sign in to comment.