@@ -5,13 +5,14 @@ import { type Tool, tool } from "ai";
55import * as blink from "blink" ;
66import { z } from "zod" ;
77import type { Message } from "../types" ;
8- import { WORKSPACE_INFO_KEY } from "./common" ;
8+ import { getWorkspaceInfoKey } from "./common" ;
99
1010export const createComputeTools = < T > ( {
1111 agent,
1212 githubAppContext,
1313 initializeWorkspace,
1414 createWorkspaceClient,
15+ chatID,
1516} : {
1617 agent : blink . Agent < Message > ;
1718 initializeWorkspace : (
@@ -23,9 +24,10 @@ export const createComputeTools = <T>({
2324 * If provided, the workspace_authenticate_git tool will be available.
2425 */
2526 githubAppContext ?: github . AppAuthOptions ;
27+ chatID : blink . ID ;
2628} ) : Record < string , Tool > => {
2729 const newClient = async ( ) => {
28- const workspaceInfo = await agent . store . get ( WORKSPACE_INFO_KEY ) ;
30+ const workspaceInfo = await agent . store . get ( getWorkspaceInfoKey ( chatID ) ) ;
2931 if ( ! workspaceInfo ) {
3032 throw new Error (
3133 "Workspace not initialized. Call initialize_workspace first."
@@ -40,16 +42,17 @@ export const createComputeTools = <T>({
4042 description : "Initialize a workspace for the user." ,
4143 inputSchema : z . object ( { } ) ,
4244 execute : async ( _args , _opts ) => {
43- const existingWorkspaceInfoRaw =
44- await agent . store . get ( WORKSPACE_INFO_KEY ) ;
45+ const existingWorkspaceInfoRaw = await agent . store . get (
46+ getWorkspaceInfoKey ( chatID )
47+ ) ;
4548 const existingWorkspaceInfo = existingWorkspaceInfoRaw
4649 ? JSON . parse ( existingWorkspaceInfoRaw )
4750 : undefined ;
4851 const { workspaceInfo, message } = await initializeWorkspace (
4952 existingWorkspaceInfo
5053 ) ;
5154 await agent . store . set (
52- WORKSPACE_INFO_KEY ,
55+ getWorkspaceInfoKey ( chatID ) ,
5356 JSON . stringify ( workspaceInfo )
5457 ) ;
5558 return message ;
0 commit comments